babylon.d.txt 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  160. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Extracts text content from a DOM element hierarchy
  282. * @param element defines the root element
  283. * @returns a string
  284. */
  285. static GetDOMTextContent(element: HTMLElement): string;
  286. }
  287. }
  288. declare module BABYLON {
  289. /**
  290. * Logger used througouht the application to allow configuration of
  291. * the log level required for the messages.
  292. */
  293. export class Logger {
  294. /**
  295. * No log
  296. */
  297. static readonly NoneLogLevel: number;
  298. /**
  299. * Only message logs
  300. */
  301. static readonly MessageLogLevel: number;
  302. /**
  303. * Only warning logs
  304. */
  305. static readonly WarningLogLevel: number;
  306. /**
  307. * Only error logs
  308. */
  309. static readonly ErrorLogLevel: number;
  310. /**
  311. * All logs
  312. */
  313. static readonly AllLogLevel: number;
  314. private static _LogCache;
  315. /**
  316. * Gets a value indicating the number of loading errors
  317. * @ignorenaming
  318. */
  319. static errorsCount: number;
  320. /**
  321. * Callback called when a new log is added
  322. */
  323. static OnNewCacheEntry: (entry: string) => void;
  324. private static _AddLogEntry;
  325. private static _FormatMessage;
  326. private static _LogDisabled;
  327. private static _LogEnabled;
  328. private static _WarnDisabled;
  329. private static _WarnEnabled;
  330. private static _ErrorDisabled;
  331. private static _ErrorEnabled;
  332. /**
  333. * Log a message to the console
  334. */
  335. static Log: (message: string) => void;
  336. /**
  337. * Write a warning message to the console
  338. */
  339. static Warn: (message: string) => void;
  340. /**
  341. * Write an error message to the console
  342. */
  343. static Error: (message: string) => void;
  344. /**
  345. * Gets current log cache (list of logs)
  346. */
  347. static readonly LogCache: string;
  348. /**
  349. * Clears the log cache
  350. */
  351. static ClearLogCache(): void;
  352. /**
  353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  354. */
  355. static LogLevels: number;
  356. }
  357. }
  358. declare module BABYLON {
  359. /** @hidden */
  360. export class _TypeStore {
  361. /** @hidden */
  362. static RegisteredTypes: {
  363. [key: string]: Object;
  364. };
  365. /** @hidden */
  366. static GetClass(fqdn: string): any;
  367. }
  368. }
  369. declare module BABYLON {
  370. /**
  371. * Class containing a set of static utilities functions for deep copy.
  372. */
  373. export class DeepCopier {
  374. /**
  375. * Tries to copy an object by duplicating every property
  376. * @param source defines the source object
  377. * @param destination defines the target object
  378. * @param doNotCopyList defines a list of properties to avoid
  379. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  380. */
  381. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  382. }
  383. }
  384. declare module BABYLON {
  385. /**
  386. * Class containing a set of static utilities functions for precision date
  387. */
  388. export class PrecisionDate {
  389. /**
  390. * Gets either window.performance.now() if supported or Date.now() else
  391. */
  392. static readonly Now: number;
  393. }
  394. }
  395. declare module BABYLON {
  396. /** @hidden */
  397. export class _DevTools {
  398. static WarnImport(name: string): string;
  399. }
  400. }
  401. declare module BABYLON {
  402. /**
  403. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  404. */
  405. export class WebRequest {
  406. private _xhr;
  407. /**
  408. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  409. * i.e. when loading files, where the server/service expects an Authorization header
  410. */
  411. static CustomRequestHeaders: {
  412. [key: string]: string;
  413. };
  414. /**
  415. * Add callback functions in this array to update all the requests before they get sent to the network
  416. */
  417. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  418. private _injectCustomRequestHeaders;
  419. /**
  420. * Gets or sets a function to be called when loading progress changes
  421. */
  422. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  423. /**
  424. * Returns client's state
  425. */
  426. readonly readyState: number;
  427. /**
  428. * Returns client's status
  429. */
  430. readonly status: number;
  431. /**
  432. * Returns client's status as a text
  433. */
  434. readonly statusText: string;
  435. /**
  436. * Returns client's response
  437. */
  438. readonly response: any;
  439. /**
  440. * Returns client's response url
  441. */
  442. readonly responseURL: string;
  443. /**
  444. * Returns client's response as text
  445. */
  446. readonly responseText: string;
  447. /**
  448. * Gets or sets the expected response type
  449. */
  450. responseType: XMLHttpRequestResponseType;
  451. /** @hidden */
  452. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  453. /** @hidden */
  454. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  455. /**
  456. * Cancels any network activity
  457. */
  458. abort(): void;
  459. /**
  460. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  461. * @param body defines an optional request body
  462. */
  463. send(body?: Document | BodyInit | null): void;
  464. /**
  465. * Sets the request method, request URL
  466. * @param method defines the method to use (GET, POST, etc..)
  467. * @param url defines the url to connect with
  468. */
  469. open(method: string, url: string): void;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * File request interface
  475. */
  476. export interface IFileRequest {
  477. /**
  478. * Raised when the request is complete (success or error).
  479. */
  480. onCompleteObservable: Observable<IFileRequest>;
  481. /**
  482. * Aborts the request for a file.
  483. */
  484. abort: () => void;
  485. }
  486. }
  487. declare module BABYLON {
  488. /**
  489. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  490. */
  491. export class PerformanceMonitor {
  492. private _enabled;
  493. private _rollingFrameTime;
  494. private _lastFrameTimeMs;
  495. /**
  496. * constructor
  497. * @param frameSampleSize The number of samples required to saturate the sliding window
  498. */
  499. constructor(frameSampleSize?: number);
  500. /**
  501. * Samples current frame
  502. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  503. */
  504. sampleFrame(timeMs?: number): void;
  505. /**
  506. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  507. */
  508. readonly averageFrameTime: number;
  509. /**
  510. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  511. */
  512. readonly averageFrameTimeVariance: number;
  513. /**
  514. * Returns the frame time of the most recent frame
  515. */
  516. readonly instantaneousFrameTime: number;
  517. /**
  518. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFPS: number;
  521. /**
  522. * Returns the average framerate in frames per second using the most recent frame time
  523. */
  524. readonly instantaneousFPS: number;
  525. /**
  526. * Returns true if enough samples have been taken to completely fill the sliding window
  527. */
  528. readonly isSaturated: boolean;
  529. /**
  530. * Enables contributions to the sliding window sample set
  531. */
  532. enable(): void;
  533. /**
  534. * Disables contributions to the sliding window sample set
  535. * Samples will not be interpolated over the disabled period
  536. */
  537. disable(): void;
  538. /**
  539. * Returns true if sampling is enabled
  540. */
  541. readonly isEnabled: boolean;
  542. /**
  543. * Resets performance monitor
  544. */
  545. reset(): void;
  546. }
  547. /**
  548. * RollingAverage
  549. *
  550. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  551. */
  552. export class RollingAverage {
  553. /**
  554. * Current average
  555. */
  556. average: number;
  557. /**
  558. * Current variance
  559. */
  560. variance: number;
  561. protected _samples: Array<number>;
  562. protected _sampleCount: number;
  563. protected _pos: number;
  564. protected _m2: number;
  565. /**
  566. * constructor
  567. * @param length The number of samples required to saturate the sliding window
  568. */
  569. constructor(length: number);
  570. /**
  571. * Adds a sample to the sample set
  572. * @param v The sample value
  573. */
  574. add(v: number): void;
  575. /**
  576. * Returns previously added values or null if outside of history or outside the sliding window domain
  577. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  578. * @return Value previously recorded with add() or null if outside of range
  579. */
  580. history(i: number): number;
  581. /**
  582. * Returns true if enough samples have been taken to completely fill the sliding window
  583. * @return true if sample-set saturated
  584. */
  585. isSaturated(): boolean;
  586. /**
  587. * Resets the rolling average (equivalent to 0 samples taken so far)
  588. */
  589. reset(): void;
  590. /**
  591. * Wraps a value around the sample range boundaries
  592. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  593. * @return Wrapped position in sample range
  594. */
  595. protected _wrapPosition(i: number): number;
  596. }
  597. }
  598. declare module BABYLON {
  599. /**
  600. * This class implement a typical dictionary using a string as key and the generic type T as value.
  601. * The underlying implementation relies on an associative array to ensure the best performances.
  602. * The value can be anything including 'null' but except 'undefined'
  603. */
  604. export class StringDictionary<T> {
  605. /**
  606. * This will clear this dictionary and copy the content from the 'source' one.
  607. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  608. * @param source the dictionary to take the content from and copy to this dictionary
  609. */
  610. copyFrom(source: StringDictionary<T>): void;
  611. /**
  612. * Get a value based from its key
  613. * @param key the given key to get the matching value from
  614. * @return the value if found, otherwise undefined is returned
  615. */
  616. get(key: string): T | undefined;
  617. /**
  618. * Get a value from its key or add it if it doesn't exist.
  619. * This method will ensure you that a given key/data will be present in the dictionary.
  620. * @param key the given key to get the matching value from
  621. * @param factory the factory that will create the value if the key is not present in the dictionary.
  622. * The factory will only be invoked if there's no data for the given key.
  623. * @return the value corresponding to the key.
  624. */
  625. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  626. /**
  627. * Get a value from its key if present in the dictionary otherwise add it
  628. * @param key the key to get the value from
  629. * @param val if there's no such key/value pair in the dictionary add it with this value
  630. * @return the value corresponding to the key
  631. */
  632. getOrAdd(key: string, val: T): T;
  633. /**
  634. * Check if there's a given key in the dictionary
  635. * @param key the key to check for
  636. * @return true if the key is present, false otherwise
  637. */
  638. contains(key: string): boolean;
  639. /**
  640. * Add a new key and its corresponding value
  641. * @param key the key to add
  642. * @param value the value corresponding to the key
  643. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  644. */
  645. add(key: string, value: T): boolean;
  646. /**
  647. * Update a specific value associated to a key
  648. * @param key defines the key to use
  649. * @param value defines the value to store
  650. * @returns true if the value was updated (or false if the key was not found)
  651. */
  652. set(key: string, value: T): boolean;
  653. /**
  654. * Get the element of the given key and remove it from the dictionary
  655. * @param key defines the key to search
  656. * @returns the value associated with the key or null if not found
  657. */
  658. getAndRemove(key: string): Nullable<T>;
  659. /**
  660. * Remove a key/value from the dictionary.
  661. * @param key the key to remove
  662. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  663. */
  664. remove(key: string): boolean;
  665. /**
  666. * Clear the whole content of the dictionary
  667. */
  668. clear(): void;
  669. /**
  670. * Gets the current count
  671. */
  672. readonly count: number;
  673. /**
  674. * Execute a callback on each key/val of the dictionary.
  675. * Note that you can remove any element in this dictionary in the callback implementation
  676. * @param callback the callback to execute on a given key/value pair
  677. */
  678. forEach(callback: (key: string, val: T) => void): void;
  679. /**
  680. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  681. * If the callback returns null or undefined the method will iterate to the next key/value pair
  682. * Note that you can remove any element in this dictionary in the callback implementation
  683. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  684. * @returns the first item
  685. */
  686. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  687. private _count;
  688. private _data;
  689. }
  690. }
  691. declare module BABYLON {
  692. /**
  693. * Class used to store gfx data (like WebGLBuffer)
  694. */
  695. export class DataBuffer {
  696. /**
  697. * Gets or sets the number of objects referencing this buffer
  698. */
  699. references: number;
  700. /** Gets or sets the size of the underlying buffer */
  701. capacity: number;
  702. /**
  703. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  704. */
  705. is32Bits: boolean;
  706. /**
  707. * Gets the underlying buffer
  708. */
  709. readonly underlyingResource: any;
  710. }
  711. }
  712. declare module BABYLON {
  713. /**
  714. * Class used to store data that will be store in GPU memory
  715. */
  716. export class Buffer {
  717. private _engine;
  718. private _buffer;
  719. /** @hidden */ private _data: Nullable<DataArray>;
  720. private _updatable;
  721. private _instanced;
  722. /**
  723. * Gets the byte stride.
  724. */
  725. readonly byteStride: number;
  726. /**
  727. * Constructor
  728. * @param engine the engine
  729. * @param data the data to use for this buffer
  730. * @param updatable whether the data is updatable
  731. * @param stride the stride (optional)
  732. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  733. * @param instanced whether the buffer is instanced (optional)
  734. * @param useBytes set to true if the stride in in bytes (optional)
  735. */
  736. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  737. /**
  738. * Create a new VertexBuffer based on the current buffer
  739. * @param kind defines the vertex buffer kind (position, normal, etc.)
  740. * @param offset defines offset in the buffer (0 by default)
  741. * @param size defines the size in floats of attributes (position is 3 for instance)
  742. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  743. * @param instanced defines if the vertex buffer contains indexed data
  744. * @param useBytes defines if the offset and stride are in bytes
  745. * @returns the new vertex buffer
  746. */
  747. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  748. /**
  749. * Gets a boolean indicating if the Buffer is updatable?
  750. * @returns true if the buffer is updatable
  751. */
  752. isUpdatable(): boolean;
  753. /**
  754. * Gets current buffer's data
  755. * @returns a DataArray or null
  756. */
  757. getData(): Nullable<DataArray>;
  758. /**
  759. * Gets underlying native buffer
  760. * @returns underlying native buffer
  761. */
  762. getBuffer(): Nullable<DataBuffer>;
  763. /**
  764. * Gets the stride in float32 units (i.e. byte stride / 4).
  765. * May not be an integer if the byte stride is not divisible by 4.
  766. * DEPRECATED. Use byteStride instead.
  767. * @returns the stride in float32 units
  768. */
  769. getStrideSize(): number;
  770. /**
  771. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  772. * @param data defines the data to store
  773. */
  774. create(data?: Nullable<DataArray>): void;
  775. /** @hidden */ private _rebuild(): void;
  776. /**
  777. * Update current buffer data
  778. * @param data defines the data to store
  779. */
  780. update(data: DataArray): void;
  781. /**
  782. * Updates the data directly.
  783. * @param data the new data
  784. * @param offset the new offset
  785. * @param vertexCount the vertex count (optional)
  786. * @param useBytes set to true if the offset is in bytes
  787. */
  788. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  789. /**
  790. * Release all resources
  791. */
  792. dispose(): void;
  793. }
  794. /**
  795. * Specialized buffer used to store vertex data
  796. */
  797. export class VertexBuffer {
  798. /** @hidden */ private _buffer: Buffer;
  799. private _kind;
  800. private _size;
  801. private _ownsBuffer;
  802. private _instanced;
  803. private _instanceDivisor;
  804. /**
  805. * The byte type.
  806. */
  807. static readonly BYTE: number;
  808. /**
  809. * The unsigned byte type.
  810. */
  811. static readonly UNSIGNED_BYTE: number;
  812. /**
  813. * The short type.
  814. */
  815. static readonly SHORT: number;
  816. /**
  817. * The unsigned short type.
  818. */
  819. static readonly UNSIGNED_SHORT: number;
  820. /**
  821. * The integer type.
  822. */
  823. static readonly INT: number;
  824. /**
  825. * The unsigned integer type.
  826. */
  827. static readonly UNSIGNED_INT: number;
  828. /**
  829. * The float type.
  830. */
  831. static readonly FLOAT: number;
  832. /**
  833. * Gets or sets the instance divisor when in instanced mode
  834. */
  835. instanceDivisor: number;
  836. /**
  837. * Gets the byte stride.
  838. */
  839. readonly byteStride: number;
  840. /**
  841. * Gets the byte offset.
  842. */
  843. readonly byteOffset: number;
  844. /**
  845. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  846. */
  847. readonly normalized: boolean;
  848. /**
  849. * Gets the data type of each component in the array.
  850. */
  851. readonly type: number;
  852. /**
  853. * Constructor
  854. * @param engine the engine
  855. * @param data the data to use for this vertex buffer
  856. * @param kind the vertex buffer kind
  857. * @param updatable whether the data is updatable
  858. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  859. * @param stride the stride (optional)
  860. * @param instanced whether the buffer is instanced (optional)
  861. * @param offset the offset of the data (optional)
  862. * @param size the number of components (optional)
  863. * @param type the type of the component (optional)
  864. * @param normalized whether the data contains normalized data (optional)
  865. * @param useBytes set to true if stride and offset are in bytes (optional)
  866. */
  867. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  868. /** @hidden */ private _rebuild(): void;
  869. /**
  870. * Returns the kind of the VertexBuffer (string)
  871. * @returns a string
  872. */
  873. getKind(): string;
  874. /**
  875. * Gets a boolean indicating if the VertexBuffer is updatable?
  876. * @returns true if the buffer is updatable
  877. */
  878. isUpdatable(): boolean;
  879. /**
  880. * Gets current buffer's data
  881. * @returns a DataArray or null
  882. */
  883. getData(): Nullable<DataArray>;
  884. /**
  885. * Gets underlying native buffer
  886. * @returns underlying native buffer
  887. */
  888. getBuffer(): Nullable<DataBuffer>;
  889. /**
  890. * Gets the stride in float32 units (i.e. byte stride / 4).
  891. * May not be an integer if the byte stride is not divisible by 4.
  892. * DEPRECATED. Use byteStride instead.
  893. * @returns the stride in float32 units
  894. */
  895. getStrideSize(): number;
  896. /**
  897. * Returns the offset as a multiple of the type byte length.
  898. * DEPRECATED. Use byteOffset instead.
  899. * @returns the offset in bytes
  900. */
  901. getOffset(): number;
  902. /**
  903. * Returns the number of components per vertex attribute (integer)
  904. * @returns the size in float
  905. */
  906. getSize(): number;
  907. /**
  908. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  909. * @returns true if this buffer is instanced
  910. */
  911. getIsInstanced(): boolean;
  912. /**
  913. * Returns the instancing divisor, zero for non-instanced (integer).
  914. * @returns a number
  915. */
  916. getInstanceDivisor(): number;
  917. /**
  918. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  919. * @param data defines the data to store
  920. */
  921. create(data?: DataArray): void;
  922. /**
  923. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  924. * This function will create a new buffer if the current one is not updatable
  925. * @param data defines the data to store
  926. */
  927. update(data: DataArray): void;
  928. /**
  929. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  930. * Returns the directly updated WebGLBuffer.
  931. * @param data the new data
  932. * @param offset the new offset
  933. * @param useBytes set to true if the offset is in bytes
  934. */
  935. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  936. /**
  937. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  938. */
  939. dispose(): void;
  940. /**
  941. * Enumerates each value of this vertex buffer as numbers.
  942. * @param count the number of values to enumerate
  943. * @param callback the callback function called for each value
  944. */
  945. forEach(count: number, callback: (value: number, index: number) => void): void;
  946. /**
  947. * Positions
  948. */
  949. static readonly PositionKind: string;
  950. /**
  951. * Normals
  952. */
  953. static readonly NormalKind: string;
  954. /**
  955. * Tangents
  956. */
  957. static readonly TangentKind: string;
  958. /**
  959. * Texture coordinates
  960. */
  961. static readonly UVKind: string;
  962. /**
  963. * Texture coordinates 2
  964. */
  965. static readonly UV2Kind: string;
  966. /**
  967. * Texture coordinates 3
  968. */
  969. static readonly UV3Kind: string;
  970. /**
  971. * Texture coordinates 4
  972. */
  973. static readonly UV4Kind: string;
  974. /**
  975. * Texture coordinates 5
  976. */
  977. static readonly UV5Kind: string;
  978. /**
  979. * Texture coordinates 6
  980. */
  981. static readonly UV6Kind: string;
  982. /**
  983. * Colors
  984. */
  985. static readonly ColorKind: string;
  986. /**
  987. * Matrix indices (for bones)
  988. */
  989. static readonly MatricesIndicesKind: string;
  990. /**
  991. * Matrix weights (for bones)
  992. */
  993. static readonly MatricesWeightsKind: string;
  994. /**
  995. * Additional matrix indices (for bones)
  996. */
  997. static readonly MatricesIndicesExtraKind: string;
  998. /**
  999. * Additional matrix weights (for bones)
  1000. */
  1001. static readonly MatricesWeightsExtraKind: string;
  1002. /**
  1003. * Deduces the stride given a kind.
  1004. * @param kind The kind string to deduce
  1005. * @returns The deduced stride
  1006. */
  1007. static DeduceStride(kind: string): number;
  1008. /**
  1009. * Gets the byte length of the given type.
  1010. * @param type the type
  1011. * @returns the number of bytes
  1012. */
  1013. static GetTypeByteLength(type: number): number;
  1014. /**
  1015. * Enumerates each value of the given parameters as numbers.
  1016. * @param data the data to enumerate
  1017. * @param byteOffset the byte offset of the data
  1018. * @param byteStride the byte stride of the data
  1019. * @param componentCount the number of components per element
  1020. * @param componentType the type of the component
  1021. * @param count the number of values to enumerate
  1022. * @param normalized whether the data is normalized
  1023. * @param callback the callback function called for each value
  1024. */
  1025. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1026. private static _GetFloatValue;
  1027. }
  1028. }
  1029. declare module BABYLON {
  1030. /**
  1031. * Scalar computation library
  1032. */
  1033. export class Scalar {
  1034. /**
  1035. * Two pi constants convenient for computation.
  1036. */
  1037. static TwoPi: number;
  1038. /**
  1039. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1040. * @param a number
  1041. * @param b number
  1042. * @param epsilon (default = 1.401298E-45)
  1043. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1044. */
  1045. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1046. /**
  1047. * Returns a string : the upper case translation of the number i to hexadecimal.
  1048. * @param i number
  1049. * @returns the upper case translation of the number i to hexadecimal.
  1050. */
  1051. static ToHex(i: number): string;
  1052. /**
  1053. * Returns -1 if value is negative and +1 is value is positive.
  1054. * @param value the value
  1055. * @returns the value itself if it's equal to zero.
  1056. */
  1057. static Sign(value: number): number;
  1058. /**
  1059. * Returns the value itself if it's between min and max.
  1060. * Returns min if the value is lower than min.
  1061. * Returns max if the value is greater than max.
  1062. * @param value the value to clmap
  1063. * @param min the min value to clamp to (default: 0)
  1064. * @param max the max value to clamp to (default: 1)
  1065. * @returns the clamped value
  1066. */
  1067. static Clamp(value: number, min?: number, max?: number): number;
  1068. /**
  1069. * the log2 of value.
  1070. * @param value the value to compute log2 of
  1071. * @returns the log2 of value.
  1072. */
  1073. static Log2(value: number): number;
  1074. /**
  1075. * Loops the value, so that it is never larger than length and never smaller than 0.
  1076. *
  1077. * This is similar to the modulo operator but it works with floating point numbers.
  1078. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1079. * With t = 5 and length = 2.5, the result would be 0.0.
  1080. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1081. * @param value the value
  1082. * @param length the length
  1083. * @returns the looped value
  1084. */
  1085. static Repeat(value: number, length: number): number;
  1086. /**
  1087. * Normalize the value between 0.0 and 1.0 using min and max values
  1088. * @param value value to normalize
  1089. * @param min max to normalize between
  1090. * @param max min to normalize between
  1091. * @returns the normalized value
  1092. */
  1093. static Normalize(value: number, min: number, max: number): number;
  1094. /**
  1095. * Denormalize the value from 0.0 and 1.0 using min and max values
  1096. * @param normalized value to denormalize
  1097. * @param min max to denormalize between
  1098. * @param max min to denormalize between
  1099. * @returns the denormalized value
  1100. */
  1101. static Denormalize(normalized: number, min: number, max: number): number;
  1102. /**
  1103. * Calculates the shortest difference between two given angles given in degrees.
  1104. * @param current current angle in degrees
  1105. * @param target target angle in degrees
  1106. * @returns the delta
  1107. */
  1108. static DeltaAngle(current: number, target: number): number;
  1109. /**
  1110. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1111. * @param tx value
  1112. * @param length length
  1113. * @returns The returned value will move back and forth between 0 and length
  1114. */
  1115. static PingPong(tx: number, length: number): number;
  1116. /**
  1117. * Interpolates between min and max with smoothing at the limits.
  1118. *
  1119. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1120. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1121. * @param from from
  1122. * @param to to
  1123. * @param tx value
  1124. * @returns the smooth stepped value
  1125. */
  1126. static SmoothStep(from: number, to: number, tx: number): number;
  1127. /**
  1128. * Moves a value current towards target.
  1129. *
  1130. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1131. * Negative values of maxDelta pushes the value away from target.
  1132. * @param current current value
  1133. * @param target target value
  1134. * @param maxDelta max distance to move
  1135. * @returns resulting value
  1136. */
  1137. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1138. /**
  1139. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1140. *
  1141. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1142. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1143. * @param current current value
  1144. * @param target target value
  1145. * @param maxDelta max distance to move
  1146. * @returns resulting angle
  1147. */
  1148. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1149. /**
  1150. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1151. * @param start start value
  1152. * @param end target value
  1153. * @param amount amount to lerp between
  1154. * @returns the lerped value
  1155. */
  1156. static Lerp(start: number, end: number, amount: number): number;
  1157. /**
  1158. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1159. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1160. * @param start start value
  1161. * @param end target value
  1162. * @param amount amount to lerp between
  1163. * @returns the lerped value
  1164. */
  1165. static LerpAngle(start: number, end: number, amount: number): number;
  1166. /**
  1167. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1168. * @param a start value
  1169. * @param b target value
  1170. * @param value value between a and b
  1171. * @returns the inverseLerp value
  1172. */
  1173. static InverseLerp(a: number, b: number, value: number): number;
  1174. /**
  1175. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1176. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1177. * @param value1 spline value
  1178. * @param tangent1 spline value
  1179. * @param value2 spline value
  1180. * @param tangent2 spline value
  1181. * @param amount input value
  1182. * @returns hermite result
  1183. */
  1184. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1185. /**
  1186. * Returns a random float number between and min and max values
  1187. * @param min min value of random
  1188. * @param max max value of random
  1189. * @returns random value
  1190. */
  1191. static RandomRange(min: number, max: number): number;
  1192. /**
  1193. * This function returns percentage of a number in a given range.
  1194. *
  1195. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1196. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1197. * @param number to convert to percentage
  1198. * @param min min range
  1199. * @param max max range
  1200. * @returns the percentage
  1201. */
  1202. static RangeToPercent(number: number, min: number, max: number): number;
  1203. /**
  1204. * This function returns number that corresponds to the percentage in a given range.
  1205. *
  1206. * PercentToRange(0.34,0,100) will return 34.
  1207. * @param percent to convert to number
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the number
  1211. */
  1212. static PercentToRange(percent: number, min: number, max: number): number;
  1213. /**
  1214. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1215. * @param angle The angle to normalize in radian.
  1216. * @return The converted angle.
  1217. */
  1218. static NormalizeRadians(angle: number): number;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /**
  1223. * Constant used to convert a value to gamma space
  1224. * @ignorenaming
  1225. */
  1226. export const ToGammaSpace: number;
  1227. /**
  1228. * Constant used to convert a value to linear space
  1229. * @ignorenaming
  1230. */
  1231. export const ToLinearSpace = 2.2;
  1232. /**
  1233. * Constant used to define the minimal number value in Babylon.js
  1234. * @ignorenaming
  1235. */
  1236. let Epsilon: number;
  1237. }
  1238. declare module BABYLON {
  1239. /**
  1240. * Class used to represent a viewport on screen
  1241. */
  1242. export class Viewport {
  1243. /** viewport left coordinate */
  1244. x: number;
  1245. /** viewport top coordinate */
  1246. y: number;
  1247. /**viewport width */
  1248. width: number;
  1249. /** viewport height */
  1250. height: number;
  1251. /**
  1252. * Creates a Viewport object located at (x, y) and sized (width, height)
  1253. * @param x defines viewport left coordinate
  1254. * @param y defines viewport top coordinate
  1255. * @param width defines the viewport width
  1256. * @param height defines the viewport height
  1257. */
  1258. constructor(
  1259. /** viewport left coordinate */
  1260. x: number,
  1261. /** viewport top coordinate */
  1262. y: number,
  1263. /**viewport width */
  1264. width: number,
  1265. /** viewport height */
  1266. height: number);
  1267. /**
  1268. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1269. * @param renderWidth defines the rendering width
  1270. * @param renderHeight defines the rendering height
  1271. * @returns a new Viewport
  1272. */
  1273. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1274. /**
  1275. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1276. * @param renderWidth defines the rendering width
  1277. * @param renderHeight defines the rendering height
  1278. * @param ref defines the target viewport
  1279. * @returns the current viewport
  1280. */
  1281. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1282. /**
  1283. * Returns a new Viewport copied from the current one
  1284. * @returns a new Viewport
  1285. */
  1286. clone(): Viewport;
  1287. }
  1288. }
  1289. declare module BABYLON {
  1290. /**
  1291. * Class containing a set of static utilities functions for arrays.
  1292. */
  1293. export class ArrayTools {
  1294. /**
  1295. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1296. * @param size the number of element to construct and put in the array
  1297. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1298. * @returns a new array filled with new objects
  1299. */
  1300. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * @hidden
  1306. */
  1307. export interface IColor4Like {
  1308. r: float;
  1309. g: float;
  1310. b: float;
  1311. a: float;
  1312. }
  1313. /**
  1314. * @hidden
  1315. */
  1316. export interface IColor3Like {
  1317. r: float;
  1318. g: float;
  1319. b: float;
  1320. }
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IVector4Like {
  1325. x: float;
  1326. y: float;
  1327. z: float;
  1328. w: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IVector3Like {
  1334. x: float;
  1335. y: float;
  1336. z: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector2Like {
  1342. x: float;
  1343. y: float;
  1344. }
  1345. /**
  1346. * @hidden
  1347. */
  1348. export interface IMatrixLike {
  1349. toArray(): DeepImmutable<Float32Array>;
  1350. updateFlag: int;
  1351. }
  1352. /**
  1353. * @hidden
  1354. */
  1355. export interface IViewportLike {
  1356. x: float;
  1357. y: float;
  1358. width: float;
  1359. height: float;
  1360. }
  1361. /**
  1362. * @hidden
  1363. */
  1364. export interface IPlaneLike {
  1365. normal: IVector3Like;
  1366. d: float;
  1367. normalize(): void;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * Class representing a vector containing 2 coordinates
  1373. */
  1374. export class Vector2 {
  1375. /** defines the first coordinate */
  1376. x: number;
  1377. /** defines the second coordinate */
  1378. y: number;
  1379. /**
  1380. * Creates a new Vector2 from the given x and y coordinates
  1381. * @param x defines the first coordinate
  1382. * @param y defines the second coordinate
  1383. */
  1384. constructor(
  1385. /** defines the first coordinate */
  1386. x?: number,
  1387. /** defines the second coordinate */
  1388. y?: number);
  1389. /**
  1390. * Gets a string with the Vector2 coordinates
  1391. * @returns a string with the Vector2 coordinates
  1392. */
  1393. toString(): string;
  1394. /**
  1395. * Gets class name
  1396. * @returns the string "Vector2"
  1397. */
  1398. getClassName(): string;
  1399. /**
  1400. * Gets current vector hash code
  1401. * @returns the Vector2 hash code as a number
  1402. */
  1403. getHashCode(): number;
  1404. /**
  1405. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1406. * @param array defines the source array
  1407. * @param index defines the offset in source array
  1408. * @returns the current Vector2
  1409. */
  1410. toArray(array: FloatArray, index?: number): Vector2;
  1411. /**
  1412. * Copy the current vector to an array
  1413. * @returns a new array with 2 elements: the Vector2 coordinates.
  1414. */
  1415. asArray(): number[];
  1416. /**
  1417. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1418. * @param source defines the source Vector2
  1419. * @returns the current updated Vector2
  1420. */
  1421. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1422. /**
  1423. * Sets the Vector2 coordinates with the given floats
  1424. * @param x defines the first coordinate
  1425. * @param y defines the second coordinate
  1426. * @returns the current updated Vector2
  1427. */
  1428. copyFromFloats(x: number, y: number): Vector2;
  1429. /**
  1430. * Sets the Vector2 coordinates with the given floats
  1431. * @param x defines the first coordinate
  1432. * @param y defines the second coordinate
  1433. * @returns the current updated Vector2
  1434. */
  1435. set(x: number, y: number): Vector2;
  1436. /**
  1437. * Add another vector with the current one
  1438. * @param otherVector defines the other vector
  1439. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1440. */
  1441. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1444. * @param otherVector defines the other vector
  1445. * @param result defines the target vector
  1446. * @returns the unmodified current Vector2
  1447. */
  1448. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1449. /**
  1450. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1451. * @param otherVector defines the other vector
  1452. * @returns the current updated Vector2
  1453. */
  1454. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1455. /**
  1456. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1457. * @param otherVector defines the other vector
  1458. * @returns a new Vector2
  1459. */
  1460. addVector3(otherVector: Vector3): Vector2;
  1461. /**
  1462. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1463. * @param otherVector defines the other vector
  1464. * @returns a new Vector2
  1465. */
  1466. subtract(otherVector: Vector2): Vector2;
  1467. /**
  1468. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1469. * @param otherVector defines the other vector
  1470. * @param result defines the target vector
  1471. * @returns the unmodified current Vector2
  1472. */
  1473. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1474. /**
  1475. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1476. * @param otherVector defines the other vector
  1477. * @returns the current updated Vector2
  1478. */
  1479. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1480. /**
  1481. * Multiplies in place the current Vector2 coordinates by the given ones
  1482. * @param otherVector defines the other vector
  1483. * @returns the current updated Vector2
  1484. */
  1485. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1486. /**
  1487. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1488. * @param otherVector defines the other vector
  1489. * @returns a new Vector2
  1490. */
  1491. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1492. /**
  1493. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1494. * @param otherVector defines the other vector
  1495. * @param result defines the target vector
  1496. * @returns the unmodified current Vector2
  1497. */
  1498. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1499. /**
  1500. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1501. * @param x defines the first coordinate
  1502. * @param y defines the second coordinate
  1503. * @returns a new Vector2
  1504. */
  1505. multiplyByFloats(x: number, y: number): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. divide(otherVector: Vector2): Vector2;
  1512. /**
  1513. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Divides the current Vector2 coordinates by the given ones
  1521. * @param otherVector defines the other vector
  1522. * @returns the current updated Vector2
  1523. */
  1524. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1525. /**
  1526. * Gets a new Vector2 with current Vector2 negated coordinates
  1527. * @returns a new Vector2
  1528. */
  1529. negate(): Vector2;
  1530. /**
  1531. * Multiply the Vector2 coordinates by scale
  1532. * @param scale defines the scaling factor
  1533. * @returns the current updated Vector2
  1534. */
  1535. scaleInPlace(scale: number): Vector2;
  1536. /**
  1537. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1538. * @param scale defines the scaling factor
  1539. * @returns a new Vector2
  1540. */
  1541. scale(scale: number): Vector2;
  1542. /**
  1543. * Scale the current Vector2 values by a factor to a given Vector2
  1544. * @param scale defines the scale factor
  1545. * @param result defines the Vector2 object where to store the result
  1546. * @returns the unmodified current Vector2
  1547. */
  1548. scaleToRef(scale: number, result: Vector2): Vector2;
  1549. /**
  1550. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1551. * @param scale defines the scale factor
  1552. * @param result defines the Vector2 object where to store the result
  1553. * @returns the unmodified current Vector2
  1554. */
  1555. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1556. /**
  1557. * Gets a boolean if two vectors are equals
  1558. * @param otherVector defines the other vector
  1559. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1560. */
  1561. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1562. /**
  1563. * Gets a boolean if two vectors are equals (using an epsilon value)
  1564. * @param otherVector defines the other vector
  1565. * @param epsilon defines the minimal distance to consider equality
  1566. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1567. */
  1568. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1569. /**
  1570. * Gets a new Vector2 from current Vector2 floored values
  1571. * @returns a new Vector2
  1572. */
  1573. floor(): Vector2;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. fract(): Vector2;
  1579. /**
  1580. * Gets the length of the vector
  1581. * @returns the vector length (float)
  1582. */
  1583. length(): number;
  1584. /**
  1585. * Gets the vector squared length
  1586. * @returns the vector squared length (float)
  1587. */
  1588. lengthSquared(): number;
  1589. /**
  1590. * Normalize the vector
  1591. * @returns the current updated Vector2
  1592. */
  1593. normalize(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 copied from the Vector2
  1596. * @returns a new Vector2
  1597. */
  1598. clone(): Vector2;
  1599. /**
  1600. * Gets a new Vector2(0, 0)
  1601. * @returns a new Vector2
  1602. */
  1603. static Zero(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(1, 1)
  1606. * @returns a new Vector2
  1607. */
  1608. static One(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 set from the given index element of the given array
  1611. * @param array defines the data source
  1612. * @param offset defines the offset in the data source
  1613. * @returns a new Vector2
  1614. */
  1615. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1616. /**
  1617. * Sets "result" from the given index element of the given array
  1618. * @param array defines the data source
  1619. * @param offset defines the offset in the data source
  1620. * @param result defines the target vector
  1621. */
  1622. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1623. /**
  1624. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1625. * @param value1 defines 1st point of control
  1626. * @param value2 defines 2nd point of control
  1627. * @param value3 defines 3rd point of control
  1628. * @param value4 defines 4th point of control
  1629. * @param amount defines the interpolation factor
  1630. * @returns a new Vector2
  1631. */
  1632. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1633. /**
  1634. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1635. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1636. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1637. * @param value defines the value to clamp
  1638. * @param min defines the lower limit
  1639. * @param max defines the upper limit
  1640. * @returns a new Vector2
  1641. */
  1642. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1643. /**
  1644. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1645. * @param value1 defines the 1st control point
  1646. * @param tangent1 defines the outgoing tangent
  1647. * @param value2 defines the 2nd control point
  1648. * @param tangent2 defines the incoming tangent
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1655. * @param start defines the start vector
  1656. * @param end defines the end vector
  1657. * @param amount defines the interpolation factor
  1658. * @returns a new Vector2
  1659. */
  1660. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1661. /**
  1662. * Gets the dot product of the vector "left" and the vector "right"
  1663. * @param left defines first vector
  1664. * @param right defines second vector
  1665. * @returns the dot product (float)
  1666. */
  1667. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1668. /**
  1669. * Returns a new Vector2 equal to the normalized given vector
  1670. * @param vector defines the vector to normalize
  1671. * @returns a new Vector2
  1672. */
  1673. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1674. /**
  1675. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1676. * @param left defines 1st vector
  1677. * @param right defines 2nd vector
  1678. * @returns a new Vector2
  1679. */
  1680. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1681. /**
  1682. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1683. * @param left defines 1st vector
  1684. * @param right defines 2nd vector
  1685. * @returns a new Vector2
  1686. */
  1687. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1688. /**
  1689. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1690. * @param vector defines the vector to transform
  1691. * @param transformation defines the matrix to apply
  1692. * @returns a new Vector2
  1693. */
  1694. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1695. /**
  1696. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1697. * @param vector defines the vector to transform
  1698. * @param transformation defines the matrix to apply
  1699. * @param result defines the target vector
  1700. */
  1701. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1702. /**
  1703. * Determines if a given vector is included in a triangle
  1704. * @param p defines the vector to test
  1705. * @param p0 defines 1st triangle point
  1706. * @param p1 defines 2nd triangle point
  1707. * @param p2 defines 3rd triangle point
  1708. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1709. */
  1710. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1711. /**
  1712. * Gets the distance between the vectors "value1" and "value2"
  1713. * @param value1 defines first vector
  1714. * @param value2 defines second vector
  1715. * @returns the distance between vectors
  1716. */
  1717. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1718. /**
  1719. * Returns the squared distance between the vectors "value1" and "value2"
  1720. * @param value1 defines first vector
  1721. * @param value2 defines second vector
  1722. * @returns the squared distance between vectors
  1723. */
  1724. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1725. /**
  1726. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1727. * @param value1 defines first vector
  1728. * @param value2 defines second vector
  1729. * @returns a new Vector2
  1730. */
  1731. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1732. /**
  1733. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1734. * @param p defines the middle point
  1735. * @param segA defines one point of the segment
  1736. * @param segB defines the other point of the segment
  1737. * @returns the shortest distance
  1738. */
  1739. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1740. }
  1741. /**
  1742. * Classed used to store (x,y,z) vector representation
  1743. * A Vector3 is the main object used in 3D geometry
  1744. * It can represent etiher the coordinates of a point the space, either a direction
  1745. * Reminder: js uses a left handed forward facing system
  1746. */
  1747. export class Vector3 {
  1748. /**
  1749. * Defines the first coordinates (on X axis)
  1750. */
  1751. x: number;
  1752. /**
  1753. * Defines the second coordinates (on Y axis)
  1754. */
  1755. y: number;
  1756. /**
  1757. * Defines the third coordinates (on Z axis)
  1758. */
  1759. z: number;
  1760. private static _UpReadOnly;
  1761. private static _ZeroReadOnly;
  1762. /**
  1763. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1764. * @param x defines the first coordinates (on X axis)
  1765. * @param y defines the second coordinates (on Y axis)
  1766. * @param z defines the third coordinates (on Z axis)
  1767. */
  1768. constructor(
  1769. /**
  1770. * Defines the first coordinates (on X axis)
  1771. */
  1772. x?: number,
  1773. /**
  1774. * Defines the second coordinates (on Y axis)
  1775. */
  1776. y?: number,
  1777. /**
  1778. * Defines the third coordinates (on Z axis)
  1779. */
  1780. z?: number);
  1781. /**
  1782. * Creates a string representation of the Vector3
  1783. * @returns a string with the Vector3 coordinates.
  1784. */
  1785. toString(): string;
  1786. /**
  1787. * Gets the class name
  1788. * @returns the string "Vector3"
  1789. */
  1790. getClassName(): string;
  1791. /**
  1792. * Creates the Vector3 hash code
  1793. * @returns a number which tends to be unique between Vector3 instances
  1794. */
  1795. getHashCode(): number;
  1796. /**
  1797. * Creates an array containing three elements : the coordinates of the Vector3
  1798. * @returns a new array of numbers
  1799. */
  1800. asArray(): number[];
  1801. /**
  1802. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1803. * @param array defines the destination array
  1804. * @param index defines the offset in the destination array
  1805. * @returns the current Vector3
  1806. */
  1807. toArray(array: FloatArray, index?: number): Vector3;
  1808. /**
  1809. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1810. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1811. */
  1812. toQuaternion(): Quaternion;
  1813. /**
  1814. * Adds the given vector to the current Vector3
  1815. * @param otherVector defines the second operand
  1816. * @returns the current updated Vector3
  1817. */
  1818. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1819. /**
  1820. * Adds the given coordinates to the current Vector3
  1821. * @param x defines the x coordinate of the operand
  1822. * @param y defines the y coordinate of the operand
  1823. * @param z defines the z coordinate of the operand
  1824. * @returns the current updated Vector3
  1825. */
  1826. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1827. /**
  1828. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1829. * @param otherVector defines the second operand
  1830. * @returns the resulting Vector3
  1831. */
  1832. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1833. /**
  1834. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1835. * @param otherVector defines the second operand
  1836. * @param result defines the Vector3 object where to store the result
  1837. * @returns the current Vector3
  1838. */
  1839. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1840. /**
  1841. * Subtract the given vector from the current Vector3
  1842. * @param otherVector defines the second operand
  1843. * @returns the current updated Vector3
  1844. */
  1845. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1846. /**
  1847. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1848. * @param otherVector defines the second operand
  1849. * @returns the resulting Vector3
  1850. */
  1851. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1852. /**
  1853. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1854. * @param otherVector defines the second operand
  1855. * @param result defines the Vector3 object where to store the result
  1856. * @returns the current Vector3
  1857. */
  1858. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1859. /**
  1860. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1861. * @param x defines the x coordinate of the operand
  1862. * @param y defines the y coordinate of the operand
  1863. * @param z defines the z coordinate of the operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1867. /**
  1868. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1869. * @param x defines the x coordinate of the operand
  1870. * @param y defines the y coordinate of the operand
  1871. * @param z defines the z coordinate of the operand
  1872. * @param result defines the Vector3 object where to store the result
  1873. * @returns the current Vector3
  1874. */
  1875. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1876. /**
  1877. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1878. * @returns a new Vector3
  1879. */
  1880. negate(): Vector3;
  1881. /**
  1882. * Multiplies the Vector3 coordinates by the float "scale"
  1883. * @param scale defines the multiplier factor
  1884. * @returns the current updated Vector3
  1885. */
  1886. scaleInPlace(scale: number): Vector3;
  1887. /**
  1888. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1889. * @param scale defines the multiplier factor
  1890. * @returns a new Vector3
  1891. */
  1892. scale(scale: number): Vector3;
  1893. /**
  1894. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1895. * @param scale defines the multiplier factor
  1896. * @param result defines the Vector3 object where to store the result
  1897. * @returns the current Vector3
  1898. */
  1899. scaleToRef(scale: number, result: Vector3): Vector3;
  1900. /**
  1901. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1902. * @param scale defines the scale factor
  1903. * @param result defines the Vector3 object where to store the result
  1904. * @returns the unmodified current Vector3
  1905. */
  1906. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1907. /**
  1908. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1909. * @param otherVector defines the second operand
  1910. * @returns true if both vectors are equals
  1911. */
  1912. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1913. /**
  1914. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1915. * @param otherVector defines the second operand
  1916. * @param epsilon defines the minimal distance to define values as equals
  1917. * @returns true if both vectors are distant less than epsilon
  1918. */
  1919. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1920. /**
  1921. * Returns true if the current Vector3 coordinates equals the given floats
  1922. * @param x defines the x coordinate of the operand
  1923. * @param y defines the y coordinate of the operand
  1924. * @param z defines the z coordinate of the operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equalsToFloats(x: number, y: number, z: number): boolean;
  1928. /**
  1929. * Multiplies the current Vector3 coordinates by the given ones
  1930. * @param otherVector defines the second operand
  1931. * @returns the current updated Vector3
  1932. */
  1933. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1936. * @param otherVector defines the second operand
  1937. * @returns the new Vector3
  1938. */
  1939. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1940. /**
  1941. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1942. * @param otherVector defines the second operand
  1943. * @param result defines the Vector3 object where to store the result
  1944. * @returns the current Vector3
  1945. */
  1946. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1947. /**
  1948. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1949. * @param x defines the x coordinate of the operand
  1950. * @param y defines the y coordinate of the operand
  1951. * @param z defines the z coordinate of the operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1955. /**
  1956. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1957. * @param otherVector defines the second operand
  1958. * @returns the new Vector3
  1959. */
  1960. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1961. /**
  1962. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1963. * @param otherVector defines the second operand
  1964. * @param result defines the Vector3 object where to store the result
  1965. * @returns the current Vector3
  1966. */
  1967. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1968. /**
  1969. * Divides the current Vector3 coordinates by the given ones.
  1970. * @param otherVector defines the second operand
  1971. * @returns the current updated Vector3
  1972. */
  1973. divideInPlace(otherVector: Vector3): Vector3;
  1974. /**
  1975. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1976. * @param other defines the second operand
  1977. * @returns the current updated Vector3
  1978. */
  1979. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1980. /**
  1981. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1982. * @param other defines the second operand
  1983. * @returns the current updated Vector3
  1984. */
  1985. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1986. /**
  1987. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1988. * @param x defines the x coordinate of the operand
  1989. * @param y defines the y coordinate of the operand
  1990. * @param z defines the z coordinate of the operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1996. * @param x defines the x coordinate of the operand
  1997. * @param y defines the y coordinate of the operand
  1998. * @param z defines the z coordinate of the operand
  1999. * @returns the current updated Vector3
  2000. */
  2001. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2002. /**
  2003. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2004. * Check if is non uniform within a certain amount of decimal places to account for this
  2005. * @param epsilon the amount the values can differ
  2006. * @returns if the the vector is non uniform to a certain number of decimal places
  2007. */
  2008. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2009. /**
  2010. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2011. */
  2012. readonly isNonUniform: boolean;
  2013. /**
  2014. * Gets a new Vector3 from current Vector3 floored values
  2015. * @returns a new Vector3
  2016. */
  2017. floor(): Vector3;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. fract(): Vector3;
  2023. /**
  2024. * Gets the length of the Vector3
  2025. * @returns the length of the Vector3
  2026. */
  2027. length(): number;
  2028. /**
  2029. * Gets the squared length of the Vector3
  2030. * @returns squared length of the Vector3
  2031. */
  2032. lengthSquared(): number;
  2033. /**
  2034. * Normalize the current Vector3.
  2035. * Please note that this is an in place operation.
  2036. * @returns the current updated Vector3
  2037. */
  2038. normalize(): Vector3;
  2039. /**
  2040. * Reorders the x y z properties of the vector in place
  2041. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2042. * @returns the current updated vector
  2043. */
  2044. reorderInPlace(order: string): this;
  2045. /**
  2046. * Rotates the vector around 0,0,0 by a quaternion
  2047. * @param quaternion the rotation quaternion
  2048. * @param result vector to store the result
  2049. * @returns the resulting vector
  2050. */
  2051. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2052. /**
  2053. * Rotates a vector around a given point
  2054. * @param quaternion the rotation quaternion
  2055. * @param point the point to rotate around
  2056. * @param result vector to store the result
  2057. * @returns the resulting vector
  2058. */
  2059. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2060. /**
  2061. * Normalize the current Vector3 with the given input length.
  2062. * Please note that this is an in place operation.
  2063. * @param len the length of the vector
  2064. * @returns the current updated Vector3
  2065. */
  2066. normalizeFromLength(len: number): Vector3;
  2067. /**
  2068. * Normalize the current Vector3 to a new vector
  2069. * @returns the new Vector3
  2070. */
  2071. normalizeToNew(): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to the reference
  2074. * @param reference define the Vector3 to update
  2075. * @returns the updated Vector3
  2076. */
  2077. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2078. /**
  2079. * Creates a new Vector3 copied from the current Vector3
  2080. * @returns the new Vector3
  2081. */
  2082. clone(): Vector3;
  2083. /**
  2084. * Copies the given vector coordinates to the current Vector3 ones
  2085. * @param source defines the source Vector3
  2086. * @returns the current updated Vector3
  2087. */
  2088. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2089. /**
  2090. * Copies the given floats to the current Vector3 coordinates
  2091. * @param x defines the x coordinate of the operand
  2092. * @param y defines the y coordinate of the operand
  2093. * @param z defines the z coordinate of the operand
  2094. * @returns the current updated Vector3
  2095. */
  2096. copyFromFloats(x: number, y: number, z: number): Vector3;
  2097. /**
  2098. * Copies the given floats to the current Vector3 coordinates
  2099. * @param x defines the x coordinate of the operand
  2100. * @param y defines the y coordinate of the operand
  2101. * @param z defines the z coordinate of the operand
  2102. * @returns the current updated Vector3
  2103. */
  2104. set(x: number, y: number, z: number): Vector3;
  2105. /**
  2106. * Copies the given float to the current Vector3 coordinates
  2107. * @param v defines the x, y and z coordinates of the operand
  2108. * @returns the current updated Vector3
  2109. */
  2110. setAll(v: number): Vector3;
  2111. /**
  2112. * Get the clip factor between two vectors
  2113. * @param vector0 defines the first operand
  2114. * @param vector1 defines the second operand
  2115. * @param axis defines the axis to use
  2116. * @param size defines the size along the axis
  2117. * @returns the clip factor
  2118. */
  2119. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2120. /**
  2121. * Get angle between two vectors
  2122. * @param vector0 angle between vector0 and vector1
  2123. * @param vector1 angle between vector0 and vector1
  2124. * @param normal direction of the normal
  2125. * @return the angle between vector0 and vector1
  2126. */
  2127. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2128. /**
  2129. * Returns a new Vector3 set from the index "offset" of the given array
  2130. * @param array defines the source array
  2131. * @param offset defines the offset in the source array
  2132. * @returns the new Vector3
  2133. */
  2134. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2135. /**
  2136. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2137. * This function is deprecated. Use FromArray instead
  2138. * @param array defines the source array
  2139. * @param offset defines the offset in the source array
  2140. * @returns the new Vector3
  2141. */
  2142. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2143. /**
  2144. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @param result defines the Vector3 where to store the result
  2148. */
  2149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2150. /**
  2151. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArrayToRef instead.
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @param result defines the Vector3 where to store the result
  2156. */
  2157. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2158. /**
  2159. * Sets the given vector "result" with the given floats.
  2160. * @param x defines the x coordinate of the source
  2161. * @param y defines the y coordinate of the source
  2162. * @param z defines the z coordinate of the source
  2163. * @param result defines the Vector3 where to store the result
  2164. */
  2165. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2166. /**
  2167. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2168. * @returns a new empty Vector3
  2169. */
  2170. static Zero(): Vector3;
  2171. /**
  2172. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2173. * @returns a new unit Vector3
  2174. */
  2175. static One(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2178. * @returns a new up Vector3
  2179. */
  2180. static Up(): Vector3;
  2181. /**
  2182. * Gets a up Vector3 that must not be updated
  2183. */
  2184. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2185. /**
  2186. * Gets a zero Vector3 that must not be updated
  2187. */
  2188. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2189. /**
  2190. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2191. * @returns a new down Vector3
  2192. */
  2193. static Down(): Vector3;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2196. * @returns a new forward Vector3
  2197. */
  2198. static Forward(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Backward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2206. * @returns a new right Vector3
  2207. */
  2208. static Right(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2211. * @returns a new left Vector3
  2212. */
  2213. static Left(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2216. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2217. * @param vector defines the Vector3 to transform
  2218. * @param transformation defines the transformation matrix
  2219. * @returns the transformed Vector3
  2220. */
  2221. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2222. /**
  2223. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2224. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2225. * @param vector defines the Vector3 to transform
  2226. * @param transformation defines the transformation matrix
  2227. * @param result defines the Vector3 where to store the result
  2228. */
  2229. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2230. /**
  2231. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2232. * This method computes tranformed coordinates only, not transformed direction vectors
  2233. * @param x define the x coordinate of the source vector
  2234. * @param y define the y coordinate of the source vector
  2235. * @param z define the z coordinate of the source vector
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2242. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2243. * @param vector defines the Vector3 to transform
  2244. * @param transformation defines the transformation matrix
  2245. * @returns the new Vector3
  2246. */
  2247. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2248. /**
  2249. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2250. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2251. * @param vector defines the Vector3 to transform
  2252. * @param transformation defines the transformation matrix
  2253. * @param result defines the Vector3 where to store the result
  2254. */
  2255. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2256. /**
  2257. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2258. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2259. * @param x define the x coordinate of the source vector
  2260. * @param y define the y coordinate of the source vector
  2261. * @param z define the z coordinate of the source vector
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2268. * @param value1 defines the first control point
  2269. * @param value2 defines the second control point
  2270. * @param value3 defines the third control point
  2271. * @param value4 defines the fourth control point
  2272. * @param amount defines the amount on the spline to use
  2273. * @returns the new Vector3
  2274. */
  2275. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2276. /**
  2277. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2278. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2279. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2280. * @param value defines the current value
  2281. * @param min defines the lower range value
  2282. * @param max defines the upper range value
  2283. * @returns the new Vector3
  2284. */
  2285. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2286. /**
  2287. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @param result defines the Vector3 where to store the result
  2294. */
  2295. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2296. /**
  2297. * Checks if a given vector is inside a specific range
  2298. * @param v defines the vector to test
  2299. * @param min defines the minimum range
  2300. * @param max defines the maximum range
  2301. */
  2302. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2303. /**
  2304. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2305. * @param value1 defines the first control point
  2306. * @param tangent1 defines the first tangent vector
  2307. * @param value2 defines the second control point
  2308. * @param tangent2 defines the second tangent vector
  2309. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2310. * @returns the new Vector3
  2311. */
  2312. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2315. * @param start defines the start value
  2316. * @param end defines the end value
  2317. * @param amount max defines amount between both (between 0 and 1)
  2318. * @returns the new Vector3
  2319. */
  2320. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2321. /**
  2322. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2323. * @param start defines the start value
  2324. * @param end defines the end value
  2325. * @param amount max defines amount between both (between 0 and 1)
  2326. * @param result defines the Vector3 where to store the result
  2327. */
  2328. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2329. /**
  2330. * Returns the dot product (float) between the vectors "left" and "right"
  2331. * @param left defines the left operand
  2332. * @param right defines the right operand
  2333. * @returns the dot product
  2334. */
  2335. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2336. /**
  2337. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2338. * The cross product is then orthogonal to both "left" and "right"
  2339. * @param left defines the left operand
  2340. * @param right defines the right operand
  2341. * @returns the cross product
  2342. */
  2343. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2344. /**
  2345. * Sets the given vector "result" with the cross product of "left" and "right"
  2346. * The cross product is then orthogonal to both "left" and "right"
  2347. * @param left defines the left operand
  2348. * @param right defines the right operand
  2349. * @param result defines the Vector3 where to store the result
  2350. */
  2351. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2352. /**
  2353. * Returns a new Vector3 as the normalization of the given vector
  2354. * @param vector defines the Vector3 to normalize
  2355. * @returns the new Vector3
  2356. */
  2357. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2358. /**
  2359. * Sets the given vector "result" with the normalization of the given first vector
  2360. * @param vector defines the Vector3 to normalize
  2361. * @param result defines the Vector3 where to store the result
  2362. */
  2363. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2364. /**
  2365. * Project a Vector3 onto screen space
  2366. * @param vector defines the Vector3 to project
  2367. * @param world defines the world matrix to use
  2368. * @param transform defines the transform (view x projection) matrix to use
  2369. * @param viewport defines the screen viewport to use
  2370. * @returns the new Vector3
  2371. */
  2372. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2373. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2374. /**
  2375. * Unproject from screen space to object space
  2376. * @param source defines the screen space Vector3 to use
  2377. * @param viewportWidth defines the current width of the viewport
  2378. * @param viewportHeight defines the current height of the viewport
  2379. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2380. * @param transform defines the transform (view x projection) matrix to use
  2381. * @returns the new Vector3
  2382. */
  2383. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2384. /**
  2385. * Unproject from screen space to object space
  2386. * @param source defines the screen space Vector3 to use
  2387. * @param viewportWidth defines the current width of the viewport
  2388. * @param viewportHeight defines the current height of the viewport
  2389. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2390. * @param view defines the view matrix to use
  2391. * @param projection defines the projection matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @param result defines the Vector3 where to store the result
  2404. */
  2405. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param sourceX defines the screen space x coordinate to use
  2409. * @param sourceY defines the screen space y coordinate to use
  2410. * @param sourceZ defines the screen space z coordinate to use
  2411. * @param viewportWidth defines the current width of the viewport
  2412. * @param viewportHeight defines the current height of the viewport
  2413. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2414. * @param view defines the view matrix to use
  2415. * @param projection defines the projection matrix to use
  2416. * @param result defines the Vector3 where to store the result
  2417. */
  2418. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2419. /**
  2420. * Gets the minimal coordinate values between two Vector3
  2421. * @param left defines the first operand
  2422. * @param right defines the second operand
  2423. * @returns the new Vector3
  2424. */
  2425. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2426. /**
  2427. * Gets the maximal coordinate values between two Vector3
  2428. * @param left defines the first operand
  2429. * @param right defines the second operand
  2430. * @returns the new Vector3
  2431. */
  2432. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2433. /**
  2434. * Returns the distance between the vectors "value1" and "value2"
  2435. * @param value1 defines the first operand
  2436. * @param value2 defines the second operand
  2437. * @returns the distance
  2438. */
  2439. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2440. /**
  2441. * Returns the squared distance between the vectors "value1" and "value2"
  2442. * @param value1 defines the first operand
  2443. * @param value2 defines the second operand
  2444. * @returns the squared distance
  2445. */
  2446. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2447. /**
  2448. * Returns a new Vector3 located at the center between "value1" and "value2"
  2449. * @param value1 defines the first operand
  2450. * @param value2 defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2456. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2457. * to something in order to rotate it from its local system to the given target system
  2458. * Note: axis1, axis2 and axis3 are normalized during this operation
  2459. * @param axis1 defines the first axis
  2460. * @param axis2 defines the second axis
  2461. * @param axis3 defines the third axis
  2462. * @returns a new Vector3
  2463. */
  2464. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2467. * @param axis1 defines the first axis
  2468. * @param axis2 defines the second axis
  2469. * @param axis3 defines the third axis
  2470. * @param ref defines the Vector3 where to store the result
  2471. */
  2472. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2473. }
  2474. /**
  2475. * Vector4 class created for EulerAngle class conversion to Quaternion
  2476. */
  2477. export class Vector4 {
  2478. /** x value of the vector */
  2479. x: number;
  2480. /** y value of the vector */
  2481. y: number;
  2482. /** z value of the vector */
  2483. z: number;
  2484. /** w value of the vector */
  2485. w: number;
  2486. /**
  2487. * Creates a Vector4 object from the given floats.
  2488. * @param x x value of the vector
  2489. * @param y y value of the vector
  2490. * @param z z value of the vector
  2491. * @param w w value of the vector
  2492. */
  2493. constructor(
  2494. /** x value of the vector */
  2495. x: number,
  2496. /** y value of the vector */
  2497. y: number,
  2498. /** z value of the vector */
  2499. z: number,
  2500. /** w value of the vector */
  2501. w: number);
  2502. /**
  2503. * Returns the string with the Vector4 coordinates.
  2504. * @returns a string containing all the vector values
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Returns the string "Vector4".
  2509. * @returns "Vector4"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Returns the Vector4 hash code.
  2514. * @returns a unique hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2519. * @returns the resulting array
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Populates the given array from the given index with the Vector4 coordinates.
  2524. * @param array array to populate
  2525. * @param index index of the array to start at (default: 0)
  2526. * @returns the Vector4.
  2527. */
  2528. toArray(array: FloatArray, index?: number): Vector4;
  2529. /**
  2530. * Adds the given vector to the current Vector4.
  2531. * @param otherVector the vector to add
  2532. * @returns the updated Vector4.
  2533. */
  2534. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2535. /**
  2536. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2537. * @param otherVector the vector to add
  2538. * @returns the resulting vector
  2539. */
  2540. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @param result the vector to store the result
  2545. * @returns the current Vector4.
  2546. */
  2547. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2548. /**
  2549. * Subtract in place the given vector from the current Vector4.
  2550. * @param otherVector the vector to subtract
  2551. * @returns the updated Vector4.
  2552. */
  2553. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2554. /**
  2555. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2556. * @param otherVector the vector to add
  2557. * @returns the new vector with the result
  2558. */
  2559. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to subtract
  2563. * @param result the vector to store the result
  2564. * @returns the current Vector4.
  2565. */
  2566. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2567. /**
  2568. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2569. */
  2570. /**
  2571. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2572. * @param x value to subtract
  2573. * @param y value to subtract
  2574. * @param z value to subtract
  2575. * @param w value to subtract
  2576. * @returns new vector containing the result
  2577. */
  2578. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2579. /**
  2580. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2581. * @param x value to subtract
  2582. * @param y value to subtract
  2583. * @param z value to subtract
  2584. * @param w value to subtract
  2585. * @param result the vector to store the result in
  2586. * @returns the current Vector4.
  2587. */
  2588. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2589. /**
  2590. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2591. * @returns a new vector with the negated values
  2592. */
  2593. negate(): Vector4;
  2594. /**
  2595. * Multiplies the current Vector4 coordinates by scale (float).
  2596. * @param scale the number to scale with
  2597. * @returns the updated Vector4.
  2598. */
  2599. scaleInPlace(scale: number): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns a new vector with the result
  2604. */
  2605. scale(scale: number): Vector4;
  2606. /**
  2607. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @param result a vector to store the result in
  2610. * @returns the current Vector4.
  2611. */
  2612. scaleToRef(scale: number, result: Vector4): Vector4;
  2613. /**
  2614. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector4 object where to store the result
  2617. * @returns the unmodified current Vector4
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2620. /**
  2621. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2622. * @param otherVector the vector to compare against
  2623. * @returns true if they are equal
  2624. */
  2625. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2628. * @param otherVector vector to compare against
  2629. * @param epsilon (Default: very small number)
  2630. * @returns true if they are equal
  2631. */
  2632. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2633. /**
  2634. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2635. * @param x x value to compare against
  2636. * @param y y value to compare against
  2637. * @param z z value to compare against
  2638. * @param w w value to compare against
  2639. * @returns true if equal
  2640. */
  2641. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2642. /**
  2643. * Multiplies in place the current Vector4 by the given one.
  2644. * @param otherVector vector to multiple with
  2645. * @returns the updated Vector4.
  2646. */
  2647. multiplyInPlace(otherVector: Vector4): Vector4;
  2648. /**
  2649. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns resulting new vector
  2652. */
  2653. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2654. /**
  2655. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @param result vector to store the result
  2658. * @returns the current Vector4.
  2659. */
  2660. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2661. /**
  2662. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2663. * @param x x value multiply with
  2664. * @param y y value multiply with
  2665. * @param z z value multiply with
  2666. * @param w w value multiply with
  2667. * @returns resulting new vector
  2668. */
  2669. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2670. /**
  2671. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2672. * @param otherVector vector to devide with
  2673. * @returns resulting new vector
  2674. */
  2675. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2676. /**
  2677. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @param result vector to store the result
  2680. * @returns the current Vector4.
  2681. */
  2682. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2683. /**
  2684. * Divides the current Vector3 coordinates by the given ones.
  2685. * @param otherVector vector to devide with
  2686. * @returns the updated Vector3.
  2687. */
  2688. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2689. /**
  2690. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2691. * @param other defines the second operand
  2692. * @returns the current updated Vector4
  2693. */
  2694. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Gets a new Vector4 from current Vector4 floored values
  2703. * @returns a new Vector4
  2704. */
  2705. floor(): Vector4;
  2706. /**
  2707. * Gets a new Vector4 from current Vector3 floored values
  2708. * @returns a new Vector4
  2709. */
  2710. fract(): Vector4;
  2711. /**
  2712. * Returns the Vector4 length (float).
  2713. * @returns the length
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Returns the Vector4 squared length (float).
  2718. * @returns the length squared
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalizes in place the Vector4.
  2723. * @returns the updated Vector4.
  2724. */
  2725. normalize(): Vector4;
  2726. /**
  2727. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2728. * @returns this converted to a new vector3
  2729. */
  2730. toVector3(): Vector3;
  2731. /**
  2732. * Returns a new Vector4 copied from the current one.
  2733. * @returns the new cloned vector
  2734. */
  2735. clone(): Vector4;
  2736. /**
  2737. * Updates the current Vector4 with the given one coordinates.
  2738. * @param source the source vector to copy from
  2739. * @returns the updated Vector4.
  2740. */
  2741. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2742. /**
  2743. * Updates the current Vector4 coordinates with the given floats.
  2744. * @param x float to copy from
  2745. * @param y float to copy from
  2746. * @param z float to copy from
  2747. * @param w float to copy from
  2748. * @returns the updated Vector4.
  2749. */
  2750. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2751. /**
  2752. * Updates the current Vector4 coordinates with the given floats.
  2753. * @param x float to set from
  2754. * @param y float to set from
  2755. * @param z float to set from
  2756. * @param w float to set from
  2757. * @returns the updated Vector4.
  2758. */
  2759. set(x: number, y: number, z: number, w: number): Vector4;
  2760. /**
  2761. * Copies the given float to the current Vector3 coordinates
  2762. * @param v defines the x, y, z and w coordinates of the operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. setAll(v: number): Vector4;
  2766. /**
  2767. * Returns a new Vector4 set from the starting index of the given array.
  2768. * @param array the array to pull values from
  2769. * @param offset the offset into the array to start at
  2770. * @returns the new vector
  2771. */
  2772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2773. /**
  2774. * Updates the given vector "result" from the starting index of the given array.
  2775. * @param array the array to pull values from
  2776. * @param offset the offset into the array to start at
  2777. * @param result the vector to store the result in
  2778. */
  2779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2780. /**
  2781. * Updates the given vector "result" from the starting index of the given Float32Array.
  2782. * @param array the array to pull values from
  2783. * @param offset the offset into the array to start at
  2784. * @param result the vector to store the result in
  2785. */
  2786. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2787. /**
  2788. * Updates the given vector "result" coordinates from the given floats.
  2789. * @param x float to set from
  2790. * @param y float to set from
  2791. * @param z float to set from
  2792. * @param w float to set from
  2793. * @param result the vector to the floats in
  2794. */
  2795. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2796. /**
  2797. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2798. * @returns the new vector
  2799. */
  2800. static Zero(): Vector4;
  2801. /**
  2802. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2803. * @returns the new vector
  2804. */
  2805. static One(): Vector4;
  2806. /**
  2807. * Returns a new normalized Vector4 from the given one.
  2808. * @param vector the vector to normalize
  2809. * @returns the vector
  2810. */
  2811. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2812. /**
  2813. * Updates the given vector "result" from the normalization of the given one.
  2814. * @param vector the vector to normalize
  2815. * @param result the vector to store the result in
  2816. */
  2817. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2818. /**
  2819. * Returns a vector with the minimum values from the left and right vectors
  2820. * @param left left vector to minimize
  2821. * @param right right vector to minimize
  2822. * @returns a new vector with the minimum of the left and right vector values
  2823. */
  2824. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2825. /**
  2826. * Returns a vector with the maximum values from the left and right vectors
  2827. * @param left left vector to maximize
  2828. * @param right right vector to maximize
  2829. * @returns a new vector with the maximum of the left and right vector values
  2830. */
  2831. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2832. /**
  2833. * Returns the distance (float) between the vectors "value1" and "value2".
  2834. * @param value1 value to calulate the distance between
  2835. * @param value2 value to calulate the distance between
  2836. * @return the distance between the two vectors
  2837. */
  2838. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2839. /**
  2840. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2841. * @param value1 value to calulate the distance between
  2842. * @param value2 value to calulate the distance between
  2843. * @return the distance between the two vectors squared
  2844. */
  2845. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2846. /**
  2847. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2848. * @param value1 value to calulate the center between
  2849. * @param value2 value to calulate the center between
  2850. * @return the center between the two vectors
  2851. */
  2852. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2855. * This methods computes transformed normalized direction vectors only.
  2856. * @param vector the vector to transform
  2857. * @param transformation the transformation matrix to apply
  2858. * @returns the new vector
  2859. */
  2860. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2861. /**
  2862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2863. * This methods computes transformed normalized direction vectors only.
  2864. * @param vector the vector to transform
  2865. * @param transformation the transformation matrix to apply
  2866. * @param result the vector to store the result in
  2867. */
  2868. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2869. /**
  2870. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param x value to transform
  2873. * @param y value to transform
  2874. * @param z value to transform
  2875. * @param w value to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the results in
  2878. */
  2879. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Creates a new Vector4 from a Vector3
  2882. * @param source defines the source data
  2883. * @param w defines the 4th component (default is 0)
  2884. * @returns a new Vector4
  2885. */
  2886. static FromVector3(source: Vector3, w?: number): Vector4;
  2887. }
  2888. /**
  2889. * Class used to store quaternion data
  2890. * @see https://en.wikipedia.org/wiki/Quaternion
  2891. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2892. */
  2893. export class Quaternion {
  2894. /** defines the first component (0 by default) */
  2895. x: number;
  2896. /** defines the second component (0 by default) */
  2897. y: number;
  2898. /** defines the third component (0 by default) */
  2899. z: number;
  2900. /** defines the fourth component (1.0 by default) */
  2901. w: number;
  2902. /**
  2903. * Creates a new Quaternion from the given floats
  2904. * @param x defines the first component (0 by default)
  2905. * @param y defines the second component (0 by default)
  2906. * @param z defines the third component (0 by default)
  2907. * @param w defines the fourth component (1.0 by default)
  2908. */
  2909. constructor(
  2910. /** defines the first component (0 by default) */
  2911. x?: number,
  2912. /** defines the second component (0 by default) */
  2913. y?: number,
  2914. /** defines the third component (0 by default) */
  2915. z?: number,
  2916. /** defines the fourth component (1.0 by default) */
  2917. w?: number);
  2918. /**
  2919. * Gets a string representation for the current quaternion
  2920. * @returns a string with the Quaternion coordinates
  2921. */
  2922. toString(): string;
  2923. /**
  2924. * Gets the class name of the quaternion
  2925. * @returns the string "Quaternion"
  2926. */
  2927. getClassName(): string;
  2928. /**
  2929. * Gets a hash code for this quaternion
  2930. * @returns the quaternion hash code
  2931. */
  2932. getHashCode(): number;
  2933. /**
  2934. * Copy the quaternion to an array
  2935. * @returns a new array populated with 4 elements from the quaternion coordinates
  2936. */
  2937. asArray(): number[];
  2938. /**
  2939. * Check if two quaternions are equals
  2940. * @param otherQuaternion defines the second operand
  2941. * @return true if the current quaternion and the given one coordinates are strictly equals
  2942. */
  2943. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2944. /**
  2945. * Clone the current quaternion
  2946. * @returns a new quaternion copied from the current one
  2947. */
  2948. clone(): Quaternion;
  2949. /**
  2950. * Copy a quaternion to the current one
  2951. * @param other defines the other quaternion
  2952. * @returns the updated current quaternion
  2953. */
  2954. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2955. /**
  2956. * Updates the current quaternion with the given float coordinates
  2957. * @param x defines the x coordinate
  2958. * @param y defines the y coordinate
  2959. * @param z defines the z coordinate
  2960. * @param w defines the w coordinate
  2961. * @returns the updated current quaternion
  2962. */
  2963. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2964. /**
  2965. * Updates the current quaternion from the given float coordinates
  2966. * @param x defines the x coordinate
  2967. * @param y defines the y coordinate
  2968. * @param z defines the z coordinate
  2969. * @param w defines the w coordinate
  2970. * @returns the updated current quaternion
  2971. */
  2972. set(x: number, y: number, z: number, w: number): Quaternion;
  2973. /**
  2974. * Adds two quaternions
  2975. * @param other defines the second operand
  2976. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2977. */
  2978. add(other: DeepImmutable<Quaternion>): Quaternion;
  2979. /**
  2980. * Add a quaternion to the current one
  2981. * @param other defines the quaternion to add
  2982. * @returns the current quaternion
  2983. */
  2984. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Subtract two quaternions
  2987. * @param other defines the second operand
  2988. * @returns a new quaternion as the subtraction result of the given one from the current one
  2989. */
  2990. subtract(other: Quaternion): Quaternion;
  2991. /**
  2992. * Multiplies the current quaternion by a scale factor
  2993. * @param value defines the scale factor
  2994. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2995. */
  2996. scale(value: number): Quaternion;
  2997. /**
  2998. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2999. * @param scale defines the scale factor
  3000. * @param result defines the Quaternion object where to store the result
  3001. * @returns the unmodified current quaternion
  3002. */
  3003. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3004. /**
  3005. * Multiplies in place the current quaternion by a scale factor
  3006. * @param value defines the scale factor
  3007. * @returns the current modified quaternion
  3008. */
  3009. scaleInPlace(value: number): Quaternion;
  3010. /**
  3011. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3012. * @param scale defines the scale factor
  3013. * @param result defines the Quaternion object where to store the result
  3014. * @returns the unmodified current quaternion
  3015. */
  3016. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3017. /**
  3018. * Multiplies two quaternions
  3019. * @param q1 defines the second operand
  3020. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3021. */
  3022. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3023. /**
  3024. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3025. * @param q1 defines the second operand
  3026. * @param result defines the target quaternion
  3027. * @returns the current quaternion
  3028. */
  3029. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3030. /**
  3031. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3032. * @param q1 defines the second operand
  3033. * @returns the currentupdated quaternion
  3034. */
  3035. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3036. /**
  3037. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3038. * @param ref defines the target quaternion
  3039. * @returns the current quaternion
  3040. */
  3041. conjugateToRef(ref: Quaternion): Quaternion;
  3042. /**
  3043. * Conjugates in place (1-q) the current quaternion
  3044. * @returns the current updated quaternion
  3045. */
  3046. conjugateInPlace(): Quaternion;
  3047. /**
  3048. * Conjugates in place (1-q) the current quaternion
  3049. * @returns a new quaternion
  3050. */
  3051. conjugate(): Quaternion;
  3052. /**
  3053. * Gets length of current quaternion
  3054. * @returns the quaternion length (float)
  3055. */
  3056. length(): number;
  3057. /**
  3058. * Normalize in place the current quaternion
  3059. * @returns the current updated quaternion
  3060. */
  3061. normalize(): Quaternion;
  3062. /**
  3063. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3064. * @param order is a reserved parameter and is ignore for now
  3065. * @returns a new Vector3 containing the Euler angles
  3066. */
  3067. toEulerAngles(order?: string): Vector3;
  3068. /**
  3069. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3070. * @param result defines the vector which will be filled with the Euler angles
  3071. * @param order is a reserved parameter and is ignore for now
  3072. * @returns the current unchanged quaternion
  3073. */
  3074. toEulerAnglesToRef(result: Vector3): Quaternion;
  3075. /**
  3076. * Updates the given rotation matrix with the current quaternion values
  3077. * @param result defines the target matrix
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toRotationMatrix(result: Matrix): Quaternion;
  3081. /**
  3082. * Updates the current quaternion from the given rotation matrix values
  3083. * @param matrix defines the source matrix
  3084. * @returns the current updated quaternion
  3085. */
  3086. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3087. /**
  3088. * Creates a new quaternion from a rotation matrix
  3089. * @param matrix defines the source matrix
  3090. * @returns a new quaternion created from the given rotation matrix values
  3091. */
  3092. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Updates the given quaternion with the given rotation matrix values
  3095. * @param matrix defines the source matrix
  3096. * @param result defines the target quaternion
  3097. */
  3098. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3099. /**
  3100. * Returns the dot product (float) between the quaternions "left" and "right"
  3101. * @param left defines the left operand
  3102. * @param right defines the right operand
  3103. * @returns the dot product
  3104. */
  3105. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3106. /**
  3107. * Checks if the two quaternions are close to each other
  3108. * @param quat0 defines the first quaternion to check
  3109. * @param quat1 defines the second quaternion to check
  3110. * @returns true if the two quaternions are close to each other
  3111. */
  3112. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3113. /**
  3114. * Creates an empty quaternion
  3115. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3116. */
  3117. static Zero(): Quaternion;
  3118. /**
  3119. * Inverse a given quaternion
  3120. * @param q defines the source quaternion
  3121. * @returns a new quaternion as the inverted current quaternion
  3122. */
  3123. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @param result the quaternion the result will be stored in
  3128. * @returns the result quaternion
  3129. */
  3130. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3131. /**
  3132. * Creates an identity quaternion
  3133. * @returns the identity quaternion
  3134. */
  3135. static Identity(): Quaternion;
  3136. /**
  3137. * Gets a boolean indicating if the given quaternion is identity
  3138. * @param quaternion defines the quaternion to check
  3139. * @returns true if the quaternion is identity
  3140. */
  3141. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3142. /**
  3143. * Creates a quaternion from a rotation around an axis
  3144. * @param axis defines the axis to use
  3145. * @param angle defines the angle to use
  3146. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3147. */
  3148. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3149. /**
  3150. * Creates a rotation around an axis and stores it into the given quaternion
  3151. * @param axis defines the axis to use
  3152. * @param angle defines the angle to use
  3153. * @param result defines the target quaternion
  3154. * @returns the target quaternion
  3155. */
  3156. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3157. /**
  3158. * Creates a new quaternion from data stored into an array
  3159. * @param array defines the data source
  3160. * @param offset defines the offset in the source array where the data starts
  3161. * @returns a new quaternion
  3162. */
  3163. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3164. /**
  3165. * Create a quaternion from Euler rotation angles
  3166. * @param x Pitch
  3167. * @param y Yaw
  3168. * @param z Roll
  3169. * @returns the new Quaternion
  3170. */
  3171. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3172. /**
  3173. * Updates a quaternion from Euler rotation angles
  3174. * @param x Pitch
  3175. * @param y Yaw
  3176. * @param z Roll
  3177. * @param result the quaternion to store the result
  3178. * @returns the updated quaternion
  3179. */
  3180. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3181. /**
  3182. * Create a quaternion from Euler rotation vector
  3183. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3184. * @returns the new Quaternion
  3185. */
  3186. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3187. /**
  3188. * Updates a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @param result the quaternion to store the result
  3191. * @returns the updated quaternion
  3192. */
  3193. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3194. /**
  3195. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3196. * @param yaw defines the rotation around Y axis
  3197. * @param pitch defines the rotation around X axis
  3198. * @param roll defines the rotation around Z axis
  3199. * @returns the new quaternion
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3202. /**
  3203. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3204. * @param yaw defines the rotation around Y axis
  3205. * @param pitch defines the rotation around X axis
  3206. * @param roll defines the rotation around Z axis
  3207. * @param result defines the target quaternion
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3212. * @param alpha defines the rotation around first axis
  3213. * @param beta defines the rotation around second axis
  3214. * @param gamma defines the rotation around third axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3218. /**
  3219. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3220. * @param alpha defines the rotation around first axis
  3221. * @param beta defines the rotation around second axis
  3222. * @param gamma defines the rotation around third axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3228. * @param axis1 defines the first axis
  3229. * @param axis2 defines the second axis
  3230. * @param axis3 defines the third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3234. /**
  3235. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3236. * @param axis1 defines the first axis
  3237. * @param axis2 defines the second axis
  3238. * @param axis3 defines the third axis
  3239. * @param ref defines the target quaternion
  3240. */
  3241. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3242. /**
  3243. * Interpolates between two quaternions
  3244. * @param left defines first quaternion
  3245. * @param right defines second quaternion
  3246. * @param amount defines the gradient to use
  3247. * @returns the new interpolated quaternion
  3248. */
  3249. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3250. /**
  3251. * Interpolates between two quaternions and stores it into a target quaternion
  3252. * @param left defines first quaternion
  3253. * @param right defines second quaternion
  3254. * @param amount defines the gradient to use
  3255. * @param result defines the target quaternion
  3256. */
  3257. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3258. /**
  3259. * Interpolate between two quaternions using Hermite interpolation
  3260. * @param value1 defines first quaternion
  3261. * @param tangent1 defines the incoming tangent
  3262. * @param value2 defines second quaternion
  3263. * @param tangent2 defines the outgoing tangent
  3264. * @param amount defines the target quaternion
  3265. * @returns the new interpolated quaternion
  3266. */
  3267. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3268. }
  3269. /**
  3270. * Class used to store matrix data (4x4)
  3271. */
  3272. export class Matrix {
  3273. private static _updateFlagSeed;
  3274. private static _identityReadOnly;
  3275. private _isIdentity;
  3276. private _isIdentityDirty;
  3277. private _isIdentity3x2;
  3278. private _isIdentity3x2Dirty;
  3279. /**
  3280. * Gets the update flag of the matrix which is an unique number for the matrix.
  3281. * It will be incremented every time the matrix data change.
  3282. * You can use it to speed the comparison between two versions of the same matrix.
  3283. */
  3284. updateFlag: number;
  3285. private readonly _m;
  3286. /**
  3287. * Gets the internal data of the matrix
  3288. */
  3289. readonly m: DeepImmutable<Float32Array>;
  3290. /** @hidden */ private _markAsUpdated(): void;
  3291. /** @hidden */
  3292. private _updateIdentityStatus;
  3293. /**
  3294. * Creates an empty matrix (filled with zeros)
  3295. */
  3296. constructor();
  3297. /**
  3298. * Check if the current matrix is identity
  3299. * @returns true is the matrix is the identity matrix
  3300. */
  3301. isIdentity(): boolean;
  3302. /**
  3303. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3304. * @returns true is the matrix is the identity matrix
  3305. */
  3306. isIdentityAs3x2(): boolean;
  3307. /**
  3308. * Gets the determinant of the matrix
  3309. * @returns the matrix determinant
  3310. */
  3311. determinant(): number;
  3312. /**
  3313. * Returns the matrix as a Float32Array
  3314. * @returns the matrix underlying array
  3315. */
  3316. toArray(): DeepImmutable<Float32Array>;
  3317. /**
  3318. * Returns the matrix as a Float32Array
  3319. * @returns the matrix underlying array.
  3320. */
  3321. asArray(): DeepImmutable<Float32Array>;
  3322. /**
  3323. * Inverts the current matrix in place
  3324. * @returns the current inverted matrix
  3325. */
  3326. invert(): Matrix;
  3327. /**
  3328. * Sets all the matrix elements to zero
  3329. * @returns the current matrix
  3330. */
  3331. reset(): Matrix;
  3332. /**
  3333. * Adds the current matrix with a second one
  3334. * @param other defines the matrix to add
  3335. * @returns a new matrix as the addition of the current matrix and the given one
  3336. */
  3337. add(other: DeepImmutable<Matrix>): Matrix;
  3338. /**
  3339. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3340. * @param other defines the matrix to add
  3341. * @param result defines the target matrix
  3342. * @returns the current matrix
  3343. */
  3344. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3345. /**
  3346. * Adds in place the given matrix to the current matrix
  3347. * @param other defines the second operand
  3348. * @returns the current updated matrix
  3349. */
  3350. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3351. /**
  3352. * Sets the given matrix to the current inverted Matrix
  3353. * @param other defines the target matrix
  3354. * @returns the unmodified current matrix
  3355. */
  3356. invertToRef(other: Matrix): Matrix;
  3357. /**
  3358. * add a value at the specified position in the current Matrix
  3359. * @param index the index of the value within the matrix. between 0 and 15.
  3360. * @param value the value to be added
  3361. * @returns the current updated matrix
  3362. */
  3363. addAtIndex(index: number, value: number): Matrix;
  3364. /**
  3365. * mutiply the specified position in the current Matrix by a value
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. multiplyAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * Inserts the translation vector (using 3 floats) in the current matrix
  3373. * @param x defines the 1st component of the translation
  3374. * @param y defines the 2nd component of the translation
  3375. * @param z defines the 3rd component of the translation
  3376. * @returns the current updated matrix
  3377. */
  3378. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3379. /**
  3380. * Adds the translation vector (using 3 floats) in the current matrix
  3381. * @param x defines the 1st component of the translation
  3382. * @param y defines the 2nd component of the translation
  3383. * @param z defines the 3rd component of the translation
  3384. * @returns the current updated matrix
  3385. */
  3386. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3387. /**
  3388. * Inserts the translation vector in the current matrix
  3389. * @param vector3 defines the translation to insert
  3390. * @returns the current updated matrix
  3391. */
  3392. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * Gets the translation value of the current matrix
  3395. * @returns a new Vector3 as the extracted translation from the matrix
  3396. */
  3397. getTranslation(): Vector3;
  3398. /**
  3399. * Fill a Vector3 with the extracted translation from the matrix
  3400. * @param result defines the Vector3 where to store the translation
  3401. * @returns the current matrix
  3402. */
  3403. getTranslationToRef(result: Vector3): Matrix;
  3404. /**
  3405. * Remove rotation and scaling part from the matrix
  3406. * @returns the updated matrix
  3407. */
  3408. removeRotationAndScaling(): Matrix;
  3409. /**
  3410. * Multiply two matrices
  3411. * @param other defines the second operand
  3412. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3413. */
  3414. multiply(other: DeepImmutable<Matrix>): Matrix;
  3415. /**
  3416. * Copy the current matrix from the given one
  3417. * @param other defines the source matrix
  3418. * @returns the current updated matrix
  3419. */
  3420. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3421. /**
  3422. * Populates the given array from the starting index with the current matrix values
  3423. * @param array defines the target array
  3424. * @param offset defines the offset in the target array where to start storing values
  3425. * @returns the current matrix
  3426. */
  3427. copyToArray(array: Float32Array, offset?: number): Matrix;
  3428. /**
  3429. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3430. * @param other defines the second operand
  3431. * @param result defines the matrix where to store the multiplication
  3432. * @returns the current matrix
  3433. */
  3434. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3435. /**
  3436. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the array where to store the multiplication
  3439. * @param offset defines the offset in the target array where to start storing values
  3440. * @returns the current matrix
  3441. */
  3442. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3443. /**
  3444. * Check equality between this matrix and a second one
  3445. * @param value defines the second matrix to compare
  3446. * @returns true is the current matrix and the given one values are strictly equal
  3447. */
  3448. equals(value: DeepImmutable<Matrix>): boolean;
  3449. /**
  3450. * Clone the current matrix
  3451. * @returns a new matrix from the current matrix
  3452. */
  3453. clone(): Matrix;
  3454. /**
  3455. * Returns the name of the current matrix class
  3456. * @returns the string "Matrix"
  3457. */
  3458. getClassName(): string;
  3459. /**
  3460. * Gets the hash code of the current matrix
  3461. * @returns the hash code
  3462. */
  3463. getHashCode(): number;
  3464. /**
  3465. * Decomposes the current Matrix into a translation, rotation and scaling components
  3466. * @param scale defines the scale vector3 given as a reference to update
  3467. * @param rotation defines the rotation quaternion given as a reference to update
  3468. * @param translation defines the translation vector3 given as a reference to update
  3469. * @returns true if operation was successful
  3470. */
  3471. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3472. /**
  3473. * Gets specific row of the matrix
  3474. * @param index defines the number of the row to get
  3475. * @returns the index-th row of the current matrix as a new Vector4
  3476. */
  3477. getRow(index: number): Nullable<Vector4>;
  3478. /**
  3479. * Sets the index-th row of the current matrix to the vector4 values
  3480. * @param index defines the number of the row to set
  3481. * @param row defines the target vector4
  3482. * @returns the updated current matrix
  3483. */
  3484. setRow(index: number, row: Vector4): Matrix;
  3485. /**
  3486. * Compute the transpose of the matrix
  3487. * @returns the new transposed matrix
  3488. */
  3489. transpose(): Matrix;
  3490. /**
  3491. * Compute the transpose of the matrix and store it in a given matrix
  3492. * @param result defines the target matrix
  3493. * @returns the current matrix
  3494. */
  3495. transposeToRef(result: Matrix): Matrix;
  3496. /**
  3497. * Sets the index-th row of the current matrix with the given 4 x float values
  3498. * @param index defines the row index
  3499. * @param x defines the x component to set
  3500. * @param y defines the y component to set
  3501. * @param z defines the z component to set
  3502. * @param w defines the w component to set
  3503. * @returns the updated current matrix
  3504. */
  3505. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3506. /**
  3507. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3508. * @param scale defines the scale factor
  3509. * @returns a new matrix
  3510. */
  3511. scale(scale: number): Matrix;
  3512. /**
  3513. * Scale the current matrix values by a factor to a given result matrix
  3514. * @param scale defines the scale factor
  3515. * @param result defines the matrix to store the result
  3516. * @returns the current matrix
  3517. */
  3518. scaleToRef(scale: number, result: Matrix): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor and add the result to a given matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the Matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3528. * @param ref matrix to store the result
  3529. */
  3530. toNormalMatrix(ref: Matrix): void;
  3531. /**
  3532. * Gets only rotation part of the current matrix
  3533. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3534. */
  3535. getRotationMatrix(): Matrix;
  3536. /**
  3537. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3538. * @param result defines the target matrix to store data to
  3539. * @returns the current matrix
  3540. */
  3541. getRotationMatrixToRef(result: Matrix): Matrix;
  3542. /**
  3543. * Toggles model matrix from being right handed to left handed in place and vice versa
  3544. */
  3545. toggleModelMatrixHandInPlace(): void;
  3546. /**
  3547. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3548. */
  3549. toggleProjectionMatrixHandInPlace(): void;
  3550. /**
  3551. * Creates a matrix from an array
  3552. * @param array defines the source array
  3553. * @param offset defines an offset in the source array
  3554. * @returns a new Matrix set from the starting index of the given array
  3555. */
  3556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3557. /**
  3558. * Copy the content of an array into a given matrix
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @param result defines the target matrix
  3562. */
  3563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3564. /**
  3565. * Stores an array into a matrix after having multiplied each component by a given factor
  3566. * @param array defines the source array
  3567. * @param offset defines the offset in the source array
  3568. * @param scale defines the scaling factor
  3569. * @param result defines the target matrix
  3570. */
  3571. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3572. /**
  3573. * Gets an identity matrix that must not be updated
  3574. */
  3575. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3576. /**
  3577. * Stores a list of values (16) inside a given matrix
  3578. * @param initialM11 defines 1st value of 1st row
  3579. * @param initialM12 defines 2nd value of 1st row
  3580. * @param initialM13 defines 3rd value of 1st row
  3581. * @param initialM14 defines 4th value of 1st row
  3582. * @param initialM21 defines 1st value of 2nd row
  3583. * @param initialM22 defines 2nd value of 2nd row
  3584. * @param initialM23 defines 3rd value of 2nd row
  3585. * @param initialM24 defines 4th value of 2nd row
  3586. * @param initialM31 defines 1st value of 3rd row
  3587. * @param initialM32 defines 2nd value of 3rd row
  3588. * @param initialM33 defines 3rd value of 3rd row
  3589. * @param initialM34 defines 4th value of 3rd row
  3590. * @param initialM41 defines 1st value of 4th row
  3591. * @param initialM42 defines 2nd value of 4th row
  3592. * @param initialM43 defines 3rd value of 4th row
  3593. * @param initialM44 defines 4th value of 4th row
  3594. * @param result defines the target matrix
  3595. */
  3596. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3597. /**
  3598. * Creates new matrix from a list of values (16)
  3599. * @param initialM11 defines 1st value of 1st row
  3600. * @param initialM12 defines 2nd value of 1st row
  3601. * @param initialM13 defines 3rd value of 1st row
  3602. * @param initialM14 defines 4th value of 1st row
  3603. * @param initialM21 defines 1st value of 2nd row
  3604. * @param initialM22 defines 2nd value of 2nd row
  3605. * @param initialM23 defines 3rd value of 2nd row
  3606. * @param initialM24 defines 4th value of 2nd row
  3607. * @param initialM31 defines 1st value of 3rd row
  3608. * @param initialM32 defines 2nd value of 3rd row
  3609. * @param initialM33 defines 3rd value of 3rd row
  3610. * @param initialM34 defines 4th value of 3rd row
  3611. * @param initialM41 defines 1st value of 4th row
  3612. * @param initialM42 defines 2nd value of 4th row
  3613. * @param initialM43 defines 3rd value of 4th row
  3614. * @param initialM44 defines 4th value of 4th row
  3615. * @returns the new matrix
  3616. */
  3617. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3618. /**
  3619. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3620. * @param scale defines the scale vector3
  3621. * @param rotation defines the rotation quaternion
  3622. * @param translation defines the translation vector3
  3623. * @returns a new matrix
  3624. */
  3625. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3626. /**
  3627. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3628. * @param scale defines the scale vector3
  3629. * @param rotation defines the rotation quaternion
  3630. * @param translation defines the translation vector3
  3631. * @param result defines the target matrix
  3632. */
  3633. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3634. /**
  3635. * Creates a new identity matrix
  3636. * @returns a new identity matrix
  3637. */
  3638. static Identity(): Matrix;
  3639. /**
  3640. * Creates a new identity matrix and stores the result in a given matrix
  3641. * @param result defines the target matrix
  3642. */
  3643. static IdentityToRef(result: Matrix): void;
  3644. /**
  3645. * Creates a new zero matrix
  3646. * @returns a new zero matrix
  3647. */
  3648. static Zero(): Matrix;
  3649. /**
  3650. * Creates a new rotation matrix for "angle" radians around the X axis
  3651. * @param angle defines the angle (in radians) to use
  3652. * @return the new matrix
  3653. */
  3654. static RotationX(angle: number): Matrix;
  3655. /**
  3656. * Creates a new matrix as the invert of a given matrix
  3657. * @param source defines the source matrix
  3658. * @returns the new matrix
  3659. */
  3660. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3663. * @param angle defines the angle (in radians) to use
  3664. * @param result defines the target matrix
  3665. */
  3666. static RotationXToRef(angle: number, result: Matrix): void;
  3667. /**
  3668. * Creates a new rotation matrix for "angle" radians around the Y axis
  3669. * @param angle defines the angle (in radians) to use
  3670. * @return the new matrix
  3671. */
  3672. static RotationY(angle: number): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationYToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Z axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationZ(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationZToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the given axis
  3693. * @param axis defines the axis to use
  3694. * @param angle defines the angle (in radians) to use
  3695. * @return the new matrix
  3696. */
  3697. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @param result defines the target matrix
  3703. */
  3704. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3705. /**
  3706. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3707. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3708. * @param from defines the vector to align
  3709. * @param to defines the vector to align to
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3713. /**
  3714. * Creates a rotation matrix
  3715. * @param yaw defines the yaw angle in radians (Y axis)
  3716. * @param pitch defines the pitch angle in radians (X axis)
  3717. * @param roll defines the roll angle in radians (X axis)
  3718. * @returns the new rotation matrix
  3719. */
  3720. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3721. /**
  3722. * Creates a rotation matrix and stores it in a given matrix
  3723. * @param yaw defines the yaw angle in radians (Y axis)
  3724. * @param pitch defines the pitch angle in radians (X axis)
  3725. * @param roll defines the roll angle in radians (X axis)
  3726. * @param result defines the target matrix
  3727. */
  3728. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3729. /**
  3730. * Creates a scaling matrix
  3731. * @param x defines the scale factor on X axis
  3732. * @param y defines the scale factor on Y axis
  3733. * @param z defines the scale factor on Z axis
  3734. * @returns the new matrix
  3735. */
  3736. static Scaling(x: number, y: number, z: number): Matrix;
  3737. /**
  3738. * Creates a scaling matrix and stores it in a given matrix
  3739. * @param x defines the scale factor on X axis
  3740. * @param y defines the scale factor on Y axis
  3741. * @param z defines the scale factor on Z axis
  3742. * @param result defines the target matrix
  3743. */
  3744. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3745. /**
  3746. * Creates a translation matrix
  3747. * @param x defines the translation on X axis
  3748. * @param y defines the translation on Y axis
  3749. * @param z defines the translationon Z axis
  3750. * @returns the new matrix
  3751. */
  3752. static Translation(x: number, y: number, z: number): Matrix;
  3753. /**
  3754. * Creates a translation matrix and stores it in a given matrix
  3755. * @param x defines the translation on X axis
  3756. * @param y defines the translation on Y axis
  3757. * @param z defines the translationon Z axis
  3758. * @param result defines the target matrix
  3759. */
  3760. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3761. /**
  3762. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3763. * @param startValue defines the start value
  3764. * @param endValue defines the end value
  3765. * @param gradient defines the gradient factor
  3766. * @returns the new matrix
  3767. */
  3768. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3769. /**
  3770. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3771. * @param startValue defines the start value
  3772. * @param endValue defines the end value
  3773. * @param gradient defines the gradient factor
  3774. * @param result defines the Matrix object where to store data
  3775. */
  3776. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3777. /**
  3778. * Builds a new matrix whose values are computed by:
  3779. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3780. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3781. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3782. * @param startValue defines the first matrix
  3783. * @param endValue defines the second matrix
  3784. * @param gradient defines the gradient between the two matrices
  3785. * @returns the new matrix
  3786. */
  3787. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3788. /**
  3789. * Update a matrix to values which are computed by:
  3790. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3791. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3792. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3793. * @param startValue defines the first matrix
  3794. * @param endValue defines the second matrix
  3795. * @param gradient defines the gradient between the two matrices
  3796. * @param result defines the target matrix
  3797. */
  3798. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3801. * This function works in left handed mode
  3802. * @param eye defines the final position of the entity
  3803. * @param target defines where the entity should look at
  3804. * @param up defines the up vector for the entity
  3805. * @returns the new matrix
  3806. */
  3807. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3808. /**
  3809. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3810. * This function works in left handed mode
  3811. * @param eye defines the final position of the entity
  3812. * @param target defines where the entity should look at
  3813. * @param up defines the up vector for the entity
  3814. * @param result defines the target matrix
  3815. */
  3816. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3817. /**
  3818. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3819. * This function works in right handed mode
  3820. * @param eye defines the final position of the entity
  3821. * @param target defines where the entity should look at
  3822. * @param up defines the up vector for the entity
  3823. * @returns the new matrix
  3824. */
  3825. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3826. /**
  3827. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3828. * This function works in right handed mode
  3829. * @param eye defines the final position of the entity
  3830. * @param target defines where the entity should look at
  3831. * @param up defines the up vector for the entity
  3832. * @param result defines the target matrix
  3833. */
  3834. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3835. /**
  3836. * Create a left-handed orthographic projection matrix
  3837. * @param width defines the viewport width
  3838. * @param height defines the viewport height
  3839. * @param znear defines the near clip plane
  3840. * @param zfar defines the far clip plane
  3841. * @returns a new matrix as a left-handed orthographic projection matrix
  3842. */
  3843. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3844. /**
  3845. * Store a left-handed orthographic projection to a given matrix
  3846. * @param width defines the viewport width
  3847. * @param height defines the viewport height
  3848. * @param znear defines the near clip plane
  3849. * @param zfar defines the far clip plane
  3850. * @param result defines the target matrix
  3851. */
  3852. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3853. /**
  3854. * Create a left-handed orthographic projection matrix
  3855. * @param left defines the viewport left coordinate
  3856. * @param right defines the viewport right coordinate
  3857. * @param bottom defines the viewport bottom coordinate
  3858. * @param top defines the viewport top coordinate
  3859. * @param znear defines the near clip plane
  3860. * @param zfar defines the far clip plane
  3861. * @returns a new matrix as a left-handed orthographic projection matrix
  3862. */
  3863. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3864. /**
  3865. * Stores a left-handed orthographic projection into a given matrix
  3866. * @param left defines the viewport left coordinate
  3867. * @param right defines the viewport right coordinate
  3868. * @param bottom defines the viewport bottom coordinate
  3869. * @param top defines the viewport top coordinate
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Creates a right-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a right-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a right-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a left-handed perspective projection matrix
  3899. * @param width defines the viewport width
  3900. * @param height defines the viewport height
  3901. * @param znear defines the near clip plane
  3902. * @param zfar defines the far clip plane
  3903. * @returns a new matrix as a left-handed perspective projection matrix
  3904. */
  3905. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3906. /**
  3907. * Creates a left-handed perspective projection matrix
  3908. * @param fov defines the horizontal field of view
  3909. * @param aspect defines the aspect ratio
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a left-handed perspective projection matrix
  3913. */
  3914. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a left-handed perspective projection into a given matrix
  3917. * @param fov defines the horizontal field of view
  3918. * @param aspect defines the aspect ratio
  3919. * @param znear defines the near clip plane
  3920. * @param zfar defines the far clip plane
  3921. * @param result defines the target matrix
  3922. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3923. */
  3924. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3925. /**
  3926. * Creates a right-handed perspective projection matrix
  3927. * @param fov defines the horizontal field of view
  3928. * @param aspect defines the aspect ratio
  3929. * @param znear defines the near clip plane
  3930. * @param zfar defines the far clip plane
  3931. * @returns a new matrix as a right-handed perspective projection matrix
  3932. */
  3933. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3934. /**
  3935. * Stores a right-handed perspective projection into a given matrix
  3936. * @param fov defines the horizontal field of view
  3937. * @param aspect defines the aspect ratio
  3938. * @param znear defines the near clip plane
  3939. * @param zfar defines the far clip plane
  3940. * @param result defines the target matrix
  3941. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3942. */
  3943. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3944. /**
  3945. * Stores a perspective projection for WebVR info a given matrix
  3946. * @param fov defines the field of view
  3947. * @param znear defines the near clip plane
  3948. * @param zfar defines the far clip plane
  3949. * @param result defines the target matrix
  3950. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3951. */
  3952. static PerspectiveFovWebVRToRef(fov: {
  3953. upDegrees: number;
  3954. downDegrees: number;
  3955. leftDegrees: number;
  3956. rightDegrees: number;
  3957. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3958. /**
  3959. * Computes a complete transformation matrix
  3960. * @param viewport defines the viewport to use
  3961. * @param world defines the world matrix
  3962. * @param view defines the view matrix
  3963. * @param projection defines the projection matrix
  3964. * @param zmin defines the near clip plane
  3965. * @param zmax defines the far clip plane
  3966. * @returns the transformation matrix
  3967. */
  3968. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3969. /**
  3970. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3971. * @param matrix defines the matrix to use
  3972. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3973. */
  3974. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3975. /**
  3976. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3977. * @param matrix defines the matrix to use
  3978. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3979. */
  3980. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3981. /**
  3982. * Compute the transpose of a given matrix
  3983. * @param matrix defines the matrix to transpose
  3984. * @returns the new matrix
  3985. */
  3986. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Compute the transpose of a matrix and store it in a target matrix
  3989. * @param matrix defines the matrix to transpose
  3990. * @param result defines the target matrix
  3991. */
  3992. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3993. /**
  3994. * Computes a reflection matrix from a plane
  3995. * @param plane defines the reflection plane
  3996. * @returns a new matrix
  3997. */
  3998. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3999. /**
  4000. * Computes a reflection matrix from a plane
  4001. * @param plane defines the reflection plane
  4002. * @param result defines the target matrix
  4003. */
  4004. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4005. /**
  4006. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4007. * @param xaxis defines the value of the 1st axis
  4008. * @param yaxis defines the value of the 2nd axis
  4009. * @param zaxis defines the value of the 3rd axis
  4010. * @param result defines the target matrix
  4011. */
  4012. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4013. /**
  4014. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4015. * @param quat defines the quaternion to use
  4016. * @param result defines the target matrix
  4017. */
  4018. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4019. }
  4020. /**
  4021. * @hidden
  4022. */
  4023. export class TmpVectors {
  4024. static Vector2: Vector2[];
  4025. static Vector3: Vector3[];
  4026. static Vector4: Vector4[];
  4027. static Quaternion: Quaternion[];
  4028. static Matrix: Matrix[];
  4029. }
  4030. }
  4031. declare module BABYLON {
  4032. /** Defines the cross module used constants to avoid circular dependncies */
  4033. export class Constants {
  4034. /** Defines that alpha blending is disabled */
  4035. static readonly ALPHA_DISABLE: number;
  4036. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4037. static readonly ALPHA_ADD: number;
  4038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4039. static readonly ALPHA_COMBINE: number;
  4040. /** Defines that alpha blending to DEST - SRC * DEST */
  4041. static readonly ALPHA_SUBTRACT: number;
  4042. /** Defines that alpha blending to SRC * DEST */
  4043. static readonly ALPHA_MULTIPLY: number;
  4044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4045. static readonly ALPHA_MAXIMIZED: number;
  4046. /** Defines that alpha blending to SRC + DEST */
  4047. static readonly ALPHA_ONEONE: number;
  4048. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4049. static readonly ALPHA_PREMULTIPLIED: number;
  4050. /**
  4051. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4052. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4053. */
  4054. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4055. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4056. static readonly ALPHA_INTERPOLATE: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4059. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_SCREENMODE: number;
  4062. /** Defines that the ressource is not delayed*/
  4063. static readonly DELAYLOADSTATE_NONE: number;
  4064. /** Defines that the ressource was successfully delay loaded */
  4065. static readonly DELAYLOADSTATE_LOADED: number;
  4066. /** Defines that the ressource is currently delay loading */
  4067. static readonly DELAYLOADSTATE_LOADING: number;
  4068. /** Defines that the ressource is delayed and has not started loading */
  4069. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4071. static readonly NEVER: number;
  4072. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4073. static readonly ALWAYS: number;
  4074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4075. static readonly LESS: number;
  4076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4077. static readonly EQUAL: number;
  4078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4079. static readonly LEQUAL: number;
  4080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4081. static readonly GREATER: number;
  4082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4083. static readonly GEQUAL: number;
  4084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4085. static readonly NOTEQUAL: number;
  4086. /** Passed to stencilOperation to specify that stencil value must be kept */
  4087. static readonly KEEP: number;
  4088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4089. static readonly REPLACE: number;
  4090. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4091. static readonly INCR: number;
  4092. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4093. static readonly DECR: number;
  4094. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4095. static readonly INVERT: number;
  4096. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4097. static readonly INCR_WRAP: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4099. static readonly DECR_WRAP: number;
  4100. /** Texture is not repeating outside of 0..1 UVs */
  4101. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4102. /** Texture is repeating outside of 0..1 UVs */
  4103. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4104. /** Texture is repeating and mirrored */
  4105. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4106. /** ALPHA */
  4107. static readonly TEXTUREFORMAT_ALPHA: number;
  4108. /** LUMINANCE */
  4109. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4110. /** LUMINANCE_ALPHA */
  4111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4112. /** RGB */
  4113. static readonly TEXTUREFORMAT_RGB: number;
  4114. /** RGBA */
  4115. static readonly TEXTUREFORMAT_RGBA: number;
  4116. /** RED */
  4117. static readonly TEXTUREFORMAT_RED: number;
  4118. /** RED (2nd reference) */
  4119. static readonly TEXTUREFORMAT_R: number;
  4120. /** RG */
  4121. static readonly TEXTUREFORMAT_RG: number;
  4122. /** RED_INTEGER */
  4123. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4124. /** RED_INTEGER (2nd reference) */
  4125. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4126. /** RG_INTEGER */
  4127. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4128. /** RGB_INTEGER */
  4129. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4130. /** RGBA_INTEGER */
  4131. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4132. /** UNSIGNED_BYTE */
  4133. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4134. /** UNSIGNED_BYTE (2nd reference) */
  4135. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4136. /** FLOAT */
  4137. static readonly TEXTURETYPE_FLOAT: number;
  4138. /** HALF_FLOAT */
  4139. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4140. /** BYTE */
  4141. static readonly TEXTURETYPE_BYTE: number;
  4142. /** SHORT */
  4143. static readonly TEXTURETYPE_SHORT: number;
  4144. /** UNSIGNED_SHORT */
  4145. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4146. /** INT */
  4147. static readonly TEXTURETYPE_INT: number;
  4148. /** UNSIGNED_INT */
  4149. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4150. /** UNSIGNED_SHORT_4_4_4_4 */
  4151. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4152. /** UNSIGNED_SHORT_5_5_5_1 */
  4153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4154. /** UNSIGNED_SHORT_5_6_5 */
  4155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4156. /** UNSIGNED_INT_2_10_10_10_REV */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4158. /** UNSIGNED_INT_24_8 */
  4159. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4160. /** UNSIGNED_INT_10F_11F_11F_REV */
  4161. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4162. /** UNSIGNED_INT_5_9_9_9_REV */
  4163. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4164. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4165. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4166. /** nearest is mag = nearest and min = nearest and mip = linear */
  4167. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4170. /** Trilinear is mag = linear and min = linear and mip = linear */
  4171. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4172. /** nearest is mag = nearest and min = nearest and mip = linear */
  4173. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4175. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4176. /** Trilinear is mag = linear and min = linear and mip = linear */
  4177. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4178. /** mag = nearest and min = nearest and mip = nearest */
  4179. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4180. /** mag = nearest and min = linear and mip = nearest */
  4181. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4182. /** mag = nearest and min = linear and mip = linear */
  4183. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4184. /** mag = nearest and min = linear and mip = none */
  4185. static readonly TEXTURE_NEAREST_LINEAR: number;
  4186. /** mag = nearest and min = nearest and mip = none */
  4187. static readonly TEXTURE_NEAREST_NEAREST: number;
  4188. /** mag = linear and min = nearest and mip = nearest */
  4189. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4190. /** mag = linear and min = nearest and mip = linear */
  4191. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4192. /** mag = linear and min = linear and mip = none */
  4193. static readonly TEXTURE_LINEAR_LINEAR: number;
  4194. /** mag = linear and min = nearest and mip = none */
  4195. static readonly TEXTURE_LINEAR_NEAREST: number;
  4196. /** Explicit coordinates mode */
  4197. static readonly TEXTURE_EXPLICIT_MODE: number;
  4198. /** Spherical coordinates mode */
  4199. static readonly TEXTURE_SPHERICAL_MODE: number;
  4200. /** Planar coordinates mode */
  4201. static readonly TEXTURE_PLANAR_MODE: number;
  4202. /** Cubic coordinates mode */
  4203. static readonly TEXTURE_CUBIC_MODE: number;
  4204. /** Projection coordinates mode */
  4205. static readonly TEXTURE_PROJECTION_MODE: number;
  4206. /** Skybox coordinates mode */
  4207. static readonly TEXTURE_SKYBOX_MODE: number;
  4208. /** Inverse Cubic coordinates mode */
  4209. static readonly TEXTURE_INVCUBIC_MODE: number;
  4210. /** Equirectangular coordinates mode */
  4211. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4212. /** Equirectangular Fixed coordinates mode */
  4213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4214. /** Equirectangular Fixed Mirrored coordinates mode */
  4215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4216. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4217. static readonly SCALEMODE_FLOOR: number;
  4218. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4219. static readonly SCALEMODE_NEAREST: number;
  4220. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4221. static readonly SCALEMODE_CEILING: number;
  4222. /**
  4223. * The dirty texture flag value
  4224. */
  4225. static readonly MATERIAL_TextureDirtyFlag: number;
  4226. /**
  4227. * The dirty light flag value
  4228. */
  4229. static readonly MATERIAL_LightDirtyFlag: number;
  4230. /**
  4231. * The dirty fresnel flag value
  4232. */
  4233. static readonly MATERIAL_FresnelDirtyFlag: number;
  4234. /**
  4235. * The dirty attribute flag value
  4236. */
  4237. static readonly MATERIAL_AttributesDirtyFlag: number;
  4238. /**
  4239. * The dirty misc flag value
  4240. */
  4241. static readonly MATERIAL_MiscDirtyFlag: number;
  4242. /**
  4243. * The all dirty flag value
  4244. */
  4245. static readonly MATERIAL_AllDirtyFlag: number;
  4246. /**
  4247. * Returns the triangle fill mode
  4248. */
  4249. static readonly MATERIAL_TriangleFillMode: number;
  4250. /**
  4251. * Returns the wireframe mode
  4252. */
  4253. static readonly MATERIAL_WireFrameFillMode: number;
  4254. /**
  4255. * Returns the point fill mode
  4256. */
  4257. static readonly MATERIAL_PointFillMode: number;
  4258. /**
  4259. * Returns the point list draw mode
  4260. */
  4261. static readonly MATERIAL_PointListDrawMode: number;
  4262. /**
  4263. * Returns the line list draw mode
  4264. */
  4265. static readonly MATERIAL_LineListDrawMode: number;
  4266. /**
  4267. * Returns the line loop draw mode
  4268. */
  4269. static readonly MATERIAL_LineLoopDrawMode: number;
  4270. /**
  4271. * Returns the line strip draw mode
  4272. */
  4273. static readonly MATERIAL_LineStripDrawMode: number;
  4274. /**
  4275. * Returns the triangle strip draw mode
  4276. */
  4277. static readonly MATERIAL_TriangleStripDrawMode: number;
  4278. /**
  4279. * Returns the triangle fan draw mode
  4280. */
  4281. static readonly MATERIAL_TriangleFanDrawMode: number;
  4282. /**
  4283. * Stores the clock-wise side orientation
  4284. */
  4285. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4286. /**
  4287. * Stores the counter clock-wise side orientation
  4288. */
  4289. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4290. /**
  4291. * Nothing
  4292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4293. */
  4294. static readonly ACTION_NothingTrigger: number;
  4295. /**
  4296. * On pick
  4297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4298. */
  4299. static readonly ACTION_OnPickTrigger: number;
  4300. /**
  4301. * On left pick
  4302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4303. */
  4304. static readonly ACTION_OnLeftPickTrigger: number;
  4305. /**
  4306. * On right pick
  4307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4308. */
  4309. static readonly ACTION_OnRightPickTrigger: number;
  4310. /**
  4311. * On center pick
  4312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4313. */
  4314. static readonly ACTION_OnCenterPickTrigger: number;
  4315. /**
  4316. * On pick down
  4317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4318. */
  4319. static readonly ACTION_OnPickDownTrigger: number;
  4320. /**
  4321. * On double pick
  4322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4323. */
  4324. static readonly ACTION_OnDoublePickTrigger: number;
  4325. /**
  4326. * On pick up
  4327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4328. */
  4329. static readonly ACTION_OnPickUpTrigger: number;
  4330. /**
  4331. * On pick out.
  4332. * This trigger will only be raised if you also declared a OnPickDown
  4333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4334. */
  4335. static readonly ACTION_OnPickOutTrigger: number;
  4336. /**
  4337. * On long press
  4338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4339. */
  4340. static readonly ACTION_OnLongPressTrigger: number;
  4341. /**
  4342. * On pointer over
  4343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4344. */
  4345. static readonly ACTION_OnPointerOverTrigger: number;
  4346. /**
  4347. * On pointer out
  4348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4349. */
  4350. static readonly ACTION_OnPointerOutTrigger: number;
  4351. /**
  4352. * On every frame
  4353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4354. */
  4355. static readonly ACTION_OnEveryFrameTrigger: number;
  4356. /**
  4357. * On intersection enter
  4358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4359. */
  4360. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4361. /**
  4362. * On intersection exit
  4363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4364. */
  4365. static readonly ACTION_OnIntersectionExitTrigger: number;
  4366. /**
  4367. * On key down
  4368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4369. */
  4370. static readonly ACTION_OnKeyDownTrigger: number;
  4371. /**
  4372. * On key up
  4373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4374. */
  4375. static readonly ACTION_OnKeyUpTrigger: number;
  4376. /**
  4377. * Billboard mode will only apply to Y axis
  4378. */
  4379. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4380. /**
  4381. * Billboard mode will apply to all axes
  4382. */
  4383. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4384. /**
  4385. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4386. */
  4387. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4388. /**
  4389. * Gets or sets base Assets URL
  4390. */
  4391. static PARTICLES_BaseAssetsUrl: string;
  4392. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4393. * Test order :
  4394. * Is the bounding sphere outside the frustum ?
  4395. * If not, are the bounding box vertices outside the frustum ?
  4396. * It not, then the cullable object is in the frustum.
  4397. */
  4398. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4399. /** Culling strategy : Bounding Sphere Only.
  4400. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4401. * It's also less accurate than the standard because some not visible objects can still be selected.
  4402. * Test : is the bounding sphere outside the frustum ?
  4403. * If not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4406. /** Culling strategy : Optimistic Inclusion.
  4407. * This in an inclusion test first, then the standard exclusion test.
  4408. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4409. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4410. * Anyway, it's as accurate as the standard strategy.
  4411. * Test :
  4412. * Is the cullable object bounding sphere center in the frustum ?
  4413. * If not, apply the default culling strategy.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4416. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4417. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4418. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4419. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4420. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4421. * Test :
  4422. * Is the cullable object bounding sphere center in the frustum ?
  4423. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4424. */
  4425. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4426. /**
  4427. * No logging while loading
  4428. */
  4429. static readonly SCENELOADER_NO_LOGGING: number;
  4430. /**
  4431. * Minimal logging while loading
  4432. */
  4433. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4434. /**
  4435. * Summary logging while loading
  4436. */
  4437. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4438. /**
  4439. * Detailled logging while loading
  4440. */
  4441. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4442. }
  4443. }
  4444. declare module BABYLON {
  4445. /**
  4446. * Class used to store and describe the pipeline context associated with an effect
  4447. */
  4448. export interface IPipelineContext {
  4449. /**
  4450. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4451. */
  4452. isAsync: boolean;
  4453. /**
  4454. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4455. */
  4456. isReady: boolean;
  4457. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. /** @hidden */
  4462. export interface IShaderProcessor {
  4463. attributeProcessor?: (attribute: string) => string;
  4464. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4465. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4466. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4467. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4468. lineProcessor?: (line: string, isFragment: boolean) => string;
  4469. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4470. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface ProcessingOptions {
  4476. defines: string[];
  4477. indexParameters: any;
  4478. isFragment: boolean;
  4479. shouldUseHighPrecisionShader: boolean;
  4480. supportsUniformBuffers: boolean;
  4481. shadersRepository: string;
  4482. includesShadersStore: {
  4483. [key: string]: string;
  4484. };
  4485. processor?: IShaderProcessor;
  4486. version: string;
  4487. platformName: string;
  4488. lookForClosingBracketForUniformBuffer?: boolean;
  4489. }
  4490. }
  4491. declare module BABYLON {
  4492. /**
  4493. * Helper to manipulate strings
  4494. */
  4495. export class StringTools {
  4496. /**
  4497. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4498. * @param str Source string
  4499. * @param suffix Suffix to search for in the source string
  4500. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4501. */
  4502. static EndsWith(str: string, suffix: string): boolean;
  4503. /**
  4504. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4505. * @param str Source string
  4506. * @param suffix Suffix to search for in the source string
  4507. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4508. */
  4509. static StartsWith(str: string, suffix: string): boolean;
  4510. }
  4511. }
  4512. declare module BABYLON {
  4513. /** @hidden */
  4514. export class ShaderCodeNode {
  4515. line: string;
  4516. children: ShaderCodeNode[];
  4517. additionalDefineKey?: string;
  4518. additionalDefineValue?: string;
  4519. isValid(preprocessors: {
  4520. [key: string]: string;
  4521. }): boolean;
  4522. process(preprocessors: {
  4523. [key: string]: string;
  4524. }, options: ProcessingOptions): string;
  4525. }
  4526. }
  4527. declare module BABYLON {
  4528. /** @hidden */
  4529. export class ShaderCodeCursor {
  4530. private _lines;
  4531. lineIndex: number;
  4532. readonly currentLine: string;
  4533. readonly canRead: boolean;
  4534. lines: string[];
  4535. }
  4536. }
  4537. declare module BABYLON {
  4538. /** @hidden */
  4539. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4540. process(preprocessors: {
  4541. [key: string]: string;
  4542. }, options: ProcessingOptions): string;
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderDefineExpression {
  4548. isTrue(preprocessors: {
  4549. [key: string]: string;
  4550. }): boolean;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderCodeTestNode extends ShaderCodeNode {
  4556. testExpression: ShaderDefineExpression;
  4557. isValid(preprocessors: {
  4558. [key: string]: string;
  4559. }): boolean;
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. /** @hidden */
  4564. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4565. define: string;
  4566. not: boolean;
  4567. constructor(define: string, not?: boolean);
  4568. isTrue(preprocessors: {
  4569. [key: string]: string;
  4570. }): boolean;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. /** @hidden */
  4575. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4576. leftOperand: ShaderDefineExpression;
  4577. rightOperand: ShaderDefineExpression;
  4578. isTrue(preprocessors: {
  4579. [key: string]: string;
  4580. }): boolean;
  4581. }
  4582. }
  4583. declare module BABYLON {
  4584. /** @hidden */
  4585. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4586. leftOperand: ShaderDefineExpression;
  4587. rightOperand: ShaderDefineExpression;
  4588. isTrue(preprocessors: {
  4589. [key: string]: string;
  4590. }): boolean;
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /** @hidden */
  4595. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4596. define: string;
  4597. operand: string;
  4598. testValue: string;
  4599. constructor(define: string, operand: string, testValue: string);
  4600. isTrue(preprocessors: {
  4601. [key: string]: string;
  4602. }): boolean;
  4603. }
  4604. }
  4605. declare module BABYLON {
  4606. /**
  4607. * @ignore
  4608. * Application error to support additional information when loading a file
  4609. */
  4610. export class LoadFileError extends Error {
  4611. /** defines the optional web request */
  4612. request?: WebRequest | undefined;
  4613. private static _setPrototypeOf;
  4614. /**
  4615. * Creates a new LoadFileError
  4616. * @param message defines the message of the error
  4617. * @param request defines the optional web request
  4618. */
  4619. constructor(message: string,
  4620. /** defines the optional web request */
  4621. request?: WebRequest | undefined);
  4622. }
  4623. }
  4624. declare module BABYLON {
  4625. /**
  4626. * Class used to enable access to offline support
  4627. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4628. */
  4629. export interface IOfflineProvider {
  4630. /**
  4631. * Gets a boolean indicating if scene must be saved in the database
  4632. */
  4633. enableSceneOffline: boolean;
  4634. /**
  4635. * Gets a boolean indicating if textures must be saved in the database
  4636. */
  4637. enableTexturesOffline: boolean;
  4638. /**
  4639. * Open the offline support and make it available
  4640. * @param successCallback defines the callback to call on success
  4641. * @param errorCallback defines the callback to call on error
  4642. */
  4643. open(successCallback: () => void, errorCallback: () => void): void;
  4644. /**
  4645. * Loads an image from the offline support
  4646. * @param url defines the url to load from
  4647. * @param image defines the target DOM image
  4648. */
  4649. loadImage(url: string, image: HTMLImageElement): void;
  4650. /**
  4651. * Loads a file from offline support
  4652. * @param url defines the URL to load from
  4653. * @param sceneLoaded defines a callback to call on success
  4654. * @param progressCallBack defines a callback to call when progress changed
  4655. * @param errorCallback defines a callback to call on error
  4656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4657. */
  4658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4659. }
  4660. }
  4661. declare module BABYLON {
  4662. /**
  4663. * Class used to help managing file picking and drag'n'drop
  4664. * File Storage
  4665. */
  4666. export class FilesInputStore {
  4667. /**
  4668. * List of files ready to be loaded
  4669. */
  4670. static FilesToLoad: {
  4671. [key: string]: File;
  4672. };
  4673. }
  4674. }
  4675. declare module BABYLON {
  4676. /**
  4677. * Class used to define a retry strategy when error happens while loading assets
  4678. */
  4679. export class RetryStrategy {
  4680. /**
  4681. * Function used to defines an exponential back off strategy
  4682. * @param maxRetries defines the maximum number of retries (3 by default)
  4683. * @param baseInterval defines the interval between retries
  4684. * @returns the strategy function to use
  4685. */
  4686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4687. }
  4688. }
  4689. declare module BABYLON {
  4690. /**
  4691. * @hidden
  4692. */
  4693. export class FileTools {
  4694. /**
  4695. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4696. */
  4697. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4698. /**
  4699. * Gets or sets the base URL to use to load assets
  4700. */
  4701. static BaseUrl: string;
  4702. /**
  4703. * Default behaviour for cors in the application.
  4704. * It can be a string if the expected behavior is identical in the entire app.
  4705. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4706. */
  4707. static CorsBehavior: string | ((url: string | string[]) => string);
  4708. /**
  4709. * Gets or sets a function used to pre-process url before using them to load assets
  4710. */
  4711. static PreprocessUrl: (url: string) => string;
  4712. /**
  4713. * Removes unwanted characters from an url
  4714. * @param url defines the url to clean
  4715. * @returns the cleaned url
  4716. */
  4717. private static _CleanUrl;
  4718. /**
  4719. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4720. * @param url define the url we are trying
  4721. * @param element define the dom element where to configure the cors policy
  4722. */
  4723. static SetCorsBehavior(url: string | string[], element: {
  4724. crossOrigin: string | null;
  4725. }): void;
  4726. /**
  4727. * Loads an image as an HTMLImageElement.
  4728. * @param input url string, ArrayBuffer, or Blob to load
  4729. * @param onLoad callback called when the image successfully loads
  4730. * @param onError callback called when the image fails to load
  4731. * @param offlineProvider offline provider for caching
  4732. * @returns the HTMLImageElement of the loaded image
  4733. */
  4734. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4735. /**
  4736. * Loads a file
  4737. * @param fileToLoad defines the file to load
  4738. * @param callback defines the callback to call when data is loaded
  4739. * @param progressCallBack defines the callback to call during loading process
  4740. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4741. * @returns a file request object
  4742. */
  4743. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4744. /**
  4745. * Loads a file
  4746. * @param url url string, ArrayBuffer, or Blob to load
  4747. * @param onSuccess callback called when the file successfully loads
  4748. * @param onProgress callback called while file is loading (if the server supports this mode)
  4749. * @param offlineProvider defines the offline provider for caching
  4750. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4751. * @param onError callback called when the file fails to load
  4752. * @returns a file request object
  4753. */
  4754. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4755. /**
  4756. * Checks if the loaded document was accessed via `file:`-Protocol.
  4757. * @returns boolean
  4758. */
  4759. static IsFileURL(): boolean;
  4760. }
  4761. }
  4762. declare module BABYLON {
  4763. /** @hidden */
  4764. export class ShaderProcessor {
  4765. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4766. private static _ProcessPrecision;
  4767. private static _ExtractOperation;
  4768. private static _BuildSubExpression;
  4769. private static _BuildExpression;
  4770. private static _MoveCursorWithinIf;
  4771. private static _MoveCursor;
  4772. private static _EvaluatePreProcessors;
  4773. private static _PreparePreProcessors;
  4774. private static _ProcessShaderConversion;
  4775. private static _ProcessIncludes;
  4776. }
  4777. }
  4778. declare module BABYLON {
  4779. /**
  4780. * Class used to hold a RBG color
  4781. */
  4782. export class Color3 {
  4783. /**
  4784. * Defines the red component (between 0 and 1, default is 0)
  4785. */
  4786. r: number;
  4787. /**
  4788. * Defines the green component (between 0 and 1, default is 0)
  4789. */
  4790. g: number;
  4791. /**
  4792. * Defines the blue component (between 0 and 1, default is 0)
  4793. */
  4794. b: number;
  4795. /**
  4796. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4797. * @param r defines the red component (between 0 and 1, default is 0)
  4798. * @param g defines the green component (between 0 and 1, default is 0)
  4799. * @param b defines the blue component (between 0 and 1, default is 0)
  4800. */
  4801. constructor(
  4802. /**
  4803. * Defines the red component (between 0 and 1, default is 0)
  4804. */
  4805. r?: number,
  4806. /**
  4807. * Defines the green component (between 0 and 1, default is 0)
  4808. */
  4809. g?: number,
  4810. /**
  4811. * Defines the blue component (between 0 and 1, default is 0)
  4812. */
  4813. b?: number);
  4814. /**
  4815. * Creates a string with the Color3 current values
  4816. * @returns the string representation of the Color3 object
  4817. */
  4818. toString(): string;
  4819. /**
  4820. * Returns the string "Color3"
  4821. * @returns "Color3"
  4822. */
  4823. getClassName(): string;
  4824. /**
  4825. * Compute the Color3 hash code
  4826. * @returns an unique number that can be used to hash Color3 objects
  4827. */
  4828. getHashCode(): number;
  4829. /**
  4830. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4831. * @param array defines the array where to store the r,g,b components
  4832. * @param index defines an optional index in the target array to define where to start storing values
  4833. * @returns the current Color3 object
  4834. */
  4835. toArray(array: FloatArray, index?: number): Color3;
  4836. /**
  4837. * Returns a new Color4 object from the current Color3 and the given alpha
  4838. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4839. * @returns a new Color4 object
  4840. */
  4841. toColor4(alpha?: number): Color4;
  4842. /**
  4843. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4844. * @returns the new array
  4845. */
  4846. asArray(): number[];
  4847. /**
  4848. * Returns the luminance value
  4849. * @returns a float value
  4850. */
  4851. toLuminance(): number;
  4852. /**
  4853. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4854. * @param otherColor defines the second operand
  4855. * @returns the new Color3 object
  4856. */
  4857. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4858. /**
  4859. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4860. * @param otherColor defines the second operand
  4861. * @param result defines the Color3 object where to store the result
  4862. * @returns the current Color3
  4863. */
  4864. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4865. /**
  4866. * Determines equality between Color3 objects
  4867. * @param otherColor defines the second operand
  4868. * @returns true if the rgb values are equal to the given ones
  4869. */
  4870. equals(otherColor: DeepImmutable<Color3>): boolean;
  4871. /**
  4872. * Determines equality between the current Color3 object and a set of r,b,g values
  4873. * @param r defines the red component to check
  4874. * @param g defines the green component to check
  4875. * @param b defines the blue component to check
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equalsFloats(r: number, g: number, b: number): boolean;
  4879. /**
  4880. * Multiplies in place each rgb value by scale
  4881. * @param scale defines the scaling factor
  4882. * @returns the updated Color3
  4883. */
  4884. scale(scale: number): Color3;
  4885. /**
  4886. * Multiplies the rgb values by scale and stores the result into "result"
  4887. * @param scale defines the scaling factor
  4888. * @param result defines the Color3 object where to store the result
  4889. * @returns the unmodified current Color3
  4890. */
  4891. scaleToRef(scale: number, result: Color3): Color3;
  4892. /**
  4893. * Scale the current Color3 values by a factor and add the result to a given Color3
  4894. * @param scale defines the scale factor
  4895. * @param result defines color to store the result into
  4896. * @returns the unmodified current Color3
  4897. */
  4898. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4899. /**
  4900. * Clamps the rgb values by the min and max values and stores the result into "result"
  4901. * @param min defines minimum clamping value (default is 0)
  4902. * @param max defines maximum clamping value (default is 1)
  4903. * @param result defines color to store the result into
  4904. * @returns the original Color3
  4905. */
  4906. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4907. /**
  4908. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4909. * @param otherColor defines the second operand
  4910. * @returns the new Color3
  4911. */
  4912. add(otherColor: DeepImmutable<Color3>): Color3;
  4913. /**
  4914. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4915. * @param otherColor defines the second operand
  4916. * @param result defines Color3 object to store the result into
  4917. * @returns the unmodified current Color3
  4918. */
  4919. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4920. /**
  4921. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Copy the current object
  4935. * @returns a new Color3 copied the current one
  4936. */
  4937. clone(): Color3;
  4938. /**
  4939. * Copies the rgb values from the source in the current Color3
  4940. * @param source defines the source Color3 object
  4941. * @returns the updated Color3 object
  4942. */
  4943. copyFrom(source: DeepImmutable<Color3>): Color3;
  4944. /**
  4945. * Updates the Color3 rgb values from the given floats
  4946. * @param r defines the red component to read from
  4947. * @param g defines the green component to read from
  4948. * @param b defines the blue component to read from
  4949. * @returns the current Color3 object
  4950. */
  4951. copyFromFloats(r: number, g: number, b: number): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. set(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Compute the Color3 hexadecimal code as a string
  4962. * @returns a string containing the hexadecimal representation of the Color3 object
  4963. */
  4964. toHexString(): string;
  4965. /**
  4966. * Computes a new Color3 converted from the current one to linear space
  4967. * @returns a new Color3 object
  4968. */
  4969. toLinearSpace(): Color3;
  4970. /**
  4971. * Converts current color in rgb space to HSV values
  4972. * @returns a new color3 representing the HSV values
  4973. */
  4974. toHSV(): Color3;
  4975. /**
  4976. * Converts current color in rgb space to HSV values
  4977. * @param result defines the Color3 where to store the HSV values
  4978. */
  4979. toHSVToRef(result: Color3): void;
  4980. /**
  4981. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4982. * @param convertedColor defines the Color3 object where to store the linear space version
  4983. * @returns the unmodified Color3
  4984. */
  4985. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4986. /**
  4987. * Computes a new Color3 converted from the current one to gamma space
  4988. * @returns a new Color3 object
  4989. */
  4990. toGammaSpace(): Color3;
  4991. /**
  4992. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4993. * @param convertedColor defines the Color3 object where to store the gamma space version
  4994. * @returns the unmodified Color3
  4995. */
  4996. toGammaSpaceToRef(convertedColor: Color3): Color3;
  4997. private static _BlackReadOnly;
  4998. /**
  4999. * Convert Hue, saturation and value to a Color3 (RGB)
  5000. * @param hue defines the hue
  5001. * @param saturation defines the saturation
  5002. * @param value defines the value
  5003. * @param result defines the Color3 where to store the RGB values
  5004. */
  5005. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5006. /**
  5007. * Creates a new Color3 from the string containing valid hexadecimal values
  5008. * @param hex defines a string containing valid hexadecimal values
  5009. * @returns a new Color3 object
  5010. */
  5011. static FromHexString(hex: string): Color3;
  5012. /**
  5013. * Creates a new Color3 from the starting index of the given array
  5014. * @param array defines the source array
  5015. * @param offset defines an offset in the source array
  5016. * @returns a new Color3 object
  5017. */
  5018. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5019. /**
  5020. * Creates a new Color3 from integer values (< 256)
  5021. * @param r defines the red component to read from (value between 0 and 255)
  5022. * @param g defines the green component to read from (value between 0 and 255)
  5023. * @param b defines the blue component to read from (value between 0 and 255)
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromInts(r: number, g: number, b: number): Color3;
  5027. /**
  5028. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5029. * @param start defines the start Color3 value
  5030. * @param end defines the end Color3 value
  5031. * @param amount defines the gradient value between start and end
  5032. * @returns a new Color3 object
  5033. */
  5034. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param left defines the start value
  5038. * @param right defines the end value
  5039. * @param amount defines the gradient factor
  5040. * @param result defines the Color3 object where to store the result
  5041. */
  5042. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5043. /**
  5044. * Returns a Color3 value containing a red color
  5045. * @returns a new Color3 object
  5046. */
  5047. static Red(): Color3;
  5048. /**
  5049. * Returns a Color3 value containing a green color
  5050. * @returns a new Color3 object
  5051. */
  5052. static Green(): Color3;
  5053. /**
  5054. * Returns a Color3 value containing a blue color
  5055. * @returns a new Color3 object
  5056. */
  5057. static Blue(): Color3;
  5058. /**
  5059. * Returns a Color3 value containing a black color
  5060. * @returns a new Color3 object
  5061. */
  5062. static Black(): Color3;
  5063. /**
  5064. * Gets a Color3 value containing a black color that must not be updated
  5065. */
  5066. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5067. /**
  5068. * Returns a Color3 value containing a white color
  5069. * @returns a new Color3 object
  5070. */
  5071. static White(): Color3;
  5072. /**
  5073. * Returns a Color3 value containing a purple color
  5074. * @returns a new Color3 object
  5075. */
  5076. static Purple(): Color3;
  5077. /**
  5078. * Returns a Color3 value containing a magenta color
  5079. * @returns a new Color3 object
  5080. */
  5081. static Magenta(): Color3;
  5082. /**
  5083. * Returns a Color3 value containing a yellow color
  5084. * @returns a new Color3 object
  5085. */
  5086. static Yellow(): Color3;
  5087. /**
  5088. * Returns a Color3 value containing a gray color
  5089. * @returns a new Color3 object
  5090. */
  5091. static Gray(): Color3;
  5092. /**
  5093. * Returns a Color3 value containing a teal color
  5094. * @returns a new Color3 object
  5095. */
  5096. static Teal(): Color3;
  5097. /**
  5098. * Returns a Color3 value containing a random color
  5099. * @returns a new Color3 object
  5100. */
  5101. static Random(): Color3;
  5102. }
  5103. /**
  5104. * Class used to hold a RBGA color
  5105. */
  5106. export class Color4 {
  5107. /**
  5108. * Defines the red component (between 0 and 1, default is 0)
  5109. */
  5110. r: number;
  5111. /**
  5112. * Defines the green component (between 0 and 1, default is 0)
  5113. */
  5114. g: number;
  5115. /**
  5116. * Defines the blue component (between 0 and 1, default is 0)
  5117. */
  5118. b: number;
  5119. /**
  5120. * Defines the alpha component (between 0 and 1, default is 1)
  5121. */
  5122. a: number;
  5123. /**
  5124. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5125. * @param r defines the red component (between 0 and 1, default is 0)
  5126. * @param g defines the green component (between 0 and 1, default is 0)
  5127. * @param b defines the blue component (between 0 and 1, default is 0)
  5128. * @param a defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. constructor(
  5131. /**
  5132. * Defines the red component (between 0 and 1, default is 0)
  5133. */
  5134. r?: number,
  5135. /**
  5136. * Defines the green component (between 0 and 1, default is 0)
  5137. */
  5138. g?: number,
  5139. /**
  5140. * Defines the blue component (between 0 and 1, default is 0)
  5141. */
  5142. b?: number,
  5143. /**
  5144. * Defines the alpha component (between 0 and 1, default is 1)
  5145. */
  5146. a?: number);
  5147. /**
  5148. * Adds in place the given Color4 values to the current Color4 object
  5149. * @param right defines the second operand
  5150. * @returns the current updated Color4 object
  5151. */
  5152. addInPlace(right: DeepImmutable<Color4>): Color4;
  5153. /**
  5154. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5155. * @returns the new array
  5156. */
  5157. asArray(): number[];
  5158. /**
  5159. * Stores from the starting index in the given array the Color4 successive values
  5160. * @param array defines the array where to store the r,g,b components
  5161. * @param index defines an optional index in the target array to define where to start storing values
  5162. * @returns the current Color4 object
  5163. */
  5164. toArray(array: number[], index?: number): Color4;
  5165. /**
  5166. * Determines equality between Color4 objects
  5167. * @param otherColor defines the second operand
  5168. * @returns true if the rgba values are equal to the given ones
  5169. */
  5170. equals(otherColor: DeepImmutable<Color4>): boolean;
  5171. /**
  5172. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5173. * @param right defines the second operand
  5174. * @returns a new Color4 object
  5175. */
  5176. add(right: DeepImmutable<Color4>): Color4;
  5177. /**
  5178. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5179. * @param right defines the second operand
  5180. * @returns a new Color4 object
  5181. */
  5182. subtract(right: DeepImmutable<Color4>): Color4;
  5183. /**
  5184. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5185. * @param right defines the second operand
  5186. * @param result defines the Color4 object where to store the result
  5187. * @returns the current Color4 object
  5188. */
  5189. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5190. /**
  5191. * Creates a new Color4 with the current Color4 values multiplied by scale
  5192. * @param scale defines the scaling factor to apply
  5193. * @returns a new Color4 object
  5194. */
  5195. scale(scale: number): Color4;
  5196. /**
  5197. * Multiplies the current Color4 values by scale and stores the result in "result"
  5198. * @param scale defines the scaling factor to apply
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current unmodified Color4
  5201. */
  5202. scaleToRef(scale: number, result: Color4): Color4;
  5203. /**
  5204. * Scale the current Color4 values by a factor and add the result to a given Color4
  5205. * @param scale defines the scale factor
  5206. * @param result defines the Color4 object where to store the result
  5207. * @returns the unmodified current Color4
  5208. */
  5209. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5210. /**
  5211. * Clamps the rgb values by the min and max values and stores the result into "result"
  5212. * @param min defines minimum clamping value (default is 0)
  5213. * @param max defines maximum clamping value (default is 1)
  5214. * @param result defines color to store the result into.
  5215. * @returns the cuurent Color4
  5216. */
  5217. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5218. /**
  5219. * Multipy an Color4 value by another and return a new Color4 object
  5220. * @param color defines the Color4 value to multiply by
  5221. * @returns a new Color4 object
  5222. */
  5223. multiply(color: Color4): Color4;
  5224. /**
  5225. * Multipy a Color4 value by another and push the result in a reference value
  5226. * @param color defines the Color4 value to multiply by
  5227. * @param result defines the Color4 to fill the result in
  5228. * @returns the result Color4
  5229. */
  5230. multiplyToRef(color: Color4, result: Color4): Color4;
  5231. /**
  5232. * Creates a string with the Color4 current values
  5233. * @returns the string representation of the Color4 object
  5234. */
  5235. toString(): string;
  5236. /**
  5237. * Returns the string "Color4"
  5238. * @returns "Color4"
  5239. */
  5240. getClassName(): string;
  5241. /**
  5242. * Compute the Color4 hash code
  5243. * @returns an unique number that can be used to hash Color4 objects
  5244. */
  5245. getHashCode(): number;
  5246. /**
  5247. * Creates a new Color4 copied from the current one
  5248. * @returns a new Color4 object
  5249. */
  5250. clone(): Color4;
  5251. /**
  5252. * Copies the given Color4 values into the current one
  5253. * @param source defines the source Color4 object
  5254. * @returns the current updated Color4 object
  5255. */
  5256. copyFrom(source: Color4): Color4;
  5257. /**
  5258. * Copies the given float values into the current one
  5259. * @param r defines the red component to read from
  5260. * @param g defines the green component to read from
  5261. * @param b defines the blue component to read from
  5262. * @param a defines the alpha component to read from
  5263. * @returns the current updated Color4 object
  5264. */
  5265. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5266. /**
  5267. * Copies the given float values into the current one
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @param a defines the alpha component to read from
  5272. * @returns the current updated Color4 object
  5273. */
  5274. set(r: number, g: number, b: number, a: number): Color4;
  5275. /**
  5276. * Compute the Color4 hexadecimal code as a string
  5277. * @returns a string containing the hexadecimal representation of the Color4 object
  5278. */
  5279. toHexString(): string;
  5280. /**
  5281. * Computes a new Color4 converted from the current one to linear space
  5282. * @returns a new Color4 object
  5283. */
  5284. toLinearSpace(): Color4;
  5285. /**
  5286. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5287. * @param convertedColor defines the Color4 object where to store the linear space version
  5288. * @returns the unmodified Color4
  5289. */
  5290. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5291. /**
  5292. * Computes a new Color4 converted from the current one to gamma space
  5293. * @returns a new Color4 object
  5294. */
  5295. toGammaSpace(): Color4;
  5296. /**
  5297. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5298. * @param convertedColor defines the Color4 object where to store the gamma space version
  5299. * @returns the unmodified Color4
  5300. */
  5301. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5302. /**
  5303. * Creates a new Color4 from the string containing valid hexadecimal values
  5304. * @param hex defines a string containing valid hexadecimal values
  5305. * @returns a new Color4 object
  5306. */
  5307. static FromHexString(hex: string): Color4;
  5308. /**
  5309. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5310. * @param left defines the start value
  5311. * @param right defines the end value
  5312. * @param amount defines the gradient factor
  5313. * @returns a new Color4 object
  5314. */
  5315. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5316. /**
  5317. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @param result defines the Color4 object where to store data
  5322. */
  5323. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5324. /**
  5325. * Creates a new Color4 from a Color3 and an alpha value
  5326. * @param color3 defines the source Color3 to read from
  5327. * @param alpha defines the alpha component (1.0 by default)
  5328. * @returns a new Color4 object
  5329. */
  5330. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5331. /**
  5332. * Creates a new Color4 from the starting index element of the given array
  5333. * @param array defines the source array to read from
  5334. * @param offset defines the offset in the source array
  5335. * @returns a new Color4 object
  5336. */
  5337. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5338. /**
  5339. * Creates a new Color3 from integer values (< 256)
  5340. * @param r defines the red component to read from (value between 0 and 255)
  5341. * @param g defines the green component to read from (value between 0 and 255)
  5342. * @param b defines the blue component to read from (value between 0 and 255)
  5343. * @param a defines the alpha component to read from (value between 0 and 255)
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5347. /**
  5348. * Check the content of a given array and convert it to an array containing RGBA data
  5349. * If the original array was already containing count * 4 values then it is returned directly
  5350. * @param colors defines the array to check
  5351. * @param count defines the number of RGBA data to expect
  5352. * @returns an array containing count * 4 values (RGBA)
  5353. */
  5354. static CheckColors4(colors: number[], count: number): number[];
  5355. }
  5356. /**
  5357. * @hidden
  5358. */
  5359. export class TmpColors {
  5360. static Color3: Color3[];
  5361. static Color4: Color4[];
  5362. }
  5363. }
  5364. declare module BABYLON {
  5365. /**
  5366. * Class representing spherical harmonics coefficients to the 3rd degree
  5367. */
  5368. export class SphericalHarmonics {
  5369. /**
  5370. * Defines whether or not the harmonics have been prescaled for rendering.
  5371. */
  5372. preScaled: boolean;
  5373. /**
  5374. * The l0,0 coefficients of the spherical harmonics
  5375. */
  5376. l00: Vector3;
  5377. /**
  5378. * The l1,-1 coefficients of the spherical harmonics
  5379. */
  5380. l1_1: Vector3;
  5381. /**
  5382. * The l1,0 coefficients of the spherical harmonics
  5383. */
  5384. l10: Vector3;
  5385. /**
  5386. * The l1,1 coefficients of the spherical harmonics
  5387. */
  5388. l11: Vector3;
  5389. /**
  5390. * The l2,-2 coefficients of the spherical harmonics
  5391. */
  5392. l2_2: Vector3;
  5393. /**
  5394. * The l2,-1 coefficients of the spherical harmonics
  5395. */
  5396. l2_1: Vector3;
  5397. /**
  5398. * The l2,0 coefficients of the spherical harmonics
  5399. */
  5400. l20: Vector3;
  5401. /**
  5402. * The l2,1 coefficients of the spherical harmonics
  5403. */
  5404. l21: Vector3;
  5405. /**
  5406. * The l2,2 coefficients of the spherical harmonics
  5407. */
  5408. l22: Vector3;
  5409. /**
  5410. * Adds a light to the spherical harmonics
  5411. * @param direction the direction of the light
  5412. * @param color the color of the light
  5413. * @param deltaSolidAngle the delta solid angle of the light
  5414. */
  5415. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5416. /**
  5417. * Scales the spherical harmonics by the given amount
  5418. * @param scale the amount to scale
  5419. */
  5420. scaleInPlace(scale: number): void;
  5421. /**
  5422. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5423. *
  5424. * ```
  5425. * E_lm = A_l * L_lm
  5426. * ```
  5427. *
  5428. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5429. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5430. * the scaling factors are given in equation 9.
  5431. */
  5432. convertIncidentRadianceToIrradiance(): void;
  5433. /**
  5434. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5435. *
  5436. * ```
  5437. * L = (1/pi) * E * rho
  5438. * ```
  5439. *
  5440. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5441. */
  5442. convertIrradianceToLambertianRadiance(): void;
  5443. /**
  5444. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5445. * required operations at run time.
  5446. *
  5447. * This is simply done by scaling back the SH with Ylm constants parameter.
  5448. * The trigonometric part being applied by the shader at run time.
  5449. */
  5450. preScaleForRendering(): void;
  5451. /**
  5452. * Constructs a spherical harmonics from an array.
  5453. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5454. * @returns the spherical harmonics
  5455. */
  5456. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5457. /**
  5458. * Gets the spherical harmonics from polynomial
  5459. * @param polynomial the spherical polynomial
  5460. * @returns the spherical harmonics
  5461. */
  5462. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5463. }
  5464. /**
  5465. * Class representing spherical polynomial coefficients to the 3rd degree
  5466. */
  5467. export class SphericalPolynomial {
  5468. private _harmonics;
  5469. /**
  5470. * The spherical harmonics used to create the polynomials.
  5471. */
  5472. readonly preScaledHarmonics: SphericalHarmonics;
  5473. /**
  5474. * The x coefficients of the spherical polynomial
  5475. */
  5476. x: Vector3;
  5477. /**
  5478. * The y coefficients of the spherical polynomial
  5479. */
  5480. y: Vector3;
  5481. /**
  5482. * The z coefficients of the spherical polynomial
  5483. */
  5484. z: Vector3;
  5485. /**
  5486. * The xx coefficients of the spherical polynomial
  5487. */
  5488. xx: Vector3;
  5489. /**
  5490. * The yy coefficients of the spherical polynomial
  5491. */
  5492. yy: Vector3;
  5493. /**
  5494. * The zz coefficients of the spherical polynomial
  5495. */
  5496. zz: Vector3;
  5497. /**
  5498. * The xy coefficients of the spherical polynomial
  5499. */
  5500. xy: Vector3;
  5501. /**
  5502. * The yz coefficients of the spherical polynomial
  5503. */
  5504. yz: Vector3;
  5505. /**
  5506. * The zx coefficients of the spherical polynomial
  5507. */
  5508. zx: Vector3;
  5509. /**
  5510. * Adds an ambient color to the spherical polynomial
  5511. * @param color the color to add
  5512. */
  5513. addAmbient(color: Color3): void;
  5514. /**
  5515. * Scales the spherical polynomial by the given amount
  5516. * @param scale the amount to scale
  5517. */
  5518. scaleInPlace(scale: number): void;
  5519. /**
  5520. * Gets the spherical polynomial from harmonics
  5521. * @param harmonics the spherical harmonics
  5522. * @returns the spherical polynomial
  5523. */
  5524. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5525. /**
  5526. * Constructs a spherical polynomial from an array.
  5527. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5528. * @returns the spherical polynomial
  5529. */
  5530. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5531. }
  5532. }
  5533. declare module BABYLON {
  5534. /**
  5535. * Define options used to create a render target texture
  5536. */
  5537. export class RenderTargetCreationOptions {
  5538. /**
  5539. * Specifies is mipmaps must be generated
  5540. */
  5541. generateMipMaps?: boolean;
  5542. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5543. generateDepthBuffer?: boolean;
  5544. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5545. generateStencilBuffer?: boolean;
  5546. /** Defines texture type (int by default) */
  5547. type?: number;
  5548. /** Defines sampling mode (trilinear by default) */
  5549. samplingMode?: number;
  5550. /** Defines format (RGBA by default) */
  5551. format?: number;
  5552. }
  5553. }
  5554. declare module BABYLON {
  5555. /**
  5556. * @hidden
  5557. **/
  5558. export class _AlphaState {
  5559. private _isAlphaBlendDirty;
  5560. private _isBlendFunctionParametersDirty;
  5561. private _isBlendEquationParametersDirty;
  5562. private _isBlendConstantsDirty;
  5563. private _alphaBlend;
  5564. private _blendFunctionParameters;
  5565. private _blendEquationParameters;
  5566. private _blendConstants;
  5567. /**
  5568. * Initializes the state.
  5569. */
  5570. constructor();
  5571. readonly isDirty: boolean;
  5572. alphaBlend: boolean;
  5573. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5574. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5575. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5576. reset(): void;
  5577. apply(gl: WebGLRenderingContext): void;
  5578. }
  5579. }
  5580. declare module BABYLON {
  5581. /**
  5582. * @hidden
  5583. **/
  5584. export class _DepthCullingState {
  5585. private _isDepthTestDirty;
  5586. private _isDepthMaskDirty;
  5587. private _isDepthFuncDirty;
  5588. private _isCullFaceDirty;
  5589. private _isCullDirty;
  5590. private _isZOffsetDirty;
  5591. private _isFrontFaceDirty;
  5592. private _depthTest;
  5593. private _depthMask;
  5594. private _depthFunc;
  5595. private _cull;
  5596. private _cullFace;
  5597. private _zOffset;
  5598. private _frontFace;
  5599. /**
  5600. * Initializes the state.
  5601. */
  5602. constructor();
  5603. readonly isDirty: boolean;
  5604. zOffset: number;
  5605. cullFace: Nullable<number>;
  5606. cull: Nullable<boolean>;
  5607. depthFunc: Nullable<number>;
  5608. depthMask: boolean;
  5609. depthTest: boolean;
  5610. frontFace: Nullable<number>;
  5611. reset(): void;
  5612. apply(gl: WebGLRenderingContext): void;
  5613. }
  5614. }
  5615. declare module BABYLON {
  5616. /**
  5617. * @hidden
  5618. **/
  5619. export class _StencilState {
  5620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5621. static readonly ALWAYS: number;
  5622. /** Passed to stencilOperation to specify that stencil value must be kept */
  5623. static readonly KEEP: number;
  5624. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5625. static readonly REPLACE: number;
  5626. private _isStencilTestDirty;
  5627. private _isStencilMaskDirty;
  5628. private _isStencilFuncDirty;
  5629. private _isStencilOpDirty;
  5630. private _stencilTest;
  5631. private _stencilMask;
  5632. private _stencilFunc;
  5633. private _stencilFuncRef;
  5634. private _stencilFuncMask;
  5635. private _stencilOpStencilFail;
  5636. private _stencilOpDepthFail;
  5637. private _stencilOpStencilDepthPass;
  5638. readonly isDirty: boolean;
  5639. stencilFunc: number;
  5640. stencilFuncRef: number;
  5641. stencilFuncMask: number;
  5642. stencilOpStencilFail: number;
  5643. stencilOpDepthFail: number;
  5644. stencilOpStencilDepthPass: number;
  5645. stencilMask: number;
  5646. stencilTest: boolean;
  5647. constructor();
  5648. reset(): void;
  5649. apply(gl: WebGLRenderingContext): void;
  5650. }
  5651. }
  5652. declare module BABYLON {
  5653. /**
  5654. * @hidden
  5655. **/
  5656. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5657. }
  5658. }
  5659. declare module BABYLON {
  5660. /**
  5661. * Class used to evalaute queries containing `and` and `or` operators
  5662. */
  5663. export class AndOrNotEvaluator {
  5664. /**
  5665. * Evaluate a query
  5666. * @param query defines the query to evaluate
  5667. * @param evaluateCallback defines the callback used to filter result
  5668. * @returns true if the query matches
  5669. */
  5670. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5671. private static _HandleParenthesisContent;
  5672. private static _SimplifyNegation;
  5673. }
  5674. }
  5675. declare module BABYLON {
  5676. /**
  5677. * Class used to store custom tags
  5678. */
  5679. export class Tags {
  5680. /**
  5681. * Adds support for tags on the given object
  5682. * @param obj defines the object to use
  5683. */
  5684. static EnableFor(obj: any): void;
  5685. /**
  5686. * Removes tags support
  5687. * @param obj defines the object to use
  5688. */
  5689. static DisableFor(obj: any): void;
  5690. /**
  5691. * Gets a boolean indicating if the given object has tags
  5692. * @param obj defines the object to use
  5693. * @returns a boolean
  5694. */
  5695. static HasTags(obj: any): boolean;
  5696. /**
  5697. * Gets the tags available on a given object
  5698. * @param obj defines the object to use
  5699. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5700. * @returns the tags
  5701. */
  5702. static GetTags(obj: any, asString?: boolean): any;
  5703. /**
  5704. * Adds tags to an object
  5705. * @param obj defines the object to use
  5706. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5707. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5708. */
  5709. static AddTagsTo(obj: any, tagsString: string): void;
  5710. /**
  5711. * @hidden
  5712. */ private static _AddTagTo(obj: any, tag: string): void;
  5713. /**
  5714. * Removes specific tags from a specific object
  5715. * @param obj defines the object to use
  5716. * @param tagsString defines the tags to remove
  5717. */
  5718. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5719. /**
  5720. * @hidden
  5721. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5722. /**
  5723. * Defines if tags hosted on an object match a given query
  5724. * @param obj defines the object to use
  5725. * @param tagsQuery defines the tag query
  5726. * @returns a boolean
  5727. */
  5728. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5729. }
  5730. }
  5731. declare module BABYLON {
  5732. /**
  5733. * Defines potential orientation for back face culling
  5734. */
  5735. export enum Orientation {
  5736. /**
  5737. * Clockwise
  5738. */
  5739. CW = 0,
  5740. /** Counter clockwise */
  5741. CCW = 1
  5742. }
  5743. /** Class used to represent a Bezier curve */
  5744. export class BezierCurve {
  5745. /**
  5746. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5747. * @param t defines the time
  5748. * @param x1 defines the left coordinate on X axis
  5749. * @param y1 defines the left coordinate on Y axis
  5750. * @param x2 defines the right coordinate on X axis
  5751. * @param y2 defines the right coordinate on Y axis
  5752. * @returns the interpolated value
  5753. */
  5754. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5755. }
  5756. /**
  5757. * Defines angle representation
  5758. */
  5759. export class Angle {
  5760. private _radians;
  5761. /**
  5762. * Creates an Angle object of "radians" radians (float).
  5763. * @param radians the angle in radians
  5764. */
  5765. constructor(radians: number);
  5766. /**
  5767. * Get value in degrees
  5768. * @returns the Angle value in degrees (float)
  5769. */
  5770. degrees(): number;
  5771. /**
  5772. * Get value in radians
  5773. * @returns the Angle value in radians (float)
  5774. */
  5775. radians(): number;
  5776. /**
  5777. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5778. * @param a defines first vector
  5779. * @param b defines second vector
  5780. * @returns a new Angle
  5781. */
  5782. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5783. /**
  5784. * Gets a new Angle object from the given float in radians
  5785. * @param radians defines the angle value in radians
  5786. * @returns a new Angle
  5787. */
  5788. static FromRadians(radians: number): Angle;
  5789. /**
  5790. * Gets a new Angle object from the given float in degrees
  5791. * @param degrees defines the angle value in degrees
  5792. * @returns a new Angle
  5793. */
  5794. static FromDegrees(degrees: number): Angle;
  5795. }
  5796. /**
  5797. * This represents an arc in a 2d space.
  5798. */
  5799. export class Arc2 {
  5800. /** Defines the start point of the arc */
  5801. startPoint: Vector2;
  5802. /** Defines the mid point of the arc */
  5803. midPoint: Vector2;
  5804. /** Defines the end point of the arc */
  5805. endPoint: Vector2;
  5806. /**
  5807. * Defines the center point of the arc.
  5808. */
  5809. centerPoint: Vector2;
  5810. /**
  5811. * Defines the radius of the arc.
  5812. */
  5813. radius: number;
  5814. /**
  5815. * Defines the angle of the arc (from mid point to end point).
  5816. */
  5817. angle: Angle;
  5818. /**
  5819. * Defines the start angle of the arc (from start point to middle point).
  5820. */
  5821. startAngle: Angle;
  5822. /**
  5823. * Defines the orientation of the arc (clock wise/counter clock wise).
  5824. */
  5825. orientation: Orientation;
  5826. /**
  5827. * Creates an Arc object from the three given points : start, middle and end.
  5828. * @param startPoint Defines the start point of the arc
  5829. * @param midPoint Defines the midlle point of the arc
  5830. * @param endPoint Defines the end point of the arc
  5831. */
  5832. constructor(
  5833. /** Defines the start point of the arc */
  5834. startPoint: Vector2,
  5835. /** Defines the mid point of the arc */
  5836. midPoint: Vector2,
  5837. /** Defines the end point of the arc */
  5838. endPoint: Vector2);
  5839. }
  5840. /**
  5841. * Represents a 2D path made up of multiple 2D points
  5842. */
  5843. export class Path2 {
  5844. private _points;
  5845. private _length;
  5846. /**
  5847. * If the path start and end point are the same
  5848. */
  5849. closed: boolean;
  5850. /**
  5851. * Creates a Path2 object from the starting 2D coordinates x and y.
  5852. * @param x the starting points x value
  5853. * @param y the starting points y value
  5854. */
  5855. constructor(x: number, y: number);
  5856. /**
  5857. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5858. * @param x the added points x value
  5859. * @param y the added points y value
  5860. * @returns the updated Path2.
  5861. */
  5862. addLineTo(x: number, y: number): Path2;
  5863. /**
  5864. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5865. * @param midX middle point x value
  5866. * @param midY middle point y value
  5867. * @param endX end point x value
  5868. * @param endY end point y value
  5869. * @param numberOfSegments (default: 36)
  5870. * @returns the updated Path2.
  5871. */
  5872. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5873. /**
  5874. * Closes the Path2.
  5875. * @returns the Path2.
  5876. */
  5877. close(): Path2;
  5878. /**
  5879. * Gets the sum of the distance between each sequential point in the path
  5880. * @returns the Path2 total length (float).
  5881. */
  5882. length(): number;
  5883. /**
  5884. * Gets the points which construct the path
  5885. * @returns the Path2 internal array of points.
  5886. */
  5887. getPoints(): Vector2[];
  5888. /**
  5889. * Retreives the point at the distance aways from the starting point
  5890. * @param normalizedLengthPosition the length along the path to retreive the point from
  5891. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5892. */
  5893. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5894. /**
  5895. * Creates a new path starting from an x and y position
  5896. * @param x starting x value
  5897. * @param y starting y value
  5898. * @returns a new Path2 starting at the coordinates (x, y).
  5899. */
  5900. static StartingAt(x: number, y: number): Path2;
  5901. }
  5902. /**
  5903. * Represents a 3D path made up of multiple 3D points
  5904. */
  5905. export class Path3D {
  5906. /**
  5907. * an array of Vector3, the curve axis of the Path3D
  5908. */
  5909. path: Vector3[];
  5910. private _curve;
  5911. private _distances;
  5912. private _tangents;
  5913. private _normals;
  5914. private _binormals;
  5915. private _raw;
  5916. /**
  5917. * new Path3D(path, normal, raw)
  5918. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5919. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5920. * @param path an array of Vector3, the curve axis of the Path3D
  5921. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5922. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5923. */
  5924. constructor(
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5929. /**
  5930. * Returns the Path3D array of successive Vector3 designing its curve.
  5931. * @returns the Path3D array of successive Vector3 designing its curve.
  5932. */
  5933. getCurve(): Vector3[];
  5934. /**
  5935. * Returns an array populated with tangent vectors on each Path3D curve point.
  5936. * @returns an array populated with tangent vectors on each Path3D curve point.
  5937. */
  5938. getTangents(): Vector3[];
  5939. /**
  5940. * Returns an array populated with normal vectors on each Path3D curve point.
  5941. * @returns an array populated with normal vectors on each Path3D curve point.
  5942. */
  5943. getNormals(): Vector3[];
  5944. /**
  5945. * Returns an array populated with binormal vectors on each Path3D curve point.
  5946. * @returns an array populated with binormal vectors on each Path3D curve point.
  5947. */
  5948. getBinormals(): Vector3[];
  5949. /**
  5950. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5951. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5952. */
  5953. getDistances(): number[];
  5954. /**
  5955. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5956. * @param path path which all values are copied into the curves points
  5957. * @param firstNormal which should be projected onto the curve
  5958. * @returns the same object updated.
  5959. */
  5960. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5961. private _compute;
  5962. private _getFirstNonNullVector;
  5963. private _getLastNonNullVector;
  5964. private _normalVector;
  5965. }
  5966. /**
  5967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5968. * A Curve3 is designed from a series of successive Vector3.
  5969. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5970. */
  5971. export class Curve3 {
  5972. private _points;
  5973. private _length;
  5974. /**
  5975. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5976. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5977. * @param v1 (Vector3) the control point
  5978. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5979. * @param nbPoints (integer) the wanted number of points in the curve
  5980. * @returns the created Curve3
  5981. */
  5982. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5983. /**
  5984. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5985. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5986. * @param v1 (Vector3) the first control point
  5987. * @param v2 (Vector3) the second control point
  5988. * @param v3 (Vector3) the end point of the Cubic Bezier
  5989. * @param nbPoints (integer) the wanted number of points in the curve
  5990. * @returns the created Curve3
  5991. */
  5992. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5993. /**
  5994. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5995. * @param p1 (Vector3) the origin point of the Hermite Spline
  5996. * @param t1 (Vector3) the tangent vector at the origin point
  5997. * @param p2 (Vector3) the end point of the Hermite Spline
  5998. * @param t2 (Vector3) the tangent vector at the end point
  5999. * @param nbPoints (integer) the wanted number of points in the curve
  6000. * @returns the created Curve3
  6001. */
  6002. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6003. /**
  6004. * Returns a Curve3 object along a CatmullRom Spline curve :
  6005. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6006. * @param nbPoints (integer) the wanted number of points between each curve control points
  6007. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6008. * @returns the created Curve3
  6009. */
  6010. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6011. /**
  6012. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6013. * A Curve3 is designed from a series of successive Vector3.
  6014. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6015. * @param points points which make up the curve
  6016. */
  6017. constructor(points: Vector3[]);
  6018. /**
  6019. * @returns the Curve3 stored array of successive Vector3
  6020. */
  6021. getPoints(): Vector3[];
  6022. /**
  6023. * @returns the computed length (float) of the curve.
  6024. */
  6025. length(): number;
  6026. /**
  6027. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6028. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6029. * curveA and curveB keep unchanged.
  6030. * @param curve the curve to continue from this curve
  6031. * @returns the newly constructed curve
  6032. */
  6033. continue(curve: DeepImmutable<Curve3>): Curve3;
  6034. private _computeLength;
  6035. }
  6036. }
  6037. declare module BABYLON {
  6038. /**
  6039. * This represents the main contract an easing function should follow.
  6040. * Easing functions are used throughout the animation system.
  6041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6042. */
  6043. export interface IEasingFunction {
  6044. /**
  6045. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6046. * of the easing function.
  6047. * The link below provides some of the most common examples of easing functions.
  6048. * @see https://easings.net/
  6049. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6050. * @returns the corresponding value on the curve defined by the easing function
  6051. */
  6052. ease(gradient: number): number;
  6053. }
  6054. /**
  6055. * Base class used for every default easing function.
  6056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6057. */
  6058. export class EasingFunction implements IEasingFunction {
  6059. /**
  6060. * Interpolation follows the mathematical formula associated with the easing function.
  6061. */
  6062. static readonly EASINGMODE_EASEIN: number;
  6063. /**
  6064. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6065. */
  6066. static readonly EASINGMODE_EASEOUT: number;
  6067. /**
  6068. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6069. */
  6070. static readonly EASINGMODE_EASEINOUT: number;
  6071. private _easingMode;
  6072. /**
  6073. * Sets the easing mode of the current function.
  6074. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6075. */
  6076. setEasingMode(easingMode: number): void;
  6077. /**
  6078. * Gets the current easing mode.
  6079. * @returns the easing mode
  6080. */
  6081. getEasingMode(): number;
  6082. /**
  6083. * @hidden
  6084. */
  6085. easeInCore(gradient: number): number;
  6086. /**
  6087. * Given an input gradient between 0 and 1, this returns the corresponding value
  6088. * of the easing function.
  6089. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6090. * @returns the corresponding value on the curve defined by the easing function
  6091. */
  6092. ease(gradient: number): number;
  6093. }
  6094. /**
  6095. * Easing function with a circle shape (see link below).
  6096. * @see https://easings.net/#easeInCirc
  6097. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6098. */
  6099. export class CircleEase extends EasingFunction implements IEasingFunction {
  6100. /** @hidden */
  6101. easeInCore(gradient: number): number;
  6102. }
  6103. /**
  6104. * Easing function with a ease back shape (see link below).
  6105. * @see https://easings.net/#easeInBack
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export class BackEase extends EasingFunction implements IEasingFunction {
  6109. /** Defines the amplitude of the function */
  6110. amplitude: number;
  6111. /**
  6112. * Instantiates a back ease easing
  6113. * @see https://easings.net/#easeInBack
  6114. * @param amplitude Defines the amplitude of the function
  6115. */
  6116. constructor(
  6117. /** Defines the amplitude of the function */
  6118. amplitude?: number);
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a bouncing shape (see link below).
  6124. * @see https://easings.net/#easeInBounce
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BounceEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the number of bounces */
  6129. bounces: number;
  6130. /** Defines the amplitude of the bounce */
  6131. bounciness: number;
  6132. /**
  6133. * Instantiates a bounce easing
  6134. * @see https://easings.net/#easeInBounce
  6135. * @param bounces Defines the number of bounces
  6136. * @param bounciness Defines the amplitude of the bounce
  6137. */
  6138. constructor(
  6139. /** Defines the number of bounces */
  6140. bounces?: number,
  6141. /** Defines the amplitude of the bounce */
  6142. bounciness?: number);
  6143. /** @hidden */
  6144. easeInCore(gradient: number): number;
  6145. }
  6146. /**
  6147. * Easing function with a power of 3 shape (see link below).
  6148. * @see https://easings.net/#easeInCubic
  6149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6150. */
  6151. export class CubicEase extends EasingFunction implements IEasingFunction {
  6152. /** @hidden */
  6153. easeInCore(gradient: number): number;
  6154. }
  6155. /**
  6156. * Easing function with an elastic shape (see link below).
  6157. * @see https://easings.net/#easeInElastic
  6158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6159. */
  6160. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6161. /** Defines the number of oscillations*/
  6162. oscillations: number;
  6163. /** Defines the amplitude of the oscillations*/
  6164. springiness: number;
  6165. /**
  6166. * Instantiates an elastic easing function
  6167. * @see https://easings.net/#easeInElastic
  6168. * @param oscillations Defines the number of oscillations
  6169. * @param springiness Defines the amplitude of the oscillations
  6170. */
  6171. constructor(
  6172. /** Defines the number of oscillations*/
  6173. oscillations?: number,
  6174. /** Defines the amplitude of the oscillations*/
  6175. springiness?: number);
  6176. /** @hidden */
  6177. easeInCore(gradient: number): number;
  6178. }
  6179. /**
  6180. * Easing function with an exponential shape (see link below).
  6181. * @see https://easings.net/#easeInExpo
  6182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6183. */
  6184. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6185. /** Defines the exponent of the function */
  6186. exponent: number;
  6187. /**
  6188. * Instantiates an exponential easing function
  6189. * @see https://easings.net/#easeInExpo
  6190. * @param exponent Defines the exponent of the function
  6191. */
  6192. constructor(
  6193. /** Defines the exponent of the function */
  6194. exponent?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with a power shape (see link below).
  6200. * @see https://easings.net/#easeInQuad
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class PowerEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the power of the function */
  6205. power: number;
  6206. /**
  6207. * Instantiates an power base easing function
  6208. * @see https://easings.net/#easeInQuad
  6209. * @param power Defines the power of the function
  6210. */
  6211. constructor(
  6212. /** Defines the power of the function */
  6213. power?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power of 2 shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. /**
  6227. * Easing function with a power of 4 shape (see link below).
  6228. * @see https://easings.net/#easeInQuart
  6229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6230. */
  6231. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6232. /** @hidden */
  6233. easeInCore(gradient: number): number;
  6234. }
  6235. /**
  6236. * Easing function with a power of 5 shape (see link below).
  6237. * @see https://easings.net/#easeInQuint
  6238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6239. */
  6240. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with a sin shape (see link below).
  6246. * @see https://easings.net/#easeInSine
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class SineEase extends EasingFunction implements IEasingFunction {
  6250. /** @hidden */
  6251. easeInCore(gradient: number): number;
  6252. }
  6253. /**
  6254. * Easing function with a bezier shape (see link below).
  6255. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6257. */
  6258. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6259. /** Defines the x component of the start tangent in the bezier curve */
  6260. x1: number;
  6261. /** Defines the y component of the start tangent in the bezier curve */
  6262. y1: number;
  6263. /** Defines the x component of the end tangent in the bezier curve */
  6264. x2: number;
  6265. /** Defines the y component of the end tangent in the bezier curve */
  6266. y2: number;
  6267. /**
  6268. * Instantiates a bezier function
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @param x1 Defines the x component of the start tangent in the bezier curve
  6271. * @param y1 Defines the y component of the start tangent in the bezier curve
  6272. * @param x2 Defines the x component of the end tangent in the bezier curve
  6273. * @param y2 Defines the y component of the end tangent in the bezier curve
  6274. */
  6275. constructor(
  6276. /** Defines the x component of the start tangent in the bezier curve */
  6277. x1?: number,
  6278. /** Defines the y component of the start tangent in the bezier curve */
  6279. y1?: number,
  6280. /** Defines the x component of the end tangent in the bezier curve */
  6281. x2?: number,
  6282. /** Defines the y component of the end tangent in the bezier curve */
  6283. y2?: number);
  6284. /** @hidden */
  6285. easeInCore(gradient: number): number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * Defines an interface which represents an animation key frame
  6291. */
  6292. export interface IAnimationKey {
  6293. /**
  6294. * Frame of the key frame
  6295. */
  6296. frame: number;
  6297. /**
  6298. * Value at the specifies key frame
  6299. */
  6300. value: any;
  6301. /**
  6302. * The input tangent for the cubic hermite spline
  6303. */
  6304. inTangent?: any;
  6305. /**
  6306. * The output tangent for the cubic hermite spline
  6307. */
  6308. outTangent?: any;
  6309. /**
  6310. * The animation interpolation type
  6311. */
  6312. interpolation?: AnimationKeyInterpolation;
  6313. }
  6314. /**
  6315. * Enum for the animation key frame interpolation type
  6316. */
  6317. export enum AnimationKeyInterpolation {
  6318. /**
  6319. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6320. */
  6321. STEP = 1
  6322. }
  6323. }
  6324. declare module BABYLON {
  6325. /**
  6326. * Represents the range of an animation
  6327. */
  6328. export class AnimationRange {
  6329. /**The name of the animation range**/
  6330. name: string;
  6331. /**The starting frame of the animation */
  6332. from: number;
  6333. /**The ending frame of the animation*/
  6334. to: number;
  6335. /**
  6336. * Initializes the range of an animation
  6337. * @param name The name of the animation range
  6338. * @param from The starting frame of the animation
  6339. * @param to The ending frame of the animation
  6340. */
  6341. constructor(
  6342. /**The name of the animation range**/
  6343. name: string,
  6344. /**The starting frame of the animation */
  6345. from: number,
  6346. /**The ending frame of the animation*/
  6347. to: number);
  6348. /**
  6349. * Makes a copy of the animation range
  6350. * @returns A copy of the animation range
  6351. */
  6352. clone(): AnimationRange;
  6353. }
  6354. }
  6355. declare module BABYLON {
  6356. /**
  6357. * Composed of a frame, and an action function
  6358. */
  6359. export class AnimationEvent {
  6360. /** The frame for which the event is triggered **/
  6361. frame: number;
  6362. /** The event to perform when triggered **/
  6363. action: (currentFrame: number) => void;
  6364. /** Specifies if the event should be triggered only once**/
  6365. onlyOnce?: boolean | undefined;
  6366. /**
  6367. * Specifies if the animation event is done
  6368. */
  6369. isDone: boolean;
  6370. /**
  6371. * Initializes the animation event
  6372. * @param frame The frame for which the event is triggered
  6373. * @param action The event to perform when triggered
  6374. * @param onlyOnce Specifies if the event should be triggered only once
  6375. */
  6376. constructor(
  6377. /** The frame for which the event is triggered **/
  6378. frame: number,
  6379. /** The event to perform when triggered **/
  6380. action: (currentFrame: number) => void,
  6381. /** Specifies if the event should be triggered only once**/
  6382. onlyOnce?: boolean | undefined);
  6383. /** @hidden */ private _clone(): AnimationEvent;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * Interface used to define a behavior
  6389. */
  6390. export interface Behavior<T> {
  6391. /** gets or sets behavior's name */
  6392. name: string;
  6393. /**
  6394. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6395. */
  6396. init(): void;
  6397. /**
  6398. * Called when the behavior is attached to a target
  6399. * @param target defines the target where the behavior is attached to
  6400. */
  6401. attach(target: T): void;
  6402. /**
  6403. * Called when the behavior is detached from its target
  6404. */
  6405. detach(): void;
  6406. }
  6407. /**
  6408. * Interface implemented by classes supporting behaviors
  6409. */
  6410. export interface IBehaviorAware<T> {
  6411. /**
  6412. * Attach a behavior
  6413. * @param behavior defines the behavior to attach
  6414. * @returns the current host
  6415. */
  6416. addBehavior(behavior: Behavior<T>): T;
  6417. /**
  6418. * Remove a behavior from the current object
  6419. * @param behavior defines the behavior to detach
  6420. * @returns the current host
  6421. */
  6422. removeBehavior(behavior: Behavior<T>): T;
  6423. /**
  6424. * Gets a behavior using its name to search
  6425. * @param name defines the name to search
  6426. * @returns the behavior or null if not found
  6427. */
  6428. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Defines an array and its length.
  6434. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6435. */
  6436. export interface ISmartArrayLike<T> {
  6437. /**
  6438. * The data of the array.
  6439. */
  6440. data: Array<T>;
  6441. /**
  6442. * The active length of the array.
  6443. */
  6444. length: number;
  6445. }
  6446. /**
  6447. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6448. */
  6449. export class SmartArray<T> implements ISmartArrayLike<T> {
  6450. /**
  6451. * The full set of data from the array.
  6452. */
  6453. data: Array<T>;
  6454. /**
  6455. * The active length of the array.
  6456. */
  6457. length: number;
  6458. protected _id: number;
  6459. /**
  6460. * Instantiates a Smart Array.
  6461. * @param capacity defines the default capacity of the array.
  6462. */
  6463. constructor(capacity: number);
  6464. /**
  6465. * Pushes a value at the end of the active data.
  6466. * @param value defines the object to push in the array.
  6467. */
  6468. push(value: T): void;
  6469. /**
  6470. * Iterates over the active data and apply the lambda to them.
  6471. * @param func defines the action to apply on each value.
  6472. */
  6473. forEach(func: (content: T) => void): void;
  6474. /**
  6475. * Sorts the full sets of data.
  6476. * @param compareFn defines the comparison function to apply.
  6477. */
  6478. sort(compareFn: (a: T, b: T) => number): void;
  6479. /**
  6480. * Resets the active data to an empty array.
  6481. */
  6482. reset(): void;
  6483. /**
  6484. * Releases all the data from the array as well as the array.
  6485. */
  6486. dispose(): void;
  6487. /**
  6488. * Concats the active data with a given array.
  6489. * @param array defines the data to concatenate with.
  6490. */
  6491. concat(array: any): void;
  6492. /**
  6493. * Returns the position of a value in the active data.
  6494. * @param value defines the value to find the index for
  6495. * @returns the index if found in the active data otherwise -1
  6496. */
  6497. indexOf(value: T): number;
  6498. /**
  6499. * Returns whether an element is part of the active data.
  6500. * @param value defines the value to look for
  6501. * @returns true if found in the active data otherwise false
  6502. */
  6503. contains(value: T): boolean;
  6504. private static _GlobalId;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. * The data in this array can only be present once
  6509. */
  6510. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6511. private _duplicateId;
  6512. /**
  6513. * Pushes a value at the end of the active data.
  6514. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6515. * @param value defines the object to push in the array.
  6516. */
  6517. push(value: T): void;
  6518. /**
  6519. * Pushes a value at the end of the active data.
  6520. * If the data is already present, it won t be added again
  6521. * @param value defines the object to push in the array.
  6522. * @returns true if added false if it was already present
  6523. */
  6524. pushNoDuplicate(value: T): boolean;
  6525. /**
  6526. * Resets the active data to an empty array.
  6527. */
  6528. reset(): void;
  6529. /**
  6530. * Concats the active data with a given array.
  6531. * This ensures no dupplicate will be present in the result.
  6532. * @param array defines the data to concatenate with.
  6533. */
  6534. concatWithNoDuplicate(array: any): void;
  6535. }
  6536. }
  6537. declare module BABYLON {
  6538. /**
  6539. * @ignore
  6540. * This is a list of all the different input types that are available in the application.
  6541. * Fo instance: ArcRotateCameraGamepadInput...
  6542. */
  6543. export var CameraInputTypes: {};
  6544. /**
  6545. * This is the contract to implement in order to create a new input class.
  6546. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6547. */
  6548. export interface ICameraInput<TCamera extends Camera> {
  6549. /**
  6550. * Defines the camera the input is attached to.
  6551. */
  6552. camera: Nullable<TCamera>;
  6553. /**
  6554. * Gets the class name of the current intput.
  6555. * @returns the class name
  6556. */
  6557. getClassName(): string;
  6558. /**
  6559. * Get the friendly name associated with the input class.
  6560. * @returns the input friendly name
  6561. */
  6562. getSimpleName(): string;
  6563. /**
  6564. * Attach the input controls to a specific dom element to get the input from.
  6565. * @param element Defines the element the controls should be listened from
  6566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6567. */
  6568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6569. /**
  6570. * Detach the current controls from the specified dom element.
  6571. * @param element Defines the element to stop listening the inputs from
  6572. */
  6573. detachControl(element: Nullable<HTMLElement>): void;
  6574. /**
  6575. * Update the current camera state depending on the inputs that have been used this frame.
  6576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6577. */
  6578. checkInputs?: () => void;
  6579. }
  6580. /**
  6581. * Represents a map of input types to input instance or input index to input instance.
  6582. */
  6583. export interface CameraInputsMap<TCamera extends Camera> {
  6584. /**
  6585. * Accessor to the input by input type.
  6586. */
  6587. [name: string]: ICameraInput<TCamera>;
  6588. /**
  6589. * Accessor to the input by input index.
  6590. */
  6591. [idx: number]: ICameraInput<TCamera>;
  6592. }
  6593. /**
  6594. * This represents the input manager used within a camera.
  6595. * It helps dealing with all the different kind of input attached to a camera.
  6596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6597. */
  6598. export class CameraInputsManager<TCamera extends Camera> {
  6599. /**
  6600. * Defines the list of inputs attahed to the camera.
  6601. */
  6602. attached: CameraInputsMap<TCamera>;
  6603. /**
  6604. * Defines the dom element the camera is collecting inputs from.
  6605. * This is null if the controls have not been attached.
  6606. */
  6607. attachedElement: Nullable<HTMLElement>;
  6608. /**
  6609. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6610. */
  6611. noPreventDefault: boolean;
  6612. /**
  6613. * Defined the camera the input manager belongs to.
  6614. */
  6615. camera: TCamera;
  6616. /**
  6617. * Update the current camera state depending on the inputs that have been used this frame.
  6618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6619. */
  6620. checkInputs: () => void;
  6621. /**
  6622. * Instantiate a new Camera Input Manager.
  6623. * @param camera Defines the camera the input manager blongs to
  6624. */
  6625. constructor(camera: TCamera);
  6626. /**
  6627. * Add an input method to a camera
  6628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6629. * @param input camera input method
  6630. */
  6631. add(input: ICameraInput<TCamera>): void;
  6632. /**
  6633. * Remove a specific input method from a camera
  6634. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6635. * @param inputToRemove camera input method
  6636. */
  6637. remove(inputToRemove: ICameraInput<TCamera>): void;
  6638. /**
  6639. * Remove a specific input type from a camera
  6640. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6641. * @param inputType the type of the input to remove
  6642. */
  6643. removeByType(inputType: string): void;
  6644. private _addCheckInputs;
  6645. /**
  6646. * Attach the input controls to the currently attached dom element to listen the events from.
  6647. * @param input Defines the input to attach
  6648. */
  6649. attachInput(input: ICameraInput<TCamera>): void;
  6650. /**
  6651. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6652. * @param element Defines the dom element to collect the events from
  6653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6654. */
  6655. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6656. /**
  6657. * Detach the current manager inputs controls from a specific dom element.
  6658. * @param element Defines the dom element to collect the events from
  6659. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6660. */
  6661. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6662. /**
  6663. * Rebuild the dynamic inputCheck function from the current list of
  6664. * defined inputs in the manager.
  6665. */
  6666. rebuildInputCheck(): void;
  6667. /**
  6668. * Remove all attached input methods from a camera
  6669. */
  6670. clear(): void;
  6671. /**
  6672. * Serialize the current input manager attached to a camera.
  6673. * This ensures than once parsed,
  6674. * the input associated to the camera will be identical to the current ones
  6675. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6676. */
  6677. serialize(serializedCamera: any): void;
  6678. /**
  6679. * Parses an input manager serialized JSON to restore the previous list of inputs
  6680. * and states associated to a camera.
  6681. * @param parsedCamera Defines the JSON to parse
  6682. */
  6683. parse(parsedCamera: any): void;
  6684. }
  6685. }
  6686. declare module BABYLON {
  6687. /**
  6688. * @hidden
  6689. */
  6690. export class IntersectionInfo {
  6691. bu: Nullable<number>;
  6692. bv: Nullable<number>;
  6693. distance: number;
  6694. faceId: number;
  6695. subMeshId: number;
  6696. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6697. }
  6698. }
  6699. declare module BABYLON {
  6700. /**
  6701. * Represens a plane by the equation ax + by + cz + d = 0
  6702. */
  6703. export class Plane {
  6704. private static _TmpMatrix;
  6705. /**
  6706. * Normal of the plane (a,b,c)
  6707. */
  6708. normal: Vector3;
  6709. /**
  6710. * d component of the plane
  6711. */
  6712. d: number;
  6713. /**
  6714. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6715. * @param a a component of the plane
  6716. * @param b b component of the plane
  6717. * @param c c component of the plane
  6718. * @param d d component of the plane
  6719. */
  6720. constructor(a: number, b: number, c: number, d: number);
  6721. /**
  6722. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6723. */
  6724. asArray(): number[];
  6725. /**
  6726. * @returns a new plane copied from the current Plane.
  6727. */
  6728. clone(): Plane;
  6729. /**
  6730. * @returns the string "Plane".
  6731. */
  6732. getClassName(): string;
  6733. /**
  6734. * @returns the Plane hash code.
  6735. */
  6736. getHashCode(): number;
  6737. /**
  6738. * Normalize the current Plane in place.
  6739. * @returns the updated Plane.
  6740. */
  6741. normalize(): Plane;
  6742. /**
  6743. * Applies a transformation the plane and returns the result
  6744. * @param transformation the transformation matrix to be applied to the plane
  6745. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6746. */
  6747. transform(transformation: DeepImmutable<Matrix>): Plane;
  6748. /**
  6749. * Calcualtte the dot product between the point and the plane normal
  6750. * @param point point to calculate the dot product with
  6751. * @returns the dot product (float) of the point coordinates and the plane normal.
  6752. */
  6753. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6754. /**
  6755. * Updates the current Plane from the plane defined by the three given points.
  6756. * @param point1 one of the points used to contruct the plane
  6757. * @param point2 one of the points used to contruct the plane
  6758. * @param point3 one of the points used to contruct the plane
  6759. * @returns the updated Plane.
  6760. */
  6761. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6762. /**
  6763. * Checks if the plane is facing a given direction
  6764. * @param direction the direction to check if the plane is facing
  6765. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6766. * @returns True is the vector "direction" is the same side than the plane normal.
  6767. */
  6768. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6769. /**
  6770. * Calculates the distance to a point
  6771. * @param point point to calculate distance to
  6772. * @returns the signed distance (float) from the given point to the Plane.
  6773. */
  6774. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6775. /**
  6776. * Creates a plane from an array
  6777. * @param array the array to create a plane from
  6778. * @returns a new Plane from the given array.
  6779. */
  6780. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6781. /**
  6782. * Creates a plane from three points
  6783. * @param point1 point used to create the plane
  6784. * @param point2 point used to create the plane
  6785. * @param point3 point used to create the plane
  6786. * @returns a new Plane defined by the three given points.
  6787. */
  6788. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6789. /**
  6790. * Creates a plane from an origin point and a normal
  6791. * @param origin origin of the plane to be constructed
  6792. * @param normal normal of the plane to be constructed
  6793. * @returns a new Plane the normal vector to this plane at the given origin point.
  6794. * Note : the vector "normal" is updated because normalized.
  6795. */
  6796. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6797. /**
  6798. * Calculates the distance from a plane and a point
  6799. * @param origin origin of the plane to be constructed
  6800. * @param normal normal of the plane to be constructed
  6801. * @param point point to calculate distance to
  6802. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6803. */
  6804. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6805. }
  6806. }
  6807. declare module BABYLON {
  6808. /**
  6809. * Class used to store bounding sphere information
  6810. */
  6811. export class BoundingSphere {
  6812. /**
  6813. * Gets the center of the bounding sphere in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Radius of the bounding sphere in local space
  6818. */
  6819. radius: number;
  6820. /**
  6821. * Gets the center of the bounding sphere in world space
  6822. */
  6823. readonly centerWorld: Vector3;
  6824. /**
  6825. * Radius of the bounding sphere in world space
  6826. */
  6827. radiusWorld: number;
  6828. /**
  6829. * Gets the minimum vector in local space
  6830. */
  6831. readonly minimum: Vector3;
  6832. /**
  6833. * Gets the maximum vector in local space
  6834. */
  6835. readonly maximum: Vector3;
  6836. private _worldMatrix;
  6837. private static readonly TmpVector3;
  6838. /**
  6839. * Creates a new bounding sphere
  6840. * @param min defines the minimum vector (in local space)
  6841. * @param max defines the maximum vector (in local space)
  6842. * @param worldMatrix defines the new world matrix
  6843. */
  6844. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6845. /**
  6846. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6847. * @param min defines the new minimum vector (in local space)
  6848. * @param max defines the new maximum vector (in local space)
  6849. * @param worldMatrix defines the new world matrix
  6850. */
  6851. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Scale the current bounding sphere by applying a scale factor
  6854. * @param factor defines the scale factor to apply
  6855. * @returns the current bounding box
  6856. */
  6857. scale(factor: number): BoundingSphere;
  6858. /**
  6859. * Gets the world matrix of the bounding box
  6860. * @returns a matrix
  6861. */
  6862. getWorldMatrix(): DeepImmutable<Matrix>;
  6863. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6864. /**
  6865. * Tests if the bounding sphere is intersecting the frustum planes
  6866. * @param frustumPlanes defines the frustum planes to test
  6867. * @returns true if there is an intersection
  6868. */
  6869. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6870. /**
  6871. * Tests if the bounding sphere center is in between the frustum planes.
  6872. * Used for optimistic fast inclusion.
  6873. * @param frustumPlanes defines the frustum planes to test
  6874. * @returns true if the sphere center is in between the frustum planes
  6875. */
  6876. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6877. /**
  6878. * Tests if a point is inside the bounding sphere
  6879. * @param point defines the point to test
  6880. * @returns true if the point is inside the bounding sphere
  6881. */
  6882. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6883. /**
  6884. * Checks if two sphere intersct
  6885. * @param sphere0 sphere 0
  6886. * @param sphere1 sphere 1
  6887. * @returns true if the speres intersect
  6888. */
  6889. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6890. }
  6891. }
  6892. declare module BABYLON {
  6893. /**
  6894. * Class used to store bounding box information
  6895. */
  6896. export class BoundingBox implements ICullable {
  6897. /**
  6898. * Gets the 8 vectors representing the bounding box in local space
  6899. */
  6900. readonly vectors: Vector3[];
  6901. /**
  6902. * Gets the center of the bounding box in local space
  6903. */
  6904. readonly center: Vector3;
  6905. /**
  6906. * Gets the center of the bounding box in world space
  6907. */
  6908. readonly centerWorld: Vector3;
  6909. /**
  6910. * Gets the extend size in local space
  6911. */
  6912. readonly extendSize: Vector3;
  6913. /**
  6914. * Gets the extend size in world space
  6915. */
  6916. readonly extendSizeWorld: Vector3;
  6917. /**
  6918. * Gets the OBB (object bounding box) directions
  6919. */
  6920. readonly directions: Vector3[];
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in world space
  6923. */
  6924. readonly vectorsWorld: Vector3[];
  6925. /**
  6926. * Gets the minimum vector in world space
  6927. */
  6928. readonly minimumWorld: Vector3;
  6929. /**
  6930. * Gets the maximum vector in world space
  6931. */
  6932. readonly maximumWorld: Vector3;
  6933. /**
  6934. * Gets the minimum vector in local space
  6935. */
  6936. readonly minimum: Vector3;
  6937. /**
  6938. * Gets the maximum vector in local space
  6939. */
  6940. readonly maximum: Vector3;
  6941. private _worldMatrix;
  6942. private static readonly TmpVector3;
  6943. /**
  6944. * @hidden
  6945. */ private _tag: number;
  6946. /**
  6947. * Creates a new bounding box
  6948. * @param min defines the minimum vector (in local space)
  6949. * @param max defines the maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6953. /**
  6954. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6955. * @param min defines the new minimum vector (in local space)
  6956. * @param max defines the new maximum vector (in local space)
  6957. * @param worldMatrix defines the new world matrix
  6958. */
  6959. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6960. /**
  6961. * Scale the current bounding box by applying a scale factor
  6962. * @param factor defines the scale factor to apply
  6963. * @returns the current bounding box
  6964. */
  6965. scale(factor: number): BoundingBox;
  6966. /**
  6967. * Gets the world matrix of the bounding box
  6968. * @returns a matrix
  6969. */
  6970. getWorldMatrix(): DeepImmutable<Matrix>;
  6971. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding box is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding box is entirely inside the frustum planes
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @returns true if there is an inclusion
  6982. */
  6983. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a point is inside the bounding box
  6986. * @param point defines the point to test
  6987. * @returns true if the point is inside the bounding box
  6988. */
  6989. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if the bounding box intersects with a bounding sphere
  6992. * @param sphere defines the sphere to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6996. /**
  6997. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6998. * @param min defines the min vector to use
  6999. * @param max defines the max vector to use
  7000. * @returns true if there is an intersection
  7001. */
  7002. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7003. /**
  7004. * Tests if two bounding boxes are intersections
  7005. * @param box0 defines the first box to test
  7006. * @param box1 defines the second box to test
  7007. * @returns true if there is an intersection
  7008. */
  7009. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7010. /**
  7011. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7012. * @param minPoint defines the minimum vector of the bounding box
  7013. * @param maxPoint defines the maximum vector of the bounding box
  7014. * @param sphereCenter defines the sphere center
  7015. * @param sphereRadius defines the sphere radius
  7016. * @returns true if there is an intersection
  7017. */
  7018. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7019. /**
  7020. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7021. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7022. * @param frustumPlanes defines the frustum planes to test
  7023. * @return true if there is an inclusion
  7024. */
  7025. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7026. /**
  7027. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7028. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7029. * @param frustumPlanes defines the frustum planes to test
  7030. * @return true if there is an intersection
  7031. */
  7032. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7033. }
  7034. }
  7035. declare module BABYLON {
  7036. /** @hidden */
  7037. export class Collider {
  7038. /** Define if a collision was found */
  7039. collisionFound: boolean;
  7040. /**
  7041. * Define last intersection point in local space
  7042. */
  7043. intersectionPoint: Vector3;
  7044. /**
  7045. * Define last collided mesh
  7046. */
  7047. collidedMesh: Nullable<AbstractMesh>;
  7048. private _collisionPoint;
  7049. private _planeIntersectionPoint;
  7050. private _tempVector;
  7051. private _tempVector2;
  7052. private _tempVector3;
  7053. private _tempVector4;
  7054. private _edge;
  7055. private _baseToVertex;
  7056. private _destinationPoint;
  7057. private _slidePlaneNormal;
  7058. private _displacementVector;
  7059. /** @hidden */ private _radius: Vector3;
  7060. /** @hidden */ private _retry: number;
  7061. private _velocity;
  7062. private _basePoint;
  7063. private _epsilon;
  7064. /** @hidden */ private _velocityWorldLength: number;
  7065. /** @hidden */ private _basePointWorld: Vector3;
  7066. private _velocityWorld;
  7067. private _normalizedVelocity;
  7068. /** @hidden */ private _initialVelocity: Vector3;
  7069. /** @hidden */ private _initialPosition: Vector3;
  7070. private _nearestDistance;
  7071. private _collisionMask;
  7072. collisionMask: number;
  7073. /**
  7074. * Gets the plane normal used to compute the sliding response (in local space)
  7075. */
  7076. readonly slidePlaneNormal: Vector3;
  7077. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7078. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7080. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7081. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7082. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7083. }
  7084. }
  7085. declare module BABYLON {
  7086. /**
  7087. * Interface for cullable objects
  7088. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7089. */
  7090. export interface ICullable {
  7091. /**
  7092. * Checks if the object or part of the object is in the frustum
  7093. * @param frustumPlanes Camera near/planes
  7094. * @returns true if the object is in frustum otherwise false
  7095. */
  7096. isInFrustum(frustumPlanes: Plane[]): boolean;
  7097. /**
  7098. * Checks if a cullable object (mesh...) is in the camera frustum
  7099. * Unlike isInFrustum this cheks the full bounding box
  7100. * @param frustumPlanes Camera near/planes
  7101. * @returns true if the object is in frustum otherwise false
  7102. */
  7103. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7104. }
  7105. /**
  7106. * Info for a bounding data of a mesh
  7107. */
  7108. export class BoundingInfo implements ICullable {
  7109. /**
  7110. * Bounding box for the mesh
  7111. */
  7112. readonly boundingBox: BoundingBox;
  7113. /**
  7114. * Bounding sphere for the mesh
  7115. */
  7116. readonly boundingSphere: BoundingSphere;
  7117. private _isLocked;
  7118. private static readonly TmpVector3;
  7119. /**
  7120. * Constructs bounding info
  7121. * @param minimum min vector of the bounding box/sphere
  7122. * @param maximum max vector of the bounding box/sphere
  7123. * @param worldMatrix defines the new world matrix
  7124. */
  7125. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7126. /**
  7127. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7128. * @param min defines the new minimum vector (in local space)
  7129. * @param max defines the new maximum vector (in local space)
  7130. * @param worldMatrix defines the new world matrix
  7131. */
  7132. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * min vector of the bounding box/sphere
  7135. */
  7136. readonly minimum: Vector3;
  7137. /**
  7138. * max vector of the bounding box/sphere
  7139. */
  7140. readonly maximum: Vector3;
  7141. /**
  7142. * If the info is locked and won't be updated to avoid perf overhead
  7143. */
  7144. isLocked: boolean;
  7145. /**
  7146. * Updates the bounding sphere and box
  7147. * @param world world matrix to be used to update
  7148. */
  7149. update(world: DeepImmutable<Matrix>): void;
  7150. /**
  7151. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7152. * @param center New center of the bounding info
  7153. * @param extend New extend of the bounding info
  7154. * @returns the current bounding info
  7155. */
  7156. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7157. /**
  7158. * Scale the current bounding info by applying a scale factor
  7159. * @param factor defines the scale factor to apply
  7160. * @returns the current bounding info
  7161. */
  7162. scale(factor: number): BoundingInfo;
  7163. /**
  7164. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7165. * @param frustumPlanes defines the frustum to test
  7166. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7167. * @returns true if the bounding info is in the frustum planes
  7168. */
  7169. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7170. /**
  7171. * Gets the world distance between the min and max points of the bounding box
  7172. */
  7173. readonly diagonalLength: number;
  7174. /**
  7175. * Checks if a cullable object (mesh...) is in the camera frustum
  7176. * Unlike isInFrustum this cheks the full bounding box
  7177. * @param frustumPlanes Camera near/planes
  7178. * @returns true if the object is in frustum otherwise false
  7179. */
  7180. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7181. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7182. /**
  7183. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7184. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7185. * @param point the point to check intersection with
  7186. * @returns if the point intersects
  7187. */
  7188. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7189. /**
  7190. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7191. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7192. * @param boundingInfo the bounding info to check intersection with
  7193. * @param precise if the intersection should be done using OBB
  7194. * @returns if the bounding info intersects
  7195. */
  7196. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7197. }
  7198. }
  7199. declare module BABYLON {
  7200. /**
  7201. * Extracts minimum and maximum values from a list of indexed positions
  7202. * @param positions defines the positions to use
  7203. * @param indices defines the indices to the positions
  7204. * @param indexStart defines the start index
  7205. * @param indexCount defines the end index
  7206. * @param bias defines bias value to add to the result
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. /**
  7214. * Extracts minimum and maximum values from a list of positions
  7215. * @param positions defines the positions to use
  7216. * @param start defines the start index in the positions array
  7217. * @param count defines the number of positions to handle
  7218. * @param bias defines bias value to add to the result
  7219. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7220. * @return minimum and maximum values
  7221. */
  7222. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7223. minimum: Vector3;
  7224. maximum: Vector3;
  7225. };
  7226. }
  7227. declare module BABYLON {
  7228. /**
  7229. * Enum that determines the text-wrapping mode to use.
  7230. */
  7231. export enum InspectableType {
  7232. /**
  7233. * Checkbox for booleans
  7234. */
  7235. Checkbox = 0,
  7236. /**
  7237. * Sliders for numbers
  7238. */
  7239. Slider = 1,
  7240. /**
  7241. * Vector3
  7242. */
  7243. Vector3 = 2,
  7244. /**
  7245. * Quaternions
  7246. */
  7247. Quaternion = 3,
  7248. /**
  7249. * Color3
  7250. */
  7251. Color3 = 4,
  7252. /**
  7253. * String
  7254. */
  7255. String = 5
  7256. }
  7257. /**
  7258. * Interface used to define custom inspectable properties.
  7259. * This interface is used by the inspector to display custom property grids
  7260. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7261. */
  7262. export interface IInspectable {
  7263. /**
  7264. * Gets the label to display
  7265. */
  7266. label: string;
  7267. /**
  7268. * Gets the name of the property to edit
  7269. */
  7270. propertyName: string;
  7271. /**
  7272. * Gets the type of the editor to use
  7273. */
  7274. type: InspectableType;
  7275. /**
  7276. * Gets the minimum value of the property when using in "slider" mode
  7277. */
  7278. min?: number;
  7279. /**
  7280. * Gets the maximum value of the property when using in "slider" mode
  7281. */
  7282. max?: number;
  7283. /**
  7284. * Gets the setp to use when using in "slider" mode
  7285. */
  7286. step?: number;
  7287. }
  7288. }
  7289. declare module BABYLON {
  7290. /**
  7291. * Class used to provide helper for timing
  7292. */
  7293. export class TimingTools {
  7294. /**
  7295. * Polyfill for setImmediate
  7296. * @param action defines the action to execute after the current execution block
  7297. */
  7298. static SetImmediate(action: () => void): void;
  7299. }
  7300. }
  7301. declare module BABYLON {
  7302. /**
  7303. * Class used to enable instatition of objects by class name
  7304. */
  7305. export class InstantiationTools {
  7306. /**
  7307. * Use this object to register external classes like custom textures or material
  7308. * to allow the laoders to instantiate them
  7309. */
  7310. static RegisteredExternalClasses: {
  7311. [key: string]: Object;
  7312. };
  7313. /**
  7314. * Tries to instantiate a new object from a given class name
  7315. * @param className defines the class name to instantiate
  7316. * @returns the new object or null if the system was not able to do the instantiation
  7317. */
  7318. static Instantiate(className: string): any;
  7319. }
  7320. }
  7321. declare module BABYLON {
  7322. /**
  7323. * This represents the required contract to create a new type of texture loader.
  7324. */
  7325. export interface IInternalTextureLoader {
  7326. /**
  7327. * Defines wether the loader supports cascade loading the different faces.
  7328. */
  7329. supportCascades: boolean;
  7330. /**
  7331. * This returns if the loader support the current file information.
  7332. * @param extension defines the file extension of the file being loaded
  7333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7334. * @param fallback defines the fallback internal texture if any
  7335. * @param isBase64 defines whether the texture is encoded as a base64
  7336. * @param isBuffer defines whether the texture data are stored as a buffer
  7337. * @returns true if the loader can load the specified file
  7338. */
  7339. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7340. /**
  7341. * Transform the url before loading if required.
  7342. * @param rootUrl the url of the texture
  7343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7344. * @returns the transformed texture
  7345. */
  7346. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7347. /**
  7348. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7349. * @param rootUrl the url of the texture
  7350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7351. * @returns the fallback texture
  7352. */
  7353. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7354. /**
  7355. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7356. * @param data contains the texture data
  7357. * @param texture defines the BabylonJS internal texture
  7358. * @param createPolynomials will be true if polynomials have been requested
  7359. * @param onLoad defines the callback to trigger once the texture is ready
  7360. * @param onError defines the callback to trigger in case of error
  7361. */
  7362. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7363. /**
  7364. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7365. * @param data contains the texture data
  7366. * @param texture defines the BabylonJS internal texture
  7367. * @param callback defines the method to call once ready to upload
  7368. */
  7369. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7370. }
  7371. }
  7372. declare module BABYLON {
  7373. interface Engine {
  7374. /**
  7375. * Creates a depth stencil cube texture.
  7376. * This is only available in WebGL 2.
  7377. * @param size The size of face edge in the cube texture.
  7378. * @param options The options defining the cube texture.
  7379. * @returns The cube texture
  7380. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7381. /**
  7382. * Creates a cube texture
  7383. * @param rootUrl defines the url where the files to load is located
  7384. * @param scene defines the current scene
  7385. * @param files defines the list of files to load (1 per face)
  7386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7387. * @param onLoad defines an optional callback raised when the texture is loaded
  7388. * @param onError defines an optional callback raised if there is an issue to load the texture
  7389. * @param format defines the format of the data
  7390. * @param forcedExtension defines the extension to use to pick the right loader
  7391. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7392. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7393. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7394. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7395. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7396. * @returns the cube texture as an InternalTexture
  7397. */
  7398. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7399. /**
  7400. * Creates a cube texture
  7401. * @param rootUrl defines the url where the files to load is located
  7402. * @param scene defines the current scene
  7403. * @param files defines the list of files to load (1 per face)
  7404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7405. * @param onLoad defines an optional callback raised when the texture is loaded
  7406. * @param onError defines an optional callback raised if there is an issue to load the texture
  7407. * @param format defines the format of the data
  7408. * @param forcedExtension defines the extension to use to pick the right loader
  7409. * @returns the cube texture as an InternalTexture
  7410. */
  7411. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7412. /**
  7413. * Creates a cube texture
  7414. * @param rootUrl defines the url where the files to load is located
  7415. * @param scene defines the current scene
  7416. * @param files defines the list of files to load (1 per face)
  7417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7418. * @param onLoad defines an optional callback raised when the texture is loaded
  7419. * @param onError defines an optional callback raised if there is an issue to load the texture
  7420. * @param format defines the format of the data
  7421. * @param forcedExtension defines the extension to use to pick the right loader
  7422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7425. * @returns the cube texture as an InternalTexture
  7426. */
  7427. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7428. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7429. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7430. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7431. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7432. }
  7433. }
  7434. declare module BABYLON {
  7435. /**
  7436. * Class for creating a cube texture
  7437. */
  7438. export class CubeTexture extends BaseTexture {
  7439. private _delayedOnLoad;
  7440. /**
  7441. * The url of the texture
  7442. */
  7443. url: string;
  7444. /**
  7445. * Gets or sets the center of the bounding box associated with the cube texture.
  7446. * It must define where the camera used to render the texture was set
  7447. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7448. */
  7449. boundingBoxPosition: Vector3;
  7450. private _boundingBoxSize;
  7451. /**
  7452. * Gets or sets the size of the bounding box associated with the cube texture
  7453. * When defined, the cubemap will switch to local mode
  7454. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7455. * @example https://www.babylonjs-playground.com/#RNASML
  7456. */
  7457. /**
  7458. * Returns the bounding box size
  7459. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7460. */
  7461. boundingBoxSize: Vector3;
  7462. protected _rotationY: number;
  7463. /**
  7464. * Sets texture matrix rotation angle around Y axis in radians.
  7465. */
  7466. /**
  7467. * Gets texture matrix rotation angle around Y axis radians.
  7468. */
  7469. rotationY: number;
  7470. /**
  7471. * Are mip maps generated for this texture or not.
  7472. */
  7473. readonly noMipmap: boolean;
  7474. private _noMipmap;
  7475. private _files;
  7476. private _extensions;
  7477. private _textureMatrix;
  7478. private _format;
  7479. private _createPolynomials;
  7480. /** @hidden */ private _prefiltered: boolean;
  7481. /**
  7482. * Creates a cube texture from an array of image urls
  7483. * @param files defines an array of image urls
  7484. * @param scene defines the hosting scene
  7485. * @param noMipmap specifies if mip maps are not used
  7486. * @returns a cube texture
  7487. */
  7488. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7489. /**
  7490. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7491. * @param url defines the url of the prefiltered texture
  7492. * @param scene defines the scene the texture is attached to
  7493. * @param forcedExtension defines the extension of the file if different from the url
  7494. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7495. * @return the prefiltered texture
  7496. */
  7497. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7498. /**
  7499. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7500. * as prefiltered data.
  7501. * @param rootUrl defines the url of the texture or the root name of the six images
  7502. * @param scene defines the scene the texture is attached to
  7503. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7504. * @param noMipmap defines if mipmaps should be created or not
  7505. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7506. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7507. * @param onError defines a callback triggered in case of error during load
  7508. * @param format defines the internal format to use for the texture once loaded
  7509. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7510. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7511. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7512. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7513. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7514. * @return the cube texture
  7515. */
  7516. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7517. /**
  7518. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7519. */
  7520. readonly isPrefiltered: boolean;
  7521. /**
  7522. * Get the current class name of the texture useful for serialization or dynamic coding.
  7523. * @returns "CubeTexture"
  7524. */
  7525. getClassName(): string;
  7526. /**
  7527. * Update the url (and optional buffer) of this texture if url was null during construction.
  7528. * @param url the url of the texture
  7529. * @param forcedExtension defines the extension to use
  7530. * @param onLoad callback called when the texture is loaded (defaults to null)
  7531. */
  7532. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7533. /**
  7534. * Delays loading of the cube texture
  7535. * @param forcedExtension defines the extension to use
  7536. */
  7537. delayLoad(forcedExtension?: string): void;
  7538. /**
  7539. * Returns the reflection texture matrix
  7540. * @returns the reflection texture matrix
  7541. */
  7542. getReflectionTextureMatrix(): Matrix;
  7543. /**
  7544. * Sets the reflection texture matrix
  7545. * @param value Reflection texture matrix
  7546. */
  7547. setReflectionTextureMatrix(value: Matrix): void;
  7548. /**
  7549. * Parses text to create a cube texture
  7550. * @param parsedTexture define the serialized text to read from
  7551. * @param scene defines the hosting scene
  7552. * @param rootUrl defines the root url of the cube texture
  7553. * @returns a cube texture
  7554. */
  7555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7556. /**
  7557. * Makes a clone, or deep copy, of the cube texture
  7558. * @returns a new cube texture
  7559. */
  7560. clone(): CubeTexture;
  7561. }
  7562. }
  7563. declare module BABYLON {
  7564. /**
  7565. * Manages the defines for the Material
  7566. */
  7567. export class MaterialDefines {
  7568. /** @hidden */
  7569. protected _keys: string[];
  7570. private _isDirty;
  7571. /** @hidden */ private _renderId: number;
  7572. /** @hidden */ private _areLightsDirty: boolean;
  7573. /** @hidden */ private _areAttributesDirty: boolean;
  7574. /** @hidden */ private _areTexturesDirty: boolean;
  7575. /** @hidden */ private _areFresnelDirty: boolean;
  7576. /** @hidden */ private _areMiscDirty: boolean;
  7577. /** @hidden */ private _areImageProcessingDirty: boolean;
  7578. /** @hidden */ private _normals: boolean;
  7579. /** @hidden */ private _uvs: boolean;
  7580. /** @hidden */ private _needNormals: boolean;
  7581. /** @hidden */ private _needUVs: boolean;
  7582. [id: string]: any;
  7583. /**
  7584. * Specifies if the material needs to be re-calculated
  7585. */
  7586. readonly isDirty: boolean;
  7587. /**
  7588. * Marks the material to indicate that it has been re-calculated
  7589. */
  7590. markAsProcessed(): void;
  7591. /**
  7592. * Marks the material to indicate that it needs to be re-calculated
  7593. */
  7594. markAsUnprocessed(): void;
  7595. /**
  7596. * Marks the material to indicate all of its defines need to be re-calculated
  7597. */
  7598. markAllAsDirty(): void;
  7599. /**
  7600. * Marks the material to indicate that image processing needs to be re-calculated
  7601. */
  7602. markAsImageProcessingDirty(): void;
  7603. /**
  7604. * Marks the material to indicate the lights need to be re-calculated
  7605. */
  7606. markAsLightDirty(): void;
  7607. /**
  7608. * Marks the attribute state as changed
  7609. */
  7610. markAsAttributesDirty(): void;
  7611. /**
  7612. * Marks the texture state as changed
  7613. */
  7614. markAsTexturesDirty(): void;
  7615. /**
  7616. * Marks the fresnel state as changed
  7617. */
  7618. markAsFresnelDirty(): void;
  7619. /**
  7620. * Marks the misc state as changed
  7621. */
  7622. markAsMiscDirty(): void;
  7623. /**
  7624. * Rebuilds the material defines
  7625. */
  7626. rebuild(): void;
  7627. /**
  7628. * Specifies if two material defines are equal
  7629. * @param other - A material define instance to compare to
  7630. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7631. */
  7632. isEqual(other: MaterialDefines): boolean;
  7633. /**
  7634. * Clones this instance's defines to another instance
  7635. * @param other - material defines to clone values to
  7636. */
  7637. cloneTo(other: MaterialDefines): void;
  7638. /**
  7639. * Resets the material define values
  7640. */
  7641. reset(): void;
  7642. /**
  7643. * Converts the material define values to a string
  7644. * @returns - String of material define information
  7645. */
  7646. toString(): string;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. /**
  7651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7653. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7655. */
  7656. export class ColorCurves {
  7657. private _dirty;
  7658. private _tempColor;
  7659. private _globalCurve;
  7660. private _highlightsCurve;
  7661. private _midtonesCurve;
  7662. private _shadowsCurve;
  7663. private _positiveCurve;
  7664. private _negativeCurve;
  7665. private _globalHue;
  7666. private _globalDensity;
  7667. private _globalSaturation;
  7668. private _globalExposure;
  7669. /**
  7670. * Gets the global Hue value.
  7671. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7672. */
  7673. /**
  7674. * Sets the global Hue value.
  7675. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7676. */
  7677. globalHue: number;
  7678. /**
  7679. * Gets the global Density value.
  7680. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7681. * Values less than zero provide a filter of opposite hue.
  7682. */
  7683. /**
  7684. * Sets the global Density value.
  7685. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7686. * Values less than zero provide a filter of opposite hue.
  7687. */
  7688. globalDensity: number;
  7689. /**
  7690. * Gets the global Saturation value.
  7691. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7692. */
  7693. /**
  7694. * Sets the global Saturation value.
  7695. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7696. */
  7697. globalSaturation: number;
  7698. /**
  7699. * Gets the global Exposure value.
  7700. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7701. */
  7702. /**
  7703. * Sets the global Exposure value.
  7704. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7705. */
  7706. globalExposure: number;
  7707. private _highlightsHue;
  7708. private _highlightsDensity;
  7709. private _highlightsSaturation;
  7710. private _highlightsExposure;
  7711. /**
  7712. * Gets the highlights Hue value.
  7713. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7714. */
  7715. /**
  7716. * Sets the highlights Hue value.
  7717. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7718. */
  7719. highlightsHue: number;
  7720. /**
  7721. * Gets the highlights Density value.
  7722. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7723. * Values less than zero provide a filter of opposite hue.
  7724. */
  7725. /**
  7726. * Sets the highlights Density value.
  7727. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7728. * Values less than zero provide a filter of opposite hue.
  7729. */
  7730. highlightsDensity: number;
  7731. /**
  7732. * Gets the highlights Saturation value.
  7733. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7734. */
  7735. /**
  7736. * Sets the highlights Saturation value.
  7737. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7738. */
  7739. highlightsSaturation: number;
  7740. /**
  7741. * Gets the highlights Exposure value.
  7742. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7743. */
  7744. /**
  7745. * Sets the highlights Exposure value.
  7746. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7747. */
  7748. highlightsExposure: number;
  7749. private _midtonesHue;
  7750. private _midtonesDensity;
  7751. private _midtonesSaturation;
  7752. private _midtonesExposure;
  7753. /**
  7754. * Gets the midtones Hue value.
  7755. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7756. */
  7757. /**
  7758. * Sets the midtones Hue value.
  7759. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7760. */
  7761. midtonesHue: number;
  7762. /**
  7763. * Gets the midtones Density value.
  7764. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7765. * Values less than zero provide a filter of opposite hue.
  7766. */
  7767. /**
  7768. * Sets the midtones Density value.
  7769. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7770. * Values less than zero provide a filter of opposite hue.
  7771. */
  7772. midtonesDensity: number;
  7773. /**
  7774. * Gets the midtones Saturation value.
  7775. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7776. */
  7777. /**
  7778. * Sets the midtones Saturation value.
  7779. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7780. */
  7781. midtonesSaturation: number;
  7782. /**
  7783. * Gets the midtones Exposure value.
  7784. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7785. */
  7786. /**
  7787. * Sets the midtones Exposure value.
  7788. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7789. */
  7790. midtonesExposure: number;
  7791. private _shadowsHue;
  7792. private _shadowsDensity;
  7793. private _shadowsSaturation;
  7794. private _shadowsExposure;
  7795. /**
  7796. * Gets the shadows Hue value.
  7797. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7798. */
  7799. /**
  7800. * Sets the shadows Hue value.
  7801. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7802. */
  7803. shadowsHue: number;
  7804. /**
  7805. * Gets the shadows Density value.
  7806. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7807. * Values less than zero provide a filter of opposite hue.
  7808. */
  7809. /**
  7810. * Sets the shadows Density value.
  7811. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7812. * Values less than zero provide a filter of opposite hue.
  7813. */
  7814. shadowsDensity: number;
  7815. /**
  7816. * Gets the shadows Saturation value.
  7817. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7818. */
  7819. /**
  7820. * Sets the shadows Saturation value.
  7821. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7822. */
  7823. shadowsSaturation: number;
  7824. /**
  7825. * Gets the shadows Exposure value.
  7826. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7827. */
  7828. /**
  7829. * Sets the shadows Exposure value.
  7830. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7831. */
  7832. shadowsExposure: number;
  7833. /**
  7834. * Returns the class name
  7835. * @returns The class name
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Binds the color curves to the shader.
  7840. * @param colorCurves The color curve to bind
  7841. * @param effect The effect to bind to
  7842. * @param positiveUniform The positive uniform shader parameter
  7843. * @param neutralUniform The neutral uniform shader parameter
  7844. * @param negativeUniform The negative uniform shader parameter
  7845. */
  7846. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7847. /**
  7848. * Prepare the list of uniforms associated with the ColorCurves effects.
  7849. * @param uniformsList The list of uniforms used in the effect
  7850. */
  7851. static PrepareUniforms(uniformsList: string[]): void;
  7852. /**
  7853. * Returns color grading data based on a hue, density, saturation and exposure value.
  7854. * @param filterHue The hue of the color filter.
  7855. * @param filterDensity The density of the color filter.
  7856. * @param saturation The saturation.
  7857. * @param exposure The exposure.
  7858. * @param result The result data container.
  7859. */
  7860. private getColorGradingDataToRef;
  7861. /**
  7862. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7863. * @param value The input slider value in range [-100,100].
  7864. * @returns Adjusted value.
  7865. */
  7866. private static applyColorGradingSliderNonlinear;
  7867. /**
  7868. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7869. * @param hue The hue (H) input.
  7870. * @param saturation The saturation (S) input.
  7871. * @param brightness The brightness (B) input.
  7872. * @result An RGBA color represented as Vector4.
  7873. */
  7874. private static fromHSBToRef;
  7875. /**
  7876. * Returns a value clamped between min and max
  7877. * @param value The value to clamp
  7878. * @param min The minimum of value
  7879. * @param max The maximum of value
  7880. * @returns The clamped value.
  7881. */
  7882. private static clamp;
  7883. /**
  7884. * Clones the current color curve instance.
  7885. * @return The cloned curves
  7886. */
  7887. clone(): ColorCurves;
  7888. /**
  7889. * Serializes the current color curve instance to a json representation.
  7890. * @return a JSON representation
  7891. */
  7892. serialize(): any;
  7893. /**
  7894. * Parses the color curve from a json representation.
  7895. * @param source the JSON source to parse
  7896. * @return The parsed curves
  7897. */
  7898. static Parse(source: any): ColorCurves;
  7899. }
  7900. }
  7901. declare module BABYLON {
  7902. /**
  7903. * Interface to follow in your material defines to integrate easily the
  7904. * Image proccessing functions.
  7905. * @hidden
  7906. */
  7907. export interface IImageProcessingConfigurationDefines {
  7908. IMAGEPROCESSING: boolean;
  7909. VIGNETTE: boolean;
  7910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7911. VIGNETTEBLENDMODEOPAQUE: boolean;
  7912. TONEMAPPING: boolean;
  7913. TONEMAPPING_ACES: boolean;
  7914. CONTRAST: boolean;
  7915. EXPOSURE: boolean;
  7916. COLORCURVES: boolean;
  7917. COLORGRADING: boolean;
  7918. COLORGRADING3D: boolean;
  7919. SAMPLER3DGREENDEPTH: boolean;
  7920. SAMPLER3DBGRMAP: boolean;
  7921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7922. }
  7923. /**
  7924. * @hidden
  7925. */
  7926. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7927. IMAGEPROCESSING: boolean;
  7928. VIGNETTE: boolean;
  7929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7930. VIGNETTEBLENDMODEOPAQUE: boolean;
  7931. TONEMAPPING: boolean;
  7932. TONEMAPPING_ACES: boolean;
  7933. CONTRAST: boolean;
  7934. COLORCURVES: boolean;
  7935. COLORGRADING: boolean;
  7936. COLORGRADING3D: boolean;
  7937. SAMPLER3DGREENDEPTH: boolean;
  7938. SAMPLER3DBGRMAP: boolean;
  7939. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7940. EXPOSURE: boolean;
  7941. constructor();
  7942. }
  7943. /**
  7944. * This groups together the common properties used for image processing either in direct forward pass
  7945. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7946. * or not.
  7947. */
  7948. export class ImageProcessingConfiguration {
  7949. /**
  7950. * Default tone mapping applied in BabylonJS.
  7951. */
  7952. static readonly TONEMAPPING_STANDARD: number;
  7953. /**
  7954. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7955. * to other engines rendering to increase portability.
  7956. */
  7957. static readonly TONEMAPPING_ACES: number;
  7958. /**
  7959. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7960. */
  7961. colorCurves: Nullable<ColorCurves>;
  7962. private _colorCurvesEnabled;
  7963. /**
  7964. * Gets wether the color curves effect is enabled.
  7965. */
  7966. /**
  7967. * Sets wether the color curves effect is enabled.
  7968. */
  7969. colorCurvesEnabled: boolean;
  7970. private _colorGradingTexture;
  7971. /**
  7972. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7973. */
  7974. /**
  7975. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7976. */
  7977. colorGradingTexture: Nullable<BaseTexture>;
  7978. private _colorGradingEnabled;
  7979. /**
  7980. * Gets wether the color grading effect is enabled.
  7981. */
  7982. /**
  7983. * Sets wether the color grading effect is enabled.
  7984. */
  7985. colorGradingEnabled: boolean;
  7986. private _colorGradingWithGreenDepth;
  7987. /**
  7988. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7989. */
  7990. /**
  7991. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7992. */
  7993. colorGradingWithGreenDepth: boolean;
  7994. private _colorGradingBGR;
  7995. /**
  7996. * Gets wether the color grading texture contains BGR values.
  7997. */
  7998. /**
  7999. * Sets wether the color grading texture contains BGR values.
  8000. */
  8001. colorGradingBGR: boolean;
  8002. /** @hidden */ private _exposure: number;
  8003. /**
  8004. * Gets the Exposure used in the effect.
  8005. */
  8006. /**
  8007. * Sets the Exposure used in the effect.
  8008. */
  8009. exposure: number;
  8010. private _toneMappingEnabled;
  8011. /**
  8012. * Gets wether the tone mapping effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the tone mapping effect is enabled.
  8016. */
  8017. toneMappingEnabled: boolean;
  8018. private _toneMappingType;
  8019. /**
  8020. * Gets the type of tone mapping effect.
  8021. */
  8022. /**
  8023. * Sets the type of tone mapping effect used in BabylonJS.
  8024. */
  8025. toneMappingType: number;
  8026. protected _contrast: number;
  8027. /**
  8028. * Gets the contrast used in the effect.
  8029. */
  8030. /**
  8031. * Sets the contrast used in the effect.
  8032. */
  8033. contrast: number;
  8034. /**
  8035. * Vignette stretch size.
  8036. */
  8037. vignetteStretch: number;
  8038. /**
  8039. * Vignette centre X Offset.
  8040. */
  8041. vignetteCentreX: number;
  8042. /**
  8043. * Vignette centre Y Offset.
  8044. */
  8045. vignetteCentreY: number;
  8046. /**
  8047. * Vignette weight or intensity of the vignette effect.
  8048. */
  8049. vignetteWeight: number;
  8050. /**
  8051. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8052. * if vignetteEnabled is set to true.
  8053. */
  8054. vignetteColor: Color4;
  8055. /**
  8056. * Camera field of view used by the Vignette effect.
  8057. */
  8058. vignetteCameraFov: number;
  8059. private _vignetteBlendMode;
  8060. /**
  8061. * Gets the vignette blend mode allowing different kind of effect.
  8062. */
  8063. /**
  8064. * Sets the vignette blend mode allowing different kind of effect.
  8065. */
  8066. vignetteBlendMode: number;
  8067. private _vignetteEnabled;
  8068. /**
  8069. * Gets wether the vignette effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the vignette effect is enabled.
  8073. */
  8074. vignetteEnabled: boolean;
  8075. private _applyByPostProcess;
  8076. /**
  8077. * Gets wether the image processing is applied through a post process or not.
  8078. */
  8079. /**
  8080. * Sets wether the image processing is applied through a post process or not.
  8081. */
  8082. applyByPostProcess: boolean;
  8083. private _isEnabled;
  8084. /**
  8085. * Gets wether the image processing is enabled or not.
  8086. */
  8087. /**
  8088. * Sets wether the image processing is enabled or not.
  8089. */
  8090. isEnabled: boolean;
  8091. /**
  8092. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8093. */
  8094. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8095. /**
  8096. * Method called each time the image processing information changes requires to recompile the effect.
  8097. */
  8098. protected _updateParameters(): void;
  8099. /**
  8100. * Gets the current class name.
  8101. * @return "ImageProcessingConfiguration"
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Prepare the list of uniforms associated with the Image Processing effects.
  8106. * @param uniforms The list of uniforms used in the effect
  8107. * @param defines the list of defines currently in use
  8108. */
  8109. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8110. /**
  8111. * Prepare the list of samplers associated with the Image Processing effects.
  8112. * @param samplersList The list of uniforms used in the effect
  8113. * @param defines the list of defines currently in use
  8114. */
  8115. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8116. /**
  8117. * Prepare the list of defines associated to the shader.
  8118. * @param defines the list of defines to complete
  8119. * @param forPostProcess Define if we are currently in post process mode or not
  8120. */
  8121. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8122. /**
  8123. * Returns true if all the image processing information are ready.
  8124. * @returns True if ready, otherwise, false
  8125. */
  8126. isReady(): boolean;
  8127. /**
  8128. * Binds the image processing to the shader.
  8129. * @param effect The effect to bind to
  8130. * @param aspectRatio Define the current aspect ratio of the effect
  8131. */
  8132. bind(effect: Effect, aspectRatio?: number): void;
  8133. /**
  8134. * Clones the current image processing instance.
  8135. * @return The cloned image processing
  8136. */
  8137. clone(): ImageProcessingConfiguration;
  8138. /**
  8139. * Serializes the current image processing instance to a json representation.
  8140. * @return a JSON representation
  8141. */
  8142. serialize(): any;
  8143. /**
  8144. * Parses the image processing from a json representation.
  8145. * @param source the JSON source to parse
  8146. * @return The parsed image processing
  8147. */
  8148. static Parse(source: any): ImageProcessingConfiguration;
  8149. private static _VIGNETTEMODE_MULTIPLY;
  8150. private static _VIGNETTEMODE_OPAQUE;
  8151. /**
  8152. * Used to apply the vignette as a mix with the pixel color.
  8153. */
  8154. static readonly VIGNETTEMODE_MULTIPLY: number;
  8155. /**
  8156. * Used to apply the vignette as a replacement of the pixel color.
  8157. */
  8158. static readonly VIGNETTEMODE_OPAQUE: number;
  8159. }
  8160. }
  8161. declare module BABYLON {
  8162. /** @hidden */
  8163. export var postprocessVertexShader: {
  8164. name: string;
  8165. shader: string;
  8166. };
  8167. }
  8168. declare module BABYLON {
  8169. /** Defines supported spaces */
  8170. export enum Space {
  8171. /** Local (object) space */
  8172. LOCAL = 0,
  8173. /** World space */
  8174. WORLD = 1,
  8175. /** Bone space */
  8176. BONE = 2
  8177. }
  8178. /** Defines the 3 main axes */
  8179. export class Axis {
  8180. /** X axis */
  8181. static X: Vector3;
  8182. /** Y axis */
  8183. static Y: Vector3;
  8184. /** Z axis */
  8185. static Z: Vector3;
  8186. }
  8187. }
  8188. declare module BABYLON {
  8189. /**
  8190. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8191. * This is the base of the follow, arc rotate cameras and Free camera
  8192. * @see http://doc.babylonjs.com/features/cameras
  8193. */
  8194. export class TargetCamera extends Camera {
  8195. private static _RigCamTransformMatrix;
  8196. private static _TargetTransformMatrix;
  8197. private static _TargetFocalPoint;
  8198. /**
  8199. * Define the current direction the camera is moving to
  8200. */
  8201. cameraDirection: Vector3;
  8202. /**
  8203. * Define the current rotation the camera is rotating to
  8204. */
  8205. cameraRotation: Vector2;
  8206. /**
  8207. * When set, the up vector of the camera will be updated by the rotation of the camera
  8208. */
  8209. updateUpVectorFromRotation: boolean;
  8210. private _tmpQuaternion;
  8211. /**
  8212. * Define the current rotation of the camera
  8213. */
  8214. rotation: Vector3;
  8215. /**
  8216. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8217. */
  8218. rotationQuaternion: Quaternion;
  8219. /**
  8220. * Define the current speed of the camera
  8221. */
  8222. speed: number;
  8223. /**
  8224. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8225. * around all axis.
  8226. */
  8227. noRotationConstraint: boolean;
  8228. /**
  8229. * Define the current target of the camera as an object or a position.
  8230. */
  8231. lockedTarget: any;
  8232. /** @hidden */ private _currentTarget: Vector3;
  8233. /** @hidden */ private _initialFocalDistance: number;
  8234. /** @hidden */ private _viewMatrix: Matrix;
  8235. /** @hidden */ private _camMatrix: Matrix;
  8236. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8237. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8238. /** @hidden */ private _referencePoint: Vector3;
  8239. /** @hidden */ private _transformedReferencePoint: Vector3;
  8240. protected _globalCurrentTarget: Vector3;
  8241. protected _globalCurrentUpVector: Vector3;
  8242. /** @hidden */ private _reset: () => void;
  8243. private _defaultUp;
  8244. /**
  8245. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8246. * This is the base of the follow, arc rotate cameras and Free camera
  8247. * @see http://doc.babylonjs.com/features/cameras
  8248. * @param name Defines the name of the camera in the scene
  8249. * @param position Defines the start position of the camera in the scene
  8250. * @param scene Defines the scene the camera belongs to
  8251. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8252. */
  8253. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8254. /**
  8255. * Gets the position in front of the camera at a given distance.
  8256. * @param distance The distance from the camera we want the position to be
  8257. * @returns the position
  8258. */
  8259. getFrontPosition(distance: number): Vector3;
  8260. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8261. private _storedPosition;
  8262. private _storedRotation;
  8263. private _storedRotationQuaternion;
  8264. /**
  8265. * Store current camera state of the camera (fov, position, rotation, etc..)
  8266. * @returns the camera
  8267. */
  8268. storeState(): Camera;
  8269. /**
  8270. * Restored camera state. You must call storeState() first
  8271. * @returns whether it was successful or not
  8272. * @hidden
  8273. */ private _restoreStateValues(): boolean;
  8274. /** @hidden */ private _initCache(): void;
  8275. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8276. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8277. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8278. /**
  8279. * Defines the target the camera should look at.
  8280. * @param target Defines the new target as a Vector or a mesh
  8281. */
  8282. setTarget(target: Vector3): void;
  8283. /**
  8284. * Return the current target position of the camera. This value is expressed in local space.
  8285. * @returns the target position
  8286. */
  8287. getTarget(): Vector3;
  8288. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8289. /** @hidden */ private _updatePosition(): void;
  8290. /** @hidden */ private _checkInputs(): void;
  8291. protected _updateCameraRotationMatrix(): void;
  8292. /**
  8293. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8294. * @returns the current camera
  8295. */
  8296. private _rotateUpVectorWithCameraRotationMatrix;
  8297. private _cachedRotationZ;
  8298. private _cachedQuaternionRotationZ;
  8299. /** @hidden */ private _getViewMatrix(): Matrix;
  8300. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8301. /**
  8302. * @hidden
  8303. */
  8304. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8305. /**
  8306. * @hidden
  8307. */ private _updateRigCameras(): void;
  8308. private _getRigCamPositionAndTarget;
  8309. /**
  8310. * Gets the current object class name.
  8311. * @return the class name
  8312. */
  8313. getClassName(): string;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * Gather the list of keyboard event types as constants.
  8319. */
  8320. export class KeyboardEventTypes {
  8321. /**
  8322. * The keydown event is fired when a key becomes active (pressed).
  8323. */
  8324. static readonly KEYDOWN: number;
  8325. /**
  8326. * The keyup event is fired when a key has been released.
  8327. */
  8328. static readonly KEYUP: number;
  8329. }
  8330. /**
  8331. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8332. */
  8333. export class KeyboardInfo {
  8334. /**
  8335. * Defines the type of event (KeyboardEventTypes)
  8336. */
  8337. type: number;
  8338. /**
  8339. * Defines the related dom event
  8340. */
  8341. event: KeyboardEvent;
  8342. /**
  8343. * Instantiates a new keyboard info.
  8344. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8345. * @param type Defines the type of event (KeyboardEventTypes)
  8346. * @param event Defines the related dom event
  8347. */
  8348. constructor(
  8349. /**
  8350. * Defines the type of event (KeyboardEventTypes)
  8351. */
  8352. type: number,
  8353. /**
  8354. * Defines the related dom event
  8355. */
  8356. event: KeyboardEvent);
  8357. }
  8358. /**
  8359. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8360. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8361. */
  8362. export class KeyboardInfoPre extends KeyboardInfo {
  8363. /**
  8364. * Defines the type of event (KeyboardEventTypes)
  8365. */
  8366. type: number;
  8367. /**
  8368. * Defines the related dom event
  8369. */
  8370. event: KeyboardEvent;
  8371. /**
  8372. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8373. */
  8374. skipOnPointerObservable: boolean;
  8375. /**
  8376. * Instantiates a new keyboard pre info.
  8377. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8378. * @param type Defines the type of event (KeyboardEventTypes)
  8379. * @param event Defines the related dom event
  8380. */
  8381. constructor(
  8382. /**
  8383. * Defines the type of event (KeyboardEventTypes)
  8384. */
  8385. type: number,
  8386. /**
  8387. * Defines the related dom event
  8388. */
  8389. event: KeyboardEvent);
  8390. }
  8391. }
  8392. declare module BABYLON {
  8393. /**
  8394. * Manage the keyboard inputs to control the movement of a free camera.
  8395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8396. */
  8397. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8398. /**
  8399. * Defines the camera the input is attached to.
  8400. */
  8401. camera: FreeCamera;
  8402. /**
  8403. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8404. */
  8405. keysUp: number[];
  8406. /**
  8407. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8408. */
  8409. keysDown: number[];
  8410. /**
  8411. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8412. */
  8413. keysLeft: number[];
  8414. /**
  8415. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8416. */
  8417. keysRight: number[];
  8418. private _keys;
  8419. private _onCanvasBlurObserver;
  8420. private _onKeyboardObserver;
  8421. private _engine;
  8422. private _scene;
  8423. /**
  8424. * Attach the input controls to a specific dom element to get the input from.
  8425. * @param element Defines the element the controls should be listened from
  8426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8427. */
  8428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8429. /**
  8430. * Detach the current controls from the specified dom element.
  8431. * @param element Defines the element to stop listening the inputs from
  8432. */
  8433. detachControl(element: Nullable<HTMLElement>): void;
  8434. /**
  8435. * Update the current camera state depending on the inputs that have been used this frame.
  8436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8437. */
  8438. checkInputs(): void;
  8439. /**
  8440. * Gets the class name of the current intput.
  8441. * @returns the class name
  8442. */
  8443. getClassName(): string;
  8444. /** @hidden */ private _onLostFocus(): void;
  8445. /**
  8446. * Get the friendly name associated with the input class.
  8447. * @returns the input friendly name
  8448. */
  8449. getSimpleName(): string;
  8450. }
  8451. }
  8452. declare module BABYLON {
  8453. /**
  8454. * Interface describing all the common properties and methods a shadow light needs to implement.
  8455. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8456. * as well as binding the different shadow properties to the effects.
  8457. */
  8458. export interface IShadowLight extends Light {
  8459. /**
  8460. * The light id in the scene (used in scene.findLighById for instance)
  8461. */
  8462. id: string;
  8463. /**
  8464. * The position the shdow will be casted from.
  8465. */
  8466. position: Vector3;
  8467. /**
  8468. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8469. */
  8470. direction: Vector3;
  8471. /**
  8472. * The transformed position. Position of the light in world space taking parenting in account.
  8473. */
  8474. transformedPosition: Vector3;
  8475. /**
  8476. * The transformed direction. Direction of the light in world space taking parenting in account.
  8477. */
  8478. transformedDirection: Vector3;
  8479. /**
  8480. * The friendly name of the light in the scene.
  8481. */
  8482. name: string;
  8483. /**
  8484. * Defines the shadow projection clipping minimum z value.
  8485. */
  8486. shadowMinZ: number;
  8487. /**
  8488. * Defines the shadow projection clipping maximum z value.
  8489. */
  8490. shadowMaxZ: number;
  8491. /**
  8492. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8493. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8494. */
  8495. computeTransformedInformation(): boolean;
  8496. /**
  8497. * Gets the scene the light belongs to.
  8498. * @returns The scene
  8499. */
  8500. getScene(): Scene;
  8501. /**
  8502. * Callback defining a custom Projection Matrix Builder.
  8503. * This can be used to override the default projection matrix computation.
  8504. */
  8505. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8506. /**
  8507. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8508. * @param matrix The materix to updated with the projection information
  8509. * @param viewMatrix The transform matrix of the light
  8510. * @param renderList The list of mesh to render in the map
  8511. * @returns The current light
  8512. */
  8513. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8514. /**
  8515. * Gets the current depth scale used in ESM.
  8516. * @returns The scale
  8517. */
  8518. getDepthScale(): number;
  8519. /**
  8520. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8521. * @returns true if a cube texture needs to be use
  8522. */
  8523. needCube(): boolean;
  8524. /**
  8525. * Detects if the projection matrix requires to be recomputed this frame.
  8526. * @returns true if it requires to be recomputed otherwise, false.
  8527. */
  8528. needProjectionMatrixCompute(): boolean;
  8529. /**
  8530. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8531. */
  8532. forceProjectionMatrixCompute(): void;
  8533. /**
  8534. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8535. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8536. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8537. */
  8538. getShadowDirection(faceIndex?: number): Vector3;
  8539. /**
  8540. * Gets the minZ used for shadow according to both the scene and the light.
  8541. * @param activeCamera The camera we are returning the min for
  8542. * @returns the depth min z
  8543. */
  8544. getDepthMinZ(activeCamera: Camera): number;
  8545. /**
  8546. * Gets the maxZ used for shadow according to both the scene and the light.
  8547. * @param activeCamera The camera we are returning the max for
  8548. * @returns the depth max z
  8549. */
  8550. getDepthMaxZ(activeCamera: Camera): number;
  8551. }
  8552. /**
  8553. * Base implementation IShadowLight
  8554. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8555. */
  8556. export abstract class ShadowLight extends Light implements IShadowLight {
  8557. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8558. protected _position: Vector3;
  8559. protected _setPosition(value: Vector3): void;
  8560. /**
  8561. * Sets the position the shadow will be casted from. Also use as the light position for both
  8562. * point and spot lights.
  8563. */
  8564. /**
  8565. * Sets the position the shadow will be casted from. Also use as the light position for both
  8566. * point and spot lights.
  8567. */
  8568. position: Vector3;
  8569. protected _direction: Vector3;
  8570. protected _setDirection(value: Vector3): void;
  8571. /**
  8572. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8573. * Also use as the light direction on spot and directional lights.
  8574. */
  8575. /**
  8576. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8577. * Also use as the light direction on spot and directional lights.
  8578. */
  8579. direction: Vector3;
  8580. private _shadowMinZ;
  8581. /**
  8582. * Gets the shadow projection clipping minimum z value.
  8583. */
  8584. /**
  8585. * Sets the shadow projection clipping minimum z value.
  8586. */
  8587. shadowMinZ: number;
  8588. private _shadowMaxZ;
  8589. /**
  8590. * Sets the shadow projection clipping maximum z value.
  8591. */
  8592. /**
  8593. * Gets the shadow projection clipping maximum z value.
  8594. */
  8595. shadowMaxZ: number;
  8596. /**
  8597. * Callback defining a custom Projection Matrix Builder.
  8598. * This can be used to override the default projection matrix computation.
  8599. */
  8600. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8601. /**
  8602. * The transformed position. Position of the light in world space taking parenting in account.
  8603. */
  8604. transformedPosition: Vector3;
  8605. /**
  8606. * The transformed direction. Direction of the light in world space taking parenting in account.
  8607. */
  8608. transformedDirection: Vector3;
  8609. private _needProjectionMatrixCompute;
  8610. /**
  8611. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8612. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8613. */
  8614. computeTransformedInformation(): boolean;
  8615. /**
  8616. * Return the depth scale used for the shadow map.
  8617. * @returns the depth scale.
  8618. */
  8619. getDepthScale(): number;
  8620. /**
  8621. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8622. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8623. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8624. */
  8625. getShadowDirection(faceIndex?: number): Vector3;
  8626. /**
  8627. * Returns the ShadowLight absolute position in the World.
  8628. * @returns the position vector in world space
  8629. */
  8630. getAbsolutePosition(): Vector3;
  8631. /**
  8632. * Sets the ShadowLight direction toward the passed target.
  8633. * @param target The point to target in local space
  8634. * @returns the updated ShadowLight direction
  8635. */
  8636. setDirectionToTarget(target: Vector3): Vector3;
  8637. /**
  8638. * Returns the light rotation in euler definition.
  8639. * @returns the x y z rotation in local space.
  8640. */
  8641. getRotation(): Vector3;
  8642. /**
  8643. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8644. * @returns true if a cube texture needs to be use
  8645. */
  8646. needCube(): boolean;
  8647. /**
  8648. * Detects if the projection matrix requires to be recomputed this frame.
  8649. * @returns true if it requires to be recomputed otherwise, false.
  8650. */
  8651. needProjectionMatrixCompute(): boolean;
  8652. /**
  8653. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8654. */
  8655. forceProjectionMatrixCompute(): void;
  8656. /** @hidden */ private _initCache(): void;
  8657. /** @hidden */ private _isSynchronized(): boolean;
  8658. /**
  8659. * Computes the world matrix of the node
  8660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8661. * @returns the world matrix
  8662. */
  8663. computeWorldMatrix(force?: boolean): Matrix;
  8664. /**
  8665. * Gets the minZ used for shadow according to both the scene and the light.
  8666. * @param activeCamera The camera we are returning the min for
  8667. * @returns the depth min z
  8668. */
  8669. getDepthMinZ(activeCamera: Camera): number;
  8670. /**
  8671. * Gets the maxZ used for shadow according to both the scene and the light.
  8672. * @param activeCamera The camera we are returning the max for
  8673. * @returns the depth max z
  8674. */
  8675. getDepthMaxZ(activeCamera: Camera): number;
  8676. /**
  8677. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8678. * @param matrix The materix to updated with the projection information
  8679. * @param viewMatrix The transform matrix of the light
  8680. * @param renderList The list of mesh to render in the map
  8681. * @returns The current light
  8682. */
  8683. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * "Static Class" containing the most commonly used helper while dealing with material for
  8689. * rendering purpose.
  8690. *
  8691. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8692. *
  8693. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8694. */
  8695. export class MaterialHelper {
  8696. /**
  8697. * Bind the current view position to an effect.
  8698. * @param effect The effect to be bound
  8699. * @param scene The scene the eyes position is used from
  8700. */
  8701. static BindEyePosition(effect: Effect, scene: Scene): void;
  8702. /**
  8703. * Helps preparing the defines values about the UVs in used in the effect.
  8704. * UVs are shared as much as we can accross channels in the shaders.
  8705. * @param texture The texture we are preparing the UVs for
  8706. * @param defines The defines to update
  8707. * @param key The channel key "diffuse", "specular"... used in the shader
  8708. */
  8709. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8710. /**
  8711. * Binds a texture matrix value to its corrsponding uniform
  8712. * @param texture The texture to bind the matrix for
  8713. * @param uniformBuffer The uniform buffer receivin the data
  8714. * @param key The channel key "diffuse", "specular"... used in the shader
  8715. */
  8716. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8717. /**
  8718. * Gets the current status of the fog (should it be enabled?)
  8719. * @param mesh defines the mesh to evaluate for fog support
  8720. * @param scene defines the hosting scene
  8721. * @returns true if fog must be enabled
  8722. */
  8723. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8724. /**
  8725. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8726. * @param mesh defines the current mesh
  8727. * @param scene defines the current scene
  8728. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8729. * @param pointsCloud defines if point cloud rendering has to be turned on
  8730. * @param fogEnabled defines if fog has to be turned on
  8731. * @param alphaTest defines if alpha testing has to be turned on
  8732. * @param defines defines the current list of defines
  8733. */
  8734. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8735. /**
  8736. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8737. * @param scene defines the current scene
  8738. * @param engine defines the current engine
  8739. * @param defines specifies the list of active defines
  8740. * @param useInstances defines if instances have to be turned on
  8741. * @param useClipPlane defines if clip plane have to be turned on
  8742. */
  8743. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8744. /**
  8745. * Prepares the defines for bones
  8746. * @param mesh The mesh containing the geometry data we will draw
  8747. * @param defines The defines to update
  8748. */
  8749. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8750. /**
  8751. * Prepares the defines for morph targets
  8752. * @param mesh The mesh containing the geometry data we will draw
  8753. * @param defines The defines to update
  8754. */
  8755. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8756. /**
  8757. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8758. * @param mesh The mesh containing the geometry data we will draw
  8759. * @param defines The defines to update
  8760. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8761. * @param useBones Precise whether bones should be used or not (override mesh info)
  8762. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8763. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8764. * @returns false if defines are considered not dirty and have not been checked
  8765. */
  8766. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8767. /**
  8768. * Prepares the defines related to multiview
  8769. * @param scene The scene we are intending to draw
  8770. * @param defines The defines to update
  8771. */
  8772. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8773. /**
  8774. * Prepares the defines related to the light information passed in parameter
  8775. * @param scene The scene we are intending to draw
  8776. * @param mesh The mesh the effect is compiling for
  8777. * @param light The light the effect is compiling for
  8778. * @param lightIndex The index of the light
  8779. * @param defines The defines to update
  8780. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8781. * @param state Defines the current state regarding what is needed (normals, etc...)
  8782. */
  8783. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8784. needNormals: boolean;
  8785. needRebuild: boolean;
  8786. shadowEnabled: boolean;
  8787. specularEnabled: boolean;
  8788. lightmapMode: boolean;
  8789. }): void;
  8790. /**
  8791. * Prepares the defines related to the light information passed in parameter
  8792. * @param scene The scene we are intending to draw
  8793. * @param mesh The mesh the effect is compiling for
  8794. * @param defines The defines to update
  8795. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8796. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8797. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8798. * @returns true if normals will be required for the rest of the effect
  8799. */
  8800. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8801. /**
  8802. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8803. * @param lightIndex defines the light index
  8804. * @param uniformsList The uniform list
  8805. * @param samplersList The sampler list
  8806. * @param projectedLightTexture defines if projected texture must be used
  8807. * @param uniformBuffersList defines an optional list of uniform buffers
  8808. */
  8809. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8810. /**
  8811. * Prepares the uniforms and samplers list to be used in the effect
  8812. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8813. * @param samplersList The sampler list
  8814. * @param defines The defines helping in the list generation
  8815. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8816. */
  8817. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8818. /**
  8819. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8820. * @param defines The defines to update while falling back
  8821. * @param fallbacks The authorized effect fallbacks
  8822. * @param maxSimultaneousLights The maximum number of lights allowed
  8823. * @param rank the current rank of the Effect
  8824. * @returns The newly affected rank
  8825. */
  8826. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8827. private static _TmpMorphInfluencers;
  8828. /**
  8829. * Prepares the list of attributes required for morph targets according to the effect defines.
  8830. * @param attribs The current list of supported attribs
  8831. * @param mesh The mesh to prepare the morph targets attributes for
  8832. * @param influencers The number of influencers
  8833. */
  8834. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8835. /**
  8836. * Prepares the list of attributes required for morph targets according to the effect defines.
  8837. * @param attribs The current list of supported attribs
  8838. * @param mesh The mesh to prepare the morph targets attributes for
  8839. * @param defines The current Defines of the effect
  8840. */
  8841. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8842. /**
  8843. * Prepares the list of attributes required for bones according to the effect defines.
  8844. * @param attribs The current list of supported attribs
  8845. * @param mesh The mesh to prepare the bones attributes for
  8846. * @param defines The current Defines of the effect
  8847. * @param fallbacks The current efffect fallback strategy
  8848. */
  8849. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8850. /**
  8851. * Check and prepare the list of attributes required for instances according to the effect defines.
  8852. * @param attribs The current list of supported attribs
  8853. * @param defines The current MaterialDefines of the effect
  8854. */
  8855. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8856. /**
  8857. * Add the list of attributes required for instances to the attribs array.
  8858. * @param attribs The current list of supported attribs
  8859. */
  8860. static PushAttributesForInstances(attribs: string[]): void;
  8861. /**
  8862. * Binds the light shadow information to the effect for the given mesh.
  8863. * @param light The light containing the generator
  8864. * @param scene The scene the lights belongs to
  8865. * @param mesh The mesh we are binding the information to render
  8866. * @param lightIndex The light index in the effect used to render the mesh
  8867. * @param effect The effect we are binding the data to
  8868. */
  8869. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8870. /**
  8871. * Binds the light information to the effect.
  8872. * @param light The light containing the generator
  8873. * @param effect The effect we are binding the data to
  8874. * @param lightIndex The light index in the effect used to render
  8875. */
  8876. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8877. /**
  8878. * Binds the lights information from the scene to the effect for the given mesh.
  8879. * @param light Light to bind
  8880. * @param lightIndex Light index
  8881. * @param scene The scene where the light belongs to
  8882. * @param mesh The mesh we are binding the information to render
  8883. * @param effect The effect we are binding the data to
  8884. * @param useSpecular Defines if specular is supported
  8885. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8886. */
  8887. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8888. /**
  8889. * Binds the lights information from the scene to the effect for the given mesh.
  8890. * @param scene The scene the lights belongs to
  8891. * @param mesh The mesh we are binding the information to render
  8892. * @param effect The effect we are binding the data to
  8893. * @param defines The generated defines for the effect
  8894. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8895. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8896. */
  8897. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8898. private static _tempFogColor;
  8899. /**
  8900. * Binds the fog information from the scene to the effect for the given mesh.
  8901. * @param scene The scene the lights belongs to
  8902. * @param mesh The mesh we are binding the information to render
  8903. * @param effect The effect we are binding the data to
  8904. * @param linearSpace Defines if the fog effect is applied in linear space
  8905. */
  8906. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8907. /**
  8908. * Binds the bones information from the mesh to the effect.
  8909. * @param mesh The mesh we are binding the information to render
  8910. * @param effect The effect we are binding the data to
  8911. */
  8912. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8913. /**
  8914. * Binds the morph targets information from the mesh to the effect.
  8915. * @param abstractMesh The mesh we are binding the information to render
  8916. * @param effect The effect we are binding the data to
  8917. */
  8918. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8919. /**
  8920. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8921. * @param defines The generated defines used in the effect
  8922. * @param effect The effect we are binding the data to
  8923. * @param scene The scene we are willing to render with logarithmic scale for
  8924. */
  8925. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8926. /**
  8927. * Binds the clip plane information from the scene to the effect.
  8928. * @param scene The scene the clip plane information are extracted from
  8929. * @param effect The effect we are binding the data to
  8930. */
  8931. static BindClipPlane(effect: Effect, scene: Scene): void;
  8932. }
  8933. }
  8934. declare module BABYLON {
  8935. /** @hidden */
  8936. export var packingFunctions: {
  8937. name: string;
  8938. shader: string;
  8939. };
  8940. }
  8941. declare module BABYLON {
  8942. /** @hidden */
  8943. export var shadowMapPixelShader: {
  8944. name: string;
  8945. shader: string;
  8946. };
  8947. }
  8948. declare module BABYLON {
  8949. /** @hidden */
  8950. export var bonesDeclaration: {
  8951. name: string;
  8952. shader: string;
  8953. };
  8954. }
  8955. declare module BABYLON {
  8956. /** @hidden */
  8957. export var morphTargetsVertexGlobalDeclaration: {
  8958. name: string;
  8959. shader: string;
  8960. };
  8961. }
  8962. declare module BABYLON {
  8963. /** @hidden */
  8964. export var morphTargetsVertexDeclaration: {
  8965. name: string;
  8966. shader: string;
  8967. };
  8968. }
  8969. declare module BABYLON {
  8970. /** @hidden */
  8971. export var instancesDeclaration: {
  8972. name: string;
  8973. shader: string;
  8974. };
  8975. }
  8976. declare module BABYLON {
  8977. /** @hidden */
  8978. export var helperFunctions: {
  8979. name: string;
  8980. shader: string;
  8981. };
  8982. }
  8983. declare module BABYLON {
  8984. /** @hidden */
  8985. export var morphTargetsVertex: {
  8986. name: string;
  8987. shader: string;
  8988. };
  8989. }
  8990. declare module BABYLON {
  8991. /** @hidden */
  8992. export var instancesVertex: {
  8993. name: string;
  8994. shader: string;
  8995. };
  8996. }
  8997. declare module BABYLON {
  8998. /** @hidden */
  8999. export var bonesVertex: {
  9000. name: string;
  9001. shader: string;
  9002. };
  9003. }
  9004. declare module BABYLON {
  9005. /** @hidden */
  9006. export var shadowMapVertexShader: {
  9007. name: string;
  9008. shader: string;
  9009. };
  9010. }
  9011. declare module BABYLON {
  9012. /** @hidden */
  9013. export var depthBoxBlurPixelShader: {
  9014. name: string;
  9015. shader: string;
  9016. };
  9017. }
  9018. declare module BABYLON {
  9019. /**
  9020. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9021. */
  9022. export interface ICustomShaderOptions {
  9023. /**
  9024. * Gets or sets the custom shader name to use
  9025. */
  9026. shaderName: string;
  9027. /**
  9028. * The list of attribute names used in the shader
  9029. */
  9030. attributes?: string[];
  9031. /**
  9032. * The list of unifrom names used in the shader
  9033. */
  9034. uniforms?: string[];
  9035. /**
  9036. * The list of sampler names used in the shader
  9037. */
  9038. samplers?: string[];
  9039. /**
  9040. * The list of defines used in the shader
  9041. */
  9042. defines?: string[];
  9043. }
  9044. /**
  9045. * Interface to implement to create a shadow generator compatible with BJS.
  9046. */
  9047. export interface IShadowGenerator {
  9048. /**
  9049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9050. * @returns The render target texture if present otherwise, null
  9051. */
  9052. getShadowMap(): Nullable<RenderTargetTexture>;
  9053. /**
  9054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9055. * @returns The render target texture if the shadow map is present otherwise, null
  9056. */
  9057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9058. /**
  9059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9060. * @param subMesh The submesh we want to render in the shadow map
  9061. * @param useInstances Defines wether will draw in the map using instances
  9062. * @returns true if ready otherwise, false
  9063. */
  9064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9065. /**
  9066. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9067. * @param defines Defines of the material we want to update
  9068. * @param lightIndex Index of the light in the enabled light list of the material
  9069. */
  9070. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9071. /**
  9072. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9073. * defined in the generator but impacting the effect).
  9074. * It implies the unifroms available on the materials are the standard BJS ones.
  9075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9076. * @param effect The effect we are binfing the information for
  9077. */
  9078. bindShadowLight(lightIndex: string, effect: Effect): void;
  9079. /**
  9080. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9081. * (eq to shadow prjection matrix * light transform matrix)
  9082. * @returns The transform matrix used to create the shadow map
  9083. */
  9084. getTransformMatrix(): Matrix;
  9085. /**
  9086. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9087. * Cube and 2D textures for instance.
  9088. */
  9089. recreateShadowMap(): void;
  9090. /**
  9091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9092. * @param onCompiled Callback triggered at the and of the effects compilation
  9093. * @param options Sets of optional options forcing the compilation with different modes
  9094. */
  9095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9096. useInstances: boolean;
  9097. }>): void;
  9098. /**
  9099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9100. * @param options Sets of optional options forcing the compilation with different modes
  9101. * @returns A promise that resolves when the compilation completes
  9102. */
  9103. forceCompilationAsync(options?: Partial<{
  9104. useInstances: boolean;
  9105. }>): Promise<void>;
  9106. /**
  9107. * Serializes the shadow generator setup to a json object.
  9108. * @returns The serialized JSON object
  9109. */
  9110. serialize(): any;
  9111. /**
  9112. * Disposes the Shadow map and related Textures and effects.
  9113. */
  9114. dispose(): void;
  9115. }
  9116. /**
  9117. * Default implementation IShadowGenerator.
  9118. * This is the main object responsible of generating shadows in the framework.
  9119. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9120. */
  9121. export class ShadowGenerator implements IShadowGenerator {
  9122. /**
  9123. * Shadow generator mode None: no filtering applied.
  9124. */
  9125. static readonly FILTER_NONE: number;
  9126. /**
  9127. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9129. */
  9130. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9131. /**
  9132. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9133. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9134. */
  9135. static readonly FILTER_POISSONSAMPLING: number;
  9136. /**
  9137. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9138. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9139. */
  9140. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9141. /**
  9142. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9143. * edge artifacts on steep falloff.
  9144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9145. */
  9146. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9147. /**
  9148. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9149. * edge artifacts on steep falloff.
  9150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9151. */
  9152. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9153. /**
  9154. * Shadow generator mode PCF: Percentage Closer Filtering
  9155. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9156. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9157. */
  9158. static readonly FILTER_PCF: number;
  9159. /**
  9160. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9161. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9162. * Contact Hardening
  9163. */
  9164. static readonly FILTER_PCSS: number;
  9165. /**
  9166. * Reserved for PCF and PCSS
  9167. * Highest Quality.
  9168. *
  9169. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9170. *
  9171. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9172. */
  9173. static readonly QUALITY_HIGH: number;
  9174. /**
  9175. * Reserved for PCF and PCSS
  9176. * Good tradeoff for quality/perf cross devices
  9177. *
  9178. * Execute PCF on a 3*3 kernel.
  9179. *
  9180. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9181. */
  9182. static readonly QUALITY_MEDIUM: number;
  9183. /**
  9184. * Reserved for PCF and PCSS
  9185. * The lowest quality but the fastest.
  9186. *
  9187. * Execute PCF on a 1*1 kernel.
  9188. *
  9189. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9190. */
  9191. static readonly QUALITY_LOW: number;
  9192. /** Gets or sets the custom shader name to use */
  9193. customShaderOptions: ICustomShaderOptions;
  9194. /**
  9195. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9196. */
  9197. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9198. /**
  9199. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9200. */
  9201. onAfterShadowMapRenderObservable: Observable<Effect>;
  9202. /**
  9203. * Observable triggered before a mesh is rendered in the shadow map.
  9204. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9205. */
  9206. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9207. /**
  9208. * Observable triggered after a mesh is rendered in the shadow map.
  9209. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9210. */
  9211. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9212. private _bias;
  9213. /**
  9214. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9215. */
  9216. /**
  9217. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9218. */
  9219. bias: number;
  9220. private _normalBias;
  9221. /**
  9222. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9223. */
  9224. /**
  9225. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9226. */
  9227. normalBias: number;
  9228. private _blurBoxOffset;
  9229. /**
  9230. * Gets the blur box offset: offset applied during the blur pass.
  9231. * Only useful if useKernelBlur = false
  9232. */
  9233. /**
  9234. * Sets the blur box offset: offset applied during the blur pass.
  9235. * Only useful if useKernelBlur = false
  9236. */
  9237. blurBoxOffset: number;
  9238. private _blurScale;
  9239. /**
  9240. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9241. * 2 means half of the size.
  9242. */
  9243. /**
  9244. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9245. * 2 means half of the size.
  9246. */
  9247. blurScale: number;
  9248. private _blurKernel;
  9249. /**
  9250. * Gets the blur kernel: kernel size of the blur pass.
  9251. * Only useful if useKernelBlur = true
  9252. */
  9253. /**
  9254. * Sets the blur kernel: kernel size of the blur pass.
  9255. * Only useful if useKernelBlur = true
  9256. */
  9257. blurKernel: number;
  9258. private _useKernelBlur;
  9259. /**
  9260. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9261. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9262. */
  9263. /**
  9264. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9265. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9266. */
  9267. useKernelBlur: boolean;
  9268. private _depthScale;
  9269. /**
  9270. * Gets the depth scale used in ESM mode.
  9271. */
  9272. /**
  9273. * Sets the depth scale used in ESM mode.
  9274. * This can override the scale stored on the light.
  9275. */
  9276. depthScale: number;
  9277. private _filter;
  9278. /**
  9279. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9280. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9281. */
  9282. /**
  9283. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9284. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9285. */
  9286. filter: number;
  9287. /**
  9288. * Gets if the current filter is set to Poisson Sampling.
  9289. */
  9290. /**
  9291. * Sets the current filter to Poisson Sampling.
  9292. */
  9293. usePoissonSampling: boolean;
  9294. /**
  9295. * Gets if the current filter is set to ESM.
  9296. */
  9297. /**
  9298. * Sets the current filter is to ESM.
  9299. */
  9300. useExponentialShadowMap: boolean;
  9301. /**
  9302. * Gets if the current filter is set to filtered ESM.
  9303. */
  9304. /**
  9305. * Gets if the current filter is set to filtered ESM.
  9306. */
  9307. useBlurExponentialShadowMap: boolean;
  9308. /**
  9309. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9310. * exponential to prevent steep falloff artifacts).
  9311. */
  9312. /**
  9313. * Sets the current filter to "close ESM" (using the inverse of the
  9314. * exponential to prevent steep falloff artifacts).
  9315. */
  9316. useCloseExponentialShadowMap: boolean;
  9317. /**
  9318. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9319. * exponential to prevent steep falloff artifacts).
  9320. */
  9321. /**
  9322. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9323. * exponential to prevent steep falloff artifacts).
  9324. */
  9325. useBlurCloseExponentialShadowMap: boolean;
  9326. /**
  9327. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9328. */
  9329. /**
  9330. * Sets the current filter to "PCF" (percentage closer filtering).
  9331. */
  9332. usePercentageCloserFiltering: boolean;
  9333. private _filteringQuality;
  9334. /**
  9335. * Gets the PCF or PCSS Quality.
  9336. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9337. */
  9338. /**
  9339. * Sets the PCF or PCSS Quality.
  9340. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9341. */
  9342. filteringQuality: number;
  9343. /**
  9344. * Gets if the current filter is set to "PCSS" (contact hardening).
  9345. */
  9346. /**
  9347. * Sets the current filter to "PCSS" (contact hardening).
  9348. */
  9349. useContactHardeningShadow: boolean;
  9350. private _contactHardeningLightSizeUVRatio;
  9351. /**
  9352. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9353. * Using a ratio helps keeping shape stability independently of the map size.
  9354. *
  9355. * It does not account for the light projection as it was having too much
  9356. * instability during the light setup or during light position changes.
  9357. *
  9358. * Only valid if useContactHardeningShadow is true.
  9359. */
  9360. /**
  9361. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9362. * Using a ratio helps keeping shape stability independently of the map size.
  9363. *
  9364. * It does not account for the light projection as it was having too much
  9365. * instability during the light setup or during light position changes.
  9366. *
  9367. * Only valid if useContactHardeningShadow is true.
  9368. */
  9369. contactHardeningLightSizeUVRatio: number;
  9370. private _darkness;
  9371. /** Gets or sets the actual darkness of a shadow */
  9372. darkness: number;
  9373. /**
  9374. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9375. * 0 means strongest and 1 would means no shadow.
  9376. * @returns the darkness.
  9377. */
  9378. getDarkness(): number;
  9379. /**
  9380. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9381. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9382. * @returns the shadow generator allowing fluent coding.
  9383. */
  9384. setDarkness(darkness: number): ShadowGenerator;
  9385. private _transparencyShadow;
  9386. /** Gets or sets the ability to have transparent shadow */
  9387. transparencyShadow: boolean;
  9388. /**
  9389. * Sets the ability to have transparent shadow (boolean).
  9390. * @param transparent True if transparent else False
  9391. * @returns the shadow generator allowing fluent coding
  9392. */
  9393. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9394. private _shadowMap;
  9395. private _shadowMap2;
  9396. /**
  9397. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9398. * @returns The render target texture if present otherwise, null
  9399. */
  9400. getShadowMap(): Nullable<RenderTargetTexture>;
  9401. /**
  9402. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9403. * @returns The render target texture if the shadow map is present otherwise, null
  9404. */
  9405. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9406. /**
  9407. * Gets the class name of that object
  9408. * @returns "ShadowGenerator"
  9409. */
  9410. getClassName(): string;
  9411. /**
  9412. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9413. * @param mesh Mesh to add
  9414. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9415. * @returns the Shadow Generator itself
  9416. */
  9417. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9418. /**
  9419. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9420. * @param mesh Mesh to remove
  9421. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9422. * @returns the Shadow Generator itself
  9423. */
  9424. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9425. /**
  9426. * Controls the extent to which the shadows fade out at the edge of the frustum
  9427. * Used only by directionals and spots
  9428. */
  9429. frustumEdgeFalloff: number;
  9430. private _light;
  9431. /**
  9432. * Returns the associated light object.
  9433. * @returns the light generating the shadow
  9434. */
  9435. getLight(): IShadowLight;
  9436. /**
  9437. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9438. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9439. * It might on the other hand introduce peter panning.
  9440. */
  9441. forceBackFacesOnly: boolean;
  9442. private _scene;
  9443. private _lightDirection;
  9444. private _effect;
  9445. private _viewMatrix;
  9446. private _projectionMatrix;
  9447. private _transformMatrix;
  9448. private _cachedPosition;
  9449. private _cachedDirection;
  9450. private _cachedDefines;
  9451. private _currentRenderID;
  9452. private _boxBlurPostprocess;
  9453. private _kernelBlurXPostprocess;
  9454. private _kernelBlurYPostprocess;
  9455. private _blurPostProcesses;
  9456. private _mapSize;
  9457. private _currentFaceIndex;
  9458. private _currentFaceIndexCache;
  9459. private _textureType;
  9460. private _defaultTextureMatrix;
  9461. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9462. /**
  9463. * Creates a ShadowGenerator object.
  9464. * A ShadowGenerator is the required tool to use the shadows.
  9465. * Each light casting shadows needs to use its own ShadowGenerator.
  9466. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9467. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9468. * @param light The light object generating the shadows.
  9469. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9470. */
  9471. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9472. private _initializeGenerator;
  9473. private _initializeShadowMap;
  9474. private _initializeBlurRTTAndPostProcesses;
  9475. private _renderForShadowMap;
  9476. private _renderSubMeshForShadowMap;
  9477. private _applyFilterValues;
  9478. /**
  9479. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9480. * @param onCompiled Callback triggered at the and of the effects compilation
  9481. * @param options Sets of optional options forcing the compilation with different modes
  9482. */
  9483. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9484. useInstances: boolean;
  9485. }>): void;
  9486. /**
  9487. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9488. * @param options Sets of optional options forcing the compilation with different modes
  9489. * @returns A promise that resolves when the compilation completes
  9490. */
  9491. forceCompilationAsync(options?: Partial<{
  9492. useInstances: boolean;
  9493. }>): Promise<void>;
  9494. /**
  9495. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9496. * @param subMesh The submesh we want to render in the shadow map
  9497. * @param useInstances Defines wether will draw in the map using instances
  9498. * @returns true if ready otherwise, false
  9499. */
  9500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9501. /**
  9502. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9503. * @param defines Defines of the material we want to update
  9504. * @param lightIndex Index of the light in the enabled light list of the material
  9505. */
  9506. prepareDefines(defines: any, lightIndex: number): void;
  9507. /**
  9508. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9509. * defined in the generator but impacting the effect).
  9510. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9511. * @param effect The effect we are binfing the information for
  9512. */
  9513. bindShadowLight(lightIndex: string, effect: Effect): void;
  9514. /**
  9515. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9516. * (eq to shadow prjection matrix * light transform matrix)
  9517. * @returns The transform matrix used to create the shadow map
  9518. */
  9519. getTransformMatrix(): Matrix;
  9520. /**
  9521. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9522. * Cube and 2D textures for instance.
  9523. */
  9524. recreateShadowMap(): void;
  9525. private _disposeBlurPostProcesses;
  9526. private _disposeRTTandPostProcesses;
  9527. /**
  9528. * Disposes the ShadowGenerator.
  9529. * Returns nothing.
  9530. */
  9531. dispose(): void;
  9532. /**
  9533. * Serializes the shadow generator setup to a json object.
  9534. * @returns The serialized JSON object
  9535. */
  9536. serialize(): any;
  9537. /**
  9538. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9539. * @param parsedShadowGenerator The JSON object to parse
  9540. * @param scene The scene to create the shadow map for
  9541. * @returns The parsed shadow generator
  9542. */
  9543. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9544. }
  9545. }
  9546. declare module BABYLON {
  9547. /**
  9548. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9549. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9550. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9551. */
  9552. export abstract class Light extends Node {
  9553. /**
  9554. * Falloff Default: light is falling off following the material specification:
  9555. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9556. */
  9557. static readonly FALLOFF_DEFAULT: number;
  9558. /**
  9559. * Falloff Physical: light is falling off following the inverse squared distance law.
  9560. */
  9561. static readonly FALLOFF_PHYSICAL: number;
  9562. /**
  9563. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9564. * to enhance interoperability with other engines.
  9565. */
  9566. static readonly FALLOFF_GLTF: number;
  9567. /**
  9568. * Falloff Standard: light is falling off like in the standard material
  9569. * to enhance interoperability with other materials.
  9570. */
  9571. static readonly FALLOFF_STANDARD: number;
  9572. /**
  9573. * If every light affecting the material is in this lightmapMode,
  9574. * material.lightmapTexture adds or multiplies
  9575. * (depends on material.useLightmapAsShadowmap)
  9576. * after every other light calculations.
  9577. */
  9578. static readonly LIGHTMAP_DEFAULT: number;
  9579. /**
  9580. * material.lightmapTexture as only diffuse lighting from this light
  9581. * adds only specular lighting from this light
  9582. * adds dynamic shadows
  9583. */
  9584. static readonly LIGHTMAP_SPECULAR: number;
  9585. /**
  9586. * material.lightmapTexture as only lighting
  9587. * no light calculation from this light
  9588. * only adds dynamic shadows from this light
  9589. */
  9590. static readonly LIGHTMAP_SHADOWSONLY: number;
  9591. /**
  9592. * Each light type uses the default quantity according to its type:
  9593. * point/spot lights use luminous intensity
  9594. * directional lights use illuminance
  9595. */
  9596. static readonly INTENSITYMODE_AUTOMATIC: number;
  9597. /**
  9598. * lumen (lm)
  9599. */
  9600. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9601. /**
  9602. * candela (lm/sr)
  9603. */
  9604. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9605. /**
  9606. * lux (lm/m^2)
  9607. */
  9608. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9609. /**
  9610. * nit (cd/m^2)
  9611. */
  9612. static readonly INTENSITYMODE_LUMINANCE: number;
  9613. /**
  9614. * Light type const id of the point light.
  9615. */
  9616. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9617. /**
  9618. * Light type const id of the directional light.
  9619. */
  9620. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9621. /**
  9622. * Light type const id of the spot light.
  9623. */
  9624. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9625. /**
  9626. * Light type const id of the hemispheric light.
  9627. */
  9628. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9629. /**
  9630. * Diffuse gives the basic color to an object.
  9631. */
  9632. diffuse: Color3;
  9633. /**
  9634. * Specular produces a highlight color on an object.
  9635. * Note: This is note affecting PBR materials.
  9636. */
  9637. specular: Color3;
  9638. /**
  9639. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9640. * falling off base on range or angle.
  9641. * This can be set to any values in Light.FALLOFF_x.
  9642. *
  9643. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9644. * other types of materials.
  9645. */
  9646. falloffType: number;
  9647. /**
  9648. * Strength of the light.
  9649. * Note: By default it is define in the framework own unit.
  9650. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9651. */
  9652. intensity: number;
  9653. private _range;
  9654. protected _inverseSquaredRange: number;
  9655. /**
  9656. * Defines how far from the source the light is impacting in scene units.
  9657. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9658. */
  9659. /**
  9660. * Defines how far from the source the light is impacting in scene units.
  9661. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9662. */
  9663. range: number;
  9664. /**
  9665. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9666. * of light.
  9667. */
  9668. private _photometricScale;
  9669. private _intensityMode;
  9670. /**
  9671. * Gets the photometric scale used to interpret the intensity.
  9672. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9673. */
  9674. /**
  9675. * Sets the photometric scale used to interpret the intensity.
  9676. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9677. */
  9678. intensityMode: number;
  9679. private _radius;
  9680. /**
  9681. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9682. */
  9683. /**
  9684. * sets the light radius used by PBR Materials to simulate soft area lights.
  9685. */
  9686. radius: number;
  9687. private _renderPriority;
  9688. /**
  9689. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9690. * exceeding the number allowed of the materials.
  9691. */
  9692. renderPriority: number;
  9693. private _shadowEnabled;
  9694. /**
  9695. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9696. * the current shadow generator.
  9697. */
  9698. /**
  9699. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9700. * the current shadow generator.
  9701. */
  9702. shadowEnabled: boolean;
  9703. private _includedOnlyMeshes;
  9704. /**
  9705. * Gets the only meshes impacted by this light.
  9706. */
  9707. /**
  9708. * Sets the only meshes impacted by this light.
  9709. */
  9710. includedOnlyMeshes: AbstractMesh[];
  9711. private _excludedMeshes;
  9712. /**
  9713. * Gets the meshes not impacted by this light.
  9714. */
  9715. /**
  9716. * Sets the meshes not impacted by this light.
  9717. */
  9718. excludedMeshes: AbstractMesh[];
  9719. private _excludeWithLayerMask;
  9720. /**
  9721. * Gets the layer id use to find what meshes are not impacted by the light.
  9722. * Inactive if 0
  9723. */
  9724. /**
  9725. * Sets the layer id use to find what meshes are not impacted by the light.
  9726. * Inactive if 0
  9727. */
  9728. excludeWithLayerMask: number;
  9729. private _includeOnlyWithLayerMask;
  9730. /**
  9731. * Gets the layer id use to find what meshes are impacted by the light.
  9732. * Inactive if 0
  9733. */
  9734. /**
  9735. * Sets the layer id use to find what meshes are impacted by the light.
  9736. * Inactive if 0
  9737. */
  9738. includeOnlyWithLayerMask: number;
  9739. private _lightmapMode;
  9740. /**
  9741. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9742. */
  9743. /**
  9744. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9745. */
  9746. lightmapMode: number;
  9747. /**
  9748. * Shadow generator associted to the light.
  9749. * @hidden Internal use only.
  9750. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9751. /**
  9752. * @hidden Internal use only.
  9753. */ private _excludedMeshesIds: string[];
  9754. /**
  9755. * @hidden Internal use only.
  9756. */ private _includedOnlyMeshesIds: string[];
  9757. /**
  9758. * The current light unifom buffer.
  9759. * @hidden Internal use only.
  9760. */ private _uniformBuffer: UniformBuffer;
  9761. /**
  9762. * Creates a Light object in the scene.
  9763. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9764. * @param name The firendly name of the light
  9765. * @param scene The scene the light belongs too
  9766. */
  9767. constructor(name: string, scene: Scene);
  9768. protected abstract _buildUniformLayout(): void;
  9769. /**
  9770. * Sets the passed Effect "effect" with the Light information.
  9771. * @param effect The effect to update
  9772. * @param lightIndex The index of the light in the effect to update
  9773. * @returns The light
  9774. */
  9775. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9776. /**
  9777. * Returns the string "Light".
  9778. * @returns the class name
  9779. */
  9780. getClassName(): string;
  9781. /** @hidden */ protected readonly _isLight: boolean;
  9782. /**
  9783. * Converts the light information to a readable string for debug purpose.
  9784. * @param fullDetails Supports for multiple levels of logging within scene loading
  9785. * @returns the human readable light info
  9786. */
  9787. toString(fullDetails?: boolean): string;
  9788. /** @hidden */
  9789. protected _syncParentEnabledState(): void;
  9790. /**
  9791. * Set the enabled state of this node.
  9792. * @param value - the new enabled state
  9793. */
  9794. setEnabled(value: boolean): void;
  9795. /**
  9796. * Returns the Light associated shadow generator if any.
  9797. * @return the associated shadow generator.
  9798. */
  9799. getShadowGenerator(): Nullable<IShadowGenerator>;
  9800. /**
  9801. * Returns a Vector3, the absolute light position in the World.
  9802. * @returns the world space position of the light
  9803. */
  9804. getAbsolutePosition(): Vector3;
  9805. /**
  9806. * Specifies if the light will affect the passed mesh.
  9807. * @param mesh The mesh to test against the light
  9808. * @return true the mesh is affected otherwise, false.
  9809. */
  9810. canAffectMesh(mesh: AbstractMesh): boolean;
  9811. /**
  9812. * Sort function to order lights for rendering.
  9813. * @param a First Light object to compare to second.
  9814. * @param b Second Light object to compare first.
  9815. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9816. */
  9817. static CompareLightsPriority(a: Light, b: Light): number;
  9818. /**
  9819. * Releases resources associated with this node.
  9820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9822. */
  9823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9824. /**
  9825. * Returns the light type ID (integer).
  9826. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9827. */
  9828. getTypeID(): number;
  9829. /**
  9830. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9831. * @returns the scaled intensity in intensity mode unit
  9832. */
  9833. getScaledIntensity(): number;
  9834. /**
  9835. * Returns a new Light object, named "name", from the current one.
  9836. * @param name The name of the cloned light
  9837. * @returns the new created light
  9838. */
  9839. clone(name: string): Nullable<Light>;
  9840. /**
  9841. * Serializes the current light into a Serialization object.
  9842. * @returns the serialized object.
  9843. */
  9844. serialize(): any;
  9845. /**
  9846. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9847. * This new light is named "name" and added to the passed scene.
  9848. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9849. * @param name The friendly name of the light
  9850. * @param scene The scene the new light will belong to
  9851. * @returns the constructor function
  9852. */
  9853. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9854. /**
  9855. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9856. * @param parsedLight The JSON representation of the light
  9857. * @param scene The scene to create the parsed light in
  9858. * @returns the created light after parsing
  9859. */
  9860. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9861. private _hookArrayForExcluded;
  9862. private _hookArrayForIncludedOnly;
  9863. private _resyncMeshes;
  9864. /**
  9865. * Forces the meshes to update their light related information in their rendering used effects
  9866. * @hidden Internal Use Only
  9867. */ private _markMeshesAsLightDirty(): void;
  9868. /**
  9869. * Recomputes the cached photometric scale if needed.
  9870. */
  9871. private _computePhotometricScale;
  9872. /**
  9873. * Returns the Photometric Scale according to the light type and intensity mode.
  9874. */
  9875. private _getPhotometricScale;
  9876. /**
  9877. * Reorder the light in the scene according to their defined priority.
  9878. * @hidden Internal Use Only
  9879. */ private _reorderLightsInScene(): void;
  9880. /**
  9881. * Prepares the list of defines specific to the light type.
  9882. * @param defines the list of defines
  9883. * @param lightIndex defines the index of the light for the effect
  9884. */
  9885. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9886. }
  9887. }
  9888. declare module BABYLON {
  9889. /**
  9890. * Interface used to define Action
  9891. */
  9892. export interface IAction {
  9893. /**
  9894. * Trigger for the action
  9895. */
  9896. trigger: number;
  9897. /** Options of the trigger */
  9898. triggerOptions: any;
  9899. /**
  9900. * Gets the trigger parameters
  9901. * @returns the trigger parameters
  9902. */
  9903. getTriggerParameter(): any;
  9904. /**
  9905. * Internal only - executes current action event
  9906. * @hidden
  9907. */ private _executeCurrent(evt?: ActionEvent): void;
  9908. /**
  9909. * Serialize placeholder for child classes
  9910. * @param parent of child
  9911. * @returns the serialized object
  9912. */
  9913. serialize(parent: any): any;
  9914. /**
  9915. * Internal only
  9916. * @hidden
  9917. */ private _prepare(): void;
  9918. /**
  9919. * Internal only - manager for action
  9920. * @hidden
  9921. */ private _actionManager: AbstractActionManager;
  9922. /**
  9923. * Adds action to chain of actions, may be a DoNothingAction
  9924. * @param action defines the next action to execute
  9925. * @returns The action passed in
  9926. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9927. */
  9928. then(action: IAction): IAction;
  9929. }
  9930. /**
  9931. * The action to be carried out following a trigger
  9932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9933. */
  9934. export class Action implements IAction {
  9935. /** the trigger, with or without parameters, for the action */
  9936. triggerOptions: any;
  9937. /**
  9938. * Trigger for the action
  9939. */
  9940. trigger: number;
  9941. /**
  9942. * Internal only - manager for action
  9943. * @hidden
  9944. */ private _actionManager: ActionManager;
  9945. private _nextActiveAction;
  9946. private _child;
  9947. private _condition?;
  9948. private _triggerParameter;
  9949. /**
  9950. * An event triggered prior to action being executed.
  9951. */
  9952. onBeforeExecuteObservable: Observable<Action>;
  9953. /**
  9954. * Creates a new Action
  9955. * @param triggerOptions the trigger, with or without parameters, for the action
  9956. * @param condition an optional determinant of action
  9957. */
  9958. constructor(
  9959. /** the trigger, with or without parameters, for the action */
  9960. triggerOptions: any, condition?: Condition);
  9961. /**
  9962. * Internal only
  9963. * @hidden
  9964. */ private _prepare(): void;
  9965. /**
  9966. * Gets the trigger parameters
  9967. * @returns the trigger parameters
  9968. */
  9969. getTriggerParameter(): any;
  9970. /**
  9971. * Internal only - executes current action event
  9972. * @hidden
  9973. */ private _executeCurrent(evt?: ActionEvent): void;
  9974. /**
  9975. * Execute placeholder for child classes
  9976. * @param evt optional action event
  9977. */
  9978. execute(evt?: ActionEvent): void;
  9979. /**
  9980. * Skips to next active action
  9981. */
  9982. skipToNextActiveAction(): void;
  9983. /**
  9984. * Adds action to chain of actions, may be a DoNothingAction
  9985. * @param action defines the next action to execute
  9986. * @returns The action passed in
  9987. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9988. */
  9989. then(action: Action): Action;
  9990. /**
  9991. * Internal only
  9992. * @hidden
  9993. */ private _getProperty(propertyPath: string): string;
  9994. /**
  9995. * Internal only
  9996. * @hidden
  9997. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  9998. /**
  9999. * Serialize placeholder for child classes
  10000. * @param parent of child
  10001. * @returns the serialized object
  10002. */
  10003. serialize(parent: any): any;
  10004. /**
  10005. * Internal only called by serialize
  10006. * @hidden
  10007. */
  10008. protected _serialize(serializedAction: any, parent?: any): any;
  10009. /**
  10010. * Internal only
  10011. * @hidden
  10012. */ private static _SerializeValueAsString: (value: any) => string;
  10013. /**
  10014. * Internal only
  10015. * @hidden
  10016. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10017. name: string;
  10018. targetType: string;
  10019. value: string;
  10020. };
  10021. }
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * A Condition applied to an Action
  10026. */
  10027. export class Condition {
  10028. /**
  10029. * Internal only - manager for action
  10030. * @hidden
  10031. */ private _actionManager: ActionManager;
  10032. /**
  10033. * Internal only
  10034. * @hidden
  10035. */ private _evaluationId: number;
  10036. /**
  10037. * Internal only
  10038. * @hidden
  10039. */ private _currentResult: boolean;
  10040. /**
  10041. * Creates a new Condition
  10042. * @param actionManager the manager of the action the condition is applied to
  10043. */
  10044. constructor(actionManager: ActionManager);
  10045. /**
  10046. * Check if the current condition is valid
  10047. * @returns a boolean
  10048. */
  10049. isValid(): boolean;
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */ private _getProperty(propertyPath: string): string;
  10054. /**
  10055. * Internal only
  10056. * @hidden
  10057. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10058. /**
  10059. * Serialize placeholder for child classes
  10060. * @returns the serialized object
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Internal only
  10065. * @hidden
  10066. */
  10067. protected _serialize(serializedCondition: any): any;
  10068. }
  10069. /**
  10070. * Defines specific conditional operators as extensions of Condition
  10071. */
  10072. export class ValueCondition extends Condition {
  10073. /** path to specify the property of the target the conditional operator uses */
  10074. propertyPath: string;
  10075. /** the value compared by the conditional operator against the current value of the property */
  10076. value: any;
  10077. /** the conditional operator, default ValueCondition.IsEqual */
  10078. operator: number;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. private static _IsEqual;
  10084. /**
  10085. * Internal only
  10086. * @hidden
  10087. */
  10088. private static _IsDifferent;
  10089. /**
  10090. * Internal only
  10091. * @hidden
  10092. */
  10093. private static _IsGreater;
  10094. /**
  10095. * Internal only
  10096. * @hidden
  10097. */
  10098. private static _IsLesser;
  10099. /**
  10100. * returns the number for IsEqual
  10101. */
  10102. static readonly IsEqual: number;
  10103. /**
  10104. * Returns the number for IsDifferent
  10105. */
  10106. static readonly IsDifferent: number;
  10107. /**
  10108. * Returns the number for IsGreater
  10109. */
  10110. static readonly IsGreater: number;
  10111. /**
  10112. * Returns the number for IsLesser
  10113. */
  10114. static readonly IsLesser: number;
  10115. /**
  10116. * Internal only The action manager for the condition
  10117. * @hidden
  10118. */ private _actionManager: ActionManager;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. private _target;
  10124. /**
  10125. * Internal only
  10126. * @hidden
  10127. */
  10128. private _effectiveTarget;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. private _property;
  10134. /**
  10135. * Creates a new ValueCondition
  10136. * @param actionManager manager for the action the condition applies to
  10137. * @param target for the action
  10138. * @param propertyPath path to specify the property of the target the conditional operator uses
  10139. * @param value the value compared by the conditional operator against the current value of the property
  10140. * @param operator the conditional operator, default ValueCondition.IsEqual
  10141. */
  10142. constructor(actionManager: ActionManager, target: any,
  10143. /** path to specify the property of the target the conditional operator uses */
  10144. propertyPath: string,
  10145. /** the value compared by the conditional operator against the current value of the property */
  10146. value: any,
  10147. /** the conditional operator, default ValueCondition.IsEqual */
  10148. operator?: number);
  10149. /**
  10150. * Compares the given value with the property value for the specified conditional operator
  10151. * @returns the result of the comparison
  10152. */
  10153. isValid(): boolean;
  10154. /**
  10155. * Serialize the ValueCondition into a JSON compatible object
  10156. * @returns serialization object
  10157. */
  10158. serialize(): any;
  10159. /**
  10160. * Gets the name of the conditional operator for the ValueCondition
  10161. * @param operator the conditional operator
  10162. * @returns the name
  10163. */
  10164. static GetOperatorName(operator: number): string;
  10165. }
  10166. /**
  10167. * Defines a predicate condition as an extension of Condition
  10168. */
  10169. export class PredicateCondition extends Condition {
  10170. /** defines the predicate function used to validate the condition */
  10171. predicate: () => boolean;
  10172. /**
  10173. * Internal only - manager for action
  10174. * @hidden
  10175. */ private _actionManager: ActionManager;
  10176. /**
  10177. * Creates a new PredicateCondition
  10178. * @param actionManager manager for the action the condition applies to
  10179. * @param predicate defines the predicate function used to validate the condition
  10180. */
  10181. constructor(actionManager: ActionManager,
  10182. /** defines the predicate function used to validate the condition */
  10183. predicate: () => boolean);
  10184. /**
  10185. * @returns the validity of the predicate condition
  10186. */
  10187. isValid(): boolean;
  10188. }
  10189. /**
  10190. * Defines a state condition as an extension of Condition
  10191. */
  10192. export class StateCondition extends Condition {
  10193. /** Value to compare with target state */
  10194. value: string;
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */ private _actionManager: ActionManager;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */
  10203. private _target;
  10204. /**
  10205. * Creates a new StateCondition
  10206. * @param actionManager manager for the action the condition applies to
  10207. * @param target of the condition
  10208. * @param value to compare with target state
  10209. */
  10210. constructor(actionManager: ActionManager, target: any,
  10211. /** Value to compare with target state */
  10212. value: string);
  10213. /**
  10214. * Gets a boolean indicating if the current condition is met
  10215. * @returns the validity of the state
  10216. */
  10217. isValid(): boolean;
  10218. /**
  10219. * Serialize the StateCondition into a JSON compatible object
  10220. * @returns serialization object
  10221. */
  10222. serialize(): any;
  10223. }
  10224. }
  10225. declare module BABYLON {
  10226. /**
  10227. * This defines an action responsible to toggle a boolean once triggered.
  10228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class SwitchBooleanAction extends Action {
  10231. /**
  10232. * The path to the boolean property in the target object
  10233. */
  10234. propertyPath: string;
  10235. private _target;
  10236. private _effectiveTarget;
  10237. private _property;
  10238. /**
  10239. * Instantiate the action
  10240. * @param triggerOptions defines the trigger options
  10241. * @param target defines the object containing the boolean
  10242. * @param propertyPath defines the path to the boolean property in the target object
  10243. * @param condition defines the trigger related conditions
  10244. */
  10245. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10246. /** @hidden */ private _prepare(): void;
  10247. /**
  10248. * Execute the action toggle the boolean value.
  10249. */
  10250. execute(): void;
  10251. /**
  10252. * Serializes the actions and its related information.
  10253. * @param parent defines the object to serialize in
  10254. * @returns the serialized object
  10255. */
  10256. serialize(parent: any): any;
  10257. }
  10258. /**
  10259. * This defines an action responsible to set a the state field of the target
  10260. * to a desired value once triggered.
  10261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10262. */
  10263. export class SetStateAction extends Action {
  10264. /**
  10265. * The value to store in the state field.
  10266. */
  10267. value: string;
  10268. private _target;
  10269. /**
  10270. * Instantiate the action
  10271. * @param triggerOptions defines the trigger options
  10272. * @param target defines the object containing the state property
  10273. * @param value defines the value to store in the state field
  10274. * @param condition defines the trigger related conditions
  10275. */
  10276. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10277. /**
  10278. * Execute the action and store the value on the target state property.
  10279. */
  10280. execute(): void;
  10281. /**
  10282. * Serializes the actions and its related information.
  10283. * @param parent defines the object to serialize in
  10284. * @returns the serialized object
  10285. */
  10286. serialize(parent: any): any;
  10287. }
  10288. /**
  10289. * This defines an action responsible to set a property of the target
  10290. * to a desired value once triggered.
  10291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10292. */
  10293. export class SetValueAction extends Action {
  10294. /**
  10295. * The path of the property to set in the target.
  10296. */
  10297. propertyPath: string;
  10298. /**
  10299. * The value to set in the property
  10300. */
  10301. value: any;
  10302. private _target;
  10303. private _effectiveTarget;
  10304. private _property;
  10305. /**
  10306. * Instantiate the action
  10307. * @param triggerOptions defines the trigger options
  10308. * @param target defines the object containing the property
  10309. * @param propertyPath defines the path of the property to set in the target
  10310. * @param value defines the value to set in the property
  10311. * @param condition defines the trigger related conditions
  10312. */
  10313. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10314. /** @hidden */ private _prepare(): void;
  10315. /**
  10316. * Execute the action and set the targetted property to the desired value.
  10317. */
  10318. execute(): void;
  10319. /**
  10320. * Serializes the actions and its related information.
  10321. * @param parent defines the object to serialize in
  10322. * @returns the serialized object
  10323. */
  10324. serialize(parent: any): any;
  10325. }
  10326. /**
  10327. * This defines an action responsible to increment the target value
  10328. * to a desired value once triggered.
  10329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10330. */
  10331. export class IncrementValueAction extends Action {
  10332. /**
  10333. * The path of the property to increment in the target.
  10334. */
  10335. propertyPath: string;
  10336. /**
  10337. * The value we should increment the property by.
  10338. */
  10339. value: any;
  10340. private _target;
  10341. private _effectiveTarget;
  10342. private _property;
  10343. /**
  10344. * Instantiate the action
  10345. * @param triggerOptions defines the trigger options
  10346. * @param target defines the object containing the property
  10347. * @param propertyPath defines the path of the property to increment in the target
  10348. * @param value defines the value value we should increment the property by
  10349. * @param condition defines the trigger related conditions
  10350. */
  10351. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10352. /** @hidden */ private _prepare(): void;
  10353. /**
  10354. * Execute the action and increment the target of the value amount.
  10355. */
  10356. execute(): void;
  10357. /**
  10358. * Serializes the actions and its related information.
  10359. * @param parent defines the object to serialize in
  10360. * @returns the serialized object
  10361. */
  10362. serialize(parent: any): any;
  10363. }
  10364. /**
  10365. * This defines an action responsible to start an animation once triggered.
  10366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10367. */
  10368. export class PlayAnimationAction extends Action {
  10369. /**
  10370. * Where the animation should start (animation frame)
  10371. */
  10372. from: number;
  10373. /**
  10374. * Where the animation should stop (animation frame)
  10375. */
  10376. to: number;
  10377. /**
  10378. * Define if the animation should loop or stop after the first play.
  10379. */
  10380. loop?: boolean;
  10381. private _target;
  10382. /**
  10383. * Instantiate the action
  10384. * @param triggerOptions defines the trigger options
  10385. * @param target defines the target animation or animation name
  10386. * @param from defines from where the animation should start (animation frame)
  10387. * @param end defines where the animation should stop (animation frame)
  10388. * @param loop defines if the animation should loop or stop after the first play
  10389. * @param condition defines the trigger related conditions
  10390. */
  10391. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10392. /** @hidden */ private _prepare(): void;
  10393. /**
  10394. * Execute the action and play the animation.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to stop an animation once triggered.
  10406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10407. */
  10408. export class StopAnimationAction extends Action {
  10409. private _target;
  10410. /**
  10411. * Instantiate the action
  10412. * @param triggerOptions defines the trigger options
  10413. * @param target defines the target animation or animation name
  10414. * @param condition defines the trigger related conditions
  10415. */
  10416. constructor(triggerOptions: any, target: any, condition?: Condition);
  10417. /** @hidden */ private _prepare(): void;
  10418. /**
  10419. * Execute the action and stop the animation.
  10420. */
  10421. execute(): void;
  10422. /**
  10423. * Serializes the actions and its related information.
  10424. * @param parent defines the object to serialize in
  10425. * @returns the serialized object
  10426. */
  10427. serialize(parent: any): any;
  10428. }
  10429. /**
  10430. * This defines an action responsible that does nothing once triggered.
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10432. */
  10433. export class DoNothingAction extends Action {
  10434. /**
  10435. * Instantiate the action
  10436. * @param triggerOptions defines the trigger options
  10437. * @param condition defines the trigger related conditions
  10438. */
  10439. constructor(triggerOptions?: any, condition?: Condition);
  10440. /**
  10441. * Execute the action and do nothing.
  10442. */
  10443. execute(): void;
  10444. /**
  10445. * Serializes the actions and its related information.
  10446. * @param parent defines the object to serialize in
  10447. * @returns the serialized object
  10448. */
  10449. serialize(parent: any): any;
  10450. }
  10451. /**
  10452. * This defines an action responsible to trigger several actions once triggered.
  10453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10454. */
  10455. export class CombineAction extends Action {
  10456. /**
  10457. * The list of aggregated animations to run.
  10458. */
  10459. children: Action[];
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param children defines the list of aggregated animations to run
  10464. * @param condition defines the trigger related conditions
  10465. */
  10466. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10467. /** @hidden */ private _prepare(): void;
  10468. /**
  10469. * Execute the action and executes all the aggregated actions.
  10470. */
  10471. execute(evt: ActionEvent): void;
  10472. /**
  10473. * Serializes the actions and its related information.
  10474. * @param parent defines the object to serialize in
  10475. * @returns the serialized object
  10476. */
  10477. serialize(parent: any): any;
  10478. }
  10479. /**
  10480. * This defines an action responsible to run code (external event) once triggered.
  10481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10482. */
  10483. export class ExecuteCodeAction extends Action {
  10484. /**
  10485. * The callback function to run.
  10486. */
  10487. func: (evt: ActionEvent) => void;
  10488. /**
  10489. * Instantiate the action
  10490. * @param triggerOptions defines the trigger options
  10491. * @param func defines the callback function to run
  10492. * @param condition defines the trigger related conditions
  10493. */
  10494. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10495. /**
  10496. * Execute the action and run the attached code.
  10497. */
  10498. execute(evt: ActionEvent): void;
  10499. }
  10500. /**
  10501. * This defines an action responsible to set the parent property of the target once triggered.
  10502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10503. */
  10504. export class SetParentAction extends Action {
  10505. private _parent;
  10506. private _target;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the target containing the parent property
  10511. * @param parent defines from where the animation should start (animation frame)
  10512. * @param condition defines the trigger related conditions
  10513. */
  10514. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10515. /** @hidden */ private _prepare(): void;
  10516. /**
  10517. * Execute the action and set the parent property.
  10518. */
  10519. execute(): void;
  10520. /**
  10521. * Serializes the actions and its related information.
  10522. * @param parent defines the object to serialize in
  10523. * @returns the serialized object
  10524. */
  10525. serialize(parent: any): any;
  10526. }
  10527. }
  10528. declare module BABYLON {
  10529. /**
  10530. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10531. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class ActionManager extends AbstractActionManager {
  10535. /**
  10536. * Nothing
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10538. */
  10539. static readonly NothingTrigger: number;
  10540. /**
  10541. * On pick
  10542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10543. */
  10544. static readonly OnPickTrigger: number;
  10545. /**
  10546. * On left pick
  10547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10548. */
  10549. static readonly OnLeftPickTrigger: number;
  10550. /**
  10551. * On right pick
  10552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10553. */
  10554. static readonly OnRightPickTrigger: number;
  10555. /**
  10556. * On center pick
  10557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10558. */
  10559. static readonly OnCenterPickTrigger: number;
  10560. /**
  10561. * On pick down
  10562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10563. */
  10564. static readonly OnPickDownTrigger: number;
  10565. /**
  10566. * On double pick
  10567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10568. */
  10569. static readonly OnDoublePickTrigger: number;
  10570. /**
  10571. * On pick up
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10573. */
  10574. static readonly OnPickUpTrigger: number;
  10575. /**
  10576. * On pick out.
  10577. * This trigger will only be raised if you also declared a OnPickDown
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10579. */
  10580. static readonly OnPickOutTrigger: number;
  10581. /**
  10582. * On long press
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10584. */
  10585. static readonly OnLongPressTrigger: number;
  10586. /**
  10587. * On pointer over
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10589. */
  10590. static readonly OnPointerOverTrigger: number;
  10591. /**
  10592. * On pointer out
  10593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10594. */
  10595. static readonly OnPointerOutTrigger: number;
  10596. /**
  10597. * On every frame
  10598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10599. */
  10600. static readonly OnEveryFrameTrigger: number;
  10601. /**
  10602. * On intersection enter
  10603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10604. */
  10605. static readonly OnIntersectionEnterTrigger: number;
  10606. /**
  10607. * On intersection exit
  10608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10609. */
  10610. static readonly OnIntersectionExitTrigger: number;
  10611. /**
  10612. * On key down
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10614. */
  10615. static readonly OnKeyDownTrigger: number;
  10616. /**
  10617. * On key up
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10619. */
  10620. static readonly OnKeyUpTrigger: number;
  10621. private _scene;
  10622. /**
  10623. * Creates a new action manager
  10624. * @param scene defines the hosting scene
  10625. */
  10626. constructor(scene: Scene);
  10627. /**
  10628. * Releases all associated resources
  10629. */
  10630. dispose(): void;
  10631. /**
  10632. * Gets hosting scene
  10633. * @returns the hosting scene
  10634. */
  10635. getScene(): Scene;
  10636. /**
  10637. * Does this action manager handles actions of any of the given triggers
  10638. * @param triggers defines the triggers to be tested
  10639. * @return a boolean indicating whether one (or more) of the triggers is handled
  10640. */
  10641. hasSpecificTriggers(triggers: number[]): boolean;
  10642. /**
  10643. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10644. * speed.
  10645. * @param triggerA defines the trigger to be tested
  10646. * @param triggerB defines the trigger to be tested
  10647. * @return a boolean indicating whether one (or more) of the triggers is handled
  10648. */
  10649. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10650. /**
  10651. * Does this action manager handles actions of a given trigger
  10652. * @param trigger defines the trigger to be tested
  10653. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10654. * @return whether the trigger is handled
  10655. */
  10656. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10657. /**
  10658. * Does this action manager has pointer triggers
  10659. */
  10660. readonly hasPointerTriggers: boolean;
  10661. /**
  10662. * Does this action manager has pick triggers
  10663. */
  10664. readonly hasPickTriggers: boolean;
  10665. /**
  10666. * Registers an action to this action manager
  10667. * @param action defines the action to be registered
  10668. * @return the action amended (prepared) after registration
  10669. */
  10670. registerAction(action: IAction): Nullable<IAction>;
  10671. /**
  10672. * Unregisters an action to this action manager
  10673. * @param action defines the action to be unregistered
  10674. * @return a boolean indicating whether the action has been unregistered
  10675. */
  10676. unregisterAction(action: IAction): Boolean;
  10677. /**
  10678. * Process a specific trigger
  10679. * @param trigger defines the trigger to process
  10680. * @param evt defines the event details to be processed
  10681. */
  10682. processTrigger(trigger: number, evt?: IActionEvent): void;
  10683. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10684. /** @hidden */ private _getProperty(propertyPath: string): string;
  10685. /**
  10686. * Serialize this manager to a JSON object
  10687. * @param name defines the property name to store this manager
  10688. * @returns a JSON representation of this manager
  10689. */
  10690. serialize(name: string): any;
  10691. /**
  10692. * Creates a new ActionManager from a JSON data
  10693. * @param parsedActions defines the JSON data to read from
  10694. * @param object defines the hosting mesh
  10695. * @param scene defines the hosting scene
  10696. */
  10697. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10698. /**
  10699. * Get a trigger name by index
  10700. * @param trigger defines the trigger index
  10701. * @returns a trigger name
  10702. */
  10703. static GetTriggerName(trigger: number): string;
  10704. }
  10705. }
  10706. declare module BABYLON {
  10707. /**
  10708. * Class representing a ray with position and direction
  10709. */
  10710. export class Ray {
  10711. /** origin point */
  10712. origin: Vector3;
  10713. /** direction */
  10714. direction: Vector3;
  10715. /** length of the ray */
  10716. length: number;
  10717. private static readonly TmpVector3;
  10718. private _tmpRay;
  10719. /**
  10720. * Creates a new ray
  10721. * @param origin origin point
  10722. * @param direction direction
  10723. * @param length length of the ray
  10724. */
  10725. constructor(
  10726. /** origin point */
  10727. origin: Vector3,
  10728. /** direction */
  10729. direction: Vector3,
  10730. /** length of the ray */
  10731. length?: number);
  10732. /**
  10733. * Checks if the ray intersects a box
  10734. * @param minimum bound of the box
  10735. * @param maximum bound of the box
  10736. * @param intersectionTreshold extra extend to be added to the box in all direction
  10737. * @returns if the box was hit
  10738. */
  10739. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10740. /**
  10741. * Checks if the ray intersects a box
  10742. * @param box the bounding box to check
  10743. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10744. * @returns if the box was hit
  10745. */
  10746. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10747. /**
  10748. * If the ray hits a sphere
  10749. * @param sphere the bounding sphere to check
  10750. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10751. * @returns true if it hits the sphere
  10752. */
  10753. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10754. /**
  10755. * If the ray hits a triange
  10756. * @param vertex0 triangle vertex
  10757. * @param vertex1 triangle vertex
  10758. * @param vertex2 triangle vertex
  10759. * @returns intersection information if hit
  10760. */
  10761. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10762. /**
  10763. * Checks if ray intersects a plane
  10764. * @param plane the plane to check
  10765. * @returns the distance away it was hit
  10766. */
  10767. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10768. /**
  10769. * Calculate the intercept of a ray on a given axis
  10770. * @param axis to check 'x' | 'y' | 'z'
  10771. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10772. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10773. */
  10774. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10775. /**
  10776. * Checks if ray intersects a mesh
  10777. * @param mesh the mesh to check
  10778. * @param fastCheck if only the bounding box should checked
  10779. * @returns picking info of the intersecton
  10780. */
  10781. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10782. /**
  10783. * Checks if ray intersects a mesh
  10784. * @param meshes the meshes to check
  10785. * @param fastCheck if only the bounding box should checked
  10786. * @param results array to store result in
  10787. * @returns Array of picking infos
  10788. */
  10789. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10790. private _comparePickingInfo;
  10791. private static smallnum;
  10792. private static rayl;
  10793. /**
  10794. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10795. * @param sega the first point of the segment to test the intersection against
  10796. * @param segb the second point of the segment to test the intersection against
  10797. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10798. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10799. */
  10800. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10801. /**
  10802. * Update the ray from viewport position
  10803. * @param x position
  10804. * @param y y position
  10805. * @param viewportWidth viewport width
  10806. * @param viewportHeight viewport height
  10807. * @param world world matrix
  10808. * @param view view matrix
  10809. * @param projection projection matrix
  10810. * @returns this ray updated
  10811. */
  10812. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10813. /**
  10814. * Creates a ray with origin and direction of 0,0,0
  10815. * @returns the new ray
  10816. */
  10817. static Zero(): Ray;
  10818. /**
  10819. * Creates a new ray from screen space and viewport
  10820. * @param x position
  10821. * @param y y position
  10822. * @param viewportWidth viewport width
  10823. * @param viewportHeight viewport height
  10824. * @param world world matrix
  10825. * @param view view matrix
  10826. * @param projection projection matrix
  10827. * @returns new ray
  10828. */
  10829. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10830. /**
  10831. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10832. * transformed to the given world matrix.
  10833. * @param origin The origin point
  10834. * @param end The end point
  10835. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10836. * @returns the new ray
  10837. */
  10838. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10839. /**
  10840. * Transforms a ray by a matrix
  10841. * @param ray ray to transform
  10842. * @param matrix matrix to apply
  10843. * @returns the resulting new ray
  10844. */
  10845. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * Transforms a ray by a matrix
  10848. * @param ray ray to transform
  10849. * @param matrix matrix to apply
  10850. * @param result ray to store result in
  10851. */
  10852. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10853. /**
  10854. * Unproject a ray from screen space to object space
  10855. * @param sourceX defines the screen space x coordinate to use
  10856. * @param sourceY defines the screen space y coordinate to use
  10857. * @param viewportWidth defines the current width of the viewport
  10858. * @param viewportHeight defines the current height of the viewport
  10859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10860. * @param view defines the view matrix to use
  10861. * @param projection defines the projection matrix to use
  10862. */
  10863. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10864. }
  10865. /**
  10866. * Type used to define predicate used to select faces when a mesh intersection is detected
  10867. */
  10868. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10869. interface Scene {
  10870. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10871. /** @hidden */ private _cachedRayForTransform: Ray;
  10872. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10873. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10874. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10875. }
  10876. }
  10877. declare module BABYLON {
  10878. /**
  10879. * Groups all the scene component constants in one place to ease maintenance.
  10880. * @hidden
  10881. */
  10882. export class SceneComponentConstants {
  10883. static readonly NAME_EFFECTLAYER: string;
  10884. static readonly NAME_LAYER: string;
  10885. static readonly NAME_LENSFLARESYSTEM: string;
  10886. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10887. static readonly NAME_PARTICLESYSTEM: string;
  10888. static readonly NAME_GAMEPAD: string;
  10889. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10890. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10891. static readonly NAME_DEPTHRENDERER: string;
  10892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10893. static readonly NAME_SPRITE: string;
  10894. static readonly NAME_OUTLINERENDERER: string;
  10895. static readonly NAME_PROCEDURALTEXTURE: string;
  10896. static readonly NAME_SHADOWGENERATOR: string;
  10897. static readonly NAME_OCTREE: string;
  10898. static readonly NAME_PHYSICSENGINE: string;
  10899. static readonly NAME_AUDIO: string;
  10900. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10901. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10902. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10903. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10904. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10905. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10906. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10907. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10908. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10909. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10910. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10911. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10912. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10913. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10914. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10915. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10917. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10919. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10920. static readonly STEP_AFTERRENDER_AUDIO: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10922. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10923. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10924. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10925. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10926. static readonly STEP_POINTERMOVE_SPRITE: number;
  10927. static readonly STEP_POINTERDOWN_SPRITE: number;
  10928. static readonly STEP_POINTERUP_SPRITE: number;
  10929. }
  10930. /**
  10931. * This represents a scene component.
  10932. *
  10933. * This is used to decouple the dependency the scene is having on the different workloads like
  10934. * layers, post processes...
  10935. */
  10936. export interface ISceneComponent {
  10937. /**
  10938. * The name of the component. Each component must have a unique name.
  10939. */
  10940. name: string;
  10941. /**
  10942. * The scene the component belongs to.
  10943. */
  10944. scene: Scene;
  10945. /**
  10946. * Register the component to one instance of a scene.
  10947. */
  10948. register(): void;
  10949. /**
  10950. * Rebuilds the elements related to this component in case of
  10951. * context lost for instance.
  10952. */
  10953. rebuild(): void;
  10954. /**
  10955. * Disposes the component and the associated ressources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. /**
  10960. * This represents a SERIALIZABLE scene component.
  10961. *
  10962. * This extends Scene Component to add Serialization methods on top.
  10963. */
  10964. export interface ISceneSerializableComponent extends ISceneComponent {
  10965. /**
  10966. * Adds all the elements from the container to the scene
  10967. * @param container the container holding the elements
  10968. */
  10969. addFromContainer(container: AbstractScene): void;
  10970. /**
  10971. * Removes all the elements in the container from the scene
  10972. * @param container contains the elements to remove
  10973. * @param dispose if the removed element should be disposed (default: false)
  10974. */
  10975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10976. /**
  10977. * Serializes the component data to the specified json object
  10978. * @param serializationObject The object to serialize to
  10979. */
  10980. serialize(serializationObject: any): void;
  10981. }
  10982. /**
  10983. * Strong typing of a Mesh related stage step action
  10984. */
  10985. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10986. /**
  10987. * Strong typing of a Evaluate Sub Mesh related stage step action
  10988. */
  10989. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10990. /**
  10991. * Strong typing of a Active Mesh related stage step action
  10992. */
  10993. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10994. /**
  10995. * Strong typing of a Camera related stage step action
  10996. */
  10997. export type CameraStageAction = (camera: Camera) => void;
  10998. /**
  10999. * Strong typing of a Camera Frame buffer related stage step action
  11000. */
  11001. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11002. /**
  11003. * Strong typing of a Render Target related stage step action
  11004. */
  11005. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11006. /**
  11007. * Strong typing of a RenderingGroup related stage step action
  11008. */
  11009. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11010. /**
  11011. * Strong typing of a Mesh Render related stage step action
  11012. */
  11013. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11014. /**
  11015. * Strong typing of a simple stage step action
  11016. */
  11017. export type SimpleStageAction = () => void;
  11018. /**
  11019. * Strong typing of a render target action.
  11020. */
  11021. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11022. /**
  11023. * Strong typing of a pointer move action.
  11024. */
  11025. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11026. /**
  11027. * Strong typing of a pointer up/down action.
  11028. */
  11029. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11030. /**
  11031. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11032. * @hidden
  11033. */
  11034. export class Stage<T extends Function> extends Array<{
  11035. index: number;
  11036. component: ISceneComponent;
  11037. action: T;
  11038. }> {
  11039. /**
  11040. * Hide ctor from the rest of the world.
  11041. * @param items The items to add.
  11042. */
  11043. private constructor();
  11044. /**
  11045. * Creates a new Stage.
  11046. * @returns A new instance of a Stage
  11047. */
  11048. static Create<T extends Function>(): Stage<T>;
  11049. /**
  11050. * Registers a step in an ordered way in the targeted stage.
  11051. * @param index Defines the position to register the step in
  11052. * @param component Defines the component attached to the step
  11053. * @param action Defines the action to launch during the step
  11054. */
  11055. registerStep(index: number, component: ISceneComponent, action: T): void;
  11056. /**
  11057. * Clears all the steps from the stage.
  11058. */
  11059. clear(): void;
  11060. }
  11061. }
  11062. declare module BABYLON {
  11063. interface Scene {
  11064. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11065. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11067. /**
  11068. * All of the sprite managers added to this scene
  11069. * @see http://doc.babylonjs.com/babylon101/sprites
  11070. */
  11071. spriteManagers: Array<ISpriteManager>;
  11072. /**
  11073. * An event triggered when sprites rendering is about to start
  11074. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11075. */
  11076. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11077. /**
  11078. * An event triggered when sprites rendering is done
  11079. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11080. */
  11081. onAfterSpritesRenderingObservable: Observable<Scene>;
  11082. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11083. /** Launch a ray to try to pick a sprite in the scene
  11084. * @param x position on screen
  11085. * @param y position on screen
  11086. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11087. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11089. * @returns a PickingInfo
  11090. */
  11091. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11092. /** Use the given ray to pick a sprite in the scene
  11093. * @param ray The ray (in world space) to use to pick meshes
  11094. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11095. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11096. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11097. * @returns a PickingInfo
  11098. */
  11099. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11100. /**
  11101. * Force the sprite under the pointer
  11102. * @param sprite defines the sprite to use
  11103. */
  11104. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11105. /**
  11106. * Gets the sprite under the pointer
  11107. * @returns a Sprite or null if no sprite is under the pointer
  11108. */
  11109. getPointerOverSprite(): Nullable<Sprite>;
  11110. }
  11111. /**
  11112. * Defines the sprite scene component responsible to manage sprites
  11113. * in a given scene.
  11114. */
  11115. export class SpriteSceneComponent implements ISceneComponent {
  11116. /**
  11117. * The component name helpfull to identify the component in the list of scene components.
  11118. */
  11119. readonly name: string;
  11120. /**
  11121. * The scene the component belongs to.
  11122. */
  11123. scene: Scene;
  11124. /** @hidden */
  11125. private _spritePredicate;
  11126. /**
  11127. * Creates a new instance of the component for the given scene
  11128. * @param scene Defines the scene to register the component in
  11129. */
  11130. constructor(scene: Scene);
  11131. /**
  11132. * Registers the component in a given scene
  11133. */
  11134. register(): void;
  11135. /**
  11136. * Rebuilds the elements related to this component in case of
  11137. * context lost for instance.
  11138. */
  11139. rebuild(): void;
  11140. /**
  11141. * Disposes the component and the associated ressources.
  11142. */
  11143. dispose(): void;
  11144. private _pickSpriteButKeepRay;
  11145. private _pointerMove;
  11146. private _pointerDown;
  11147. private _pointerUp;
  11148. }
  11149. }
  11150. declare module BABYLON {
  11151. /** @hidden */
  11152. export var fogFragmentDeclaration: {
  11153. name: string;
  11154. shader: string;
  11155. };
  11156. }
  11157. declare module BABYLON {
  11158. /** @hidden */
  11159. export var fogFragment: {
  11160. name: string;
  11161. shader: string;
  11162. };
  11163. }
  11164. declare module BABYLON {
  11165. /** @hidden */
  11166. export var spritesPixelShader: {
  11167. name: string;
  11168. shader: string;
  11169. };
  11170. }
  11171. declare module BABYLON {
  11172. /** @hidden */
  11173. export var fogVertexDeclaration: {
  11174. name: string;
  11175. shader: string;
  11176. };
  11177. }
  11178. declare module BABYLON {
  11179. /** @hidden */
  11180. export var spritesVertexShader: {
  11181. name: string;
  11182. shader: string;
  11183. };
  11184. }
  11185. declare module BABYLON {
  11186. /**
  11187. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11188. */
  11189. export interface ISpriteManager extends IDisposable {
  11190. /**
  11191. * Restricts the camera to viewing objects with the same layerMask.
  11192. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11193. */
  11194. layerMask: number;
  11195. /**
  11196. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11197. */
  11198. isPickable: boolean;
  11199. /**
  11200. * Specifies the rendering group id for this mesh (0 by default)
  11201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * Defines the list of sprites managed by the manager.
  11206. */
  11207. sprites: Array<Sprite>;
  11208. /**
  11209. * Tests the intersection of a sprite with a specific ray.
  11210. * @param ray The ray we are sending to test the collision
  11211. * @param camera The camera space we are sending rays in
  11212. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11213. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11214. * @returns picking info or null.
  11215. */
  11216. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11217. /**
  11218. * Renders the list of sprites on screen.
  11219. */
  11220. render(): void;
  11221. }
  11222. /**
  11223. * Class used to manage multiple sprites on the same spritesheet
  11224. * @see http://doc.babylonjs.com/babylon101/sprites
  11225. */
  11226. export class SpriteManager implements ISpriteManager {
  11227. /** defines the manager's name */
  11228. name: string;
  11229. /** Gets the list of sprites */
  11230. sprites: Sprite[];
  11231. /** Gets or sets the rendering group id (0 by default) */
  11232. renderingGroupId: number;
  11233. /** Gets or sets camera layer mask */
  11234. layerMask: number;
  11235. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11236. fogEnabled: boolean;
  11237. /** Gets or sets a boolean indicating if the sprites are pickable */
  11238. isPickable: boolean;
  11239. /** Defines the default width of a cell in the spritesheet */
  11240. cellWidth: number;
  11241. /** Defines the default height of a cell in the spritesheet */
  11242. cellHeight: number;
  11243. /**
  11244. * An event triggered when the manager is disposed.
  11245. */
  11246. onDisposeObservable: Observable<SpriteManager>;
  11247. private _onDisposeObserver;
  11248. /**
  11249. * Callback called when the manager is disposed
  11250. */
  11251. onDispose: () => void;
  11252. private _capacity;
  11253. private _spriteTexture;
  11254. private _epsilon;
  11255. private _scene;
  11256. private _vertexData;
  11257. private _buffer;
  11258. private _vertexBuffers;
  11259. private _indexBuffer;
  11260. private _effectBase;
  11261. private _effectFog;
  11262. /**
  11263. * Gets or sets the spritesheet texture
  11264. */
  11265. texture: Texture;
  11266. /**
  11267. * Creates a new sprite manager
  11268. * @param name defines the manager's name
  11269. * @param imgUrl defines the sprite sheet url
  11270. * @param capacity defines the maximum allowed number of sprites
  11271. * @param cellSize defines the size of a sprite cell
  11272. * @param scene defines the hosting scene
  11273. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11274. * @param samplingMode defines the smapling mode to use with spritesheet
  11275. */
  11276. constructor(
  11277. /** defines the manager's name */
  11278. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11279. private _appendSpriteVertex;
  11280. /**
  11281. * Intersects the sprites with a ray
  11282. * @param ray defines the ray to intersect with
  11283. * @param camera defines the current active camera
  11284. * @param predicate defines a predicate used to select candidate sprites
  11285. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11286. * @returns null if no hit or a PickingInfo
  11287. */
  11288. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11289. /**
  11290. * Render all child sprites
  11291. */
  11292. render(): void;
  11293. /**
  11294. * Release associated resources
  11295. */
  11296. dispose(): void;
  11297. }
  11298. }
  11299. declare module BABYLON {
  11300. /**
  11301. * Class used to represent a sprite
  11302. * @see http://doc.babylonjs.com/babylon101/sprites
  11303. */
  11304. export class Sprite {
  11305. /** defines the name */
  11306. name: string;
  11307. /** Gets or sets the current world position */
  11308. position: Vector3;
  11309. /** Gets or sets the main color */
  11310. color: Color4;
  11311. /** Gets or sets the width */
  11312. width: number;
  11313. /** Gets or sets the height */
  11314. height: number;
  11315. /** Gets or sets rotation angle */
  11316. angle: number;
  11317. /** Gets or sets the cell index in the sprite sheet */
  11318. cellIndex: number;
  11319. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11320. invertU: number;
  11321. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11322. invertV: number;
  11323. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11324. disposeWhenFinishedAnimating: boolean;
  11325. /** Gets the list of attached animations */
  11326. animations: Animation[];
  11327. /** Gets or sets a boolean indicating if the sprite can be picked */
  11328. isPickable: boolean;
  11329. /**
  11330. * Gets or sets the associated action manager
  11331. */
  11332. actionManager: Nullable<ActionManager>;
  11333. private _animationStarted;
  11334. private _loopAnimation;
  11335. private _fromIndex;
  11336. private _toIndex;
  11337. private _delay;
  11338. private _direction;
  11339. private _manager;
  11340. private _time;
  11341. private _onAnimationEnd;
  11342. /**
  11343. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11344. */
  11345. isVisible: boolean;
  11346. /**
  11347. * Gets or sets the sprite size
  11348. */
  11349. size: number;
  11350. /**
  11351. * Creates a new Sprite
  11352. * @param name defines the name
  11353. * @param manager defines the manager
  11354. */
  11355. constructor(
  11356. /** defines the name */
  11357. name: string, manager: ISpriteManager);
  11358. /**
  11359. * Starts an animation
  11360. * @param from defines the initial key
  11361. * @param to defines the end key
  11362. * @param loop defines if the animation must loop
  11363. * @param delay defines the start delay (in ms)
  11364. * @param onAnimationEnd defines a callback to call when animation ends
  11365. */
  11366. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11367. /** Stops current animation (if any) */
  11368. stopAnimation(): void;
  11369. /** @hidden */ private _animate(deltaTime: number): void;
  11370. /** Release associated resources */
  11371. dispose(): void;
  11372. }
  11373. }
  11374. declare module BABYLON {
  11375. /**
  11376. * Information about the result of picking within a scene
  11377. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11378. */
  11379. export class PickingInfo {
  11380. /** @hidden */ private _pickingUnavailable: boolean;
  11381. /**
  11382. * If the pick collided with an object
  11383. */
  11384. hit: boolean;
  11385. /**
  11386. * Distance away where the pick collided
  11387. */
  11388. distance: number;
  11389. /**
  11390. * The location of pick collision
  11391. */
  11392. pickedPoint: Nullable<Vector3>;
  11393. /**
  11394. * The mesh corresponding the the pick collision
  11395. */
  11396. pickedMesh: Nullable<AbstractMesh>;
  11397. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11398. bu: number;
  11399. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11400. bv: number;
  11401. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11402. faceId: number;
  11403. /** Id of the the submesh that was picked */
  11404. subMeshId: number;
  11405. /** If a sprite was picked, this will be the sprite the pick collided with */
  11406. pickedSprite: Nullable<Sprite>;
  11407. /**
  11408. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11409. */
  11410. originMesh: Nullable<AbstractMesh>;
  11411. /**
  11412. * The ray that was used to perform the picking.
  11413. */
  11414. ray: Nullable<Ray>;
  11415. /**
  11416. * Gets the normal correspodning to the face the pick collided with
  11417. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11418. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11419. * @returns The normal correspodning to the face the pick collided with
  11420. */
  11421. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11422. /**
  11423. * Gets the texture coordinates of where the pick occured
  11424. * @returns the vector containing the coordnates of the texture
  11425. */
  11426. getTextureCoordinates(): Nullable<Vector2>;
  11427. }
  11428. }
  11429. declare module BABYLON {
  11430. /**
  11431. * Gather the list of pointer event types as constants.
  11432. */
  11433. export class PointerEventTypes {
  11434. /**
  11435. * 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.
  11436. */
  11437. static readonly POINTERDOWN: number;
  11438. /**
  11439. * The pointerup event is fired when a pointer is no longer active.
  11440. */
  11441. static readonly POINTERUP: number;
  11442. /**
  11443. * The pointermove event is fired when a pointer changes coordinates.
  11444. */
  11445. static readonly POINTERMOVE: number;
  11446. /**
  11447. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11448. */
  11449. static readonly POINTERWHEEL: number;
  11450. /**
  11451. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11452. */
  11453. static readonly POINTERPICK: number;
  11454. /**
  11455. * The pointertap event is fired when a the object has been touched and released without drag.
  11456. */
  11457. static readonly POINTERTAP: number;
  11458. /**
  11459. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11460. */
  11461. static readonly POINTERDOUBLETAP: number;
  11462. }
  11463. /**
  11464. * Base class of pointer info types.
  11465. */
  11466. export class PointerInfoBase {
  11467. /**
  11468. * Defines the type of event (PointerEventTypes)
  11469. */
  11470. type: number;
  11471. /**
  11472. * Defines the related dom event
  11473. */
  11474. event: PointerEvent | MouseWheelEvent;
  11475. /**
  11476. * Instantiates the base class of pointers info.
  11477. * @param type Defines the type of event (PointerEventTypes)
  11478. * @param event Defines the related dom event
  11479. */
  11480. constructor(
  11481. /**
  11482. * Defines the type of event (PointerEventTypes)
  11483. */
  11484. type: number,
  11485. /**
  11486. * Defines the related dom event
  11487. */
  11488. event: PointerEvent | MouseWheelEvent);
  11489. }
  11490. /**
  11491. * This class is used to store pointer related info for the onPrePointerObservable event.
  11492. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11493. */
  11494. export class PointerInfoPre extends PointerInfoBase {
  11495. /**
  11496. * Ray from a pointer if availible (eg. 6dof controller)
  11497. */
  11498. ray: Nullable<Ray>;
  11499. /**
  11500. * Defines the local position of the pointer on the canvas.
  11501. */
  11502. localPosition: Vector2;
  11503. /**
  11504. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11505. */
  11506. skipOnPointerObservable: boolean;
  11507. /**
  11508. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11509. * @param type Defines the type of event (PointerEventTypes)
  11510. * @param event Defines the related dom event
  11511. * @param localX Defines the local x coordinates of the pointer when the event occured
  11512. * @param localY Defines the local y coordinates of the pointer when the event occured
  11513. */
  11514. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11515. }
  11516. /**
  11517. * This type contains all the data related to a pointer event in Babylon.js.
  11518. * 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.
  11519. */
  11520. export class PointerInfo extends PointerInfoBase {
  11521. /**
  11522. * Defines the picking info associated to the info (if any)\
  11523. */
  11524. pickInfo: Nullable<PickingInfo>;
  11525. /**
  11526. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11527. * @param type Defines the type of event (PointerEventTypes)
  11528. * @param event Defines the related dom event
  11529. * @param pickInfo Defines the picking info associated to the info (if any)\
  11530. */
  11531. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11532. /**
  11533. * Defines the picking info associated to the info (if any)\
  11534. */
  11535. pickInfo: Nullable<PickingInfo>);
  11536. }
  11537. /**
  11538. * Data relating to a touch event on the screen.
  11539. */
  11540. export interface PointerTouch {
  11541. /**
  11542. * X coordinate of touch.
  11543. */
  11544. x: number;
  11545. /**
  11546. * Y coordinate of touch.
  11547. */
  11548. y: number;
  11549. /**
  11550. * Id of touch. Unique for each finger.
  11551. */
  11552. pointerId: number;
  11553. /**
  11554. * Event type passed from DOM.
  11555. */
  11556. type: any;
  11557. }
  11558. }
  11559. declare module BABYLON {
  11560. /**
  11561. * Manage the mouse inputs to control the movement of a free camera.
  11562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11563. */
  11564. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11565. /**
  11566. * Define if touch is enabled in the mouse input
  11567. */
  11568. touchEnabled: boolean;
  11569. /**
  11570. * Defines the camera the input is attached to.
  11571. */
  11572. camera: FreeCamera;
  11573. /**
  11574. * Defines the buttons associated with the input to handle camera move.
  11575. */
  11576. buttons: number[];
  11577. /**
  11578. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11579. */
  11580. angularSensibility: number;
  11581. private _pointerInput;
  11582. private _onMouseMove;
  11583. private _observer;
  11584. private previousPosition;
  11585. /**
  11586. * Observable for when a pointer move event occurs containing the move offset
  11587. */
  11588. onPointerMovedObservable: Observable<{
  11589. offsetX: number;
  11590. offsetY: number;
  11591. }>;
  11592. /**
  11593. * @hidden
  11594. * If the camera should be rotated automatically based on pointer movement
  11595. */ private _allowCameraRotation: boolean;
  11596. /**
  11597. * Manage the mouse inputs to control the movement of a free camera.
  11598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11599. * @param touchEnabled Defines if touch is enabled or not
  11600. */
  11601. constructor(
  11602. /**
  11603. * Define if touch is enabled in the mouse input
  11604. */
  11605. touchEnabled?: boolean);
  11606. /**
  11607. * Attach the input controls to a specific dom element to get the input from.
  11608. * @param element Defines the element the controls should be listened from
  11609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11610. */
  11611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11612. /**
  11613. * Called on JS contextmenu event.
  11614. * Override this method to provide functionality.
  11615. */
  11616. protected onContextMenu(evt: PointerEvent): void;
  11617. /**
  11618. * Detach the current controls from the specified dom element.
  11619. * @param element Defines the element to stop listening the inputs from
  11620. */
  11621. detachControl(element: Nullable<HTMLElement>): void;
  11622. /**
  11623. * Gets the class name of the current intput.
  11624. * @returns the class name
  11625. */
  11626. getClassName(): string;
  11627. /**
  11628. * Get the friendly name associated with the input class.
  11629. * @returns the input friendly name
  11630. */
  11631. getSimpleName(): string;
  11632. }
  11633. }
  11634. declare module BABYLON {
  11635. /**
  11636. * Manage the touch inputs to control the movement of a free camera.
  11637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11638. */
  11639. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11640. /**
  11641. * Defines the camera the input is attached to.
  11642. */
  11643. camera: FreeCamera;
  11644. /**
  11645. * Defines the touch sensibility for rotation.
  11646. * The higher the faster.
  11647. */
  11648. touchAngularSensibility: number;
  11649. /**
  11650. * Defines the touch sensibility for move.
  11651. * The higher the faster.
  11652. */
  11653. touchMoveSensibility: number;
  11654. private _offsetX;
  11655. private _offsetY;
  11656. private _pointerPressed;
  11657. private _pointerInput;
  11658. private _observer;
  11659. private _onLostFocus;
  11660. /**
  11661. * Attach the input controls to a specific dom element to get the input from.
  11662. * @param element Defines the element the controls should be listened from
  11663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11664. */
  11665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11666. /**
  11667. * Detach the current controls from the specified dom element.
  11668. * @param element Defines the element to stop listening the inputs from
  11669. */
  11670. detachControl(element: Nullable<HTMLElement>): void;
  11671. /**
  11672. * Update the current camera state depending on the inputs that have been used this frame.
  11673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11674. */
  11675. checkInputs(): void;
  11676. /**
  11677. * Gets the class name of the current intput.
  11678. * @returns the class name
  11679. */
  11680. getClassName(): string;
  11681. /**
  11682. * Get the friendly name associated with the input class.
  11683. * @returns the input friendly name
  11684. */
  11685. getSimpleName(): string;
  11686. }
  11687. }
  11688. declare module BABYLON {
  11689. /**
  11690. * Default Inputs manager for the FreeCamera.
  11691. * It groups all the default supported inputs for ease of use.
  11692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11693. */
  11694. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11695. /**
  11696. * @hidden
  11697. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11698. /**
  11699. * Instantiates a new FreeCameraInputsManager.
  11700. * @param camera Defines the camera the inputs belong to
  11701. */
  11702. constructor(camera: FreeCamera);
  11703. /**
  11704. * Add keyboard input support to the input manager.
  11705. * @returns the current input manager
  11706. */
  11707. addKeyboard(): FreeCameraInputsManager;
  11708. /**
  11709. * Add mouse input support to the input manager.
  11710. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11711. * @returns the current input manager
  11712. */
  11713. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11714. /**
  11715. * Removes the mouse input support from the manager
  11716. * @returns the current input manager
  11717. */
  11718. removeMouse(): FreeCameraInputsManager;
  11719. /**
  11720. * Add touch input support to the input manager.
  11721. * @returns the current input manager
  11722. */
  11723. addTouch(): FreeCameraInputsManager;
  11724. /**
  11725. * Remove all attached input methods from a camera
  11726. */
  11727. clear(): void;
  11728. }
  11729. }
  11730. declare module BABYLON {
  11731. /**
  11732. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11733. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11734. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11735. */
  11736. export class FreeCamera extends TargetCamera {
  11737. /**
  11738. * Define the collision ellipsoid of the camera.
  11739. * This is helpful to simulate a camera body like the player body around the camera
  11740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11741. */
  11742. ellipsoid: Vector3;
  11743. /**
  11744. * Define an offset for the position of the ellipsoid around the camera.
  11745. * This can be helpful to determine the center of the body near the gravity center of the body
  11746. * instead of its head.
  11747. */
  11748. ellipsoidOffset: Vector3;
  11749. /**
  11750. * Enable or disable collisions of the camera with the rest of the scene objects.
  11751. */
  11752. checkCollisions: boolean;
  11753. /**
  11754. * Enable or disable gravity on the camera.
  11755. */
  11756. applyGravity: boolean;
  11757. /**
  11758. * Define the input manager associated to the camera.
  11759. */
  11760. inputs: FreeCameraInputsManager;
  11761. /**
  11762. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11763. * Higher values reduce sensitivity.
  11764. */
  11765. /**
  11766. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11767. * Higher values reduce sensitivity.
  11768. */
  11769. angularSensibility: number;
  11770. /**
  11771. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11772. */
  11773. keysUp: number[];
  11774. /**
  11775. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11776. */
  11777. keysDown: number[];
  11778. /**
  11779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11780. */
  11781. keysLeft: number[];
  11782. /**
  11783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11784. */
  11785. keysRight: number[];
  11786. /**
  11787. * Event raised when the camera collide with a mesh in the scene.
  11788. */
  11789. onCollide: (collidedMesh: AbstractMesh) => void;
  11790. private _collider;
  11791. private _needMoveForGravity;
  11792. private _oldPosition;
  11793. private _diffPosition;
  11794. private _newPosition;
  11795. /** @hidden */ private _localDirection: Vector3;
  11796. /** @hidden */ private _transformedDirection: Vector3;
  11797. /**
  11798. * Instantiates a Free Camera.
  11799. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11800. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11802. * @param name Define the name of the camera in the scene
  11803. * @param position Define the start position of the camera in the scene
  11804. * @param scene Define the scene the camera belongs to
  11805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11806. */
  11807. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11808. /**
  11809. * Attached controls to the current camera.
  11810. * @param element Defines the element the controls should be listened from
  11811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11812. */
  11813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11814. /**
  11815. * Detach the current controls from the camera.
  11816. * The camera will stop reacting to inputs.
  11817. * @param element Defines the element to stop listening the inputs from
  11818. */
  11819. detachControl(element: HTMLElement): void;
  11820. private _collisionMask;
  11821. /**
  11822. * Define a collision mask to limit the list of object the camera can collide with
  11823. */
  11824. collisionMask: number;
  11825. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11826. private _onCollisionPositionChange;
  11827. /** @hidden */ private _checkInputs(): void;
  11828. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11829. /** @hidden */ private _updatePosition(): void;
  11830. /**
  11831. * Destroy the camera and release the current resources hold by it.
  11832. */
  11833. dispose(): void;
  11834. /**
  11835. * Gets the current object class name.
  11836. * @return the class name
  11837. */
  11838. getClassName(): string;
  11839. }
  11840. }
  11841. declare module BABYLON {
  11842. /**
  11843. * Represents a gamepad control stick position
  11844. */
  11845. export class StickValues {
  11846. /**
  11847. * The x component of the control stick
  11848. */
  11849. x: number;
  11850. /**
  11851. * The y component of the control stick
  11852. */
  11853. y: number;
  11854. /**
  11855. * Initializes the gamepad x and y control stick values
  11856. * @param x The x component of the gamepad control stick value
  11857. * @param y The y component of the gamepad control stick value
  11858. */
  11859. constructor(
  11860. /**
  11861. * The x component of the control stick
  11862. */
  11863. x: number,
  11864. /**
  11865. * The y component of the control stick
  11866. */
  11867. y: number);
  11868. }
  11869. /**
  11870. * An interface which manages callbacks for gamepad button changes
  11871. */
  11872. export interface GamepadButtonChanges {
  11873. /**
  11874. * Called when a gamepad has been changed
  11875. */
  11876. changed: boolean;
  11877. /**
  11878. * Called when a gamepad press event has been triggered
  11879. */
  11880. pressChanged: boolean;
  11881. /**
  11882. * Called when a touch event has been triggered
  11883. */
  11884. touchChanged: boolean;
  11885. /**
  11886. * Called when a value has changed
  11887. */
  11888. valueChanged: boolean;
  11889. }
  11890. /**
  11891. * Represents a gamepad
  11892. */
  11893. export class Gamepad {
  11894. /**
  11895. * The id of the gamepad
  11896. */
  11897. id: string;
  11898. /**
  11899. * The index of the gamepad
  11900. */
  11901. index: number;
  11902. /**
  11903. * The browser gamepad
  11904. */
  11905. browserGamepad: any;
  11906. /**
  11907. * Specifies what type of gamepad this represents
  11908. */
  11909. type: number;
  11910. private _leftStick;
  11911. private _rightStick;
  11912. /** @hidden */ private _isConnected: boolean;
  11913. private _leftStickAxisX;
  11914. private _leftStickAxisY;
  11915. private _rightStickAxisX;
  11916. private _rightStickAxisY;
  11917. /**
  11918. * Triggered when the left control stick has been changed
  11919. */
  11920. private _onleftstickchanged;
  11921. /**
  11922. * Triggered when the right control stick has been changed
  11923. */
  11924. private _onrightstickchanged;
  11925. /**
  11926. * Represents a gamepad controller
  11927. */
  11928. static GAMEPAD: number;
  11929. /**
  11930. * Represents a generic controller
  11931. */
  11932. static GENERIC: number;
  11933. /**
  11934. * Represents an XBox controller
  11935. */
  11936. static XBOX: number;
  11937. /**
  11938. * Represents a pose-enabled controller
  11939. */
  11940. static POSE_ENABLED: number;
  11941. /**
  11942. * Specifies whether the left control stick should be Y-inverted
  11943. */
  11944. protected _invertLeftStickY: boolean;
  11945. /**
  11946. * Specifies if the gamepad has been connected
  11947. */
  11948. readonly isConnected: boolean;
  11949. /**
  11950. * Initializes the gamepad
  11951. * @param id The id of the gamepad
  11952. * @param index The index of the gamepad
  11953. * @param browserGamepad The browser gamepad
  11954. * @param leftStickX The x component of the left joystick
  11955. * @param leftStickY The y component of the left joystick
  11956. * @param rightStickX The x component of the right joystick
  11957. * @param rightStickY The y component of the right joystick
  11958. */
  11959. constructor(
  11960. /**
  11961. * The id of the gamepad
  11962. */
  11963. id: string,
  11964. /**
  11965. * The index of the gamepad
  11966. */
  11967. index: number,
  11968. /**
  11969. * The browser gamepad
  11970. */
  11971. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11972. /**
  11973. * Callback triggered when the left joystick has changed
  11974. * @param callback
  11975. */
  11976. onleftstickchanged(callback: (values: StickValues) => void): void;
  11977. /**
  11978. * Callback triggered when the right joystick has changed
  11979. * @param callback
  11980. */
  11981. onrightstickchanged(callback: (values: StickValues) => void): void;
  11982. /**
  11983. * Gets the left joystick
  11984. */
  11985. /**
  11986. * Sets the left joystick values
  11987. */
  11988. leftStick: StickValues;
  11989. /**
  11990. * Gets the right joystick
  11991. */
  11992. /**
  11993. * Sets the right joystick value
  11994. */
  11995. rightStick: StickValues;
  11996. /**
  11997. * Updates the gamepad joystick positions
  11998. */
  11999. update(): void;
  12000. /**
  12001. * Disposes the gamepad
  12002. */
  12003. dispose(): void;
  12004. }
  12005. /**
  12006. * Represents a generic gamepad
  12007. */
  12008. export class GenericPad extends Gamepad {
  12009. private _buttons;
  12010. private _onbuttondown;
  12011. private _onbuttonup;
  12012. /**
  12013. * Observable triggered when a button has been pressed
  12014. */
  12015. onButtonDownObservable: Observable<number>;
  12016. /**
  12017. * Observable triggered when a button has been released
  12018. */
  12019. onButtonUpObservable: Observable<number>;
  12020. /**
  12021. * Callback triggered when a button has been pressed
  12022. * @param callback Called when a button has been pressed
  12023. */
  12024. onbuttondown(callback: (buttonPressed: number) => void): void;
  12025. /**
  12026. * Callback triggered when a button has been released
  12027. * @param callback Called when a button has been released
  12028. */
  12029. onbuttonup(callback: (buttonReleased: number) => void): void;
  12030. /**
  12031. * Initializes the generic gamepad
  12032. * @param id The id of the generic gamepad
  12033. * @param index The index of the generic gamepad
  12034. * @param browserGamepad The browser gamepad
  12035. */
  12036. constructor(id: string, index: number, browserGamepad: any);
  12037. private _setButtonValue;
  12038. /**
  12039. * Updates the generic gamepad
  12040. */
  12041. update(): void;
  12042. /**
  12043. * Disposes the generic gamepad
  12044. */
  12045. dispose(): void;
  12046. }
  12047. }
  12048. declare module BABYLON {
  12049. interface Engine {
  12050. /**
  12051. * Creates a raw texture
  12052. * @param data defines the data to store in the texture
  12053. * @param width defines the width of the texture
  12054. * @param height defines the height of the texture
  12055. * @param format defines the format of the data
  12056. * @param generateMipMaps defines if the engine should generate the mip levels
  12057. * @param invertY defines if data must be stored with Y axis inverted
  12058. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12059. * @param compression defines the compression used (null by default)
  12060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12061. * @returns the raw texture inside an InternalTexture
  12062. */
  12063. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12064. /**
  12065. * Update a raw texture
  12066. * @param texture defines the texture to update
  12067. * @param data defines the data to store in the texture
  12068. * @param format defines the format of the data
  12069. * @param invertY defines if data must be stored with Y axis inverted
  12070. */
  12071. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12072. /**
  12073. * Update a raw texture
  12074. * @param texture defines the texture to update
  12075. * @param data defines the data to store in the texture
  12076. * @param format defines the format of the data
  12077. * @param invertY defines if data must be stored with Y axis inverted
  12078. * @param compression defines the compression used (null by default)
  12079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12080. */
  12081. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12082. /**
  12083. * Creates a new raw cube texture
  12084. * @param data defines the array of data to use to create each face
  12085. * @param size defines the size of the textures
  12086. * @param format defines the format of the data
  12087. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12088. * @param generateMipMaps defines if the engine should generate the mip levels
  12089. * @param invertY defines if data must be stored with Y axis inverted
  12090. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12091. * @param compression defines the compression used (null by default)
  12092. * @returns the cube texture as an InternalTexture
  12093. */
  12094. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12095. /**
  12096. * Update a raw cube texture
  12097. * @param texture defines the texture to udpdate
  12098. * @param data defines the data to store
  12099. * @param format defines the data format
  12100. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12101. * @param invertY defines if data must be stored with Y axis inverted
  12102. */
  12103. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12104. /**
  12105. * Update a raw cube texture
  12106. * @param texture defines the texture to udpdate
  12107. * @param data defines the data to store
  12108. * @param format defines the data format
  12109. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12110. * @param invertY defines if data must be stored with Y axis inverted
  12111. * @param compression defines the compression used (null by default)
  12112. */
  12113. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12114. /**
  12115. * Update a raw cube texture
  12116. * @param texture defines the texture to udpdate
  12117. * @param data defines the data to store
  12118. * @param format defines the data format
  12119. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12120. * @param invertY defines if data must be stored with Y axis inverted
  12121. * @param compression defines the compression used (null by default)
  12122. * @param level defines which level of the texture to update
  12123. */
  12124. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12125. /**
  12126. * Creates a new raw cube texture from a specified url
  12127. * @param url defines the url where the data is located
  12128. * @param scene defines the current scene
  12129. * @param size defines the size of the textures
  12130. * @param format defines the format of the data
  12131. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12132. * @param noMipmap defines if the engine should avoid generating the mip levels
  12133. * @param callback defines a callback used to extract texture data from loaded data
  12134. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12135. * @param onLoad defines a callback called when texture is loaded
  12136. * @param onError defines a callback called if there is an error
  12137. * @returns the cube texture as an InternalTexture
  12138. */
  12139. 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;
  12140. /**
  12141. * Creates a new raw cube texture from a specified url
  12142. * @param url defines the url where the data is located
  12143. * @param scene defines the current scene
  12144. * @param size defines the size of the textures
  12145. * @param format defines the format of the data
  12146. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12147. * @param noMipmap defines if the engine should avoid generating the mip levels
  12148. * @param callback defines a callback used to extract texture data from loaded data
  12149. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12150. * @param onLoad defines a callback called when texture is loaded
  12151. * @param onError defines a callback called if there is an error
  12152. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12153. * @param invertY defines if data must be stored with Y axis inverted
  12154. * @returns the cube texture as an InternalTexture
  12155. */
  12156. 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;
  12157. /**
  12158. * Creates a new raw 3D texture
  12159. * @param data defines the data used to create the texture
  12160. * @param width defines the width of the texture
  12161. * @param height defines the height of the texture
  12162. * @param depth defines the depth of the texture
  12163. * @param format defines the format of the texture
  12164. * @param generateMipMaps defines if the engine must generate mip levels
  12165. * @param invertY defines if data must be stored with Y axis inverted
  12166. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12167. * @param compression defines the compressed used (can be null)
  12168. * @param textureType defines the compressed used (can be null)
  12169. * @returns a new raw 3D texture (stored in an InternalTexture)
  12170. */
  12171. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12172. /**
  12173. * Update a raw 3D texture
  12174. * @param texture defines the texture to update
  12175. * @param data defines the data to store
  12176. * @param format defines the data format
  12177. * @param invertY defines if data must be stored with Y axis inverted
  12178. */
  12179. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12180. /**
  12181. * Update a raw 3D texture
  12182. * @param texture defines the texture to update
  12183. * @param data defines the data to store
  12184. * @param format defines the data format
  12185. * @param invertY defines if data must be stored with Y axis inverted
  12186. * @param compression defines the used compression (can be null)
  12187. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12188. */
  12189. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12190. }
  12191. }
  12192. declare module BABYLON {
  12193. /**
  12194. * Raw texture can help creating a texture directly from an array of data.
  12195. * This can be super useful if you either get the data from an uncompressed source or
  12196. * if you wish to create your texture pixel by pixel.
  12197. */
  12198. export class RawTexture extends Texture {
  12199. /**
  12200. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12201. */
  12202. format: number;
  12203. private _engine;
  12204. /**
  12205. * Instantiates a new RawTexture.
  12206. * Raw texture can help creating a texture directly from an array of data.
  12207. * This can be super useful if you either get the data from an uncompressed source or
  12208. * if you wish to create your texture pixel by pixel.
  12209. * @param data define the array of data to use to create the texture
  12210. * @param width define the width of the texture
  12211. * @param height define the height of the texture
  12212. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12213. * @param scene define the scene the texture belongs to
  12214. * @param generateMipMaps define whether mip maps should be generated or not
  12215. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12216. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12217. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12218. */
  12219. constructor(data: ArrayBufferView, width: number, height: number,
  12220. /**
  12221. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12222. */
  12223. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12224. /**
  12225. * Updates the texture underlying data.
  12226. * @param data Define the new data of the texture
  12227. */
  12228. update(data: ArrayBufferView): void;
  12229. /**
  12230. * Creates a luminance texture from some data.
  12231. * @param data Define the texture data
  12232. * @param width Define the width of the texture
  12233. * @param height Define the height of the texture
  12234. * @param scene Define the scene the texture belongs to
  12235. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12236. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12237. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12238. * @returns the luminance texture
  12239. */
  12240. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12241. /**
  12242. * Creates a luminance alpha texture from some data.
  12243. * @param data Define the texture data
  12244. * @param width Define the width of the texture
  12245. * @param height Define the height of the texture
  12246. * @param scene Define the scene the texture belongs to
  12247. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12250. * @returns the luminance alpha texture
  12251. */
  12252. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12253. /**
  12254. * Creates an alpha texture from some data.
  12255. * @param data Define the texture data
  12256. * @param width Define the width of the texture
  12257. * @param height Define the height of the texture
  12258. * @param scene Define the scene the texture belongs to
  12259. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12260. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12261. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12262. * @returns the alpha texture
  12263. */
  12264. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12265. /**
  12266. * Creates a RGB texture from some data.
  12267. * @param data Define the texture data
  12268. * @param width Define the width of the texture
  12269. * @param height Define the height of the texture
  12270. * @param scene Define the scene the texture belongs to
  12271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12274. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12275. * @returns the RGB alpha texture
  12276. */
  12277. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12278. /**
  12279. * Creates a RGBA texture from some data.
  12280. * @param data Define the texture data
  12281. * @param width Define the width of the texture
  12282. * @param height Define the height of the texture
  12283. * @param scene Define the scene the texture belongs to
  12284. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12285. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12286. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12287. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12288. * @returns the RGBA texture
  12289. */
  12290. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12291. /**
  12292. * Creates a R texture from some data.
  12293. * @param data Define the texture data
  12294. * @param width Define the width of the texture
  12295. * @param height Define the height of the texture
  12296. * @param scene Define the scene the texture belongs to
  12297. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12298. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12299. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12300. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12301. * @returns the R texture
  12302. */
  12303. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12304. }
  12305. }
  12306. declare module BABYLON {
  12307. /**
  12308. * Interface for the size containing width and height
  12309. */
  12310. export interface ISize {
  12311. /**
  12312. * Width
  12313. */
  12314. width: number;
  12315. /**
  12316. * Heighht
  12317. */
  12318. height: number;
  12319. }
  12320. /**
  12321. * Size containing widht and height
  12322. */
  12323. export class Size implements ISize {
  12324. /**
  12325. * Width
  12326. */
  12327. width: number;
  12328. /**
  12329. * Height
  12330. */
  12331. height: number;
  12332. /**
  12333. * Creates a Size object from the given width and height (floats).
  12334. * @param width width of the new size
  12335. * @param height height of the new size
  12336. */
  12337. constructor(width: number, height: number);
  12338. /**
  12339. * Returns a string with the Size width and height
  12340. * @returns a string with the Size width and height
  12341. */
  12342. toString(): string;
  12343. /**
  12344. * "Size"
  12345. * @returns the string "Size"
  12346. */
  12347. getClassName(): string;
  12348. /**
  12349. * Returns the Size hash code.
  12350. * @returns a hash code for a unique width and height
  12351. */
  12352. getHashCode(): number;
  12353. /**
  12354. * Updates the current size from the given one.
  12355. * @param src the given size
  12356. */
  12357. copyFrom(src: Size): void;
  12358. /**
  12359. * Updates in place the current Size from the given floats.
  12360. * @param width width of the new size
  12361. * @param height height of the new size
  12362. * @returns the updated Size.
  12363. */
  12364. copyFromFloats(width: number, height: number): Size;
  12365. /**
  12366. * Updates in place the current Size from the given floats.
  12367. * @param width width to set
  12368. * @param height height to set
  12369. * @returns the updated Size.
  12370. */
  12371. set(width: number, height: number): Size;
  12372. /**
  12373. * Multiplies the width and height by numbers
  12374. * @param w factor to multiple the width by
  12375. * @param h factor to multiple the height by
  12376. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12377. */
  12378. multiplyByFloats(w: number, h: number): Size;
  12379. /**
  12380. * Clones the size
  12381. * @returns a new Size copied from the given one.
  12382. */
  12383. clone(): Size;
  12384. /**
  12385. * True if the current Size and the given one width and height are strictly equal.
  12386. * @param other the other size to compare against
  12387. * @returns True if the current Size and the given one width and height are strictly equal.
  12388. */
  12389. equals(other: Size): boolean;
  12390. /**
  12391. * The surface of the Size : width * height (float).
  12392. */
  12393. readonly surface: number;
  12394. /**
  12395. * Create a new size of zero
  12396. * @returns a new Size set to (0.0, 0.0)
  12397. */
  12398. static Zero(): Size;
  12399. /**
  12400. * Sums the width and height of two sizes
  12401. * @param otherSize size to add to this size
  12402. * @returns a new Size set as the addition result of the current Size and the given one.
  12403. */
  12404. add(otherSize: Size): Size;
  12405. /**
  12406. * Subtracts the width and height of two
  12407. * @param otherSize size to subtract to this size
  12408. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12409. */
  12410. subtract(otherSize: Size): Size;
  12411. /**
  12412. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12413. * @param start starting size to lerp between
  12414. * @param end end size to lerp between
  12415. * @param amount amount to lerp between the start and end values
  12416. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12417. */
  12418. static Lerp(start: Size, end: Size, amount: number): Size;
  12419. }
  12420. }
  12421. declare module BABYLON {
  12422. /**
  12423. * Defines a runtime animation
  12424. */
  12425. export class RuntimeAnimation {
  12426. private _events;
  12427. /**
  12428. * The current frame of the runtime animation
  12429. */
  12430. private _currentFrame;
  12431. /**
  12432. * The animation used by the runtime animation
  12433. */
  12434. private _animation;
  12435. /**
  12436. * The target of the runtime animation
  12437. */
  12438. private _target;
  12439. /**
  12440. * The initiating animatable
  12441. */
  12442. private _host;
  12443. /**
  12444. * The original value of the runtime animation
  12445. */
  12446. private _originalValue;
  12447. /**
  12448. * The original blend value of the runtime animation
  12449. */
  12450. private _originalBlendValue;
  12451. /**
  12452. * The offsets cache of the runtime animation
  12453. */
  12454. private _offsetsCache;
  12455. /**
  12456. * The high limits cache of the runtime animation
  12457. */
  12458. private _highLimitsCache;
  12459. /**
  12460. * Specifies if the runtime animation has been stopped
  12461. */
  12462. private _stopped;
  12463. /**
  12464. * The blending factor of the runtime animation
  12465. */
  12466. private _blendingFactor;
  12467. /**
  12468. * The BabylonJS scene
  12469. */
  12470. private _scene;
  12471. /**
  12472. * The current value of the runtime animation
  12473. */
  12474. private _currentValue;
  12475. /** @hidden */ private _animationState: _IAnimationState;
  12476. /**
  12477. * The active target of the runtime animation
  12478. */
  12479. private _activeTargets;
  12480. private _currentActiveTarget;
  12481. private _directTarget;
  12482. /**
  12483. * The target path of the runtime animation
  12484. */
  12485. private _targetPath;
  12486. /**
  12487. * The weight of the runtime animation
  12488. */
  12489. private _weight;
  12490. /**
  12491. * The ratio offset of the runtime animation
  12492. */
  12493. private _ratioOffset;
  12494. /**
  12495. * The previous delay of the runtime animation
  12496. */
  12497. private _previousDelay;
  12498. /**
  12499. * The previous ratio of the runtime animation
  12500. */
  12501. private _previousRatio;
  12502. private _enableBlending;
  12503. private _keys;
  12504. private _minFrame;
  12505. private _maxFrame;
  12506. private _minValue;
  12507. private _maxValue;
  12508. private _targetIsArray;
  12509. /**
  12510. * Gets the current frame of the runtime animation
  12511. */
  12512. readonly currentFrame: number;
  12513. /**
  12514. * Gets the weight of the runtime animation
  12515. */
  12516. readonly weight: number;
  12517. /**
  12518. * Gets the current value of the runtime animation
  12519. */
  12520. readonly currentValue: any;
  12521. /**
  12522. * Gets the target path of the runtime animation
  12523. */
  12524. readonly targetPath: string;
  12525. /**
  12526. * Gets the actual target of the runtime animation
  12527. */
  12528. readonly target: any;
  12529. /** @hidden */ private _onLoop: () => void;
  12530. /**
  12531. * Create a new RuntimeAnimation object
  12532. * @param target defines the target of the animation
  12533. * @param animation defines the source animation object
  12534. * @param scene defines the hosting scene
  12535. * @param host defines the initiating Animatable
  12536. */
  12537. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12538. private _preparePath;
  12539. /**
  12540. * Gets the animation from the runtime animation
  12541. */
  12542. readonly animation: Animation;
  12543. /**
  12544. * Resets the runtime animation to the beginning
  12545. * @param restoreOriginal defines whether to restore the target property to the original value
  12546. */
  12547. reset(restoreOriginal?: boolean): void;
  12548. /**
  12549. * Specifies if the runtime animation is stopped
  12550. * @returns Boolean specifying if the runtime animation is stopped
  12551. */
  12552. isStopped(): boolean;
  12553. /**
  12554. * Disposes of the runtime animation
  12555. */
  12556. dispose(): void;
  12557. /**
  12558. * Apply the interpolated value to the target
  12559. * @param currentValue defines the value computed by the animation
  12560. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12561. */
  12562. setValue(currentValue: any, weight: number): void;
  12563. private _getOriginalValues;
  12564. private _setValue;
  12565. /**
  12566. * Gets the loop pmode of the runtime animation
  12567. * @returns Loop Mode
  12568. */
  12569. private _getCorrectLoopMode;
  12570. /**
  12571. * Move the current animation to a given frame
  12572. * @param frame defines the frame to move to
  12573. */
  12574. goToFrame(frame: number): void;
  12575. /**
  12576. * @hidden Internal use only
  12577. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12578. /**
  12579. * Execute the current animation
  12580. * @param delay defines the delay to add to the current frame
  12581. * @param from defines the lower bound of the animation range
  12582. * @param to defines the upper bound of the animation range
  12583. * @param loop defines if the current animation must loop
  12584. * @param speedRatio defines the current speed ratio
  12585. * @param weight defines the weight of the animation (default is -1 so no weight)
  12586. * @param onLoop optional callback called when animation loops
  12587. * @returns a boolean indicating if the animation is running
  12588. */
  12589. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12590. }
  12591. }
  12592. declare module BABYLON {
  12593. /**
  12594. * Class used to store an actual running animation
  12595. */
  12596. export class Animatable {
  12597. /** defines the target object */
  12598. target: any;
  12599. /** defines the starting frame number (default is 0) */
  12600. fromFrame: number;
  12601. /** defines the ending frame number (default is 100) */
  12602. toFrame: number;
  12603. /** defines if the animation must loop (default is false) */
  12604. loopAnimation: boolean;
  12605. /** defines a callback to call when animation ends if it is not looping */
  12606. onAnimationEnd?: (() => void) | null | undefined;
  12607. /** defines a callback to call when animation loops */
  12608. onAnimationLoop?: (() => void) | null | undefined;
  12609. private _localDelayOffset;
  12610. private _pausedDelay;
  12611. private _runtimeAnimations;
  12612. private _paused;
  12613. private _scene;
  12614. private _speedRatio;
  12615. private _weight;
  12616. private _syncRoot;
  12617. /**
  12618. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12619. * This will only apply for non looping animation (default is true)
  12620. */
  12621. disposeOnEnd: boolean;
  12622. /**
  12623. * Gets a boolean indicating if the animation has started
  12624. */
  12625. animationStarted: boolean;
  12626. /**
  12627. * Observer raised when the animation ends
  12628. */
  12629. onAnimationEndObservable: Observable<Animatable>;
  12630. /**
  12631. * Observer raised when the animation loops
  12632. */
  12633. onAnimationLoopObservable: Observable<Animatable>;
  12634. /**
  12635. * Gets the root Animatable used to synchronize and normalize animations
  12636. */
  12637. readonly syncRoot: Nullable<Animatable>;
  12638. /**
  12639. * Gets the current frame of the first RuntimeAnimation
  12640. * Used to synchronize Animatables
  12641. */
  12642. readonly masterFrame: number;
  12643. /**
  12644. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12645. */
  12646. weight: number;
  12647. /**
  12648. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12649. */
  12650. speedRatio: number;
  12651. /**
  12652. * Creates a new Animatable
  12653. * @param scene defines the hosting scene
  12654. * @param target defines the target object
  12655. * @param fromFrame defines the starting frame number (default is 0)
  12656. * @param toFrame defines the ending frame number (default is 100)
  12657. * @param loopAnimation defines if the animation must loop (default is false)
  12658. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12659. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12660. * @param animations defines a group of animation to add to the new Animatable
  12661. * @param onAnimationLoop defines a callback to call when animation loops
  12662. */
  12663. constructor(scene: Scene,
  12664. /** defines the target object */
  12665. target: any,
  12666. /** defines the starting frame number (default is 0) */
  12667. fromFrame?: number,
  12668. /** defines the ending frame number (default is 100) */
  12669. toFrame?: number,
  12670. /** defines if the animation must loop (default is false) */
  12671. loopAnimation?: boolean, speedRatio?: number,
  12672. /** defines a callback to call when animation ends if it is not looping */
  12673. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12674. /** defines a callback to call when animation loops */
  12675. onAnimationLoop?: (() => void) | null | undefined);
  12676. /**
  12677. * Synchronize and normalize current Animatable with a source Animatable
  12678. * This is useful when using animation weights and when animations are not of the same length
  12679. * @param root defines the root Animatable to synchronize with
  12680. * @returns the current Animatable
  12681. */
  12682. syncWith(root: Animatable): Animatable;
  12683. /**
  12684. * Gets the list of runtime animations
  12685. * @returns an array of RuntimeAnimation
  12686. */
  12687. getAnimations(): RuntimeAnimation[];
  12688. /**
  12689. * Adds more animations to the current animatable
  12690. * @param target defines the target of the animations
  12691. * @param animations defines the new animations to add
  12692. */
  12693. appendAnimations(target: any, animations: Animation[]): void;
  12694. /**
  12695. * Gets the source animation for a specific property
  12696. * @param property defines the propertyu to look for
  12697. * @returns null or the source animation for the given property
  12698. */
  12699. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12700. /**
  12701. * Gets the runtime animation for a specific property
  12702. * @param property defines the propertyu to look for
  12703. * @returns null or the runtime animation for the given property
  12704. */
  12705. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12706. /**
  12707. * Resets the animatable to its original state
  12708. */
  12709. reset(): void;
  12710. /**
  12711. * Allows the animatable to blend with current running animations
  12712. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12713. * @param blendingSpeed defines the blending speed to use
  12714. */
  12715. enableBlending(blendingSpeed: number): void;
  12716. /**
  12717. * Disable animation blending
  12718. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12719. */
  12720. disableBlending(): void;
  12721. /**
  12722. * Jump directly to a given frame
  12723. * @param frame defines the frame to jump to
  12724. */
  12725. goToFrame(frame: number): void;
  12726. /**
  12727. * Pause the animation
  12728. */
  12729. pause(): void;
  12730. /**
  12731. * Restart the animation
  12732. */
  12733. restart(): void;
  12734. private _raiseOnAnimationEnd;
  12735. /**
  12736. * Stop and delete the current animation
  12737. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12738. * @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)
  12739. */
  12740. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12741. /**
  12742. * Wait asynchronously for the animation to end
  12743. * @returns a promise which will be fullfilled when the animation ends
  12744. */
  12745. waitAsync(): Promise<Animatable>;
  12746. /** @hidden */ private _animate(delay: number): boolean;
  12747. }
  12748. interface Scene {
  12749. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12750. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12751. totalWeight: number;
  12752. animations: RuntimeAnimation[];
  12753. originalValue: Matrix;
  12754. }): any;
  12755. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12756. totalWeight: number;
  12757. animations: RuntimeAnimation[];
  12758. originalValue: Quaternion;
  12759. }, refQuaternion: Quaternion): Quaternion;
  12760. /** @hidden */ private _processLateAnimationBindings(): void;
  12761. /**
  12762. * Will start the animation sequence of a given target
  12763. * @param target defines the target
  12764. * @param from defines from which frame should animation start
  12765. * @param to defines until which frame should animation run.
  12766. * @param weight defines the weight to apply to the animation (1.0 by default)
  12767. * @param loop defines if the animation loops
  12768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12769. * @param onAnimationEnd defines the function to be executed when the animation ends
  12770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12772. * @param onAnimationLoop defines the callback to call when an animation loops
  12773. * @returns the animatable object created for this animation
  12774. */
  12775. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12776. /**
  12777. * Will start the animation sequence of a given target
  12778. * @param target defines the target
  12779. * @param from defines from which frame should animation start
  12780. * @param to defines until which frame should animation run.
  12781. * @param loop defines if the animation loops
  12782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12783. * @param onAnimationEnd defines the function to be executed when the animation ends
  12784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12786. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12787. * @param onAnimationLoop defines the callback to call when an animation loops
  12788. * @returns the animatable object created for this animation
  12789. */
  12790. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12791. /**
  12792. * Will start the animation sequence of a given target and its hierarchy
  12793. * @param target defines the target
  12794. * @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.
  12795. * @param from defines from which frame should animation start
  12796. * @param to defines until which frame should animation run.
  12797. * @param loop defines if the animation loops
  12798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12799. * @param onAnimationEnd defines the function to be executed when the animation ends
  12800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12802. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12803. * @param onAnimationLoop defines the callback to call when an animation loops
  12804. * @returns the list of created animatables
  12805. */
  12806. 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[];
  12807. /**
  12808. * Begin a new animation on a given node
  12809. * @param target defines the target where the animation will take place
  12810. * @param animations defines the list of animations to start
  12811. * @param from defines the initial value
  12812. * @param to defines the final value
  12813. * @param loop defines if you want animation to loop (off by default)
  12814. * @param speedRatio defines the speed ratio to apply to all animations
  12815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12816. * @param onAnimationLoop defines the callback to call when an animation loops
  12817. * @returns the list of created animatables
  12818. */
  12819. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12820. /**
  12821. * Begin a new animation on a given node and its hierarchy
  12822. * @param target defines the root node where the animation will take place
  12823. * @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.
  12824. * @param animations defines the list of animations to start
  12825. * @param from defines the initial value
  12826. * @param to defines the final value
  12827. * @param loop defines if you want animation to loop (off by default)
  12828. * @param speedRatio defines the speed ratio to apply to all animations
  12829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12830. * @param onAnimationLoop defines the callback to call when an animation loops
  12831. * @returns the list of animatables created for all nodes
  12832. */
  12833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12834. /**
  12835. * Gets the animatable associated with a specific target
  12836. * @param target defines the target of the animatable
  12837. * @returns the required animatable if found
  12838. */
  12839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12840. /**
  12841. * Gets all animatables associated with a given target
  12842. * @param target defines the target to look animatables for
  12843. * @returns an array of Animatables
  12844. */
  12845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12846. /**
  12847. * Stops and removes all animations that have been applied to the scene
  12848. */
  12849. stopAllAnimations(): void;
  12850. }
  12851. interface Bone {
  12852. /**
  12853. * Copy an animation range from another bone
  12854. * @param source defines the source bone
  12855. * @param rangeName defines the range name to copy
  12856. * @param frameOffset defines the frame offset
  12857. * @param rescaleAsRequired defines if rescaling must be applied if required
  12858. * @param skelDimensionsRatio defines the scaling ratio
  12859. * @returns true if operation was successful
  12860. */
  12861. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12862. }
  12863. }
  12864. declare module BABYLON {
  12865. /**
  12866. * Class used to override all child animations of a given target
  12867. */
  12868. export class AnimationPropertiesOverride {
  12869. /**
  12870. * Gets or sets a value indicating if animation blending must be used
  12871. */
  12872. enableBlending: boolean;
  12873. /**
  12874. * Gets or sets the blending speed to use when enableBlending is true
  12875. */
  12876. blendingSpeed: number;
  12877. /**
  12878. * Gets or sets the default loop mode to use
  12879. */
  12880. loopMode: number;
  12881. }
  12882. }
  12883. declare module BABYLON {
  12884. /**
  12885. * Class used to handle skinning animations
  12886. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12887. */
  12888. export class Skeleton implements IAnimatable {
  12889. /** defines the skeleton name */
  12890. name: string;
  12891. /** defines the skeleton Id */
  12892. id: string;
  12893. /**
  12894. * Defines the list of child bones
  12895. */
  12896. bones: Bone[];
  12897. /**
  12898. * Defines an estimate of the dimension of the skeleton at rest
  12899. */
  12900. dimensionsAtRest: Vector3;
  12901. /**
  12902. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12903. */
  12904. needInitialSkinMatrix: boolean;
  12905. /**
  12906. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12907. */
  12908. overrideMesh: Nullable<AbstractMesh>;
  12909. /**
  12910. * Gets the list of animations attached to this skeleton
  12911. */
  12912. animations: Array<Animation>;
  12913. private _scene;
  12914. private _isDirty;
  12915. private _transformMatrices;
  12916. private _transformMatrixTexture;
  12917. private _meshesWithPoseMatrix;
  12918. private _animatables;
  12919. private _identity;
  12920. private _synchronizedWithMesh;
  12921. private _ranges;
  12922. private _lastAbsoluteTransformsUpdateId;
  12923. private _canUseTextureForBones;
  12924. private _uniqueId;
  12925. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  12926. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  12927. /**
  12928. * Specifies if the skeleton should be serialized
  12929. */
  12930. doNotSerialize: boolean;
  12931. private _useTextureToStoreBoneMatrices;
  12932. /**
  12933. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  12934. * Please note that this option is not available if the hardware does not support it
  12935. */
  12936. useTextureToStoreBoneMatrices: boolean;
  12937. private _animationPropertiesOverride;
  12938. /**
  12939. * Gets or sets the animation properties override
  12940. */
  12941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  12942. /**
  12943. * List of inspectable custom properties (used by the Inspector)
  12944. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  12945. */
  12946. inspectableCustomProperties: IInspectable[];
  12947. /**
  12948. * An observable triggered before computing the skeleton's matrices
  12949. */
  12950. onBeforeComputeObservable: Observable<Skeleton>;
  12951. /**
  12952. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  12953. */
  12954. readonly isUsingTextureForMatrices: boolean;
  12955. /**
  12956. * Gets the unique ID of this skeleton
  12957. */
  12958. readonly uniqueId: number;
  12959. /**
  12960. * Creates a new skeleton
  12961. * @param name defines the skeleton name
  12962. * @param id defines the skeleton Id
  12963. * @param scene defines the hosting scene
  12964. */
  12965. constructor(
  12966. /** defines the skeleton name */
  12967. name: string,
  12968. /** defines the skeleton Id */
  12969. id: string, scene: Scene);
  12970. /**
  12971. * Gets the current object class name.
  12972. * @return the class name
  12973. */
  12974. getClassName(): string;
  12975. /**
  12976. * Returns an array containing the root bones
  12977. * @returns an array containing the root bones
  12978. */
  12979. getChildren(): Array<Bone>;
  12980. /**
  12981. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  12982. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  12983. * @returns a Float32Array containing matrices data
  12984. */
  12985. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  12986. /**
  12987. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  12988. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  12989. * @returns a raw texture containing the data
  12990. */
  12991. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  12992. /**
  12993. * Gets the current hosting scene
  12994. * @returns a scene object
  12995. */
  12996. getScene(): Scene;
  12997. /**
  12998. * Gets a string representing the current skeleton data
  12999. * @param fullDetails defines a boolean indicating if we want a verbose version
  13000. * @returns a string representing the current skeleton data
  13001. */
  13002. toString(fullDetails?: boolean): string;
  13003. /**
  13004. * Get bone's index searching by name
  13005. * @param name defines bone's name to search for
  13006. * @return the indice of the bone. Returns -1 if not found
  13007. */
  13008. getBoneIndexByName(name: string): number;
  13009. /**
  13010. * Creater a new animation range
  13011. * @param name defines the name of the range
  13012. * @param from defines the start key
  13013. * @param to defines the end key
  13014. */
  13015. createAnimationRange(name: string, from: number, to: number): void;
  13016. /**
  13017. * Delete a specific animation range
  13018. * @param name defines the name of the range
  13019. * @param deleteFrames defines if frames must be removed as well
  13020. */
  13021. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13022. /**
  13023. * Gets a specific animation range
  13024. * @param name defines the name of the range to look for
  13025. * @returns the requested animation range or null if not found
  13026. */
  13027. getAnimationRange(name: string): Nullable<AnimationRange>;
  13028. /**
  13029. * Gets the list of all animation ranges defined on this skeleton
  13030. * @returns an array
  13031. */
  13032. getAnimationRanges(): Nullable<AnimationRange>[];
  13033. /**
  13034. * Copy animation range from a source skeleton.
  13035. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13036. * @param source defines the source skeleton
  13037. * @param name defines the name of the range to copy
  13038. * @param rescaleAsRequired defines if rescaling must be applied if required
  13039. * @returns true if operation was successful
  13040. */
  13041. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13042. /**
  13043. * Forces the skeleton to go to rest pose
  13044. */
  13045. returnToRest(): void;
  13046. private _getHighestAnimationFrame;
  13047. /**
  13048. * Begin a specific animation range
  13049. * @param name defines the name of the range to start
  13050. * @param loop defines if looping must be turned on (false by default)
  13051. * @param speedRatio defines the speed ratio to apply (1 by default)
  13052. * @param onAnimationEnd defines a callback which will be called when animation will end
  13053. * @returns a new animatable
  13054. */
  13055. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13056. /** @hidden */ private _markAsDirty(): void;
  13057. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13058. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13059. private _computeTransformMatrices;
  13060. /**
  13061. * Build all resources required to render a skeleton
  13062. */
  13063. prepare(): void;
  13064. /**
  13065. * Gets the list of animatables currently running for this skeleton
  13066. * @returns an array of animatables
  13067. */
  13068. getAnimatables(): IAnimatable[];
  13069. /**
  13070. * Clone the current skeleton
  13071. * @param name defines the name of the new skeleton
  13072. * @param id defines the id of the new skeleton
  13073. * @returns the new skeleton
  13074. */
  13075. clone(name: string, id: string): Skeleton;
  13076. /**
  13077. * Enable animation blending for this skeleton
  13078. * @param blendingSpeed defines the blending speed to apply
  13079. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13080. */
  13081. enableBlending(blendingSpeed?: number): void;
  13082. /**
  13083. * Releases all resources associated with the current skeleton
  13084. */
  13085. dispose(): void;
  13086. /**
  13087. * Serialize the skeleton in a JSON object
  13088. * @returns a JSON object
  13089. */
  13090. serialize(): any;
  13091. /**
  13092. * Creates a new skeleton from serialized data
  13093. * @param parsedSkeleton defines the serialized data
  13094. * @param scene defines the hosting scene
  13095. * @returns a new skeleton
  13096. */
  13097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13098. /**
  13099. * Compute all node absolute transforms
  13100. * @param forceUpdate defines if computation must be done even if cache is up to date
  13101. */
  13102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13103. /**
  13104. * Gets the root pose matrix
  13105. * @returns a matrix
  13106. */
  13107. getPoseMatrix(): Nullable<Matrix>;
  13108. /**
  13109. * Sorts bones per internal index
  13110. */
  13111. sortBones(): void;
  13112. private _sortBones;
  13113. }
  13114. }
  13115. declare module BABYLON {
  13116. /**
  13117. * Class used to store bone information
  13118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13119. */
  13120. export class Bone extends Node {
  13121. /**
  13122. * defines the bone name
  13123. */
  13124. name: string;
  13125. private static _tmpVecs;
  13126. private static _tmpQuat;
  13127. private static _tmpMats;
  13128. /**
  13129. * Gets the list of child bones
  13130. */
  13131. children: Bone[];
  13132. /** Gets the animations associated with this bone */
  13133. animations: Animation[];
  13134. /**
  13135. * Gets or sets bone length
  13136. */
  13137. length: number;
  13138. /**
  13139. * @hidden Internal only
  13140. * Set this value to map this bone to a different index in the transform matrices
  13141. * Set this value to -1 to exclude the bone from the transform matrices
  13142. */ private _index: Nullable<number>;
  13143. private _skeleton;
  13144. private _localMatrix;
  13145. private _restPose;
  13146. private _baseMatrix;
  13147. private _absoluteTransform;
  13148. private _invertedAbsoluteTransform;
  13149. private _parent;
  13150. private _scalingDeterminant;
  13151. private _worldTransform;
  13152. private _localScaling;
  13153. private _localRotation;
  13154. private _localPosition;
  13155. private _needToDecompose;
  13156. private _needToCompose;
  13157. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13158. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13159. /** @hidden */
  13160. /** @hidden */ private _matrix: Matrix;
  13161. /**
  13162. * Create a new bone
  13163. * @param name defines the bone name
  13164. * @param skeleton defines the parent skeleton
  13165. * @param parentBone defines the parent (can be null if the bone is the root)
  13166. * @param localMatrix defines the local matrix
  13167. * @param restPose defines the rest pose matrix
  13168. * @param baseMatrix defines the base matrix
  13169. * @param index defines index of the bone in the hiearchy
  13170. */
  13171. constructor(
  13172. /**
  13173. * defines the bone name
  13174. */
  13175. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13176. /**
  13177. * Gets the current object class name.
  13178. * @return the class name
  13179. */
  13180. getClassName(): string;
  13181. /**
  13182. * Gets the parent skeleton
  13183. * @returns a skeleton
  13184. */
  13185. getSkeleton(): Skeleton;
  13186. /**
  13187. * Gets parent bone
  13188. * @returns a bone or null if the bone is the root of the bone hierarchy
  13189. */
  13190. getParent(): Nullable<Bone>;
  13191. /**
  13192. * Returns an array containing the root bones
  13193. * @returns an array containing the root bones
  13194. */
  13195. getChildren(): Array<Bone>;
  13196. /**
  13197. * Sets the parent bone
  13198. * @param parent defines the parent (can be null if the bone is the root)
  13199. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13200. */
  13201. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13202. /**
  13203. * Gets the local matrix
  13204. * @returns a matrix
  13205. */
  13206. getLocalMatrix(): Matrix;
  13207. /**
  13208. * Gets the base matrix (initial matrix which remains unchanged)
  13209. * @returns a matrix
  13210. */
  13211. getBaseMatrix(): Matrix;
  13212. /**
  13213. * Gets the rest pose matrix
  13214. * @returns a matrix
  13215. */
  13216. getRestPose(): Matrix;
  13217. /**
  13218. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13219. */
  13220. getWorldMatrix(): Matrix;
  13221. /**
  13222. * Sets the local matrix to rest pose matrix
  13223. */
  13224. returnToRest(): void;
  13225. /**
  13226. * Gets the inverse of the absolute transform matrix.
  13227. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13228. * @returns a matrix
  13229. */
  13230. getInvertedAbsoluteTransform(): Matrix;
  13231. /**
  13232. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13233. * @returns a matrix
  13234. */
  13235. getAbsoluteTransform(): Matrix;
  13236. /**
  13237. * Links with the given transform node.
  13238. * The local matrix of this bone is copied from the transform node every frame.
  13239. * @param transformNode defines the transform node to link to
  13240. */
  13241. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13242. /**
  13243. * Gets the node used to drive the bone's transformation
  13244. * @returns a transform node or null
  13245. */
  13246. getTransformNode(): Nullable<TransformNode>;
  13247. /** Gets or sets current position (in local space) */
  13248. position: Vector3;
  13249. /** Gets or sets current rotation (in local space) */
  13250. rotation: Vector3;
  13251. /** Gets or sets current rotation quaternion (in local space) */
  13252. rotationQuaternion: Quaternion;
  13253. /** Gets or sets current scaling (in local space) */
  13254. scaling: Vector3;
  13255. /**
  13256. * Gets the animation properties override
  13257. */
  13258. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13259. private _decompose;
  13260. private _compose;
  13261. /**
  13262. * Update the base and local matrices
  13263. * @param matrix defines the new base or local matrix
  13264. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13265. * @param updateLocalMatrix defines if the local matrix should be updated
  13266. */
  13267. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13268. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13269. /**
  13270. * Flag the bone as dirty (Forcing it to update everything)
  13271. */
  13272. markAsDirty(): void;
  13273. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13274. private _markAsDirtyAndDecompose;
  13275. /**
  13276. * Translate the bone in local or world space
  13277. * @param vec The amount to translate the bone
  13278. * @param space The space that the translation is in
  13279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13280. */
  13281. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13282. /**
  13283. * Set the postion of the bone in local or world space
  13284. * @param position The position to set the bone
  13285. * @param space The space that the position is in
  13286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13287. */
  13288. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13289. /**
  13290. * Set the absolute position of the bone (world space)
  13291. * @param position The position to set the bone
  13292. * @param mesh The mesh that this bone is attached to
  13293. */
  13294. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13295. /**
  13296. * Scale the bone on the x, y and z axes (in local space)
  13297. * @param x The amount to scale the bone on the x axis
  13298. * @param y The amount to scale the bone on the y axis
  13299. * @param z The amount to scale the bone on the z axis
  13300. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13301. */
  13302. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13303. /**
  13304. * Set the bone scaling in local space
  13305. * @param scale defines the scaling vector
  13306. */
  13307. setScale(scale: Vector3): void;
  13308. /**
  13309. * Gets the current scaling in local space
  13310. * @returns the current scaling vector
  13311. */
  13312. getScale(): Vector3;
  13313. /**
  13314. * Gets the current scaling in local space and stores it in a target vector
  13315. * @param result defines the target vector
  13316. */
  13317. getScaleToRef(result: Vector3): void;
  13318. /**
  13319. * Set the yaw, pitch, and roll of the bone in local or world space
  13320. * @param yaw The rotation of the bone on the y axis
  13321. * @param pitch The rotation of the bone on the x axis
  13322. * @param roll The rotation of the bone on the z axis
  13323. * @param space The space that the axes of rotation are in
  13324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13325. */
  13326. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13327. /**
  13328. * Add a rotation to the bone on an axis in local or world space
  13329. * @param axis The axis to rotate the bone on
  13330. * @param amount The amount to rotate the bone
  13331. * @param space The space that the axis is in
  13332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13333. */
  13334. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13335. /**
  13336. * Set the rotation of the bone to a particular axis angle in local or world space
  13337. * @param axis The axis to rotate the bone on
  13338. * @param angle The angle that the bone should be rotated to
  13339. * @param space The space that the axis is in
  13340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13341. */
  13342. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13343. /**
  13344. * Set the euler rotation of the bone in local of world space
  13345. * @param rotation The euler rotation that the bone should be set to
  13346. * @param space The space that the rotation is in
  13347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13348. */
  13349. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13350. /**
  13351. * Set the quaternion rotation of the bone in local of world space
  13352. * @param quat The quaternion rotation that the bone should be set to
  13353. * @param space The space that the rotation is in
  13354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13355. */
  13356. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13357. /**
  13358. * Set the rotation matrix of the bone in local of world space
  13359. * @param rotMat The rotation matrix that the bone should be set to
  13360. * @param space The space that the rotation is in
  13361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13362. */
  13363. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13364. private _rotateWithMatrix;
  13365. private _getNegativeRotationToRef;
  13366. /**
  13367. * Get the position of the bone in local or world space
  13368. * @param space The space that the returned position is in
  13369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13370. * @returns The position of the bone
  13371. */
  13372. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13373. /**
  13374. * Copy the position of the bone to a vector3 in local or world space
  13375. * @param space The space that the returned position is in
  13376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13377. * @param result The vector3 to copy the position to
  13378. */
  13379. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13380. /**
  13381. * Get the absolute position of the bone (world space)
  13382. * @param mesh The mesh that this bone is attached to
  13383. * @returns The absolute position of the bone
  13384. */
  13385. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13386. /**
  13387. * Copy the absolute position of the bone (world space) to the result param
  13388. * @param mesh The mesh that this bone is attached to
  13389. * @param result The vector3 to copy the absolute position to
  13390. */
  13391. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13392. /**
  13393. * Compute the absolute transforms of this bone and its children
  13394. */
  13395. computeAbsoluteTransforms(): void;
  13396. /**
  13397. * Get the world direction from an axis that is in the local space of the bone
  13398. * @param localAxis The local direction that is used to compute the world direction
  13399. * @param mesh The mesh that this bone is attached to
  13400. * @returns The world direction
  13401. */
  13402. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13403. /**
  13404. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13405. * @param localAxis The local direction that is used to compute the world direction
  13406. * @param mesh The mesh that this bone is attached to
  13407. * @param result The vector3 that the world direction will be copied to
  13408. */
  13409. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13410. /**
  13411. * Get the euler rotation of the bone in local or world space
  13412. * @param space The space that the rotation should be in
  13413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13414. * @returns The euler rotation
  13415. */
  13416. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13417. /**
  13418. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13419. * @param space The space that the rotation should be in
  13420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13421. * @param result The vector3 that the rotation should be copied to
  13422. */
  13423. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13424. /**
  13425. * Get the quaternion rotation of the bone in either local or world space
  13426. * @param space The space that the rotation should be in
  13427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13428. * @returns The quaternion rotation
  13429. */
  13430. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13431. /**
  13432. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13433. * @param space The space that the rotation should be in
  13434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13435. * @param result The quaternion that the rotation should be copied to
  13436. */
  13437. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13438. /**
  13439. * Get the rotation matrix of the bone in local or world space
  13440. * @param space The space that the rotation should be in
  13441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13442. * @returns The rotation matrix
  13443. */
  13444. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13445. /**
  13446. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13447. * @param space The space that the rotation should be in
  13448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13449. * @param result The quaternion that the rotation should be copied to
  13450. */
  13451. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13452. /**
  13453. * Get the world position of a point that is in the local space of the bone
  13454. * @param position The local position
  13455. * @param mesh The mesh that this bone is attached to
  13456. * @returns The world position
  13457. */
  13458. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13459. /**
  13460. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13461. * @param position The local position
  13462. * @param mesh The mesh that this bone is attached to
  13463. * @param result The vector3 that the world position should be copied to
  13464. */
  13465. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13466. /**
  13467. * Get the local position of a point that is in world space
  13468. * @param position The world position
  13469. * @param mesh The mesh that this bone is attached to
  13470. * @returns The local position
  13471. */
  13472. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13473. /**
  13474. * Get the local position of a point that is in world space and copy it to the result param
  13475. * @param position The world position
  13476. * @param mesh The mesh that this bone is attached to
  13477. * @param result The vector3 that the local position should be copied to
  13478. */
  13479. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13480. }
  13481. }
  13482. declare module BABYLON {
  13483. /**
  13484. * 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.
  13485. * @see https://doc.babylonjs.com/how_to/transformnode
  13486. */
  13487. export class TransformNode extends Node {
  13488. /**
  13489. * Object will not rotate to face the camera
  13490. */
  13491. static BILLBOARDMODE_NONE: number;
  13492. /**
  13493. * Object will rotate to face the camera but only on the x axis
  13494. */
  13495. static BILLBOARDMODE_X: number;
  13496. /**
  13497. * Object will rotate to face the camera but only on the y axis
  13498. */
  13499. static BILLBOARDMODE_Y: number;
  13500. /**
  13501. * Object will rotate to face the camera but only on the z axis
  13502. */
  13503. static BILLBOARDMODE_Z: number;
  13504. /**
  13505. * Object will rotate to face the camera
  13506. */
  13507. static BILLBOARDMODE_ALL: number;
  13508. private _forward;
  13509. private _forwardInverted;
  13510. private _up;
  13511. private _right;
  13512. private _rightInverted;
  13513. private _position;
  13514. private _rotation;
  13515. private _rotationQuaternion;
  13516. protected _scaling: Vector3;
  13517. protected _isDirty: boolean;
  13518. private _transformToBoneReferal;
  13519. private _isAbsoluteSynced;
  13520. private _billboardMode;
  13521. /**
  13522. * Gets or sets the billboard mode. Default is 0.
  13523. *
  13524. * | Value | Type | Description |
  13525. * | --- | --- | --- |
  13526. * | 0 | BILLBOARDMODE_NONE | |
  13527. * | 1 | BILLBOARDMODE_X | |
  13528. * | 2 | BILLBOARDMODE_Y | |
  13529. * | 4 | BILLBOARDMODE_Z | |
  13530. * | 7 | BILLBOARDMODE_ALL | |
  13531. *
  13532. */
  13533. billboardMode: number;
  13534. private _preserveParentRotationForBillboard;
  13535. /**
  13536. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13537. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13538. */
  13539. preserveParentRotationForBillboard: boolean;
  13540. /**
  13541. * 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
  13542. */
  13543. scalingDeterminant: number;
  13544. private _infiniteDistance;
  13545. /**
  13546. * Gets or sets the distance of the object to max, often used by skybox
  13547. */
  13548. infiniteDistance: boolean;
  13549. /**
  13550. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13551. * By default the system will update normals to compensate
  13552. */
  13553. ignoreNonUniformScaling: boolean;
  13554. /**
  13555. * 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
  13556. */
  13557. reIntegrateRotationIntoRotationQuaternion: boolean;
  13558. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13559. /** @hidden */ private _localMatrix: Matrix;
  13560. private _usePivotMatrix;
  13561. private _absolutePosition;
  13562. private _absoluteScaling;
  13563. private _absoluteRotationQuaternion;
  13564. private _pivotMatrix;
  13565. private _pivotMatrixInverse;
  13566. protected _postMultiplyPivotMatrix: boolean;
  13567. protected _isWorldMatrixFrozen: boolean;
  13568. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13569. /**
  13570. * An event triggered after the world matrix is updated
  13571. */
  13572. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13573. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13574. /**
  13575. * Gets a string identifying the name of the class
  13576. * @returns "TransformNode" string
  13577. */
  13578. getClassName(): string;
  13579. /**
  13580. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13581. */
  13582. position: Vector3;
  13583. /**
  13584. * 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)).
  13585. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13586. */
  13587. rotation: Vector3;
  13588. /**
  13589. * 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)).
  13590. */
  13591. scaling: Vector3;
  13592. /**
  13593. * 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).
  13594. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13595. */
  13596. rotationQuaternion: Nullable<Quaternion>;
  13597. /**
  13598. * The forward direction of that transform in world space.
  13599. */
  13600. readonly forward: Vector3;
  13601. /**
  13602. * The up direction of that transform in world space.
  13603. */
  13604. readonly up: Vector3;
  13605. /**
  13606. * The right direction of that transform in world space.
  13607. */
  13608. readonly right: Vector3;
  13609. /**
  13610. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13611. * @param matrix the matrix to copy the pose from
  13612. * @returns this TransformNode.
  13613. */
  13614. updatePoseMatrix(matrix: Matrix): TransformNode;
  13615. /**
  13616. * Returns the mesh Pose matrix.
  13617. * @returns the pose matrix
  13618. */
  13619. getPoseMatrix(): Matrix;
  13620. /** @hidden */ private _isSynchronized(): boolean;
  13621. /** @hidden */ private _initCache(): void;
  13622. /**
  13623. * Flag the transform node as dirty (Forcing it to update everything)
  13624. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13625. * @returns this transform node
  13626. */
  13627. markAsDirty(property: string): TransformNode;
  13628. /**
  13629. * Returns the current mesh absolute position.
  13630. * Returns a Vector3.
  13631. */
  13632. readonly absolutePosition: Vector3;
  13633. /**
  13634. * Returns the current mesh absolute scaling.
  13635. * Returns a Vector3.
  13636. */
  13637. readonly absoluteScaling: Vector3;
  13638. /**
  13639. * Returns the current mesh absolute rotation.
  13640. * Returns a Quaternion.
  13641. */
  13642. readonly absoluteRotationQuaternion: Quaternion;
  13643. /**
  13644. * Sets a new matrix to apply before all other transformation
  13645. * @param matrix defines the transform matrix
  13646. * @returns the current TransformNode
  13647. */
  13648. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13649. /**
  13650. * Sets a new pivot matrix to the current node
  13651. * @param matrix defines the new pivot matrix to use
  13652. * @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
  13653. * @returns the current TransformNode
  13654. */
  13655. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13656. /**
  13657. * Returns the mesh pivot matrix.
  13658. * Default : Identity.
  13659. * @returns the matrix
  13660. */
  13661. getPivotMatrix(): Matrix;
  13662. /**
  13663. * Prevents the World matrix to be computed any longer.
  13664. * @returns the TransformNode.
  13665. */
  13666. freezeWorldMatrix(): TransformNode;
  13667. /**
  13668. * Allows back the World matrix computation.
  13669. * @returns the TransformNode.
  13670. */
  13671. unfreezeWorldMatrix(): this;
  13672. /**
  13673. * True if the World matrix has been frozen.
  13674. */
  13675. readonly isWorldMatrixFrozen: boolean;
  13676. /**
  13677. * Retuns the mesh absolute position in the World.
  13678. * @returns a Vector3.
  13679. */
  13680. getAbsolutePosition(): Vector3;
  13681. /**
  13682. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13683. * @param absolutePosition the absolute position to set
  13684. * @returns the TransformNode.
  13685. */
  13686. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13687. /**
  13688. * Sets the mesh position in its local space.
  13689. * @param vector3 the position to set in localspace
  13690. * @returns the TransformNode.
  13691. */
  13692. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13693. /**
  13694. * Returns the mesh position in the local space from the current World matrix values.
  13695. * @returns a new Vector3.
  13696. */
  13697. getPositionExpressedInLocalSpace(): Vector3;
  13698. /**
  13699. * Translates the mesh along the passed Vector3 in its local space.
  13700. * @param vector3 the distance to translate in localspace
  13701. * @returns the TransformNode.
  13702. */
  13703. locallyTranslate(vector3: Vector3): TransformNode;
  13704. private static _lookAtVectorCache;
  13705. /**
  13706. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13707. * @param targetPoint the position (must be in same space as current mesh) to look at
  13708. * @param yawCor optional yaw (y-axis) correction in radians
  13709. * @param pitchCor optional pitch (x-axis) correction in radians
  13710. * @param rollCor optional roll (z-axis) correction in radians
  13711. * @param space the choosen space of the target
  13712. * @returns the TransformNode.
  13713. */
  13714. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13715. /**
  13716. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13717. * This Vector3 is expressed in the World space.
  13718. * @param localAxis axis to rotate
  13719. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13720. */
  13721. getDirection(localAxis: Vector3): Vector3;
  13722. /**
  13723. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13724. * localAxis is expressed in the mesh local space.
  13725. * result is computed in the Wordl space from the mesh World matrix.
  13726. * @param localAxis axis to rotate
  13727. * @param result the resulting transformnode
  13728. * @returns this TransformNode.
  13729. */
  13730. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13731. /**
  13732. * Sets this transform node rotation to the given local axis.
  13733. * @param localAxis the axis in local space
  13734. * @param yawCor optional yaw (y-axis) correction in radians
  13735. * @param pitchCor optional pitch (x-axis) correction in radians
  13736. * @param rollCor optional roll (z-axis) correction in radians
  13737. * @returns this TransformNode
  13738. */
  13739. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13740. /**
  13741. * Sets a new pivot point to the current node
  13742. * @param point defines the new pivot point to use
  13743. * @param space defines if the point is in world or local space (local by default)
  13744. * @returns the current TransformNode
  13745. */
  13746. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13747. /**
  13748. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13749. * @returns the pivot point
  13750. */
  13751. getPivotPoint(): Vector3;
  13752. /**
  13753. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13754. * @param result the vector3 to store the result
  13755. * @returns this TransformNode.
  13756. */
  13757. getPivotPointToRef(result: Vector3): TransformNode;
  13758. /**
  13759. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13760. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13761. */
  13762. getAbsolutePivotPoint(): Vector3;
  13763. /**
  13764. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13765. * @param result vector3 to store the result
  13766. * @returns this TransformNode.
  13767. */
  13768. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13769. /**
  13770. * Defines the passed node as the parent of the current node.
  13771. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13772. * @see https://doc.babylonjs.com/how_to/parenting
  13773. * @param node the node ot set as the parent
  13774. * @returns this TransformNode.
  13775. */
  13776. setParent(node: Nullable<Node>): TransformNode;
  13777. private _nonUniformScaling;
  13778. /**
  13779. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13780. */
  13781. readonly nonUniformScaling: boolean;
  13782. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13783. /**
  13784. * Attach the current TransformNode to another TransformNode associated with a bone
  13785. * @param bone Bone affecting the TransformNode
  13786. * @param affectedTransformNode TransformNode associated with the bone
  13787. * @returns this object
  13788. */
  13789. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13790. /**
  13791. * Detach the transform node if its associated with a bone
  13792. * @returns this object
  13793. */
  13794. detachFromBone(): TransformNode;
  13795. private static _rotationAxisCache;
  13796. /**
  13797. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13798. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13799. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13800. * The passed axis is also normalized.
  13801. * @param axis the axis to rotate around
  13802. * @param amount the amount to rotate in radians
  13803. * @param space Space to rotate in (Default: local)
  13804. * @returns the TransformNode.
  13805. */
  13806. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13807. /**
  13808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13809. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13810. * The passed axis is also normalized. .
  13811. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13812. * @param point the point to rotate around
  13813. * @param axis the axis to rotate around
  13814. * @param amount the amount to rotate in radians
  13815. * @returns the TransformNode
  13816. */
  13817. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13818. /**
  13819. * Translates the mesh along the axis vector for the passed distance in the given space.
  13820. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13821. * @param axis the axis to translate in
  13822. * @param distance the distance to translate
  13823. * @param space Space to rotate in (Default: local)
  13824. * @returns the TransformNode.
  13825. */
  13826. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13827. /**
  13828. * Adds a rotation step to the mesh current rotation.
  13829. * x, y, z are Euler angles expressed in radians.
  13830. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13831. * This means this rotation is made in the mesh local space only.
  13832. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13833. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13834. * ```javascript
  13835. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13836. * ```
  13837. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13838. * 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.
  13839. * @param x Rotation to add
  13840. * @param y Rotation to add
  13841. * @param z Rotation to add
  13842. * @returns the TransformNode.
  13843. */
  13844. addRotation(x: number, y: number, z: number): TransformNode;
  13845. /**
  13846. * @hidden
  13847. */
  13848. protected _getEffectiveParent(): Nullable<Node>;
  13849. /**
  13850. * Computes the world matrix of the node
  13851. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13852. * @returns the world matrix
  13853. */
  13854. computeWorldMatrix(force?: boolean): Matrix;
  13855. protected _afterComputeWorldMatrix(): void;
  13856. /**
  13857. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13858. * @param func callback function to add
  13859. *
  13860. * @returns the TransformNode.
  13861. */
  13862. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13863. /**
  13864. * Removes a registered callback function.
  13865. * @param func callback function to remove
  13866. * @returns the TransformNode.
  13867. */
  13868. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13869. /**
  13870. * Gets the position of the current mesh in camera space
  13871. * @param camera defines the camera to use
  13872. * @returns a position
  13873. */
  13874. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13875. /**
  13876. * Returns the distance from the mesh to the active camera
  13877. * @param camera defines the camera to use
  13878. * @returns the distance
  13879. */
  13880. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13881. /**
  13882. * Clone the current transform node
  13883. * @param name Name of the new clone
  13884. * @param newParent New parent for the clone
  13885. * @param doNotCloneChildren Do not clone children hierarchy
  13886. * @returns the new transform node
  13887. */
  13888. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13889. /**
  13890. * Serializes the objects information.
  13891. * @param currentSerializationObject defines the object to serialize in
  13892. * @returns the serialized object
  13893. */
  13894. serialize(currentSerializationObject?: any): any;
  13895. /**
  13896. * Returns a new TransformNode object parsed from the source provided.
  13897. * @param parsedTransformNode is the source.
  13898. * @param scene the scne the object belongs to
  13899. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13900. * @returns a new TransformNode object parsed from the source provided.
  13901. */
  13902. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13903. /**
  13904. * Get all child-transformNodes of this node
  13905. * @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
  13906. * @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
  13907. * @returns an array of TransformNode
  13908. */
  13909. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13910. /**
  13911. * Releases resources associated with this transform node.
  13912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13914. */
  13915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13916. /**
  13917. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13918. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13919. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13920. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13921. * @returns the current mesh
  13922. */
  13923. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13924. private _syncAbsoluteScalingAndRotation;
  13925. }
  13926. }
  13927. declare module BABYLON {
  13928. /**
  13929. * Defines the types of pose enabled controllers that are supported
  13930. */
  13931. export enum PoseEnabledControllerType {
  13932. /**
  13933. * HTC Vive
  13934. */
  13935. VIVE = 0,
  13936. /**
  13937. * Oculus Rift
  13938. */
  13939. OCULUS = 1,
  13940. /**
  13941. * Windows mixed reality
  13942. */
  13943. WINDOWS = 2,
  13944. /**
  13945. * Samsung gear VR
  13946. */
  13947. GEAR_VR = 3,
  13948. /**
  13949. * Google Daydream
  13950. */
  13951. DAYDREAM = 4,
  13952. /**
  13953. * Generic
  13954. */
  13955. GENERIC = 5
  13956. }
  13957. /**
  13958. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13959. */
  13960. export interface MutableGamepadButton {
  13961. /**
  13962. * Value of the button/trigger
  13963. */
  13964. value: number;
  13965. /**
  13966. * If the button/trigger is currently touched
  13967. */
  13968. touched: boolean;
  13969. /**
  13970. * If the button/trigger is currently pressed
  13971. */
  13972. pressed: boolean;
  13973. }
  13974. /**
  13975. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13976. * @hidden
  13977. */
  13978. export interface ExtendedGamepadButton extends GamepadButton {
  13979. /**
  13980. * If the button/trigger is currently pressed
  13981. */
  13982. readonly pressed: boolean;
  13983. /**
  13984. * If the button/trigger is currently touched
  13985. */
  13986. readonly touched: boolean;
  13987. /**
  13988. * Value of the button/trigger
  13989. */
  13990. readonly value: number;
  13991. }
  13992. /** @hidden */
  13993. export interface _GamePadFactory {
  13994. /**
  13995. * Returns wether or not the current gamepad can be created for this type of controller.
  13996. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13997. * @returns true if it can be created, otherwise false
  13998. */
  13999. canCreate(gamepadInfo: any): boolean;
  14000. /**
  14001. * Creates a new instance of the Gamepad.
  14002. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14003. * @returns the new gamepad instance
  14004. */
  14005. create(gamepadInfo: any): Gamepad;
  14006. }
  14007. /**
  14008. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14009. */
  14010. export class PoseEnabledControllerHelper {
  14011. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14012. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14013. /**
  14014. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14015. * @param vrGamepad the gamepad to initialized
  14016. * @returns a vr controller of the type the gamepad identified as
  14017. */
  14018. static InitiateController(vrGamepad: any): Gamepad;
  14019. }
  14020. /**
  14021. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14022. */
  14023. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14024. /**
  14025. * If the controller is used in a webXR session
  14026. */
  14027. isXR: boolean;
  14028. private _deviceRoomPosition;
  14029. private _deviceRoomRotationQuaternion;
  14030. /**
  14031. * The device position in babylon space
  14032. */
  14033. devicePosition: Vector3;
  14034. /**
  14035. * The device rotation in babylon space
  14036. */
  14037. deviceRotationQuaternion: Quaternion;
  14038. /**
  14039. * The scale factor of the device in babylon space
  14040. */
  14041. deviceScaleFactor: number;
  14042. /**
  14043. * (Likely devicePosition should be used instead) The device position in its room space
  14044. */
  14045. position: Vector3;
  14046. /**
  14047. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14048. */
  14049. rotationQuaternion: Quaternion;
  14050. /**
  14051. * The type of controller (Eg. Windows mixed reality)
  14052. */
  14053. controllerType: PoseEnabledControllerType;
  14054. protected _calculatedPosition: Vector3;
  14055. private _calculatedRotation;
  14056. /**
  14057. * The raw pose from the device
  14058. */
  14059. rawPose: DevicePose;
  14060. private _trackPosition;
  14061. private _maxRotationDistFromHeadset;
  14062. private _draggedRoomRotation;
  14063. /**
  14064. * @hidden
  14065. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14066. /**
  14067. * Internal, the mesh attached to the controller
  14068. * @hidden
  14069. */ private _mesh: Nullable<AbstractMesh>;
  14070. private _poseControlledCamera;
  14071. private _leftHandSystemQuaternion;
  14072. /**
  14073. * Internal, matrix used to convert room space to babylon space
  14074. * @hidden
  14075. */ private _deviceToWorld: Matrix;
  14076. /**
  14077. * Node to be used when casting a ray from the controller
  14078. * @hidden
  14079. */ private _pointingPoseNode: Nullable<TransformNode>;
  14080. /**
  14081. * Name of the child mesh that can be used to cast a ray from the controller
  14082. */
  14083. static readonly POINTING_POSE: string;
  14084. /**
  14085. * Creates a new PoseEnabledController from a gamepad
  14086. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14087. */
  14088. constructor(browserGamepad: any);
  14089. private _workingMatrix;
  14090. /**
  14091. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14092. */
  14093. update(): void;
  14094. /**
  14095. * Updates only the pose device and mesh without doing any button event checking
  14096. */
  14097. protected _updatePoseAndMesh(): void;
  14098. /**
  14099. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14100. * @param poseData raw pose fromthe device
  14101. */
  14102. updateFromDevice(poseData: DevicePose): void;
  14103. /**
  14104. * @hidden
  14105. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14106. /**
  14107. * Attaches a mesh to the controller
  14108. * @param mesh the mesh to be attached
  14109. */
  14110. attachToMesh(mesh: AbstractMesh): void;
  14111. /**
  14112. * Attaches the controllers mesh to a camera
  14113. * @param camera the camera the mesh should be attached to
  14114. */
  14115. attachToPoseControlledCamera(camera: TargetCamera): void;
  14116. /**
  14117. * Disposes of the controller
  14118. */
  14119. dispose(): void;
  14120. /**
  14121. * The mesh that is attached to the controller
  14122. */
  14123. readonly mesh: Nullable<AbstractMesh>;
  14124. /**
  14125. * Gets the ray of the controller in the direction the controller is pointing
  14126. * @param length the length the resulting ray should be
  14127. * @returns a ray in the direction the controller is pointing
  14128. */
  14129. getForwardRay(length?: number): Ray;
  14130. }
  14131. }
  14132. declare module BABYLON {
  14133. /**
  14134. * Defines the WebVRController object that represents controllers tracked in 3D space
  14135. */
  14136. export abstract class WebVRController extends PoseEnabledController {
  14137. /**
  14138. * Internal, the default controller model for the controller
  14139. */
  14140. protected _defaultModel: AbstractMesh;
  14141. /**
  14142. * Fired when the trigger state has changed
  14143. */
  14144. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14145. /**
  14146. * Fired when the main button state has changed
  14147. */
  14148. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14149. /**
  14150. * Fired when the secondary button state has changed
  14151. */
  14152. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14153. /**
  14154. * Fired when the pad state has changed
  14155. */
  14156. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14157. /**
  14158. * Fired when controllers stick values have changed
  14159. */
  14160. onPadValuesChangedObservable: Observable<StickValues>;
  14161. /**
  14162. * Array of button availible on the controller
  14163. */
  14164. protected _buttons: Array<MutableGamepadButton>;
  14165. private _onButtonStateChange;
  14166. /**
  14167. * Fired when a controller button's state has changed
  14168. * @param callback the callback containing the button that was modified
  14169. */
  14170. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14171. /**
  14172. * X and Y axis corresponding to the controllers joystick
  14173. */
  14174. pad: StickValues;
  14175. /**
  14176. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14177. */
  14178. hand: string;
  14179. /**
  14180. * The default controller model for the controller
  14181. */
  14182. readonly defaultModel: AbstractMesh;
  14183. /**
  14184. * Creates a new WebVRController from a gamepad
  14185. * @param vrGamepad the gamepad that the WebVRController should be created from
  14186. */
  14187. constructor(vrGamepad: any);
  14188. /**
  14189. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14190. */
  14191. update(): void;
  14192. /**
  14193. * Function to be called when a button is modified
  14194. */
  14195. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14196. /**
  14197. * Loads a mesh and attaches it to the controller
  14198. * @param scene the scene the mesh should be added to
  14199. * @param meshLoaded callback for when the mesh has been loaded
  14200. */
  14201. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14202. private _setButtonValue;
  14203. private _changes;
  14204. private _checkChanges;
  14205. /**
  14206. * Disposes of th webVRCOntroller
  14207. */
  14208. dispose(): void;
  14209. }
  14210. }
  14211. declare module BABYLON {
  14212. /**
  14213. * The HemisphericLight simulates the ambient environment light,
  14214. * so the passed direction is the light reflection direction, not the incoming direction.
  14215. */
  14216. export class HemisphericLight extends Light {
  14217. /**
  14218. * The groundColor is the light in the opposite direction to the one specified during creation.
  14219. * 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.
  14220. */
  14221. groundColor: Color3;
  14222. /**
  14223. * The light reflection direction, not the incoming direction.
  14224. */
  14225. direction: Vector3;
  14226. /**
  14227. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14228. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14229. * The HemisphericLight can't cast shadows.
  14230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14231. * @param name The friendly name of the light
  14232. * @param direction The direction of the light reflection
  14233. * @param scene The scene the light belongs to
  14234. */
  14235. constructor(name: string, direction: Vector3, scene: Scene);
  14236. protected _buildUniformLayout(): void;
  14237. /**
  14238. * Returns the string "HemisphericLight".
  14239. * @return The class name
  14240. */
  14241. getClassName(): string;
  14242. /**
  14243. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14244. * Returns the updated direction.
  14245. * @param target The target the direction should point to
  14246. * @return The computed direction
  14247. */
  14248. setDirectionToTarget(target: Vector3): Vector3;
  14249. /**
  14250. * Returns the shadow generator associated to the light.
  14251. * @returns Always null for hemispheric lights because it does not support shadows.
  14252. */
  14253. getShadowGenerator(): Nullable<IShadowGenerator>;
  14254. /**
  14255. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14256. * @param effect The effect to update
  14257. * @param lightIndex The index of the light in the effect to update
  14258. * @returns The hemispheric light
  14259. */
  14260. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14261. /**
  14262. * Computes the world matrix of the node
  14263. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14264. * @param useWasUpdatedFlag defines a reserved property
  14265. * @returns the world matrix
  14266. */
  14267. computeWorldMatrix(): Matrix;
  14268. /**
  14269. * Returns the integer 3.
  14270. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14271. */
  14272. getTypeID(): number;
  14273. /**
  14274. * Prepares the list of defines specific to the light type.
  14275. * @param defines the list of defines
  14276. * @param lightIndex defines the index of the light for the effect
  14277. */
  14278. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14279. }
  14280. }
  14281. declare module BABYLON {
  14282. /** @hidden */
  14283. export var vrMultiviewToSingleviewPixelShader: {
  14284. name: string;
  14285. shader: string;
  14286. };
  14287. }
  14288. declare module BABYLON {
  14289. /**
  14290. * Renders to multiple views with a single draw call
  14291. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14292. */
  14293. export class MultiviewRenderTarget extends RenderTargetTexture {
  14294. /**
  14295. * Creates a multiview render target
  14296. * @param scene scene used with the render target
  14297. * @param size the size of the render target (used for each view)
  14298. */
  14299. constructor(scene: Scene, size?: number | {
  14300. width: number;
  14301. height: number;
  14302. } | {
  14303. ratio: number;
  14304. });
  14305. /**
  14306. * @hidden
  14307. * @param faceIndex the face index, if its a cube texture
  14308. */ private _bindFrameBuffer(faceIndex?: number): void;
  14309. /**
  14310. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14311. * @returns the view count
  14312. */
  14313. getViewCount(): number;
  14314. }
  14315. }
  14316. declare module BABYLON {
  14317. /**
  14318. * Reprasents a camera frustum
  14319. */
  14320. export class Frustum {
  14321. /**
  14322. * Gets the planes representing the frustum
  14323. * @param transform matrix to be applied to the returned planes
  14324. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14325. */
  14326. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14327. /**
  14328. * Gets the near frustum plane transformed by the transform matrix
  14329. * @param transform transformation matrix to be applied to the resulting frustum plane
  14330. * @param frustumPlane the resuling frustum plane
  14331. */
  14332. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14333. /**
  14334. * Gets the far frustum plane transformed by the transform matrix
  14335. * @param transform transformation matrix to be applied to the resulting frustum plane
  14336. * @param frustumPlane the resuling frustum plane
  14337. */
  14338. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14339. /**
  14340. * Gets the left frustum plane transformed by the transform matrix
  14341. * @param transform transformation matrix to be applied to the resulting frustum plane
  14342. * @param frustumPlane the resuling frustum plane
  14343. */
  14344. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14345. /**
  14346. * Gets the right frustum plane transformed by the transform matrix
  14347. * @param transform transformation matrix to be applied to the resulting frustum plane
  14348. * @param frustumPlane the resuling frustum plane
  14349. */
  14350. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14351. /**
  14352. * Gets the top frustum plane transformed by the transform matrix
  14353. * @param transform transformation matrix to be applied to the resulting frustum plane
  14354. * @param frustumPlane the resuling frustum plane
  14355. */
  14356. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14357. /**
  14358. * Gets the bottom frustum plane transformed by the transform matrix
  14359. * @param transform transformation matrix to be applied to the resulting frustum plane
  14360. * @param frustumPlane the resuling frustum plane
  14361. */
  14362. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14363. /**
  14364. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14365. * @param transform transformation matrix to be applied to the resulting frustum planes
  14366. * @param frustumPlanes the resuling frustum planes
  14367. */
  14368. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14369. }
  14370. }
  14371. declare module BABYLON {
  14372. interface Engine {
  14373. /**
  14374. * Creates a new multiview render target
  14375. * @param width defines the width of the texture
  14376. * @param height defines the height of the texture
  14377. * @returns the created multiview texture
  14378. */
  14379. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14380. /**
  14381. * Binds a multiview framebuffer to be drawn to
  14382. * @param multiviewTexture texture to bind
  14383. */
  14384. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14385. }
  14386. interface Camera {
  14387. /**
  14388. * @hidden
  14389. * 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)
  14390. */ private _useMultiviewToSingleView: boolean;
  14391. /**
  14392. * @hidden
  14393. * 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)
  14394. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14395. /**
  14396. * @hidden
  14397. * ensures the multiview texture of the camera exists and has the specified width/height
  14398. * @param width height to set on the multiview texture
  14399. * @param height width to set on the multiview texture
  14400. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14401. }
  14402. interface Scene {
  14403. /** @hidden */ private _transformMatrixR: Matrix;
  14404. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14405. /** @hidden */ private _createMultiviewUbo(): void;
  14406. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14407. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14408. }
  14409. }
  14410. declare module BABYLON {
  14411. /**
  14412. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14413. * This will not be used for webXR as it supports displaying texture arrays directly
  14414. */
  14415. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14416. /**
  14417. * Initializes a VRMultiviewToSingleview
  14418. * @param name name of the post process
  14419. * @param camera camera to be applied to
  14420. * @param scaleFactor scaling factor to the size of the output texture
  14421. */
  14422. constructor(name: string, camera: Camera, scaleFactor: number);
  14423. }
  14424. }
  14425. declare module BABYLON {
  14426. interface Engine {
  14427. /** @hidden */ private _vrDisplay: any;
  14428. /** @hidden */ private _vrSupported: boolean;
  14429. /** @hidden */ private _oldSize: Size;
  14430. /** @hidden */ private _oldHardwareScaleFactor: number;
  14431. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14432. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14433. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14434. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14435. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14436. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14437. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14438. /**
  14439. * Observable signaled when VR display mode changes
  14440. */
  14441. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14442. /**
  14443. * Observable signaled when VR request present is complete
  14444. */
  14445. onVRRequestPresentComplete: Observable<boolean>;
  14446. /**
  14447. * Observable signaled when VR request present starts
  14448. */
  14449. onVRRequestPresentStart: Observable<Engine>;
  14450. /**
  14451. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14452. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14453. */
  14454. isInVRExclusivePointerMode: boolean;
  14455. /**
  14456. * Gets a boolean indicating if a webVR device was detected
  14457. * @returns true if a webVR device was detected
  14458. */
  14459. isVRDevicePresent(): boolean;
  14460. /**
  14461. * Gets the current webVR device
  14462. * @returns the current webVR device (or null)
  14463. */
  14464. getVRDevice(): any;
  14465. /**
  14466. * Initializes a webVR display and starts listening to display change events
  14467. * The onVRDisplayChangedObservable will be notified upon these changes
  14468. * @returns A promise containing a VRDisplay and if vr is supported
  14469. */
  14470. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14471. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14472. /**
  14473. * Call this function to switch to webVR mode
  14474. * Will do nothing if webVR is not supported or if there is no webVR device
  14475. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14476. */
  14477. enableVR(): void;
  14478. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14479. }
  14480. }
  14481. declare module BABYLON {
  14482. /**
  14483. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14484. * IMPORTANT!! The data is right-hand data.
  14485. * @export
  14486. * @interface DevicePose
  14487. */
  14488. export interface DevicePose {
  14489. /**
  14490. * The position of the device, values in array are [x,y,z].
  14491. */
  14492. readonly position: Nullable<Float32Array>;
  14493. /**
  14494. * The linearVelocity of the device, values in array are [x,y,z].
  14495. */
  14496. readonly linearVelocity: Nullable<Float32Array>;
  14497. /**
  14498. * The linearAcceleration of the device, values in array are [x,y,z].
  14499. */
  14500. readonly linearAcceleration: Nullable<Float32Array>;
  14501. /**
  14502. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14503. */
  14504. readonly orientation: Nullable<Float32Array>;
  14505. /**
  14506. * The angularVelocity of the device, values in array are [x,y,z].
  14507. */
  14508. readonly angularVelocity: Nullable<Float32Array>;
  14509. /**
  14510. * The angularAcceleration of the device, values in array are [x,y,z].
  14511. */
  14512. readonly angularAcceleration: Nullable<Float32Array>;
  14513. }
  14514. /**
  14515. * Interface representing a pose controlled object in Babylon.
  14516. * A pose controlled object has both regular pose values as well as pose values
  14517. * from an external device such as a VR head mounted display
  14518. */
  14519. export interface PoseControlled {
  14520. /**
  14521. * The position of the object in babylon space.
  14522. */
  14523. position: Vector3;
  14524. /**
  14525. * The rotation quaternion of the object in babylon space.
  14526. */
  14527. rotationQuaternion: Quaternion;
  14528. /**
  14529. * The position of the device in babylon space.
  14530. */
  14531. devicePosition?: Vector3;
  14532. /**
  14533. * The rotation quaternion of the device in babylon space.
  14534. */
  14535. deviceRotationQuaternion: Quaternion;
  14536. /**
  14537. * The raw pose coming from the device.
  14538. */
  14539. rawPose: Nullable<DevicePose>;
  14540. /**
  14541. * The scale of the device to be used when translating from device space to babylon space.
  14542. */
  14543. deviceScaleFactor: number;
  14544. /**
  14545. * Updates the poseControlled values based on the input device pose.
  14546. * @param poseData the pose data to update the object with
  14547. */
  14548. updateFromDevice(poseData: DevicePose): void;
  14549. }
  14550. /**
  14551. * Set of options to customize the webVRCamera
  14552. */
  14553. export interface WebVROptions {
  14554. /**
  14555. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14556. */
  14557. trackPosition?: boolean;
  14558. /**
  14559. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14560. */
  14561. positionScale?: number;
  14562. /**
  14563. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14564. */
  14565. displayName?: string;
  14566. /**
  14567. * Should the native controller meshes be initialized. (default: true)
  14568. */
  14569. controllerMeshes?: boolean;
  14570. /**
  14571. * Creating a default HemiLight only on controllers. (default: true)
  14572. */
  14573. defaultLightingOnControllers?: boolean;
  14574. /**
  14575. * If you don't want to use the default VR button of the helper. (default: false)
  14576. */
  14577. useCustomVRButton?: boolean;
  14578. /**
  14579. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14580. */
  14581. customVRButton?: HTMLButtonElement;
  14582. /**
  14583. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14584. */
  14585. rayLength?: number;
  14586. /**
  14587. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14588. */
  14589. defaultHeight?: number;
  14590. /**
  14591. * If multiview should be used if availible (default: false)
  14592. */
  14593. useMultiview?: boolean;
  14594. }
  14595. /**
  14596. * This represents a WebVR camera.
  14597. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14598. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14599. */
  14600. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14601. private webVROptions;
  14602. /**
  14603. * @hidden
  14604. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14605. */ private _vrDevice: any;
  14606. /**
  14607. * The rawPose of the vrDevice.
  14608. */
  14609. rawPose: Nullable<DevicePose>;
  14610. private _onVREnabled;
  14611. private _specsVersion;
  14612. private _attached;
  14613. private _frameData;
  14614. protected _descendants: Array<Node>;
  14615. private _deviceRoomPosition;
  14616. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14617. private _standingMatrix;
  14618. /**
  14619. * Represents device position in babylon space.
  14620. */
  14621. devicePosition: Vector3;
  14622. /**
  14623. * Represents device rotation in babylon space.
  14624. */
  14625. deviceRotationQuaternion: Quaternion;
  14626. /**
  14627. * The scale of the device to be used when translating from device space to babylon space.
  14628. */
  14629. deviceScaleFactor: number;
  14630. private _deviceToWorld;
  14631. private _worldToDevice;
  14632. /**
  14633. * References to the webVR controllers for the vrDevice.
  14634. */
  14635. controllers: Array<WebVRController>;
  14636. /**
  14637. * Emits an event when a controller is attached.
  14638. */
  14639. onControllersAttachedObservable: Observable<WebVRController[]>;
  14640. /**
  14641. * Emits an event when a controller's mesh has been loaded;
  14642. */
  14643. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14644. /**
  14645. * Emits an event when the HMD's pose has been updated.
  14646. */
  14647. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14648. private _poseSet;
  14649. /**
  14650. * If the rig cameras be used as parent instead of this camera.
  14651. */
  14652. rigParenting: boolean;
  14653. private _lightOnControllers;
  14654. private _defaultHeight?;
  14655. /**
  14656. * Instantiates a WebVRFreeCamera.
  14657. * @param name The name of the WebVRFreeCamera
  14658. * @param position The starting anchor position for the camera
  14659. * @param scene The scene the camera belongs to
  14660. * @param webVROptions a set of customizable options for the webVRCamera
  14661. */
  14662. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14663. /**
  14664. * Gets the device distance from the ground in meters.
  14665. * @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.
  14666. */
  14667. deviceDistanceToRoomGround(): number;
  14668. /**
  14669. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14670. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14671. */
  14672. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14673. /**
  14674. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14675. * @returns A promise with a boolean set to if the standing matrix is supported.
  14676. */
  14677. useStandingMatrixAsync(): Promise<boolean>;
  14678. /**
  14679. * Disposes the camera
  14680. */
  14681. dispose(): void;
  14682. /**
  14683. * Gets a vrController by name.
  14684. * @param name The name of the controller to retreive
  14685. * @returns the controller matching the name specified or null if not found
  14686. */
  14687. getControllerByName(name: string): Nullable<WebVRController>;
  14688. private _leftController;
  14689. /**
  14690. * The controller corresponding to the users left hand.
  14691. */
  14692. readonly leftController: Nullable<WebVRController>;
  14693. private _rightController;
  14694. /**
  14695. * The controller corresponding to the users right hand.
  14696. */
  14697. readonly rightController: Nullable<WebVRController>;
  14698. /**
  14699. * Casts a ray forward from the vrCamera's gaze.
  14700. * @param length Length of the ray (default: 100)
  14701. * @returns the ray corresponding to the gaze
  14702. */
  14703. getForwardRay(length?: number): Ray;
  14704. /**
  14705. * @hidden
  14706. * Updates the camera based on device's frame data
  14707. */ private _checkInputs(): void;
  14708. /**
  14709. * Updates the poseControlled values based on the input device pose.
  14710. * @param poseData Pose coming from the device
  14711. */
  14712. updateFromDevice(poseData: DevicePose): void;
  14713. private _htmlElementAttached;
  14714. private _detachIfAttached;
  14715. /**
  14716. * WebVR's attach control will start broadcasting frames to the device.
  14717. * Note that in certain browsers (chrome for example) this function must be called
  14718. * within a user-interaction callback. Example:
  14719. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14720. *
  14721. * @param element html element to attach the vrDevice to
  14722. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14723. */
  14724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14725. /**
  14726. * Detaches the camera from the html element and disables VR
  14727. *
  14728. * @param element html element to detach from
  14729. */
  14730. detachControl(element: HTMLElement): void;
  14731. /**
  14732. * @returns the name of this class
  14733. */
  14734. getClassName(): string;
  14735. /**
  14736. * Calls resetPose on the vrDisplay
  14737. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14738. */
  14739. resetToCurrentRotation(): void;
  14740. /**
  14741. * @hidden
  14742. * Updates the rig cameras (left and right eye)
  14743. */ private _updateRigCameras(): void;
  14744. private _workingVector;
  14745. private _oneVector;
  14746. private _workingMatrix;
  14747. private updateCacheCalled;
  14748. private _correctPositionIfNotTrackPosition;
  14749. /**
  14750. * @hidden
  14751. * Updates the cached values of the camera
  14752. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14753. */ private _updateCache(ignoreParentClass?: boolean): void;
  14754. /**
  14755. * @hidden
  14756. * Get current device position in babylon world
  14757. */ private _computeDevicePosition(): void;
  14758. /**
  14759. * Updates the current device position and rotation in the babylon world
  14760. */
  14761. update(): void;
  14762. /**
  14763. * @hidden
  14764. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14765. * @returns an identity matrix
  14766. */ private _getViewMatrix(): Matrix;
  14767. private _tmpMatrix;
  14768. /**
  14769. * This function is called by the two RIG cameras.
  14770. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14771. * @hidden
  14772. */ private _getWebVRViewMatrix(): Matrix;
  14773. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14774. private _onGamepadConnectedObserver;
  14775. private _onGamepadDisconnectedObserver;
  14776. private _updateCacheWhenTrackingDisabledObserver;
  14777. /**
  14778. * Initializes the controllers and their meshes
  14779. */
  14780. initControllers(): void;
  14781. }
  14782. }
  14783. declare module BABYLON {
  14784. /**
  14785. * Size options for a post process
  14786. */
  14787. export type PostProcessOptions = {
  14788. width: number;
  14789. height: number;
  14790. };
  14791. /**
  14792. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14793. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14794. */
  14795. export class PostProcess {
  14796. /** Name of the PostProcess. */
  14797. name: string;
  14798. /**
  14799. * Gets or sets the unique id of the post process
  14800. */
  14801. uniqueId: number;
  14802. /**
  14803. * Width of the texture to apply the post process on
  14804. */
  14805. width: number;
  14806. /**
  14807. * Height of the texture to apply the post process on
  14808. */
  14809. height: number;
  14810. /**
  14811. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14812. * @hidden
  14813. */ private _outputTexture: Nullable<InternalTexture>;
  14814. /**
  14815. * Sampling mode used by the shader
  14816. * See https://doc.babylonjs.com/classes/3.1/texture
  14817. */
  14818. renderTargetSamplingMode: number;
  14819. /**
  14820. * Clear color to use when screen clearing
  14821. */
  14822. clearColor: Color4;
  14823. /**
  14824. * If the buffer needs to be cleared before applying the post process. (default: true)
  14825. * Should be set to false if shader will overwrite all previous pixels.
  14826. */
  14827. autoClear: boolean;
  14828. /**
  14829. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14830. */
  14831. alphaMode: number;
  14832. /**
  14833. * Sets the setAlphaBlendConstants of the babylon engine
  14834. */
  14835. alphaConstants: Color4;
  14836. /**
  14837. * Animations to be used for the post processing
  14838. */
  14839. animations: Animation[];
  14840. /**
  14841. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14842. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14843. */
  14844. enablePixelPerfectMode: boolean;
  14845. /**
  14846. * Force the postprocess to be applied without taking in account viewport
  14847. */
  14848. forceFullscreenViewport: boolean;
  14849. /**
  14850. * List of inspectable custom properties (used by the Inspector)
  14851. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14852. */
  14853. inspectableCustomProperties: IInspectable[];
  14854. /**
  14855. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14856. *
  14857. * | Value | Type | Description |
  14858. * | ----- | ----------------------------------- | ----------- |
  14859. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14860. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14861. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14862. *
  14863. */
  14864. scaleMode: number;
  14865. /**
  14866. * Force textures to be a power of two (default: false)
  14867. */
  14868. alwaysForcePOT: boolean;
  14869. private _samples;
  14870. /**
  14871. * Number of sample textures (default: 1)
  14872. */
  14873. samples: number;
  14874. /**
  14875. * Modify the scale of the post process to be the same as the viewport (default: false)
  14876. */
  14877. adaptScaleToCurrentViewport: boolean;
  14878. private _camera;
  14879. private _scene;
  14880. private _engine;
  14881. private _options;
  14882. private _reusable;
  14883. private _textureType;
  14884. /**
  14885. * Smart array of input and output textures for the post process.
  14886. * @hidden
  14887. */ private _textures: SmartArray<InternalTexture>;
  14888. /**
  14889. * The index in _textures that corresponds to the output texture.
  14890. * @hidden
  14891. */ private _currentRenderTextureInd: number;
  14892. private _effect;
  14893. private _samplers;
  14894. private _fragmentUrl;
  14895. private _vertexUrl;
  14896. private _parameters;
  14897. private _scaleRatio;
  14898. protected _indexParameters: any;
  14899. private _shareOutputWithPostProcess;
  14900. private _texelSize;
  14901. private _forcedOutputTexture;
  14902. /**
  14903. * Returns the fragment url or shader name used in the post process.
  14904. * @returns the fragment url or name in the shader store.
  14905. */
  14906. getEffectName(): string;
  14907. /**
  14908. * An event triggered when the postprocess is activated.
  14909. */
  14910. onActivateObservable: Observable<Camera>;
  14911. private _onActivateObserver;
  14912. /**
  14913. * A function that is added to the onActivateObservable
  14914. */
  14915. onActivate: Nullable<(camera: Camera) => void>;
  14916. /**
  14917. * An event triggered when the postprocess changes its size.
  14918. */
  14919. onSizeChangedObservable: Observable<PostProcess>;
  14920. private _onSizeChangedObserver;
  14921. /**
  14922. * A function that is added to the onSizeChangedObservable
  14923. */
  14924. onSizeChanged: (postProcess: PostProcess) => void;
  14925. /**
  14926. * An event triggered when the postprocess applies its effect.
  14927. */
  14928. onApplyObservable: Observable<Effect>;
  14929. private _onApplyObserver;
  14930. /**
  14931. * A function that is added to the onApplyObservable
  14932. */
  14933. onApply: (effect: Effect) => void;
  14934. /**
  14935. * An event triggered before rendering the postprocess
  14936. */
  14937. onBeforeRenderObservable: Observable<Effect>;
  14938. private _onBeforeRenderObserver;
  14939. /**
  14940. * A function that is added to the onBeforeRenderObservable
  14941. */
  14942. onBeforeRender: (effect: Effect) => void;
  14943. /**
  14944. * An event triggered after rendering the postprocess
  14945. */
  14946. onAfterRenderObservable: Observable<Effect>;
  14947. private _onAfterRenderObserver;
  14948. /**
  14949. * A function that is added to the onAfterRenderObservable
  14950. */
  14951. onAfterRender: (efect: Effect) => void;
  14952. /**
  14953. * 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
  14954. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14955. */
  14956. inputTexture: InternalTexture;
  14957. /**
  14958. * Gets the camera which post process is applied to.
  14959. * @returns The camera the post process is applied to.
  14960. */
  14961. getCamera(): Camera;
  14962. /**
  14963. * Gets the texel size of the postprocess.
  14964. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14965. */
  14966. readonly texelSize: Vector2;
  14967. /**
  14968. * Creates a new instance PostProcess
  14969. * @param name The name of the PostProcess.
  14970. * @param fragmentUrl The url of the fragment shader to be used.
  14971. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14972. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14973. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14974. * @param camera The camera to apply the render pass to.
  14975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14976. * @param engine The engine which the post process will be applied. (default: current engine)
  14977. * @param reusable If the post process can be reused on the same frame. (default: false)
  14978. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14979. * @param textureType Type of textures used when performing the post process. (default: 0)
  14980. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14981. * @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
  14982. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14983. */
  14984. constructor(
  14985. /** Name of the PostProcess. */
  14986. 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);
  14987. /**
  14988. * Gets a string idenfifying the name of the class
  14989. * @returns "PostProcess" string
  14990. */
  14991. getClassName(): string;
  14992. /**
  14993. * Gets the engine which this post process belongs to.
  14994. * @returns The engine the post process was enabled with.
  14995. */
  14996. getEngine(): Engine;
  14997. /**
  14998. * The effect that is created when initializing the post process.
  14999. * @returns The created effect corresponding the the postprocess.
  15000. */
  15001. getEffect(): Effect;
  15002. /**
  15003. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15004. * @param postProcess The post process to share the output with.
  15005. * @returns This post process.
  15006. */
  15007. shareOutputWith(postProcess: PostProcess): PostProcess;
  15008. /**
  15009. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15010. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15011. */
  15012. useOwnOutput(): void;
  15013. /**
  15014. * Updates the effect with the current post process compile time values and recompiles the shader.
  15015. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15016. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15017. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15018. * @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
  15019. * @param onCompiled Called when the shader has been compiled.
  15020. * @param onError Called if there is an error when compiling a shader.
  15021. */
  15022. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15023. /**
  15024. * The post process is reusable if it can be used multiple times within one frame.
  15025. * @returns If the post process is reusable
  15026. */
  15027. isReusable(): boolean;
  15028. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15029. markTextureDirty(): void;
  15030. /**
  15031. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15032. * 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.
  15033. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15034. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15035. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15036. * @returns The target texture that was bound to be written to.
  15037. */
  15038. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15039. /**
  15040. * If the post process is supported.
  15041. */
  15042. readonly isSupported: boolean;
  15043. /**
  15044. * The aspect ratio of the output texture.
  15045. */
  15046. readonly aspectRatio: number;
  15047. /**
  15048. * Get a value indicating if the post-process is ready to be used
  15049. * @returns true if the post-process is ready (shader is compiled)
  15050. */
  15051. isReady(): boolean;
  15052. /**
  15053. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15054. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15055. */
  15056. apply(): Nullable<Effect>;
  15057. private _disposeTextures;
  15058. /**
  15059. * Disposes the post process.
  15060. * @param camera The camera to dispose the post process on.
  15061. */
  15062. dispose(camera?: Camera): void;
  15063. }
  15064. }
  15065. declare module BABYLON {
  15066. /** @hidden */
  15067. export var kernelBlurVaryingDeclaration: {
  15068. name: string;
  15069. shader: string;
  15070. };
  15071. }
  15072. declare module BABYLON {
  15073. /** @hidden */
  15074. export var kernelBlurFragment: {
  15075. name: string;
  15076. shader: string;
  15077. };
  15078. }
  15079. declare module BABYLON {
  15080. /** @hidden */
  15081. export var kernelBlurFragment2: {
  15082. name: string;
  15083. shader: string;
  15084. };
  15085. }
  15086. declare module BABYLON {
  15087. /** @hidden */
  15088. export var kernelBlurPixelShader: {
  15089. name: string;
  15090. shader: string;
  15091. };
  15092. }
  15093. declare module BABYLON {
  15094. /** @hidden */
  15095. export var kernelBlurVertex: {
  15096. name: string;
  15097. shader: string;
  15098. };
  15099. }
  15100. declare module BABYLON {
  15101. /** @hidden */
  15102. export var kernelBlurVertexShader: {
  15103. name: string;
  15104. shader: string;
  15105. };
  15106. }
  15107. declare module BABYLON {
  15108. /**
  15109. * The Blur Post Process which blurs an image based on a kernel and direction.
  15110. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15111. */
  15112. export class BlurPostProcess extends PostProcess {
  15113. /** The direction in which to blur the image. */
  15114. direction: Vector2;
  15115. private blockCompilation;
  15116. protected _kernel: number;
  15117. protected _idealKernel: number;
  15118. protected _packedFloat: boolean;
  15119. private _staticDefines;
  15120. /**
  15121. * Sets the length in pixels of the blur sample region
  15122. */
  15123. /**
  15124. * Gets the length in pixels of the blur sample region
  15125. */
  15126. kernel: number;
  15127. /**
  15128. * Sets wether or not the blur needs to unpack/repack floats
  15129. */
  15130. /**
  15131. * Gets wether or not the blur is unpacking/repacking floats
  15132. */
  15133. packedFloat: boolean;
  15134. /**
  15135. * Creates a new instance BlurPostProcess
  15136. * @param name The name of the effect.
  15137. * @param direction The direction in which to blur the image.
  15138. * @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.
  15139. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15140. * @param camera The camera to apply the render pass to.
  15141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15142. * @param engine The engine which the post process will be applied. (default: current engine)
  15143. * @param reusable If the post process can be reused on the same frame. (default: false)
  15144. * @param textureType Type of textures used when performing the post process. (default: 0)
  15145. * @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)
  15146. */
  15147. constructor(name: string,
  15148. /** The direction in which to blur the image. */
  15149. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15150. /**
  15151. * Updates the effect with the current post process compile time values and recompiles the shader.
  15152. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15153. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15154. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15155. * @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
  15156. * @param onCompiled Called when the shader has been compiled.
  15157. * @param onError Called if there is an error when compiling a shader.
  15158. */
  15159. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15160. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15161. /**
  15162. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15163. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15164. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15165. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15166. * The gaps between physical kernels are compensated for in the weighting of the samples
  15167. * @param idealKernel Ideal blur kernel.
  15168. * @return Nearest best kernel.
  15169. */
  15170. protected _nearestBestKernel(idealKernel: number): number;
  15171. /**
  15172. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15173. * @param x The point on the Gaussian distribution to sample.
  15174. * @return the value of the Gaussian function at x.
  15175. */
  15176. protected _gaussianWeight(x: number): number;
  15177. /**
  15178. * Generates a string that can be used as a floating point number in GLSL.
  15179. * @param x Value to print.
  15180. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15181. * @return GLSL float string.
  15182. */
  15183. protected _glslFloat(x: number, decimalFigures?: number): string;
  15184. }
  15185. }
  15186. declare module BABYLON {
  15187. /**
  15188. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15189. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15190. * You can then easily use it as a reflectionTexture on a flat surface.
  15191. * In case the surface is not a plane, please consider relying on reflection probes.
  15192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15193. */
  15194. export class MirrorTexture extends RenderTargetTexture {
  15195. private scene;
  15196. /**
  15197. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15198. * 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.
  15199. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15200. */
  15201. mirrorPlane: Plane;
  15202. /**
  15203. * Define the blur ratio used to blur the reflection if needed.
  15204. */
  15205. blurRatio: number;
  15206. /**
  15207. * Define the adaptive blur kernel used to blur the reflection if needed.
  15208. * This will autocompute the closest best match for the `blurKernel`
  15209. */
  15210. adaptiveBlurKernel: number;
  15211. /**
  15212. * Define the blur kernel used to blur the reflection if needed.
  15213. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15214. */
  15215. blurKernel: number;
  15216. /**
  15217. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15218. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15219. */
  15220. blurKernelX: number;
  15221. /**
  15222. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15223. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15224. */
  15225. blurKernelY: number;
  15226. private _autoComputeBlurKernel;
  15227. protected _onRatioRescale(): void;
  15228. private _updateGammaSpace;
  15229. private _imageProcessingConfigChangeObserver;
  15230. private _transformMatrix;
  15231. private _mirrorMatrix;
  15232. private _savedViewMatrix;
  15233. private _blurX;
  15234. private _blurY;
  15235. private _adaptiveBlurKernel;
  15236. private _blurKernelX;
  15237. private _blurKernelY;
  15238. private _blurRatio;
  15239. /**
  15240. * Instantiates a Mirror Texture.
  15241. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15242. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15243. * You can then easily use it as a reflectionTexture on a flat surface.
  15244. * In case the surface is not a plane, please consider relying on reflection probes.
  15245. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15246. * @param name
  15247. * @param size
  15248. * @param scene
  15249. * @param generateMipMaps
  15250. * @param type
  15251. * @param samplingMode
  15252. * @param generateDepthBuffer
  15253. */
  15254. constructor(name: string, size: number | {
  15255. width: number;
  15256. height: number;
  15257. } | {
  15258. ratio: number;
  15259. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15260. private _preparePostProcesses;
  15261. /**
  15262. * Clone the mirror texture.
  15263. * @returns the cloned texture
  15264. */
  15265. clone(): MirrorTexture;
  15266. /**
  15267. * Serialize the texture to a JSON representation you could use in Parse later on
  15268. * @returns the serialized JSON representation
  15269. */
  15270. serialize(): any;
  15271. /**
  15272. * Dispose the texture and release its associated resources.
  15273. */
  15274. dispose(): void;
  15275. }
  15276. }
  15277. declare module BABYLON {
  15278. /**
  15279. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15280. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15281. */
  15282. export class Texture extends BaseTexture {
  15283. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15284. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15285. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15286. /** nearest is mag = nearest and min = nearest and mip = linear */
  15287. static readonly NEAREST_SAMPLINGMODE: number;
  15288. /** nearest is mag = nearest and min = nearest and mip = linear */
  15289. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15290. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15291. static readonly BILINEAR_SAMPLINGMODE: number;
  15292. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15293. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15294. /** Trilinear is mag = linear and min = linear and mip = linear */
  15295. static readonly TRILINEAR_SAMPLINGMODE: number;
  15296. /** Trilinear is mag = linear and min = linear and mip = linear */
  15297. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15298. /** mag = nearest and min = nearest and mip = nearest */
  15299. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15300. /** mag = nearest and min = linear and mip = nearest */
  15301. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15302. /** mag = nearest and min = linear and mip = linear */
  15303. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15304. /** mag = nearest and min = linear and mip = none */
  15305. static readonly NEAREST_LINEAR: number;
  15306. /** mag = nearest and min = nearest and mip = none */
  15307. static readonly NEAREST_NEAREST: number;
  15308. /** mag = linear and min = nearest and mip = nearest */
  15309. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15310. /** mag = linear and min = nearest and mip = linear */
  15311. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15312. /** mag = linear and min = linear and mip = none */
  15313. static readonly LINEAR_LINEAR: number;
  15314. /** mag = linear and min = nearest and mip = none */
  15315. static readonly LINEAR_NEAREST: number;
  15316. /** Explicit coordinates mode */
  15317. static readonly EXPLICIT_MODE: number;
  15318. /** Spherical coordinates mode */
  15319. static readonly SPHERICAL_MODE: number;
  15320. /** Planar coordinates mode */
  15321. static readonly PLANAR_MODE: number;
  15322. /** Cubic coordinates mode */
  15323. static readonly CUBIC_MODE: number;
  15324. /** Projection coordinates mode */
  15325. static readonly PROJECTION_MODE: number;
  15326. /** Inverse Cubic coordinates mode */
  15327. static readonly SKYBOX_MODE: number;
  15328. /** Inverse Cubic coordinates mode */
  15329. static readonly INVCUBIC_MODE: number;
  15330. /** Equirectangular coordinates mode */
  15331. static readonly EQUIRECTANGULAR_MODE: number;
  15332. /** Equirectangular Fixed coordinates mode */
  15333. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15334. /** Equirectangular Fixed Mirrored coordinates mode */
  15335. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15336. /** Texture is not repeating outside of 0..1 UVs */
  15337. static readonly CLAMP_ADDRESSMODE: number;
  15338. /** Texture is repeating outside of 0..1 UVs */
  15339. static readonly WRAP_ADDRESSMODE: number;
  15340. /** Texture is repeating and mirrored */
  15341. static readonly MIRROR_ADDRESSMODE: number;
  15342. /**
  15343. * 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
  15344. */
  15345. static UseSerializedUrlIfAny: boolean;
  15346. /**
  15347. * Define the url of the texture.
  15348. */
  15349. url: Nullable<string>;
  15350. /**
  15351. * Define an offset on the texture to offset the u coordinates of the UVs
  15352. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15353. */
  15354. uOffset: number;
  15355. /**
  15356. * Define an offset on the texture to offset the v coordinates of the UVs
  15357. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15358. */
  15359. vOffset: number;
  15360. /**
  15361. * Define an offset on the texture to scale the u coordinates of the UVs
  15362. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15363. */
  15364. uScale: number;
  15365. /**
  15366. * Define an offset on the texture to scale the v coordinates of the UVs
  15367. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15368. */
  15369. vScale: number;
  15370. /**
  15371. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15372. * @see http://doc.babylonjs.com/how_to/more_materials
  15373. */
  15374. uAng: number;
  15375. /**
  15376. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15377. * @see http://doc.babylonjs.com/how_to/more_materials
  15378. */
  15379. vAng: number;
  15380. /**
  15381. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15382. * @see http://doc.babylonjs.com/how_to/more_materials
  15383. */
  15384. wAng: number;
  15385. /**
  15386. * Defines the center of rotation (U)
  15387. */
  15388. uRotationCenter: number;
  15389. /**
  15390. * Defines the center of rotation (V)
  15391. */
  15392. vRotationCenter: number;
  15393. /**
  15394. * Defines the center of rotation (W)
  15395. */
  15396. wRotationCenter: number;
  15397. /**
  15398. * Are mip maps generated for this texture or not.
  15399. */
  15400. readonly noMipmap: boolean;
  15401. /**
  15402. * List of inspectable custom properties (used by the Inspector)
  15403. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15404. */
  15405. inspectableCustomProperties: Nullable<IInspectable[]>;
  15406. private _noMipmap;
  15407. /** @hidden */ private _invertY: boolean;
  15408. private _rowGenerationMatrix;
  15409. private _cachedTextureMatrix;
  15410. private _projectionModeMatrix;
  15411. private _t0;
  15412. private _t1;
  15413. private _t2;
  15414. private _cachedUOffset;
  15415. private _cachedVOffset;
  15416. private _cachedUScale;
  15417. private _cachedVScale;
  15418. private _cachedUAng;
  15419. private _cachedVAng;
  15420. private _cachedWAng;
  15421. private _cachedProjectionMatrixId;
  15422. private _cachedCoordinatesMode;
  15423. /** @hidden */
  15424. protected _initialSamplingMode: number;
  15425. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15426. private _deleteBuffer;
  15427. protected _format: Nullable<number>;
  15428. private _delayedOnLoad;
  15429. private _delayedOnError;
  15430. /**
  15431. * Observable triggered once the texture has been loaded.
  15432. */
  15433. onLoadObservable: Observable<Texture>;
  15434. protected _isBlocking: boolean;
  15435. /**
  15436. * Is the texture preventing material to render while loading.
  15437. * If false, a default texture will be used instead of the loading one during the preparation step.
  15438. */
  15439. isBlocking: boolean;
  15440. /**
  15441. * Get the current sampling mode associated with the texture.
  15442. */
  15443. readonly samplingMode: number;
  15444. /**
  15445. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15446. */
  15447. readonly invertY: boolean;
  15448. /**
  15449. * Instantiates a new texture.
  15450. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15451. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15452. * @param url define the url of the picture to load as a texture
  15453. * @param scene define the scene or engine the texture will belong to
  15454. * @param noMipmap define if the texture will require mip maps or not
  15455. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15456. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15457. * @param onLoad define a callback triggered when the texture has been loaded
  15458. * @param onError define a callback triggered when an error occurred during the loading session
  15459. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15460. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15461. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15462. */
  15463. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15464. /**
  15465. * Update the url (and optional buffer) of this texture if url was null during construction.
  15466. * @param url the url of the texture
  15467. * @param buffer the buffer of the texture (defaults to null)
  15468. * @param onLoad callback called when the texture is loaded (defaults to null)
  15469. */
  15470. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15471. /**
  15472. * Finish the loading sequence of a texture flagged as delayed load.
  15473. * @hidden
  15474. */
  15475. delayLoad(): void;
  15476. private _prepareRowForTextureGeneration;
  15477. /**
  15478. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15479. * @returns the transform matrix of the texture.
  15480. */
  15481. getTextureMatrix(): Matrix;
  15482. /**
  15483. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15484. * @returns The reflection texture transform
  15485. */
  15486. getReflectionTextureMatrix(): Matrix;
  15487. /**
  15488. * Clones the texture.
  15489. * @returns the cloned texture
  15490. */
  15491. clone(): Texture;
  15492. /**
  15493. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15494. * @returns The JSON representation of the texture
  15495. */
  15496. serialize(): any;
  15497. /**
  15498. * Get the current class name of the texture useful for serialization or dynamic coding.
  15499. * @returns "Texture"
  15500. */
  15501. getClassName(): string;
  15502. /**
  15503. * Dispose the texture and release its associated resources.
  15504. */
  15505. dispose(): void;
  15506. /**
  15507. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15508. * @param parsedTexture Define the JSON representation of the texture
  15509. * @param scene Define the scene the parsed texture should be instantiated in
  15510. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15511. * @returns The parsed texture if successful
  15512. */
  15513. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15514. /**
  15515. * Creates a texture from its base 64 representation.
  15516. * @param data Define the base64 payload without the data: prefix
  15517. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15518. * @param scene Define the scene the texture should belong to
  15519. * @param noMipmap Forces the texture to not create mip map information if true
  15520. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15521. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15522. * @param onLoad define a callback triggered when the texture has been loaded
  15523. * @param onError define a callback triggered when an error occurred during the loading session
  15524. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15525. * @returns the created texture
  15526. */
  15527. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15528. /**
  15529. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15530. * @param data Define the base64 payload without the data: prefix
  15531. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15532. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15533. * @param scene Define the scene the texture should belong to
  15534. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15535. * @param noMipmap Forces the texture to not create mip map information if true
  15536. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15537. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15538. * @param onLoad define a callback triggered when the texture has been loaded
  15539. * @param onError define a callback triggered when an error occurred during the loading session
  15540. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15541. * @returns the created texture
  15542. */
  15543. 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;
  15544. }
  15545. }
  15546. declare module BABYLON {
  15547. /**
  15548. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15549. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15550. */
  15551. export class PostProcessManager {
  15552. private _scene;
  15553. private _indexBuffer;
  15554. private _vertexBuffers;
  15555. /**
  15556. * Creates a new instance PostProcess
  15557. * @param scene The scene that the post process is associated with.
  15558. */
  15559. constructor(scene: Scene);
  15560. private _prepareBuffers;
  15561. private _buildIndexBuffer;
  15562. /**
  15563. * Rebuilds the vertex buffers of the manager.
  15564. * @hidden
  15565. */ private _rebuild(): void;
  15566. /**
  15567. * Prepares a frame to be run through a post process.
  15568. * @param sourceTexture The input texture to the post procesess. (default: null)
  15569. * @param postProcesses An array of post processes to be run. (default: null)
  15570. * @returns True if the post processes were able to be run.
  15571. * @hidden
  15572. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15573. /**
  15574. * Manually render a set of post processes to a texture.
  15575. * @param postProcesses An array of post processes to be run.
  15576. * @param targetTexture The target texture to render to.
  15577. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15578. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15579. * @param lodLevel defines which lod of the texture to render to
  15580. */
  15581. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15582. /**
  15583. * Finalize the result of the output of the postprocesses.
  15584. * @param doNotPresent If true the result will not be displayed to the screen.
  15585. * @param targetTexture The target texture to render to.
  15586. * @param faceIndex The index of the face to bind the target texture to.
  15587. * @param postProcesses The array of post processes to render.
  15588. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15589. * @hidden
  15590. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15591. /**
  15592. * Disposes of the post process manager.
  15593. */
  15594. dispose(): void;
  15595. }
  15596. }
  15597. declare module BABYLON {
  15598. /** Interface used by value gradients (color, factor, ...) */
  15599. export interface IValueGradient {
  15600. /**
  15601. * Gets or sets the gradient value (between 0 and 1)
  15602. */
  15603. gradient: number;
  15604. }
  15605. /** Class used to store color4 gradient */
  15606. export class ColorGradient implements IValueGradient {
  15607. /**
  15608. * Gets or sets the gradient value (between 0 and 1)
  15609. */
  15610. gradient: number;
  15611. /**
  15612. * Gets or sets first associated color
  15613. */
  15614. color1: Color4;
  15615. /**
  15616. * Gets or sets second associated color
  15617. */
  15618. color2?: Color4;
  15619. /**
  15620. * Will get a color picked randomly between color1 and color2.
  15621. * If color2 is undefined then color1 will be used
  15622. * @param result defines the target Color4 to store the result in
  15623. */
  15624. getColorToRef(result: Color4): void;
  15625. }
  15626. /** Class used to store color 3 gradient */
  15627. export class Color3Gradient implements IValueGradient {
  15628. /**
  15629. * Gets or sets the gradient value (between 0 and 1)
  15630. */
  15631. gradient: number;
  15632. /**
  15633. * Gets or sets the associated color
  15634. */
  15635. color: Color3;
  15636. }
  15637. /** Class used to store factor gradient */
  15638. export class FactorGradient implements IValueGradient {
  15639. /**
  15640. * Gets or sets the gradient value (between 0 and 1)
  15641. */
  15642. gradient: number;
  15643. /**
  15644. * Gets or sets first associated factor
  15645. */
  15646. factor1: number;
  15647. /**
  15648. * Gets or sets second associated factor
  15649. */
  15650. factor2?: number;
  15651. /**
  15652. * Will get a number picked randomly between factor1 and factor2.
  15653. * If factor2 is undefined then factor1 will be used
  15654. * @returns the picked number
  15655. */
  15656. getFactor(): number;
  15657. }
  15658. /**
  15659. * Helper used to simplify some generic gradient tasks
  15660. */
  15661. export class GradientHelper {
  15662. /**
  15663. * Gets the current gradient from an array of IValueGradient
  15664. * @param ratio defines the current ratio to get
  15665. * @param gradients defines the array of IValueGradient
  15666. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15667. */
  15668. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15669. }
  15670. }
  15671. declare module BABYLON {
  15672. interface AbstractScene {
  15673. /**
  15674. * The list of procedural textures added to the scene
  15675. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15676. */
  15677. proceduralTextures: Array<ProceduralTexture>;
  15678. }
  15679. /**
  15680. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15681. * in a given scene.
  15682. */
  15683. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15684. /**
  15685. * The component name helpfull to identify the component in the list of scene components.
  15686. */
  15687. readonly name: string;
  15688. /**
  15689. * The scene the component belongs to.
  15690. */
  15691. scene: Scene;
  15692. /**
  15693. * Creates a new instance of the component for the given scene
  15694. * @param scene Defines the scene to register the component in
  15695. */
  15696. constructor(scene: Scene);
  15697. /**
  15698. * Registers the component in a given scene
  15699. */
  15700. register(): void;
  15701. /**
  15702. * Rebuilds the elements related to this component in case of
  15703. * context lost for instance.
  15704. */
  15705. rebuild(): void;
  15706. /**
  15707. * Disposes the component and the associated ressources.
  15708. */
  15709. dispose(): void;
  15710. private _beforeClear;
  15711. }
  15712. }
  15713. declare module BABYLON {
  15714. interface Engine {
  15715. /**
  15716. * Creates a new render target cube texture
  15717. * @param size defines the size of the texture
  15718. * @param options defines the options used to create the texture
  15719. * @returns a new render target cube texture stored in an InternalTexture
  15720. */
  15721. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15722. }
  15723. }
  15724. declare module BABYLON {
  15725. /** @hidden */
  15726. export var proceduralVertexShader: {
  15727. name: string;
  15728. shader: string;
  15729. };
  15730. }
  15731. declare module BABYLON {
  15732. /**
  15733. * 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.
  15734. * This is the base class of any Procedural texture and contains most of the shareable code.
  15735. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15736. */
  15737. export class ProceduralTexture extends Texture {
  15738. isCube: boolean;
  15739. /**
  15740. * Define if the texture is enabled or not (disabled texture will not render)
  15741. */
  15742. isEnabled: boolean;
  15743. /**
  15744. * Define if the texture must be cleared before rendering (default is true)
  15745. */
  15746. autoClear: boolean;
  15747. /**
  15748. * Callback called when the texture is generated
  15749. */
  15750. onGenerated: () => void;
  15751. /**
  15752. * Event raised when the texture is generated
  15753. */
  15754. onGeneratedObservable: Observable<ProceduralTexture>;
  15755. /** @hidden */ private _generateMipMaps: boolean;
  15756. /** @hidden **/ private _effect: Effect;
  15757. /** @hidden */ private _textures: {
  15758. [key: string]: Texture;
  15759. };
  15760. private _size;
  15761. private _currentRefreshId;
  15762. private _refreshRate;
  15763. private _vertexBuffers;
  15764. private _indexBuffer;
  15765. private _uniforms;
  15766. private _samplers;
  15767. private _fragment;
  15768. private _floats;
  15769. private _ints;
  15770. private _floatsArrays;
  15771. private _colors3;
  15772. private _colors4;
  15773. private _vectors2;
  15774. private _vectors3;
  15775. private _matrices;
  15776. private _fallbackTexture;
  15777. private _fallbackTextureUsed;
  15778. private _engine;
  15779. private _cachedDefines;
  15780. private _contentUpdateId;
  15781. private _contentData;
  15782. /**
  15783. * Instantiates a new procedural texture.
  15784. * 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.
  15785. * This is the base class of any Procedural texture and contains most of the shareable code.
  15786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15787. * @param name Define the name of the texture
  15788. * @param size Define the size of the texture to create
  15789. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15790. * @param scene Define the scene the texture belongs to
  15791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15792. * @param generateMipMaps Define if the texture should creates mip maps or not
  15793. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15794. */
  15795. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15796. /**
  15797. * The effect that is created when initializing the post process.
  15798. * @returns The created effect corresponding the the postprocess.
  15799. */
  15800. getEffect(): Effect;
  15801. /**
  15802. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15803. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15804. */
  15805. getContent(): Nullable<ArrayBufferView>;
  15806. private _createIndexBuffer;
  15807. /** @hidden */ private _rebuild(): void;
  15808. /**
  15809. * Resets the texture in order to recreate its associated resources.
  15810. * This can be called in case of context loss
  15811. */
  15812. reset(): void;
  15813. protected _getDefines(): string;
  15814. /**
  15815. * Is the texture ready to be used ? (rendered at least once)
  15816. * @returns true if ready, otherwise, false.
  15817. */
  15818. isReady(): boolean;
  15819. /**
  15820. * Resets the refresh counter of the texture and start bak from scratch.
  15821. * Could be useful to regenerate the texture if it is setup to render only once.
  15822. */
  15823. resetRefreshCounter(): void;
  15824. /**
  15825. * Set the fragment shader to use in order to render the texture.
  15826. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15827. */
  15828. setFragment(fragment: any): void;
  15829. /**
  15830. * Define the refresh rate of the texture or the rendering frequency.
  15831. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15832. */
  15833. refreshRate: number;
  15834. /** @hidden */ private _shouldRender(): boolean;
  15835. /**
  15836. * Get the size the texture is rendering at.
  15837. * @returns the size (texture is always squared)
  15838. */
  15839. getRenderSize(): number;
  15840. /**
  15841. * Resize the texture to new value.
  15842. * @param size Define the new size the texture should have
  15843. * @param generateMipMaps Define whether the new texture should create mip maps
  15844. */
  15845. resize(size: number, generateMipMaps: boolean): void;
  15846. private _checkUniform;
  15847. /**
  15848. * Set a texture in the shader program used to render.
  15849. * @param name Define the name of the uniform samplers as defined in the shader
  15850. * @param texture Define the texture to bind to this sampler
  15851. * @return the texture itself allowing "fluent" like uniform updates
  15852. */
  15853. setTexture(name: string, texture: Texture): ProceduralTexture;
  15854. /**
  15855. * Set a float in the shader.
  15856. * @param name Define the name of the uniform as defined in the shader
  15857. * @param value Define the value to give to the uniform
  15858. * @return the texture itself allowing "fluent" like uniform updates
  15859. */
  15860. setFloat(name: string, value: number): ProceduralTexture;
  15861. /**
  15862. * Set a int in the shader.
  15863. * @param name Define the name of the uniform as defined in the shader
  15864. * @param value Define the value to give to the uniform
  15865. * @return the texture itself allowing "fluent" like uniform updates
  15866. */
  15867. setInt(name: string, value: number): ProceduralTexture;
  15868. /**
  15869. * Set an array of floats in the shader.
  15870. * @param name Define the name of the uniform as defined in the shader
  15871. * @param value Define the value to give to the uniform
  15872. * @return the texture itself allowing "fluent" like uniform updates
  15873. */
  15874. setFloats(name: string, value: number[]): ProceduralTexture;
  15875. /**
  15876. * Set a vec3 in the shader from a Color3.
  15877. * @param name Define the name of the uniform as defined in the shader
  15878. * @param value Define the value to give to the uniform
  15879. * @return the texture itself allowing "fluent" like uniform updates
  15880. */
  15881. setColor3(name: string, value: Color3): ProceduralTexture;
  15882. /**
  15883. * Set a vec4 in the shader from a Color4.
  15884. * @param name Define the name of the uniform as defined in the shader
  15885. * @param value Define the value to give to the uniform
  15886. * @return the texture itself allowing "fluent" like uniform updates
  15887. */
  15888. setColor4(name: string, value: Color4): ProceduralTexture;
  15889. /**
  15890. * Set a vec2 in the shader from a Vector2.
  15891. * @param name Define the name of the uniform as defined in the shader
  15892. * @param value Define the value to give to the uniform
  15893. * @return the texture itself allowing "fluent" like uniform updates
  15894. */
  15895. setVector2(name: string, value: Vector2): ProceduralTexture;
  15896. /**
  15897. * Set a vec3 in the shader from a Vector3.
  15898. * @param name Define the name of the uniform as defined in the shader
  15899. * @param value Define the value to give to the uniform
  15900. * @return the texture itself allowing "fluent" like uniform updates
  15901. */
  15902. setVector3(name: string, value: Vector3): ProceduralTexture;
  15903. /**
  15904. * Set a mat4 in the shader from a MAtrix.
  15905. * @param name Define the name of the uniform as defined in the shader
  15906. * @param value Define the value to give to the uniform
  15907. * @return the texture itself allowing "fluent" like uniform updates
  15908. */
  15909. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15910. /**
  15911. * Render the texture to its associated render target.
  15912. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15913. */
  15914. render(useCameraPostProcess?: boolean): void;
  15915. /**
  15916. * Clone the texture.
  15917. * @returns the cloned texture
  15918. */
  15919. clone(): ProceduralTexture;
  15920. /**
  15921. * Dispose the texture and release its asoociated resources.
  15922. */
  15923. dispose(): void;
  15924. }
  15925. }
  15926. declare module BABYLON {
  15927. /**
  15928. * This represents the base class for particle system in Babylon.
  15929. * 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.
  15930. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15931. * @example https://doc.babylonjs.com/babylon101/particles
  15932. */
  15933. export class BaseParticleSystem {
  15934. /**
  15935. * Source color is added to the destination color without alpha affecting the result
  15936. */
  15937. static BLENDMODE_ONEONE: number;
  15938. /**
  15939. * Blend current color and particle color using particle’s alpha
  15940. */
  15941. static BLENDMODE_STANDARD: number;
  15942. /**
  15943. * Add current color and particle color multiplied by particle’s alpha
  15944. */
  15945. static BLENDMODE_ADD: number;
  15946. /**
  15947. * Multiply current color with particle color
  15948. */
  15949. static BLENDMODE_MULTIPLY: number;
  15950. /**
  15951. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15952. */
  15953. static BLENDMODE_MULTIPLYADD: number;
  15954. /**
  15955. * List of animations used by the particle system.
  15956. */
  15957. animations: Animation[];
  15958. /**
  15959. * The id of the Particle system.
  15960. */
  15961. id: string;
  15962. /**
  15963. * The friendly name of the Particle system.
  15964. */
  15965. name: string;
  15966. /**
  15967. * The rendering group used by the Particle system to chose when to render.
  15968. */
  15969. renderingGroupId: number;
  15970. /**
  15971. * The emitter represents the Mesh or position we are attaching the particle system to.
  15972. */
  15973. emitter: Nullable<AbstractMesh | Vector3>;
  15974. /**
  15975. * The maximum number of particles to emit per frame
  15976. */
  15977. emitRate: number;
  15978. /**
  15979. * If you want to launch only a few particles at once, that can be done, as well.
  15980. */
  15981. manualEmitCount: number;
  15982. /**
  15983. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15984. */
  15985. updateSpeed: number;
  15986. /**
  15987. * The amount of time the particle system is running (depends of the overall update speed).
  15988. */
  15989. targetStopDuration: number;
  15990. /**
  15991. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15992. */
  15993. disposeOnStop: boolean;
  15994. /**
  15995. * Minimum power of emitting particles.
  15996. */
  15997. minEmitPower: number;
  15998. /**
  15999. * Maximum power of emitting particles.
  16000. */
  16001. maxEmitPower: number;
  16002. /**
  16003. * Minimum life time of emitting particles.
  16004. */
  16005. minLifeTime: number;
  16006. /**
  16007. * Maximum life time of emitting particles.
  16008. */
  16009. maxLifeTime: number;
  16010. /**
  16011. * Minimum Size of emitting particles.
  16012. */
  16013. minSize: number;
  16014. /**
  16015. * Maximum Size of emitting particles.
  16016. */
  16017. maxSize: number;
  16018. /**
  16019. * Minimum scale of emitting particles on X axis.
  16020. */
  16021. minScaleX: number;
  16022. /**
  16023. * Maximum scale of emitting particles on X axis.
  16024. */
  16025. maxScaleX: number;
  16026. /**
  16027. * Minimum scale of emitting particles on Y axis.
  16028. */
  16029. minScaleY: number;
  16030. /**
  16031. * Maximum scale of emitting particles on Y axis.
  16032. */
  16033. maxScaleY: number;
  16034. /**
  16035. * Gets or sets the minimal initial rotation in radians.
  16036. */
  16037. minInitialRotation: number;
  16038. /**
  16039. * Gets or sets the maximal initial rotation in radians.
  16040. */
  16041. maxInitialRotation: number;
  16042. /**
  16043. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16044. */
  16045. minAngularSpeed: number;
  16046. /**
  16047. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16048. */
  16049. maxAngularSpeed: number;
  16050. /**
  16051. * The texture used to render each particle. (this can be a spritesheet)
  16052. */
  16053. particleTexture: Nullable<Texture>;
  16054. /**
  16055. * The layer mask we are rendering the particles through.
  16056. */
  16057. layerMask: number;
  16058. /**
  16059. * This can help using your own shader to render the particle system.
  16060. * The according effect will be created
  16061. */
  16062. customShader: any;
  16063. /**
  16064. * By default particle system starts as soon as they are created. This prevents the
  16065. * automatic start to happen and let you decide when to start emitting particles.
  16066. */
  16067. preventAutoStart: boolean;
  16068. private _noiseTexture;
  16069. /**
  16070. * Gets or sets a texture used to add random noise to particle positions
  16071. */
  16072. noiseTexture: Nullable<ProceduralTexture>;
  16073. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16074. noiseStrength: Vector3;
  16075. /**
  16076. * Callback triggered when the particle animation is ending.
  16077. */
  16078. onAnimationEnd: Nullable<() => void>;
  16079. /**
  16080. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16081. */
  16082. blendMode: number;
  16083. /**
  16084. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16085. * to override the particles.
  16086. */
  16087. forceDepthWrite: boolean;
  16088. /** 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 */
  16089. preWarmCycles: number;
  16090. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16091. preWarmStepOffset: number;
  16092. /**
  16093. * 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)
  16094. */
  16095. spriteCellChangeSpeed: number;
  16096. /**
  16097. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16098. */
  16099. startSpriteCellID: number;
  16100. /**
  16101. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16102. */
  16103. endSpriteCellID: number;
  16104. /**
  16105. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16106. */
  16107. spriteCellWidth: number;
  16108. /**
  16109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16110. */
  16111. spriteCellHeight: number;
  16112. /**
  16113. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16114. */
  16115. spriteRandomStartCell: boolean;
  16116. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16117. translationPivot: Vector2;
  16118. /** @hidden */
  16119. protected _isAnimationSheetEnabled: boolean;
  16120. /**
  16121. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16122. */
  16123. beginAnimationOnStart: boolean;
  16124. /**
  16125. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16126. */
  16127. beginAnimationFrom: number;
  16128. /**
  16129. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16130. */
  16131. beginAnimationTo: number;
  16132. /**
  16133. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16134. */
  16135. beginAnimationLoop: boolean;
  16136. /**
  16137. * Gets or sets a world offset applied to all particles
  16138. */
  16139. worldOffset: Vector3;
  16140. /**
  16141. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16142. */
  16143. isAnimationSheetEnabled: boolean;
  16144. /**
  16145. * Get hosting scene
  16146. * @returns the scene
  16147. */
  16148. getScene(): Scene;
  16149. /**
  16150. * You can use gravity if you want to give an orientation to your particles.
  16151. */
  16152. gravity: Vector3;
  16153. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16154. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16155. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16156. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16157. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16158. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16159. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16160. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16161. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16162. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16163. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16164. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16165. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16166. /**
  16167. * Defines the delay in milliseconds before starting the system (0 by default)
  16168. */
  16169. startDelay: number;
  16170. /**
  16171. * Gets the current list of drag gradients.
  16172. * You must use addDragGradient and removeDragGradient to udpate this list
  16173. * @returns the list of drag gradients
  16174. */
  16175. getDragGradients(): Nullable<Array<FactorGradient>>;
  16176. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16177. limitVelocityDamping: number;
  16178. /**
  16179. * Gets the current list of limit velocity gradients.
  16180. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16181. * @returns the list of limit velocity gradients
  16182. */
  16183. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16184. /**
  16185. * Gets the current list of color gradients.
  16186. * You must use addColorGradient and removeColorGradient to udpate this list
  16187. * @returns the list of color gradients
  16188. */
  16189. getColorGradients(): Nullable<Array<ColorGradient>>;
  16190. /**
  16191. * Gets the current list of size gradients.
  16192. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16193. * @returns the list of size gradients
  16194. */
  16195. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16196. /**
  16197. * Gets the current list of color remap gradients.
  16198. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16199. * @returns the list of color remap gradients
  16200. */
  16201. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16202. /**
  16203. * Gets the current list of alpha remap gradients.
  16204. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16205. * @returns the list of alpha remap gradients
  16206. */
  16207. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16208. /**
  16209. * Gets the current list of life time gradients.
  16210. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16211. * @returns the list of life time gradients
  16212. */
  16213. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16214. /**
  16215. * Gets the current list of angular speed gradients.
  16216. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16217. * @returns the list of angular speed gradients
  16218. */
  16219. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16220. /**
  16221. * Gets the current list of velocity gradients.
  16222. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16223. * @returns the list of velocity gradients
  16224. */
  16225. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16226. /**
  16227. * Gets the current list of start size gradients.
  16228. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16229. * @returns the list of start size gradients
  16230. */
  16231. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16232. /**
  16233. * Gets the current list of emit rate gradients.
  16234. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16235. * @returns the list of emit rate gradients
  16236. */
  16237. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16238. /**
  16239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16240. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16241. */
  16242. direction1: Vector3;
  16243. /**
  16244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16246. */
  16247. direction2: Vector3;
  16248. /**
  16249. * 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.
  16250. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16251. */
  16252. minEmitBox: Vector3;
  16253. /**
  16254. * 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.
  16255. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16256. */
  16257. maxEmitBox: Vector3;
  16258. /**
  16259. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16260. */
  16261. color1: Color4;
  16262. /**
  16263. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16264. */
  16265. color2: Color4;
  16266. /**
  16267. * Color the particle will have at the end of its lifetime
  16268. */
  16269. colorDead: Color4;
  16270. /**
  16271. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16272. */
  16273. textureMask: Color4;
  16274. /**
  16275. * The particle emitter type defines the emitter used by the particle system.
  16276. * It can be for example box, sphere, or cone...
  16277. */
  16278. particleEmitterType: IParticleEmitterType;
  16279. /** @hidden */ private _isSubEmitter: boolean;
  16280. /**
  16281. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16282. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16283. */
  16284. billboardMode: number;
  16285. protected _isBillboardBased: boolean;
  16286. /**
  16287. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16288. */
  16289. isBillboardBased: boolean;
  16290. /**
  16291. * The scene the particle system belongs to.
  16292. */
  16293. protected _scene: Scene;
  16294. /**
  16295. * Local cache of defines for image processing.
  16296. */
  16297. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16298. /**
  16299. * Default configuration related to image processing available in the standard Material.
  16300. */
  16301. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16302. /**
  16303. * Gets the image processing configuration used either in this material.
  16304. */
  16305. /**
  16306. * Sets the Default image processing configuration used either in the this material.
  16307. *
  16308. * If sets to null, the scene one is in use.
  16309. */
  16310. imageProcessingConfiguration: ImageProcessingConfiguration;
  16311. /**
  16312. * Attaches a new image processing configuration to the Standard Material.
  16313. * @param configuration
  16314. */
  16315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16316. /** @hidden */
  16317. protected _reset(): void;
  16318. /** @hidden */
  16319. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16320. /**
  16321. * Instantiates a particle system.
  16322. * 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.
  16323. * @param name The name of the particle system
  16324. */
  16325. constructor(name: string);
  16326. /**
  16327. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16330. * @returns the emitter
  16331. */
  16332. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16333. /**
  16334. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16335. * @param radius The radius of the hemisphere to emit from
  16336. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16337. * @returns the emitter
  16338. */
  16339. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16340. /**
  16341. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16342. * @param radius The radius of the sphere to emit from
  16343. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16344. * @returns the emitter
  16345. */
  16346. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16347. /**
  16348. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16349. * @param radius The radius of the sphere to emit from
  16350. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16351. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16352. * @returns the emitter
  16353. */
  16354. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16355. /**
  16356. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16357. * @param radius The radius of the emission cylinder
  16358. * @param height The height of the emission cylinder
  16359. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16360. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16361. * @returns the emitter
  16362. */
  16363. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16364. /**
  16365. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16366. * @param radius The radius of the cylinder to emit from
  16367. * @param height The height of the emission cylinder
  16368. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16371. * @returns the emitter
  16372. */
  16373. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16374. /**
  16375. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16376. * @param radius The radius of the cone to emit from
  16377. * @param angle The base angle of the cone
  16378. * @returns the emitter
  16379. */
  16380. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16381. /**
  16382. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16383. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16384. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16385. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16386. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16387. * @returns the emitter
  16388. */
  16389. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16390. }
  16391. }
  16392. declare module BABYLON {
  16393. /**
  16394. * Type of sub emitter
  16395. */
  16396. export enum SubEmitterType {
  16397. /**
  16398. * Attached to the particle over it's lifetime
  16399. */
  16400. ATTACHED = 0,
  16401. /**
  16402. * Created when the particle dies
  16403. */
  16404. END = 1
  16405. }
  16406. /**
  16407. * Sub emitter class used to emit particles from an existing particle
  16408. */
  16409. export class SubEmitter {
  16410. /**
  16411. * the particle system to be used by the sub emitter
  16412. */
  16413. particleSystem: ParticleSystem;
  16414. /**
  16415. * Type of the submitter (Default: END)
  16416. */
  16417. type: SubEmitterType;
  16418. /**
  16419. * 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)
  16420. * Note: This only is supported when using an emitter of type Mesh
  16421. */
  16422. inheritDirection: boolean;
  16423. /**
  16424. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16425. */
  16426. inheritedVelocityAmount: number;
  16427. /**
  16428. * Creates a sub emitter
  16429. * @param particleSystem the particle system to be used by the sub emitter
  16430. */
  16431. constructor(
  16432. /**
  16433. * the particle system to be used by the sub emitter
  16434. */
  16435. particleSystem: ParticleSystem);
  16436. /**
  16437. * Clones the sub emitter
  16438. * @returns the cloned sub emitter
  16439. */
  16440. clone(): SubEmitter;
  16441. /**
  16442. * Serialize current object to a JSON object
  16443. * @returns the serialized object
  16444. */
  16445. serialize(): any;
  16446. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16447. /**
  16448. * Creates a new SubEmitter from a serialized JSON version
  16449. * @param serializationObject defines the JSON object to read from
  16450. * @param scene defines the hosting scene
  16451. * @param rootUrl defines the rootUrl for data loading
  16452. * @returns a new SubEmitter
  16453. */
  16454. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16455. /** Release associated resources */
  16456. dispose(): void;
  16457. }
  16458. }
  16459. declare module BABYLON {
  16460. /** @hidden */
  16461. export var clipPlaneFragmentDeclaration: {
  16462. name: string;
  16463. shader: string;
  16464. };
  16465. }
  16466. declare module BABYLON {
  16467. /** @hidden */
  16468. export var imageProcessingDeclaration: {
  16469. name: string;
  16470. shader: string;
  16471. };
  16472. }
  16473. declare module BABYLON {
  16474. /** @hidden */
  16475. export var imageProcessingFunctions: {
  16476. name: string;
  16477. shader: string;
  16478. };
  16479. }
  16480. declare module BABYLON {
  16481. /** @hidden */
  16482. export var clipPlaneFragment: {
  16483. name: string;
  16484. shader: string;
  16485. };
  16486. }
  16487. declare module BABYLON {
  16488. /** @hidden */
  16489. export var particlesPixelShader: {
  16490. name: string;
  16491. shader: string;
  16492. };
  16493. }
  16494. declare module BABYLON {
  16495. /** @hidden */
  16496. export var clipPlaneVertexDeclaration: {
  16497. name: string;
  16498. shader: string;
  16499. };
  16500. }
  16501. declare module BABYLON {
  16502. /** @hidden */
  16503. export var clipPlaneVertex: {
  16504. name: string;
  16505. shader: string;
  16506. };
  16507. }
  16508. declare module BABYLON {
  16509. /** @hidden */
  16510. export var particlesVertexShader: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module BABYLON {
  16516. /**
  16517. * This represents a particle system in Babylon.
  16518. * 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.
  16519. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16520. * @example https://doc.babylonjs.com/babylon101/particles
  16521. */
  16522. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16523. /**
  16524. * Billboard mode will only apply to Y axis
  16525. */
  16526. static readonly BILLBOARDMODE_Y: number;
  16527. /**
  16528. * Billboard mode will apply to all axes
  16529. */
  16530. static readonly BILLBOARDMODE_ALL: number;
  16531. /**
  16532. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16533. */
  16534. static readonly BILLBOARDMODE_STRETCHED: number;
  16535. /**
  16536. * This function can be defined to provide custom update for active particles.
  16537. * This function will be called instead of regular update (age, position, color, etc.).
  16538. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16539. */
  16540. updateFunction: (particles: Particle[]) => void;
  16541. private _emitterWorldMatrix;
  16542. /**
  16543. * This function can be defined to specify initial direction for every new particle.
  16544. * It by default use the emitterType defined function
  16545. */
  16546. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16547. /**
  16548. * This function can be defined to specify initial position for every new particle.
  16549. * It by default use the emitterType defined function
  16550. */
  16551. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16552. /**
  16553. * @hidden
  16554. */ private _inheritedVelocityOffset: Vector3;
  16555. /**
  16556. * An event triggered when the system is disposed
  16557. */
  16558. onDisposeObservable: Observable<ParticleSystem>;
  16559. private _onDisposeObserver;
  16560. /**
  16561. * Sets a callback that will be triggered when the system is disposed
  16562. */
  16563. onDispose: () => void;
  16564. private _particles;
  16565. private _epsilon;
  16566. private _capacity;
  16567. private _stockParticles;
  16568. private _newPartsExcess;
  16569. private _vertexData;
  16570. private _vertexBuffer;
  16571. private _vertexBuffers;
  16572. private _spriteBuffer;
  16573. private _indexBuffer;
  16574. private _effect;
  16575. private _customEffect;
  16576. private _cachedDefines;
  16577. private _scaledColorStep;
  16578. private _colorDiff;
  16579. private _scaledDirection;
  16580. private _scaledGravity;
  16581. private _currentRenderId;
  16582. private _alive;
  16583. private _useInstancing;
  16584. private _started;
  16585. private _stopped;
  16586. private _actualFrame;
  16587. private _scaledUpdateSpeed;
  16588. private _vertexBufferSize;
  16589. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16590. /** @hidden */ private _currentEmitRate1: number;
  16591. /** @hidden */ private _currentEmitRate2: number;
  16592. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16593. /** @hidden */ private _currentStartSize1: number;
  16594. /** @hidden */ private _currentStartSize2: number;
  16595. private readonly _rawTextureWidth;
  16596. private _rampGradientsTexture;
  16597. private _useRampGradients;
  16598. /** Gets or sets a boolean indicating that ramp gradients must be used
  16599. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16600. */
  16601. useRampGradients: boolean;
  16602. /**
  16603. * 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.
  16604. * 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: [])
  16605. */
  16606. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16607. private _subEmitters;
  16608. /**
  16609. * @hidden
  16610. * If the particle systems emitter should be disposed when the particle system is disposed
  16611. */ private _disposeEmitterOnDispose: boolean;
  16612. /**
  16613. * The current active Sub-systems, this property is used by the root particle system only.
  16614. */
  16615. activeSubSystems: Array<ParticleSystem>;
  16616. private _rootParticleSystem;
  16617. /**
  16618. * Gets the current list of active particles
  16619. */
  16620. readonly particles: Particle[];
  16621. /**
  16622. * Returns the string "ParticleSystem"
  16623. * @returns a string containing the class name
  16624. */
  16625. getClassName(): string;
  16626. /**
  16627. * Instantiates a particle system.
  16628. * 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.
  16629. * @param name The name of the particle system
  16630. * @param capacity The max number of particles alive at the same time
  16631. * @param scene The scene the particle system belongs to
  16632. * @param customEffect a custom effect used to change the way particles are rendered by default
  16633. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16634. * @param epsilon Offset used to render the particles
  16635. */
  16636. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16637. private _addFactorGradient;
  16638. private _removeFactorGradient;
  16639. /**
  16640. * Adds a new life time gradient
  16641. * @param gradient defines the gradient to use (between 0 and 1)
  16642. * @param factor defines the life time factor to affect to the specified gradient
  16643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16644. * @returns the current particle system
  16645. */
  16646. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16647. /**
  16648. * Remove a specific life time gradient
  16649. * @param gradient defines the gradient to remove
  16650. * @returns the current particle system
  16651. */
  16652. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16653. /**
  16654. * Adds a new size gradient
  16655. * @param gradient defines the gradient to use (between 0 and 1)
  16656. * @param factor defines the size factor to affect to the specified gradient
  16657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16658. * @returns the current particle system
  16659. */
  16660. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16661. /**
  16662. * Remove a specific size gradient
  16663. * @param gradient defines the gradient to remove
  16664. * @returns the current particle system
  16665. */
  16666. removeSizeGradient(gradient: number): IParticleSystem;
  16667. /**
  16668. * Adds a new color remap gradient
  16669. * @param gradient defines the gradient to use (between 0 and 1)
  16670. * @param min defines the color remap minimal range
  16671. * @param max defines the color remap maximal range
  16672. * @returns the current particle system
  16673. */
  16674. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16675. /**
  16676. * Remove a specific color remap gradient
  16677. * @param gradient defines the gradient to remove
  16678. * @returns the current particle system
  16679. */
  16680. removeColorRemapGradient(gradient: number): IParticleSystem;
  16681. /**
  16682. * Adds a new alpha remap gradient
  16683. * @param gradient defines the gradient to use (between 0 and 1)
  16684. * @param min defines the alpha remap minimal range
  16685. * @param max defines the alpha remap maximal range
  16686. * @returns the current particle system
  16687. */
  16688. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16689. /**
  16690. * Remove a specific alpha remap gradient
  16691. * @param gradient defines the gradient to remove
  16692. * @returns the current particle system
  16693. */
  16694. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16695. /**
  16696. * Adds a new angular speed gradient
  16697. * @param gradient defines the gradient to use (between 0 and 1)
  16698. * @param factor defines the angular speed to affect to the specified gradient
  16699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16700. * @returns the current particle system
  16701. */
  16702. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16703. /**
  16704. * Remove a specific angular speed gradient
  16705. * @param gradient defines the gradient to remove
  16706. * @returns the current particle system
  16707. */
  16708. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16709. /**
  16710. * Adds a new velocity gradient
  16711. * @param gradient defines the gradient to use (between 0 and 1)
  16712. * @param factor defines the velocity to affect to the specified gradient
  16713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16714. * @returns the current particle system
  16715. */
  16716. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16717. /**
  16718. * Remove a specific velocity gradient
  16719. * @param gradient defines the gradient to remove
  16720. * @returns the current particle system
  16721. */
  16722. removeVelocityGradient(gradient: number): IParticleSystem;
  16723. /**
  16724. * Adds a new limit velocity gradient
  16725. * @param gradient defines the gradient to use (between 0 and 1)
  16726. * @param factor defines the limit velocity value to affect to the specified gradient
  16727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16728. * @returns the current particle system
  16729. */
  16730. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16731. /**
  16732. * Remove a specific limit velocity gradient
  16733. * @param gradient defines the gradient to remove
  16734. * @returns the current particle system
  16735. */
  16736. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16737. /**
  16738. * Adds a new drag gradient
  16739. * @param gradient defines the gradient to use (between 0 and 1)
  16740. * @param factor defines the drag value to affect to the specified gradient
  16741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16742. * @returns the current particle system
  16743. */
  16744. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16745. /**
  16746. * Remove a specific drag gradient
  16747. * @param gradient defines the gradient to remove
  16748. * @returns the current particle system
  16749. */
  16750. removeDragGradient(gradient: number): IParticleSystem;
  16751. /**
  16752. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16753. * @param gradient defines the gradient to use (between 0 and 1)
  16754. * @param factor defines the emit rate value to affect to the specified gradient
  16755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16756. * @returns the current particle system
  16757. */
  16758. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16759. /**
  16760. * Remove a specific emit rate gradient
  16761. * @param gradient defines the gradient to remove
  16762. * @returns the current particle system
  16763. */
  16764. removeEmitRateGradient(gradient: number): IParticleSystem;
  16765. /**
  16766. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16767. * @param gradient defines the gradient to use (between 0 and 1)
  16768. * @param factor defines the start size value to affect to the specified gradient
  16769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16770. * @returns the current particle system
  16771. */
  16772. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16773. /**
  16774. * Remove a specific start size gradient
  16775. * @param gradient defines the gradient to remove
  16776. * @returns the current particle system
  16777. */
  16778. removeStartSizeGradient(gradient: number): IParticleSystem;
  16779. private _createRampGradientTexture;
  16780. /**
  16781. * Gets the current list of ramp gradients.
  16782. * You must use addRampGradient and removeRampGradient to udpate this list
  16783. * @returns the list of ramp gradients
  16784. */
  16785. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16786. /**
  16787. * Adds a new ramp gradient used to remap particle colors
  16788. * @param gradient defines the gradient to use (between 0 and 1)
  16789. * @param color defines the color to affect to the specified gradient
  16790. * @returns the current particle system
  16791. */
  16792. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16793. /**
  16794. * Remove a specific ramp gradient
  16795. * @param gradient defines the gradient to remove
  16796. * @returns the current particle system
  16797. */
  16798. removeRampGradient(gradient: number): ParticleSystem;
  16799. /**
  16800. * Adds a new color gradient
  16801. * @param gradient defines the gradient to use (between 0 and 1)
  16802. * @param color1 defines the color to affect to the specified gradient
  16803. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16804. * @returns this particle system
  16805. */
  16806. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16807. /**
  16808. * Remove a specific color gradient
  16809. * @param gradient defines the gradient to remove
  16810. * @returns this particle system
  16811. */
  16812. removeColorGradient(gradient: number): IParticleSystem;
  16813. private _fetchR;
  16814. protected _reset(): void;
  16815. private _resetEffect;
  16816. private _createVertexBuffers;
  16817. private _createIndexBuffer;
  16818. /**
  16819. * Gets the maximum number of particles active at the same time.
  16820. * @returns The max number of active particles.
  16821. */
  16822. getCapacity(): number;
  16823. /**
  16824. * Gets whether there are still active particles in the system.
  16825. * @returns True if it is alive, otherwise false.
  16826. */
  16827. isAlive(): boolean;
  16828. /**
  16829. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16830. * @returns True if it has been started, otherwise false.
  16831. */
  16832. isStarted(): boolean;
  16833. private _prepareSubEmitterInternalArray;
  16834. /**
  16835. * Starts the particle system and begins to emit
  16836. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16837. */
  16838. start(delay?: number): void;
  16839. /**
  16840. * Stops the particle system.
  16841. * @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.
  16842. */
  16843. stop(stopSubEmitters?: boolean): void;
  16844. /**
  16845. * Remove all active particles
  16846. */
  16847. reset(): void;
  16848. /**
  16849. * @hidden (for internal use only)
  16850. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16851. /**
  16852. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16853. * Its lifetime will start back at 0.
  16854. */
  16855. recycleParticle: (particle: Particle) => void;
  16856. private _stopSubEmitters;
  16857. private _createParticle;
  16858. private _removeFromRoot;
  16859. private _emitFromParticle;
  16860. private _update;
  16861. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16862. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16863. /** @hidden */
  16864. private _getEffect;
  16865. /**
  16866. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16867. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16868. */
  16869. animate(preWarmOnly?: boolean): void;
  16870. private _appendParticleVertices;
  16871. /**
  16872. * Rebuilds the particle system.
  16873. */
  16874. rebuild(): void;
  16875. /**
  16876. * Is this system ready to be used/rendered
  16877. * @return true if the system is ready
  16878. */
  16879. isReady(): boolean;
  16880. private _render;
  16881. /**
  16882. * Renders the particle system in its current state.
  16883. * @returns the current number of particles
  16884. */
  16885. render(): number;
  16886. /**
  16887. * Disposes the particle system and free the associated resources
  16888. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16889. */
  16890. dispose(disposeTexture?: boolean): void;
  16891. /**
  16892. * Clones the particle system.
  16893. * @param name The name of the cloned object
  16894. * @param newEmitter The new emitter to use
  16895. * @returns the cloned particle system
  16896. */
  16897. clone(name: string, newEmitter: any): ParticleSystem;
  16898. /**
  16899. * Serializes the particle system to a JSON object.
  16900. * @returns the JSON object
  16901. */
  16902. serialize(): any;
  16903. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  16904. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  16905. /**
  16906. * Parses a JSON object to create a particle system.
  16907. * @param parsedParticleSystem The JSON object to parse
  16908. * @param scene The scene to create the particle system in
  16909. * @param rootUrl The root url to use to load external dependencies like texture
  16910. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16911. * @returns the Parsed particle system
  16912. */
  16913. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16914. }
  16915. }
  16916. declare module BABYLON {
  16917. /**
  16918. * A particle represents one of the element emitted by a particle system.
  16919. * This is mainly define by its coordinates, direction, velocity and age.
  16920. */
  16921. export class Particle {
  16922. /**
  16923. * The particle system the particle belongs to.
  16924. */
  16925. particleSystem: ParticleSystem;
  16926. private static _Count;
  16927. /**
  16928. * Unique ID of the particle
  16929. */
  16930. id: number;
  16931. /**
  16932. * The world position of the particle in the scene.
  16933. */
  16934. position: Vector3;
  16935. /**
  16936. * The world direction of the particle in the scene.
  16937. */
  16938. direction: Vector3;
  16939. /**
  16940. * The color of the particle.
  16941. */
  16942. color: Color4;
  16943. /**
  16944. * The color change of the particle per step.
  16945. */
  16946. colorStep: Color4;
  16947. /**
  16948. * Defines how long will the life of the particle be.
  16949. */
  16950. lifeTime: number;
  16951. /**
  16952. * The current age of the particle.
  16953. */
  16954. age: number;
  16955. /**
  16956. * The current size of the particle.
  16957. */
  16958. size: number;
  16959. /**
  16960. * The current scale of the particle.
  16961. */
  16962. scale: Vector2;
  16963. /**
  16964. * The current angle of the particle.
  16965. */
  16966. angle: number;
  16967. /**
  16968. * Defines how fast is the angle changing.
  16969. */
  16970. angularSpeed: number;
  16971. /**
  16972. * Defines the cell index used by the particle to be rendered from a sprite.
  16973. */
  16974. cellIndex: number;
  16975. /**
  16976. * The information required to support color remapping
  16977. */
  16978. remapData: Vector4;
  16979. /** @hidden */ private _randomCellOffset?: number;
  16980. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  16981. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16982. /** @hidden */ private _initialStartSpriteCellID: number;
  16983. /** @hidden */ private _initialEndSpriteCellID: number;
  16984. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  16985. /** @hidden */ private _currentColor1: Color4;
  16986. /** @hidden */ private _currentColor2: Color4;
  16987. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  16988. /** @hidden */ private _currentSize1: number;
  16989. /** @hidden */ private _currentSize2: number;
  16990. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16991. /** @hidden */ private _currentAngularSpeed1: number;
  16992. /** @hidden */ private _currentAngularSpeed2: number;
  16993. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  16994. /** @hidden */ private _currentVelocity1: number;
  16995. /** @hidden */ private _currentVelocity2: number;
  16996. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16997. /** @hidden */ private _currentLimitVelocity1: number;
  16998. /** @hidden */ private _currentLimitVelocity2: number;
  16999. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17000. /** @hidden */ private _currentDrag1: number;
  17001. /** @hidden */ private _currentDrag2: number;
  17002. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17003. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17004. /**
  17005. * Creates a new instance Particle
  17006. * @param particleSystem the particle system the particle belongs to
  17007. */
  17008. constructor(
  17009. /**
  17010. * The particle system the particle belongs to.
  17011. */
  17012. particleSystem: ParticleSystem);
  17013. private updateCellInfoFromSystem;
  17014. /**
  17015. * Defines how the sprite cell index is updated for the particle
  17016. */
  17017. updateCellIndex(): void;
  17018. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17019. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17020. /** @hidden */ private _reset(): void;
  17021. /**
  17022. * Copy the properties of particle to another one.
  17023. * @param other the particle to copy the information to.
  17024. */
  17025. copyTo(other: Particle): void;
  17026. }
  17027. }
  17028. declare module BABYLON {
  17029. /**
  17030. * Particle emitter represents a volume emitting particles.
  17031. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17032. */
  17033. export interface IParticleEmitterType {
  17034. /**
  17035. * Called by the particle System when the direction is computed for the created particle.
  17036. * @param worldMatrix is the world matrix of the particle system
  17037. * @param directionToUpdate is the direction vector to update with the result
  17038. * @param particle is the particle we are computed the direction for
  17039. */
  17040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17041. /**
  17042. * Called by the particle System when the position is computed for the created particle.
  17043. * @param worldMatrix is the world matrix of the particle system
  17044. * @param positionToUpdate is the position vector to update with the result
  17045. * @param particle is the particle we are computed the position for
  17046. */
  17047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17048. /**
  17049. * Clones the current emitter and returns a copy of it
  17050. * @returns the new emitter
  17051. */
  17052. clone(): IParticleEmitterType;
  17053. /**
  17054. * Called by the GPUParticleSystem to setup the update shader
  17055. * @param effect defines the update shader
  17056. */
  17057. applyToShader(effect: Effect): void;
  17058. /**
  17059. * Returns a string to use to update the GPU particles update shader
  17060. * @returns the effect defines string
  17061. */
  17062. getEffectDefines(): string;
  17063. /**
  17064. * Returns a string representing the class name
  17065. * @returns a string containing the class name
  17066. */
  17067. getClassName(): string;
  17068. /**
  17069. * Serializes the particle system to a JSON object.
  17070. * @returns the JSON object
  17071. */
  17072. serialize(): any;
  17073. /**
  17074. * Parse properties from a JSON object
  17075. * @param serializationObject defines the JSON object
  17076. */
  17077. parse(serializationObject: any): void;
  17078. }
  17079. }
  17080. declare module BABYLON {
  17081. /**
  17082. * Particle emitter emitting particles from the inside of a box.
  17083. * It emits the particles randomly between 2 given directions.
  17084. */
  17085. export class BoxParticleEmitter implements IParticleEmitterType {
  17086. /**
  17087. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17088. */
  17089. direction1: Vector3;
  17090. /**
  17091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17092. */
  17093. direction2: Vector3;
  17094. /**
  17095. * 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.
  17096. */
  17097. minEmitBox: Vector3;
  17098. /**
  17099. * 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.
  17100. */
  17101. maxEmitBox: Vector3;
  17102. /**
  17103. * Creates a new instance BoxParticleEmitter
  17104. */
  17105. constructor();
  17106. /**
  17107. * Called by the particle System when the direction is computed for the created particle.
  17108. * @param worldMatrix is the world matrix of the particle system
  17109. * @param directionToUpdate is the direction vector to update with the result
  17110. * @param particle is the particle we are computed the direction for
  17111. */
  17112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17113. /**
  17114. * Called by the particle System when the position is computed for the created particle.
  17115. * @param worldMatrix is the world matrix of the particle system
  17116. * @param positionToUpdate is the position vector to update with the result
  17117. * @param particle is the particle we are computed the position for
  17118. */
  17119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17120. /**
  17121. * Clones the current emitter and returns a copy of it
  17122. * @returns the new emitter
  17123. */
  17124. clone(): BoxParticleEmitter;
  17125. /**
  17126. * Called by the GPUParticleSystem to setup the update shader
  17127. * @param effect defines the update shader
  17128. */
  17129. applyToShader(effect: Effect): void;
  17130. /**
  17131. * Returns a string to use to update the GPU particles update shader
  17132. * @returns a string containng the defines string
  17133. */
  17134. getEffectDefines(): string;
  17135. /**
  17136. * Returns the string "BoxParticleEmitter"
  17137. * @returns a string containing the class name
  17138. */
  17139. getClassName(): string;
  17140. /**
  17141. * Serializes the particle system to a JSON object.
  17142. * @returns the JSON object
  17143. */
  17144. serialize(): any;
  17145. /**
  17146. * Parse properties from a JSON object
  17147. * @param serializationObject defines the JSON object
  17148. */
  17149. parse(serializationObject: any): void;
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /**
  17154. * Particle emitter emitting particles from the inside of a cone.
  17155. * It emits the particles alongside the cone volume from the base to the particle.
  17156. * The emission direction might be randomized.
  17157. */
  17158. export class ConeParticleEmitter implements IParticleEmitterType {
  17159. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17160. directionRandomizer: number;
  17161. private _radius;
  17162. private _angle;
  17163. private _height;
  17164. /**
  17165. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17166. */
  17167. radiusRange: number;
  17168. /**
  17169. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17170. */
  17171. heightRange: number;
  17172. /**
  17173. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17174. */
  17175. emitFromSpawnPointOnly: boolean;
  17176. /**
  17177. * Gets or sets the radius of the emission cone
  17178. */
  17179. radius: number;
  17180. /**
  17181. * Gets or sets the angle of the emission cone
  17182. */
  17183. angle: number;
  17184. private _buildHeight;
  17185. /**
  17186. * Creates a new instance ConeParticleEmitter
  17187. * @param radius the radius of the emission cone (1 by default)
  17188. * @param angle the cone base angle (PI by default)
  17189. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17190. */
  17191. constructor(radius?: number, angle?: number,
  17192. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17193. directionRandomizer?: number);
  17194. /**
  17195. * Called by the particle System when the direction is computed for the created particle.
  17196. * @param worldMatrix is the world matrix of the particle system
  17197. * @param directionToUpdate is the direction vector to update with the result
  17198. * @param particle is the particle we are computed the direction for
  17199. */
  17200. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17201. /**
  17202. * Called by the particle System when the position is computed for the created particle.
  17203. * @param worldMatrix is the world matrix of the particle system
  17204. * @param positionToUpdate is the position vector to update with the result
  17205. * @param particle is the particle we are computed the position for
  17206. */
  17207. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17208. /**
  17209. * Clones the current emitter and returns a copy of it
  17210. * @returns the new emitter
  17211. */
  17212. clone(): ConeParticleEmitter;
  17213. /**
  17214. * Called by the GPUParticleSystem to setup the update shader
  17215. * @param effect defines the update shader
  17216. */
  17217. applyToShader(effect: Effect): void;
  17218. /**
  17219. * Returns a string to use to update the GPU particles update shader
  17220. * @returns a string containng the defines string
  17221. */
  17222. getEffectDefines(): string;
  17223. /**
  17224. * Returns the string "ConeParticleEmitter"
  17225. * @returns a string containing the class name
  17226. */
  17227. getClassName(): string;
  17228. /**
  17229. * Serializes the particle system to a JSON object.
  17230. * @returns the JSON object
  17231. */
  17232. serialize(): any;
  17233. /**
  17234. * Parse properties from a JSON object
  17235. * @param serializationObject defines the JSON object
  17236. */
  17237. parse(serializationObject: any): void;
  17238. }
  17239. }
  17240. declare module BABYLON {
  17241. /**
  17242. * Particle emitter emitting particles from the inside of a cylinder.
  17243. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17244. */
  17245. export class CylinderParticleEmitter implements IParticleEmitterType {
  17246. /**
  17247. * The radius of the emission cylinder.
  17248. */
  17249. radius: number;
  17250. /**
  17251. * The height of the emission cylinder.
  17252. */
  17253. height: number;
  17254. /**
  17255. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17256. */
  17257. radiusRange: number;
  17258. /**
  17259. * How much to randomize the particle direction [0-1].
  17260. */
  17261. directionRandomizer: number;
  17262. /**
  17263. * Creates a new instance CylinderParticleEmitter
  17264. * @param radius the radius of the emission cylinder (1 by default)
  17265. * @param height the height of the emission cylinder (1 by default)
  17266. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17267. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17268. */
  17269. constructor(
  17270. /**
  17271. * The radius of the emission cylinder.
  17272. */
  17273. radius?: number,
  17274. /**
  17275. * The height of the emission cylinder.
  17276. */
  17277. height?: number,
  17278. /**
  17279. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17280. */
  17281. radiusRange?: number,
  17282. /**
  17283. * How much to randomize the particle direction [0-1].
  17284. */
  17285. directionRandomizer?: number);
  17286. /**
  17287. * Called by the particle System when the direction is computed for the created particle.
  17288. * @param worldMatrix is the world matrix of the particle system
  17289. * @param directionToUpdate is the direction vector to update with the result
  17290. * @param particle is the particle we are computed the direction for
  17291. */
  17292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17293. /**
  17294. * Called by the particle System when the position is computed for the created particle.
  17295. * @param worldMatrix is the world matrix of the particle system
  17296. * @param positionToUpdate is the position vector to update with the result
  17297. * @param particle is the particle we are computed the position for
  17298. */
  17299. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17300. /**
  17301. * Clones the current emitter and returns a copy of it
  17302. * @returns the new emitter
  17303. */
  17304. clone(): CylinderParticleEmitter;
  17305. /**
  17306. * Called by the GPUParticleSystem to setup the update shader
  17307. * @param effect defines the update shader
  17308. */
  17309. applyToShader(effect: Effect): void;
  17310. /**
  17311. * Returns a string to use to update the GPU particles update shader
  17312. * @returns a string containng the defines string
  17313. */
  17314. getEffectDefines(): string;
  17315. /**
  17316. * Returns the string "CylinderParticleEmitter"
  17317. * @returns a string containing the class name
  17318. */
  17319. getClassName(): string;
  17320. /**
  17321. * Serializes the particle system to a JSON object.
  17322. * @returns the JSON object
  17323. */
  17324. serialize(): any;
  17325. /**
  17326. * Parse properties from a JSON object
  17327. * @param serializationObject defines the JSON object
  17328. */
  17329. parse(serializationObject: any): void;
  17330. }
  17331. /**
  17332. * Particle emitter emitting particles from the inside of a cylinder.
  17333. * It emits the particles randomly between two vectors.
  17334. */
  17335. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17336. /**
  17337. * The min limit of the emission direction.
  17338. */
  17339. direction1: Vector3;
  17340. /**
  17341. * The max limit of the emission direction.
  17342. */
  17343. direction2: Vector3;
  17344. /**
  17345. * Creates a new instance CylinderDirectedParticleEmitter
  17346. * @param radius the radius of the emission cylinder (1 by default)
  17347. * @param height the height of the emission cylinder (1 by default)
  17348. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17349. * @param direction1 the min limit of the emission direction (up vector by default)
  17350. * @param direction2 the max limit of the emission direction (up vector by default)
  17351. */
  17352. constructor(radius?: number, height?: number, radiusRange?: number,
  17353. /**
  17354. * The min limit of the emission direction.
  17355. */
  17356. direction1?: Vector3,
  17357. /**
  17358. * The max limit of the emission direction.
  17359. */
  17360. direction2?: Vector3);
  17361. /**
  17362. * Called by the particle System when the direction is computed for the created particle.
  17363. * @param worldMatrix is the world matrix of the particle system
  17364. * @param directionToUpdate is the direction vector to update with the result
  17365. * @param particle is the particle we are computed the direction for
  17366. */
  17367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17368. /**
  17369. * Clones the current emitter and returns a copy of it
  17370. * @returns the new emitter
  17371. */
  17372. clone(): CylinderDirectedParticleEmitter;
  17373. /**
  17374. * Called by the GPUParticleSystem to setup the update shader
  17375. * @param effect defines the update shader
  17376. */
  17377. applyToShader(effect: Effect): void;
  17378. /**
  17379. * Returns a string to use to update the GPU particles update shader
  17380. * @returns a string containng the defines string
  17381. */
  17382. getEffectDefines(): string;
  17383. /**
  17384. * Returns the string "CylinderDirectedParticleEmitter"
  17385. * @returns a string containing the class name
  17386. */
  17387. getClassName(): string;
  17388. /**
  17389. * Serializes the particle system to a JSON object.
  17390. * @returns the JSON object
  17391. */
  17392. serialize(): any;
  17393. /**
  17394. * Parse properties from a JSON object
  17395. * @param serializationObject defines the JSON object
  17396. */
  17397. parse(serializationObject: any): void;
  17398. }
  17399. }
  17400. declare module BABYLON {
  17401. /**
  17402. * Particle emitter emitting particles from the inside of a hemisphere.
  17403. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17404. */
  17405. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17406. /**
  17407. * The radius of the emission hemisphere.
  17408. */
  17409. radius: number;
  17410. /**
  17411. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17412. */
  17413. radiusRange: number;
  17414. /**
  17415. * How much to randomize the particle direction [0-1].
  17416. */
  17417. directionRandomizer: number;
  17418. /**
  17419. * Creates a new instance HemisphericParticleEmitter
  17420. * @param radius the radius of the emission hemisphere (1 by default)
  17421. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17422. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17423. */
  17424. constructor(
  17425. /**
  17426. * The radius of the emission hemisphere.
  17427. */
  17428. radius?: number,
  17429. /**
  17430. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17431. */
  17432. radiusRange?: number,
  17433. /**
  17434. * How much to randomize the particle direction [0-1].
  17435. */
  17436. directionRandomizer?: number);
  17437. /**
  17438. * Called by the particle System when the direction is computed for the created particle.
  17439. * @param worldMatrix is the world matrix of the particle system
  17440. * @param directionToUpdate is the direction vector to update with the result
  17441. * @param particle is the particle we are computed the direction for
  17442. */
  17443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17444. /**
  17445. * Called by the particle System when the position is computed for the created particle.
  17446. * @param worldMatrix is the world matrix of the particle system
  17447. * @param positionToUpdate is the position vector to update with the result
  17448. * @param particle is the particle we are computed the position for
  17449. */
  17450. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17451. /**
  17452. * Clones the current emitter and returns a copy of it
  17453. * @returns the new emitter
  17454. */
  17455. clone(): HemisphericParticleEmitter;
  17456. /**
  17457. * Called by the GPUParticleSystem to setup the update shader
  17458. * @param effect defines the update shader
  17459. */
  17460. applyToShader(effect: Effect): void;
  17461. /**
  17462. * Returns a string to use to update the GPU particles update shader
  17463. * @returns a string containng the defines string
  17464. */
  17465. getEffectDefines(): string;
  17466. /**
  17467. * Returns the string "HemisphericParticleEmitter"
  17468. * @returns a string containing the class name
  17469. */
  17470. getClassName(): string;
  17471. /**
  17472. * Serializes the particle system to a JSON object.
  17473. * @returns the JSON object
  17474. */
  17475. serialize(): any;
  17476. /**
  17477. * Parse properties from a JSON object
  17478. * @param serializationObject defines the JSON object
  17479. */
  17480. parse(serializationObject: any): void;
  17481. }
  17482. }
  17483. declare module BABYLON {
  17484. /**
  17485. * Particle emitter emitting particles from a point.
  17486. * It emits the particles randomly between 2 given directions.
  17487. */
  17488. export class PointParticleEmitter implements IParticleEmitterType {
  17489. /**
  17490. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17491. */
  17492. direction1: Vector3;
  17493. /**
  17494. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17495. */
  17496. direction2: Vector3;
  17497. /**
  17498. * Creates a new instance PointParticleEmitter
  17499. */
  17500. constructor();
  17501. /**
  17502. * Called by the particle System when the direction is computed for the created particle.
  17503. * @param worldMatrix is the world matrix of the particle system
  17504. * @param directionToUpdate is the direction vector to update with the result
  17505. * @param particle is the particle we are computed the direction for
  17506. */
  17507. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17508. /**
  17509. * Called by the particle System when the position is computed for the created particle.
  17510. * @param worldMatrix is the world matrix of the particle system
  17511. * @param positionToUpdate is the position vector to update with the result
  17512. * @param particle is the particle we are computed the position for
  17513. */
  17514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17515. /**
  17516. * Clones the current emitter and returns a copy of it
  17517. * @returns the new emitter
  17518. */
  17519. clone(): PointParticleEmitter;
  17520. /**
  17521. * Called by the GPUParticleSystem to setup the update shader
  17522. * @param effect defines the update shader
  17523. */
  17524. applyToShader(effect: Effect): void;
  17525. /**
  17526. * Returns a string to use to update the GPU particles update shader
  17527. * @returns a string containng the defines string
  17528. */
  17529. getEffectDefines(): string;
  17530. /**
  17531. * Returns the string "PointParticleEmitter"
  17532. * @returns a string containing the class name
  17533. */
  17534. getClassName(): string;
  17535. /**
  17536. * Serializes the particle system to a JSON object.
  17537. * @returns the JSON object
  17538. */
  17539. serialize(): any;
  17540. /**
  17541. * Parse properties from a JSON object
  17542. * @param serializationObject defines the JSON object
  17543. */
  17544. parse(serializationObject: any): void;
  17545. }
  17546. }
  17547. declare module BABYLON {
  17548. /**
  17549. * Particle emitter emitting particles from the inside of a sphere.
  17550. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17551. */
  17552. export class SphereParticleEmitter implements IParticleEmitterType {
  17553. /**
  17554. * The radius of the emission sphere.
  17555. */
  17556. radius: number;
  17557. /**
  17558. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17559. */
  17560. radiusRange: number;
  17561. /**
  17562. * How much to randomize the particle direction [0-1].
  17563. */
  17564. directionRandomizer: number;
  17565. /**
  17566. * Creates a new instance SphereParticleEmitter
  17567. * @param radius the radius of the emission sphere (1 by default)
  17568. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17569. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17570. */
  17571. constructor(
  17572. /**
  17573. * The radius of the emission sphere.
  17574. */
  17575. radius?: number,
  17576. /**
  17577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17578. */
  17579. radiusRange?: number,
  17580. /**
  17581. * How much to randomize the particle direction [0-1].
  17582. */
  17583. directionRandomizer?: number);
  17584. /**
  17585. * Called by the particle System when the direction is computed for the created particle.
  17586. * @param worldMatrix is the world matrix of the particle system
  17587. * @param directionToUpdate is the direction vector to update with the result
  17588. * @param particle is the particle we are computed the direction for
  17589. */
  17590. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17591. /**
  17592. * Called by the particle System when the position is computed for the created particle.
  17593. * @param worldMatrix is the world matrix of the particle system
  17594. * @param positionToUpdate is the position vector to update with the result
  17595. * @param particle is the particle we are computed the position for
  17596. */
  17597. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17598. /**
  17599. * Clones the current emitter and returns a copy of it
  17600. * @returns the new emitter
  17601. */
  17602. clone(): SphereParticleEmitter;
  17603. /**
  17604. * Called by the GPUParticleSystem to setup the update shader
  17605. * @param effect defines the update shader
  17606. */
  17607. applyToShader(effect: Effect): void;
  17608. /**
  17609. * Returns a string to use to update the GPU particles update shader
  17610. * @returns a string containng the defines string
  17611. */
  17612. getEffectDefines(): string;
  17613. /**
  17614. * Returns the string "SphereParticleEmitter"
  17615. * @returns a string containing the class name
  17616. */
  17617. getClassName(): string;
  17618. /**
  17619. * Serializes the particle system to a JSON object.
  17620. * @returns the JSON object
  17621. */
  17622. serialize(): any;
  17623. /**
  17624. * Parse properties from a JSON object
  17625. * @param serializationObject defines the JSON object
  17626. */
  17627. parse(serializationObject: any): void;
  17628. }
  17629. /**
  17630. * Particle emitter emitting particles from the inside of a sphere.
  17631. * It emits the particles randomly between two vectors.
  17632. */
  17633. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17634. /**
  17635. * The min limit of the emission direction.
  17636. */
  17637. direction1: Vector3;
  17638. /**
  17639. * The max limit of the emission direction.
  17640. */
  17641. direction2: Vector3;
  17642. /**
  17643. * Creates a new instance SphereDirectedParticleEmitter
  17644. * @param radius the radius of the emission sphere (1 by default)
  17645. * @param direction1 the min limit of the emission direction (up vector by default)
  17646. * @param direction2 the max limit of the emission direction (up vector by default)
  17647. */
  17648. constructor(radius?: number,
  17649. /**
  17650. * The min limit of the emission direction.
  17651. */
  17652. direction1?: Vector3,
  17653. /**
  17654. * The max limit of the emission direction.
  17655. */
  17656. direction2?: Vector3);
  17657. /**
  17658. * Called by the particle System when the direction is computed for the created particle.
  17659. * @param worldMatrix is the world matrix of the particle system
  17660. * @param directionToUpdate is the direction vector to update with the result
  17661. * @param particle is the particle we are computed the direction for
  17662. */
  17663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17664. /**
  17665. * Clones the current emitter and returns a copy of it
  17666. * @returns the new emitter
  17667. */
  17668. clone(): SphereDirectedParticleEmitter;
  17669. /**
  17670. * Called by the GPUParticleSystem to setup the update shader
  17671. * @param effect defines the update shader
  17672. */
  17673. applyToShader(effect: Effect): void;
  17674. /**
  17675. * Returns a string to use to update the GPU particles update shader
  17676. * @returns a string containng the defines string
  17677. */
  17678. getEffectDefines(): string;
  17679. /**
  17680. * Returns the string "SphereDirectedParticleEmitter"
  17681. * @returns a string containing the class name
  17682. */
  17683. getClassName(): string;
  17684. /**
  17685. * Serializes the particle system to a JSON object.
  17686. * @returns the JSON object
  17687. */
  17688. serialize(): any;
  17689. /**
  17690. * Parse properties from a JSON object
  17691. * @param serializationObject defines the JSON object
  17692. */
  17693. parse(serializationObject: any): void;
  17694. }
  17695. }
  17696. declare module BABYLON {
  17697. /**
  17698. * Interface representing a particle system in Babylon.js.
  17699. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17700. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17701. */
  17702. export interface IParticleSystem {
  17703. /**
  17704. * List of animations used by the particle system.
  17705. */
  17706. animations: Animation[];
  17707. /**
  17708. * The id of the Particle system.
  17709. */
  17710. id: string;
  17711. /**
  17712. * The name of the Particle system.
  17713. */
  17714. name: string;
  17715. /**
  17716. * The emitter represents the Mesh or position we are attaching the particle system to.
  17717. */
  17718. emitter: Nullable<AbstractMesh | Vector3>;
  17719. /**
  17720. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17721. */
  17722. isBillboardBased: boolean;
  17723. /**
  17724. * The rendering group used by the Particle system to chose when to render.
  17725. */
  17726. renderingGroupId: number;
  17727. /**
  17728. * The layer mask we are rendering the particles through.
  17729. */
  17730. layerMask: number;
  17731. /**
  17732. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17733. */
  17734. updateSpeed: number;
  17735. /**
  17736. * The amount of time the particle system is running (depends of the overall update speed).
  17737. */
  17738. targetStopDuration: number;
  17739. /**
  17740. * The texture used to render each particle. (this can be a spritesheet)
  17741. */
  17742. particleTexture: Nullable<Texture>;
  17743. /**
  17744. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17745. */
  17746. blendMode: number;
  17747. /**
  17748. * Minimum life time of emitting particles.
  17749. */
  17750. minLifeTime: number;
  17751. /**
  17752. * Maximum life time of emitting particles.
  17753. */
  17754. maxLifeTime: number;
  17755. /**
  17756. * Minimum Size of emitting particles.
  17757. */
  17758. minSize: number;
  17759. /**
  17760. * Maximum Size of emitting particles.
  17761. */
  17762. maxSize: number;
  17763. /**
  17764. * Minimum scale of emitting particles on X axis.
  17765. */
  17766. minScaleX: number;
  17767. /**
  17768. * Maximum scale of emitting particles on X axis.
  17769. */
  17770. maxScaleX: number;
  17771. /**
  17772. * Minimum scale of emitting particles on Y axis.
  17773. */
  17774. minScaleY: number;
  17775. /**
  17776. * Maximum scale of emitting particles on Y axis.
  17777. */
  17778. maxScaleY: number;
  17779. /**
  17780. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17781. */
  17782. color1: Color4;
  17783. /**
  17784. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17785. */
  17786. color2: Color4;
  17787. /**
  17788. * Color the particle will have at the end of its lifetime.
  17789. */
  17790. colorDead: Color4;
  17791. /**
  17792. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17793. */
  17794. emitRate: number;
  17795. /**
  17796. * You can use gravity if you want to give an orientation to your particles.
  17797. */
  17798. gravity: Vector3;
  17799. /**
  17800. * Minimum power of emitting particles.
  17801. */
  17802. minEmitPower: number;
  17803. /**
  17804. * Maximum power of emitting particles.
  17805. */
  17806. maxEmitPower: number;
  17807. /**
  17808. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17809. */
  17810. minAngularSpeed: number;
  17811. /**
  17812. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17813. */
  17814. maxAngularSpeed: number;
  17815. /**
  17816. * Gets or sets the minimal initial rotation in radians.
  17817. */
  17818. minInitialRotation: number;
  17819. /**
  17820. * Gets or sets the maximal initial rotation in radians.
  17821. */
  17822. maxInitialRotation: number;
  17823. /**
  17824. * The particle emitter type defines the emitter used by the particle system.
  17825. * It can be for example box, sphere, or cone...
  17826. */
  17827. particleEmitterType: Nullable<IParticleEmitterType>;
  17828. /**
  17829. * Defines the delay in milliseconds before starting the system (0 by default)
  17830. */
  17831. startDelay: number;
  17832. /**
  17833. * 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
  17834. */
  17835. preWarmCycles: number;
  17836. /**
  17837. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17838. */
  17839. preWarmStepOffset: number;
  17840. /**
  17841. * 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)
  17842. */
  17843. spriteCellChangeSpeed: number;
  17844. /**
  17845. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17846. */
  17847. startSpriteCellID: number;
  17848. /**
  17849. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17850. */
  17851. endSpriteCellID: number;
  17852. /**
  17853. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17854. */
  17855. spriteCellWidth: number;
  17856. /**
  17857. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17858. */
  17859. spriteCellHeight: number;
  17860. /**
  17861. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17862. */
  17863. spriteRandomStartCell: boolean;
  17864. /**
  17865. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17866. */
  17867. isAnimationSheetEnabled: boolean;
  17868. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17869. translationPivot: Vector2;
  17870. /**
  17871. * Gets or sets a texture used to add random noise to particle positions
  17872. */
  17873. noiseTexture: Nullable<BaseTexture>;
  17874. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17875. noiseStrength: Vector3;
  17876. /**
  17877. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17878. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17879. */
  17880. billboardMode: number;
  17881. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17882. limitVelocityDamping: number;
  17883. /**
  17884. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17885. */
  17886. beginAnimationOnStart: boolean;
  17887. /**
  17888. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17889. */
  17890. beginAnimationFrom: number;
  17891. /**
  17892. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17893. */
  17894. beginAnimationTo: number;
  17895. /**
  17896. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17897. */
  17898. beginAnimationLoop: boolean;
  17899. /**
  17900. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17901. */
  17902. disposeOnStop: boolean;
  17903. /**
  17904. * Gets the maximum number of particles active at the same time.
  17905. * @returns The max number of active particles.
  17906. */
  17907. getCapacity(): number;
  17908. /**
  17909. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17910. * @returns True if it has been started, otherwise false.
  17911. */
  17912. isStarted(): boolean;
  17913. /**
  17914. * Animates the particle system for this frame.
  17915. */
  17916. animate(): void;
  17917. /**
  17918. * Renders the particle system in its current state.
  17919. * @returns the current number of particles
  17920. */
  17921. render(): number;
  17922. /**
  17923. * Dispose the particle system and frees its associated resources.
  17924. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17925. */
  17926. dispose(disposeTexture?: boolean): void;
  17927. /**
  17928. * Clones the particle system.
  17929. * @param name The name of the cloned object
  17930. * @param newEmitter The new emitter to use
  17931. * @returns the cloned particle system
  17932. */
  17933. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17934. /**
  17935. * Serializes the particle system to a JSON object.
  17936. * @returns the JSON object
  17937. */
  17938. serialize(): any;
  17939. /**
  17940. * Rebuild the particle system
  17941. */
  17942. rebuild(): void;
  17943. /**
  17944. * Starts the particle system and begins to emit
  17945. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17946. */
  17947. start(delay?: number): void;
  17948. /**
  17949. * Stops the particle system.
  17950. */
  17951. stop(): void;
  17952. /**
  17953. * Remove all active particles
  17954. */
  17955. reset(): void;
  17956. /**
  17957. * Is this system ready to be used/rendered
  17958. * @return true if the system is ready
  17959. */
  17960. isReady(): boolean;
  17961. /**
  17962. * Adds a new color gradient
  17963. * @param gradient defines the gradient to use (between 0 and 1)
  17964. * @param color1 defines the color to affect to the specified gradient
  17965. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17966. * @returns the current particle system
  17967. */
  17968. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17969. /**
  17970. * Remove a specific color gradient
  17971. * @param gradient defines the gradient to remove
  17972. * @returns the current particle system
  17973. */
  17974. removeColorGradient(gradient: number): IParticleSystem;
  17975. /**
  17976. * Adds a new size gradient
  17977. * @param gradient defines the gradient to use (between 0 and 1)
  17978. * @param factor defines the size factor to affect to the specified gradient
  17979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17980. * @returns the current particle system
  17981. */
  17982. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17983. /**
  17984. * Remove a specific size gradient
  17985. * @param gradient defines the gradient to remove
  17986. * @returns the current particle system
  17987. */
  17988. removeSizeGradient(gradient: number): IParticleSystem;
  17989. /**
  17990. * Gets the current list of color gradients.
  17991. * You must use addColorGradient and removeColorGradient to udpate this list
  17992. * @returns the list of color gradients
  17993. */
  17994. getColorGradients(): Nullable<Array<ColorGradient>>;
  17995. /**
  17996. * Gets the current list of size gradients.
  17997. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17998. * @returns the list of size gradients
  17999. */
  18000. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18001. /**
  18002. * Gets the current list of angular speed gradients.
  18003. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18004. * @returns the list of angular speed gradients
  18005. */
  18006. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18007. /**
  18008. * Adds a new angular speed gradient
  18009. * @param gradient defines the gradient to use (between 0 and 1)
  18010. * @param factor defines the angular speed to affect to the specified gradient
  18011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18012. * @returns the current particle system
  18013. */
  18014. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18015. /**
  18016. * Remove a specific angular speed gradient
  18017. * @param gradient defines the gradient to remove
  18018. * @returns the current particle system
  18019. */
  18020. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18021. /**
  18022. * Gets the current list of velocity gradients.
  18023. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18024. * @returns the list of velocity gradients
  18025. */
  18026. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18027. /**
  18028. * Adds a new velocity gradient
  18029. * @param gradient defines the gradient to use (between 0 and 1)
  18030. * @param factor defines the velocity to affect to the specified gradient
  18031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18032. * @returns the current particle system
  18033. */
  18034. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18035. /**
  18036. * Remove a specific velocity gradient
  18037. * @param gradient defines the gradient to remove
  18038. * @returns the current particle system
  18039. */
  18040. removeVelocityGradient(gradient: number): IParticleSystem;
  18041. /**
  18042. * Gets the current list of limit velocity gradients.
  18043. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18044. * @returns the list of limit velocity gradients
  18045. */
  18046. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18047. /**
  18048. * Adds a new limit velocity gradient
  18049. * @param gradient defines the gradient to use (between 0 and 1)
  18050. * @param factor defines the limit velocity to affect to the specified gradient
  18051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18052. * @returns the current particle system
  18053. */
  18054. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18055. /**
  18056. * Remove a specific limit velocity gradient
  18057. * @param gradient defines the gradient to remove
  18058. * @returns the current particle system
  18059. */
  18060. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18061. /**
  18062. * Adds a new drag gradient
  18063. * @param gradient defines the gradient to use (between 0 and 1)
  18064. * @param factor defines the drag to affect to the specified gradient
  18065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18066. * @returns the current particle system
  18067. */
  18068. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18069. /**
  18070. * Remove a specific drag gradient
  18071. * @param gradient defines the gradient to remove
  18072. * @returns the current particle system
  18073. */
  18074. removeDragGradient(gradient: number): IParticleSystem;
  18075. /**
  18076. * Gets the current list of drag gradients.
  18077. * You must use addDragGradient and removeDragGradient to udpate this list
  18078. * @returns the list of drag gradients
  18079. */
  18080. getDragGradients(): Nullable<Array<FactorGradient>>;
  18081. /**
  18082. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18083. * @param gradient defines the gradient to use (between 0 and 1)
  18084. * @param factor defines the emit rate to affect to the specified gradient
  18085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18086. * @returns the current particle system
  18087. */
  18088. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18089. /**
  18090. * Remove a specific emit rate gradient
  18091. * @param gradient defines the gradient to remove
  18092. * @returns the current particle system
  18093. */
  18094. removeEmitRateGradient(gradient: number): IParticleSystem;
  18095. /**
  18096. * Gets the current list of emit rate gradients.
  18097. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18098. * @returns the list of emit rate gradients
  18099. */
  18100. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18101. /**
  18102. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18103. * @param gradient defines the gradient to use (between 0 and 1)
  18104. * @param factor defines the start size to affect to the specified gradient
  18105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18106. * @returns the current particle system
  18107. */
  18108. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18109. /**
  18110. * Remove a specific start size gradient
  18111. * @param gradient defines the gradient to remove
  18112. * @returns the current particle system
  18113. */
  18114. removeStartSizeGradient(gradient: number): IParticleSystem;
  18115. /**
  18116. * Gets the current list of start size gradients.
  18117. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18118. * @returns the list of start size gradients
  18119. */
  18120. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18121. /**
  18122. * Adds a new life time gradient
  18123. * @param gradient defines the gradient to use (between 0 and 1)
  18124. * @param factor defines the life time factor to affect to the specified gradient
  18125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18126. * @returns the current particle system
  18127. */
  18128. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18129. /**
  18130. * Remove a specific life time gradient
  18131. * @param gradient defines the gradient to remove
  18132. * @returns the current particle system
  18133. */
  18134. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18135. /**
  18136. * Gets the current list of life time gradients.
  18137. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18138. * @returns the list of life time gradients
  18139. */
  18140. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18141. /**
  18142. * Gets the current list of color gradients.
  18143. * You must use addColorGradient and removeColorGradient to udpate this list
  18144. * @returns the list of color gradients
  18145. */
  18146. getColorGradients(): Nullable<Array<ColorGradient>>;
  18147. /**
  18148. * Adds a new ramp gradient used to remap particle colors
  18149. * @param gradient defines the gradient to use (between 0 and 1)
  18150. * @param color defines the color to affect to the specified gradient
  18151. * @returns the current particle system
  18152. */
  18153. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18154. /**
  18155. * Gets the current list of ramp gradients.
  18156. * You must use addRampGradient and removeRampGradient to udpate this list
  18157. * @returns the list of ramp gradients
  18158. */
  18159. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18160. /** Gets or sets a boolean indicating that ramp gradients must be used
  18161. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18162. */
  18163. useRampGradients: boolean;
  18164. /**
  18165. * Adds a new color remap gradient
  18166. * @param gradient defines the gradient to use (between 0 and 1)
  18167. * @param min defines the color remap minimal range
  18168. * @param max defines the color remap maximal range
  18169. * @returns the current particle system
  18170. */
  18171. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18172. /**
  18173. * Gets the current list of color remap gradients.
  18174. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18175. * @returns the list of color remap gradients
  18176. */
  18177. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18178. /**
  18179. * Adds a new alpha remap gradient
  18180. * @param gradient defines the gradient to use (between 0 and 1)
  18181. * @param min defines the alpha remap minimal range
  18182. * @param max defines the alpha remap maximal range
  18183. * @returns the current particle system
  18184. */
  18185. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18186. /**
  18187. * Gets the current list of alpha remap gradients.
  18188. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18189. * @returns the list of alpha remap gradients
  18190. */
  18191. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18192. /**
  18193. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18196. * @returns the emitter
  18197. */
  18198. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18199. /**
  18200. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18201. * @param radius The radius of the hemisphere to emit from
  18202. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18203. * @returns the emitter
  18204. */
  18205. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18206. /**
  18207. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18208. * @param radius The radius of the sphere to emit from
  18209. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18210. * @returns the emitter
  18211. */
  18212. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18213. /**
  18214. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18215. * @param radius The radius of the sphere to emit from
  18216. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18217. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18218. * @returns the emitter
  18219. */
  18220. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18221. /**
  18222. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18223. * @param radius The radius of the emission cylinder
  18224. * @param height The height of the emission cylinder
  18225. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18226. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18227. * @returns the emitter
  18228. */
  18229. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18230. /**
  18231. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18232. * @param radius The radius of the cylinder to emit from
  18233. * @param height The height of the emission cylinder
  18234. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18237. * @returns the emitter
  18238. */
  18239. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18240. /**
  18241. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18242. * @param radius The radius of the cone to emit from
  18243. * @param angle The base angle of the cone
  18244. * @returns the emitter
  18245. */
  18246. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18247. /**
  18248. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18249. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18250. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18251. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18252. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18253. * @returns the emitter
  18254. */
  18255. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18256. /**
  18257. * Get hosting scene
  18258. * @returns the scene
  18259. */
  18260. getScene(): Scene;
  18261. }
  18262. }
  18263. declare module BABYLON {
  18264. /**
  18265. * Creates an instance based on a source mesh.
  18266. */
  18267. export class InstancedMesh extends AbstractMesh {
  18268. private _sourceMesh;
  18269. private _currentLOD;
  18270. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18271. constructor(name: string, source: Mesh);
  18272. /**
  18273. * Returns the string "InstancedMesh".
  18274. */
  18275. getClassName(): string;
  18276. /** Gets the list of lights affecting that mesh */
  18277. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  18278. /**
  18279. * If the source mesh receives shadows
  18280. */
  18281. readonly receiveShadows: boolean;
  18282. /**
  18283. * The material of the source mesh
  18284. */
  18285. readonly material: Nullable<Material>;
  18286. /**
  18287. * Visibility of the source mesh
  18288. */
  18289. readonly visibility: number;
  18290. /**
  18291. * Skeleton of the source mesh
  18292. */
  18293. readonly skeleton: Nullable<Skeleton>;
  18294. /**
  18295. * Rendering ground id of the source mesh
  18296. */
  18297. renderingGroupId: number;
  18298. /**
  18299. * Returns the total number of vertices (integer).
  18300. */
  18301. getTotalVertices(): number;
  18302. /**
  18303. * Returns a positive integer : the total number of indices in this mesh geometry.
  18304. * @returns the numner of indices or zero if the mesh has no geometry.
  18305. */
  18306. getTotalIndices(): number;
  18307. /**
  18308. * The source mesh of the instance
  18309. */
  18310. readonly sourceMesh: Mesh;
  18311. /**
  18312. * Is this node ready to be used/rendered
  18313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18314. * @return {boolean} is it ready
  18315. */
  18316. isReady(completeCheck?: boolean): boolean;
  18317. /**
  18318. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18319. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18320. * @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.
  18321. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18322. */
  18323. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18324. /**
  18325. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18326. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18327. * The `data` are either a numeric array either a Float32Array.
  18328. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18329. * 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).
  18330. * Note that a new underlying VertexBuffer object is created each call.
  18331. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18332. *
  18333. * Possible `kind` values :
  18334. * - VertexBuffer.PositionKind
  18335. * - VertexBuffer.UVKind
  18336. * - VertexBuffer.UV2Kind
  18337. * - VertexBuffer.UV3Kind
  18338. * - VertexBuffer.UV4Kind
  18339. * - VertexBuffer.UV5Kind
  18340. * - VertexBuffer.UV6Kind
  18341. * - VertexBuffer.ColorKind
  18342. * - VertexBuffer.MatricesIndicesKind
  18343. * - VertexBuffer.MatricesIndicesExtraKind
  18344. * - VertexBuffer.MatricesWeightsKind
  18345. * - VertexBuffer.MatricesWeightsExtraKind
  18346. *
  18347. * Returns the Mesh.
  18348. */
  18349. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18350. /**
  18351. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18352. * If the mesh has no geometry, it is simply returned as it is.
  18353. * The `data` are either a numeric array either a Float32Array.
  18354. * No new underlying VertexBuffer object is created.
  18355. * 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.
  18356. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18357. *
  18358. * Possible `kind` values :
  18359. * - VertexBuffer.PositionKind
  18360. * - VertexBuffer.UVKind
  18361. * - VertexBuffer.UV2Kind
  18362. * - VertexBuffer.UV3Kind
  18363. * - VertexBuffer.UV4Kind
  18364. * - VertexBuffer.UV5Kind
  18365. * - VertexBuffer.UV6Kind
  18366. * - VertexBuffer.ColorKind
  18367. * - VertexBuffer.MatricesIndicesKind
  18368. * - VertexBuffer.MatricesIndicesExtraKind
  18369. * - VertexBuffer.MatricesWeightsKind
  18370. * - VertexBuffer.MatricesWeightsExtraKind
  18371. *
  18372. * Returns the Mesh.
  18373. */
  18374. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18375. /**
  18376. * Sets the mesh indices.
  18377. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18378. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18379. * This method creates a new index buffer each call.
  18380. * Returns the Mesh.
  18381. */
  18382. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18383. /**
  18384. * Boolean : True if the mesh owns the requested kind of data.
  18385. */
  18386. isVerticesDataPresent(kind: string): boolean;
  18387. /**
  18388. * Returns an array of indices (IndicesArray).
  18389. */
  18390. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18391. /**
  18392. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18393. * This means the mesh underlying bounding box and sphere are recomputed.
  18394. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18395. * @returns the current mesh
  18396. */
  18397. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18398. /** @hidden */ private _preActivate(): InstancedMesh;
  18399. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18400. /** @hidden */ private _postActivate(): void;
  18401. getWorldMatrix(): Matrix;
  18402. readonly isAnInstance: boolean;
  18403. /**
  18404. * Returns the current associated LOD AbstractMesh.
  18405. */
  18406. getLOD(camera: Camera): AbstractMesh;
  18407. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18408. /** @hidden */ private _generatePointsArray(): boolean;
  18409. /**
  18410. * Creates a new InstancedMesh from the current mesh.
  18411. * - name (string) : the cloned mesh name
  18412. * - newParent (optional Node) : the optional Node to parent the clone to.
  18413. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18414. *
  18415. * Returns the clone.
  18416. */
  18417. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18418. /**
  18419. * Disposes the InstancedMesh.
  18420. * Returns nothing.
  18421. */
  18422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18423. }
  18424. }
  18425. declare module BABYLON {
  18426. /**
  18427. * Defines the options associated with the creation of a shader material.
  18428. */
  18429. export interface IShaderMaterialOptions {
  18430. /**
  18431. * Does the material work in alpha blend mode
  18432. */
  18433. needAlphaBlending: boolean;
  18434. /**
  18435. * Does the material work in alpha test mode
  18436. */
  18437. needAlphaTesting: boolean;
  18438. /**
  18439. * The list of attribute names used in the shader
  18440. */
  18441. attributes: string[];
  18442. /**
  18443. * The list of unifrom names used in the shader
  18444. */
  18445. uniforms: string[];
  18446. /**
  18447. * The list of UBO names used in the shader
  18448. */
  18449. uniformBuffers: string[];
  18450. /**
  18451. * The list of sampler names used in the shader
  18452. */
  18453. samplers: string[];
  18454. /**
  18455. * The list of defines used in the shader
  18456. */
  18457. defines: string[];
  18458. }
  18459. /**
  18460. * 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.
  18461. *
  18462. * This returned material effects how the mesh will look based on the code in the shaders.
  18463. *
  18464. * @see http://doc.babylonjs.com/how_to/shader_material
  18465. */
  18466. export class ShaderMaterial extends Material {
  18467. private _shaderPath;
  18468. private _options;
  18469. private _textures;
  18470. private _textureArrays;
  18471. private _floats;
  18472. private _ints;
  18473. private _floatsArrays;
  18474. private _colors3;
  18475. private _colors3Arrays;
  18476. private _colors4;
  18477. private _colors4Arrays;
  18478. private _vectors2;
  18479. private _vectors3;
  18480. private _vectors4;
  18481. private _matrices;
  18482. private _matrices3x3;
  18483. private _matrices2x2;
  18484. private _vectors2Arrays;
  18485. private _vectors3Arrays;
  18486. private _vectors4Arrays;
  18487. private _cachedWorldViewMatrix;
  18488. private _cachedWorldViewProjectionMatrix;
  18489. private _renderId;
  18490. /**
  18491. * Instantiate a new shader material.
  18492. * 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.
  18493. * This returned material effects how the mesh will look based on the code in the shaders.
  18494. * @see http://doc.babylonjs.com/how_to/shader_material
  18495. * @param name Define the name of the material in the scene
  18496. * @param scene Define the scene the material belongs to
  18497. * @param shaderPath Defines the route to the shader code in one of three ways:
  18498. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18499. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18500. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18501. * @param options Define the options used to create the shader
  18502. */
  18503. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18504. /**
  18505. * Gets the options used to compile the shader.
  18506. * They can be modified to trigger a new compilation
  18507. */
  18508. readonly options: IShaderMaterialOptions;
  18509. /**
  18510. * Gets the current class name of the material e.g. "ShaderMaterial"
  18511. * Mainly use in serialization.
  18512. * @returns the class name
  18513. */
  18514. getClassName(): string;
  18515. /**
  18516. * Specifies if the material will require alpha blending
  18517. * @returns a boolean specifying if alpha blending is needed
  18518. */
  18519. needAlphaBlending(): boolean;
  18520. /**
  18521. * Specifies if this material should be rendered in alpha test mode
  18522. * @returns a boolean specifying if an alpha test is needed.
  18523. */
  18524. needAlphaTesting(): boolean;
  18525. private _checkUniform;
  18526. /**
  18527. * Set a texture in the shader.
  18528. * @param name Define the name of the uniform samplers as defined in the shader
  18529. * @param texture Define the texture to bind to this sampler
  18530. * @return the material itself allowing "fluent" like uniform updates
  18531. */
  18532. setTexture(name: string, texture: Texture): ShaderMaterial;
  18533. /**
  18534. * Set a texture array in the shader.
  18535. * @param name Define the name of the uniform sampler array as defined in the shader
  18536. * @param textures Define the list of textures to bind to this sampler
  18537. * @return the material itself allowing "fluent" like uniform updates
  18538. */
  18539. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18540. /**
  18541. * Set a float in the shader.
  18542. * @param name Define the name of the uniform as defined in the shader
  18543. * @param value Define the value to give to the uniform
  18544. * @return the material itself allowing "fluent" like uniform updates
  18545. */
  18546. setFloat(name: string, value: number): ShaderMaterial;
  18547. /**
  18548. * Set a int in the shader.
  18549. * @param name Define the name of the uniform as defined in the shader
  18550. * @param value Define the value to give to the uniform
  18551. * @return the material itself allowing "fluent" like uniform updates
  18552. */
  18553. setInt(name: string, value: number): ShaderMaterial;
  18554. /**
  18555. * Set an array of floats in the shader.
  18556. * @param name Define the name of the uniform as defined in the shader
  18557. * @param value Define the value to give to the uniform
  18558. * @return the material itself allowing "fluent" like uniform updates
  18559. */
  18560. setFloats(name: string, value: number[]): ShaderMaterial;
  18561. /**
  18562. * Set a vec3 in the shader from a Color3.
  18563. * @param name Define the name of the uniform as defined in the shader
  18564. * @param value Define the value to give to the uniform
  18565. * @return the material itself allowing "fluent" like uniform updates
  18566. */
  18567. setColor3(name: string, value: Color3): ShaderMaterial;
  18568. /**
  18569. * Set a vec3 array in the shader from a Color3 array.
  18570. * @param name Define the name of the uniform as defined in the shader
  18571. * @param value Define the value to give to the uniform
  18572. * @return the material itself allowing "fluent" like uniform updates
  18573. */
  18574. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18575. /**
  18576. * Set a vec4 in the shader from a Color4.
  18577. * @param name Define the name of the uniform as defined in the shader
  18578. * @param value Define the value to give to the uniform
  18579. * @return the material itself allowing "fluent" like uniform updates
  18580. */
  18581. setColor4(name: string, value: Color4): ShaderMaterial;
  18582. /**
  18583. * Set a vec4 array in the shader from a Color4 array.
  18584. * @param name Define the name of the uniform as defined in the shader
  18585. * @param value Define the value to give to the uniform
  18586. * @return the material itself allowing "fluent" like uniform updates
  18587. */
  18588. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18589. /**
  18590. * Set a vec2 in the shader from a Vector2.
  18591. * @param name Define the name of the uniform as defined in the shader
  18592. * @param value Define the value to give to the uniform
  18593. * @return the material itself allowing "fluent" like uniform updates
  18594. */
  18595. setVector2(name: string, value: Vector2): ShaderMaterial;
  18596. /**
  18597. * Set a vec3 in the shader from a Vector3.
  18598. * @param name Define the name of the uniform as defined in the shader
  18599. * @param value Define the value to give to the uniform
  18600. * @return the material itself allowing "fluent" like uniform updates
  18601. */
  18602. setVector3(name: string, value: Vector3): ShaderMaterial;
  18603. /**
  18604. * Set a vec4 in the shader from a Vector4.
  18605. * @param name Define the name of the uniform as defined in the shader
  18606. * @param value Define the value to give to the uniform
  18607. * @return the material itself allowing "fluent" like uniform updates
  18608. */
  18609. setVector4(name: string, value: Vector4): ShaderMaterial;
  18610. /**
  18611. * Set a mat4 in the shader from a Matrix.
  18612. * @param name Define the name of the uniform as defined in the shader
  18613. * @param value Define the value to give to the uniform
  18614. * @return the material itself allowing "fluent" like uniform updates
  18615. */
  18616. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18617. /**
  18618. * Set a mat3 in the shader from a Float32Array.
  18619. * @param name Define the name of the uniform as defined in the shader
  18620. * @param value Define the value to give to the uniform
  18621. * @return the material itself allowing "fluent" like uniform updates
  18622. */
  18623. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18624. /**
  18625. * Set a mat2 in the shader from a Float32Array.
  18626. * @param name Define the name of the uniform as defined in the shader
  18627. * @param value Define the value to give to the uniform
  18628. * @return the material itself allowing "fluent" like uniform updates
  18629. */
  18630. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18631. /**
  18632. * Set a vec2 array in the shader from a number array.
  18633. * @param name Define the name of the uniform as defined in the shader
  18634. * @param value Define the value to give to the uniform
  18635. * @return the material itself allowing "fluent" like uniform updates
  18636. */
  18637. setArray2(name: string, value: number[]): ShaderMaterial;
  18638. /**
  18639. * Set a vec3 array in the shader from a number array.
  18640. * @param name Define the name of the uniform as defined in the shader
  18641. * @param value Define the value to give to the uniform
  18642. * @return the material itself allowing "fluent" like uniform updates
  18643. */
  18644. setArray3(name: string, value: number[]): ShaderMaterial;
  18645. /**
  18646. * Set a vec4 array in the shader from a number array.
  18647. * @param name Define the name of the uniform as defined in the shader
  18648. * @param value Define the value to give to the uniform
  18649. * @return the material itself allowing "fluent" like uniform updates
  18650. */
  18651. setArray4(name: string, value: number[]): ShaderMaterial;
  18652. private _checkCache;
  18653. /**
  18654. * Specifies that the submesh is ready to be used
  18655. * @param mesh defines the mesh to check
  18656. * @param subMesh defines which submesh to check
  18657. * @param useInstances specifies that instances should be used
  18658. * @returns a boolean indicating that the submesh is ready or not
  18659. */
  18660. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18661. /**
  18662. * Checks if the material is ready to render the requested mesh
  18663. * @param mesh Define the mesh to render
  18664. * @param useInstances Define whether or not the material is used with instances
  18665. * @returns true if ready, otherwise false
  18666. */
  18667. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18668. /**
  18669. * Binds the world matrix to the material
  18670. * @param world defines the world transformation matrix
  18671. */
  18672. bindOnlyWorldMatrix(world: Matrix): void;
  18673. /**
  18674. * Binds the material to the mesh
  18675. * @param world defines the world transformation matrix
  18676. * @param mesh defines the mesh to bind the material to
  18677. */
  18678. bind(world: Matrix, mesh?: Mesh): void;
  18679. /**
  18680. * Gets the active textures from the material
  18681. * @returns an array of textures
  18682. */
  18683. getActiveTextures(): BaseTexture[];
  18684. /**
  18685. * Specifies if the material uses a texture
  18686. * @param texture defines the texture to check against the material
  18687. * @returns a boolean specifying if the material uses the texture
  18688. */
  18689. hasTexture(texture: BaseTexture): boolean;
  18690. /**
  18691. * Makes a duplicate of the material, and gives it a new name
  18692. * @param name defines the new name for the duplicated material
  18693. * @returns the cloned material
  18694. */
  18695. clone(name: string): ShaderMaterial;
  18696. /**
  18697. * Disposes the material
  18698. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18699. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18700. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18701. */
  18702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18703. /**
  18704. * Serializes this material in a JSON representation
  18705. * @returns the serialized material object
  18706. */
  18707. serialize(): any;
  18708. /**
  18709. * Creates a shader material from parsed shader material data
  18710. * @param source defines the JSON represnetation of the material
  18711. * @param scene defines the hosting scene
  18712. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18713. * @returns a new material
  18714. */
  18715. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18716. }
  18717. }
  18718. declare module BABYLON {
  18719. /** @hidden */
  18720. export var colorPixelShader: {
  18721. name: string;
  18722. shader: string;
  18723. };
  18724. }
  18725. declare module BABYLON {
  18726. /** @hidden */
  18727. export var colorVertexShader: {
  18728. name: string;
  18729. shader: string;
  18730. };
  18731. }
  18732. declare module BABYLON {
  18733. /**
  18734. * Line mesh
  18735. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18736. */
  18737. export class LinesMesh extends Mesh {
  18738. /**
  18739. * If vertex color should be applied to the mesh
  18740. */
  18741. readonly useVertexColor?: boolean | undefined;
  18742. /**
  18743. * If vertex alpha should be applied to the mesh
  18744. */
  18745. readonly useVertexAlpha?: boolean | undefined;
  18746. /**
  18747. * Color of the line (Default: White)
  18748. */
  18749. color: Color3;
  18750. /**
  18751. * Alpha of the line (Default: 1)
  18752. */
  18753. alpha: number;
  18754. /**
  18755. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18756. * This margin is expressed in world space coordinates, so its value may vary.
  18757. * Default value is 0.1
  18758. */
  18759. intersectionThreshold: number;
  18760. private _colorShader;
  18761. private color4;
  18762. /**
  18763. * Creates a new LinesMesh
  18764. * @param name defines the name
  18765. * @param scene defines the hosting scene
  18766. * @param parent defines the parent mesh if any
  18767. * @param source defines the optional source LinesMesh used to clone data from
  18768. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18769. * When false, achieved by calling a clone(), also passing False.
  18770. * This will make creation of children, recursive.
  18771. * @param useVertexColor defines if this LinesMesh supports vertex color
  18772. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18773. */
  18774. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18775. /**
  18776. * If vertex color should be applied to the mesh
  18777. */
  18778. useVertexColor?: boolean | undefined,
  18779. /**
  18780. * If vertex alpha should be applied to the mesh
  18781. */
  18782. useVertexAlpha?: boolean | undefined);
  18783. private _addClipPlaneDefine;
  18784. private _removeClipPlaneDefine;
  18785. isReady(): boolean;
  18786. /**
  18787. * Returns the string "LineMesh"
  18788. */
  18789. getClassName(): string;
  18790. /**
  18791. * @hidden
  18792. */
  18793. /**
  18794. * @hidden
  18795. */
  18796. material: Material;
  18797. /**
  18798. * @hidden
  18799. */
  18800. readonly checkCollisions: boolean;
  18801. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18802. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18803. /**
  18804. * Disposes of the line mesh
  18805. * @param doNotRecurse If children should be disposed
  18806. */
  18807. dispose(doNotRecurse?: boolean): void;
  18808. /**
  18809. * Returns a new LineMesh object cloned from the current one.
  18810. */
  18811. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18812. /**
  18813. * Creates a new InstancedLinesMesh object from the mesh model.
  18814. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18815. * @param name defines the name of the new instance
  18816. * @returns a new InstancedLinesMesh
  18817. */
  18818. createInstance(name: string): InstancedLinesMesh;
  18819. }
  18820. /**
  18821. * Creates an instance based on a source LinesMesh
  18822. */
  18823. export class InstancedLinesMesh extends InstancedMesh {
  18824. /**
  18825. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18826. * This margin is expressed in world space coordinates, so its value may vary.
  18827. * Initilized with the intersectionThreshold value of the source LinesMesh
  18828. */
  18829. intersectionThreshold: number;
  18830. constructor(name: string, source: LinesMesh);
  18831. /**
  18832. * Returns the string "InstancedLinesMesh".
  18833. */
  18834. getClassName(): string;
  18835. }
  18836. }
  18837. declare module BABYLON {
  18838. /** @hidden */
  18839. export var linePixelShader: {
  18840. name: string;
  18841. shader: string;
  18842. };
  18843. }
  18844. declare module BABYLON {
  18845. /** @hidden */
  18846. export var lineVertexShader: {
  18847. name: string;
  18848. shader: string;
  18849. };
  18850. }
  18851. declare module BABYLON {
  18852. interface AbstractMesh {
  18853. /**
  18854. * Gets the edgesRenderer associated with the mesh
  18855. */
  18856. edgesRenderer: Nullable<EdgesRenderer>;
  18857. }
  18858. interface LinesMesh {
  18859. /**
  18860. * Enables the edge rendering mode on the mesh.
  18861. * This mode makes the mesh edges visible
  18862. * @param epsilon defines the maximal distance between two angles to detect a face
  18863. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18864. * @returns the currentAbstractMesh
  18865. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18866. */
  18867. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18868. }
  18869. interface InstancedLinesMesh {
  18870. /**
  18871. * Enables the edge rendering mode on the mesh.
  18872. * This mode makes the mesh edges visible
  18873. * @param epsilon defines the maximal distance between two angles to detect a face
  18874. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18875. * @returns the current InstancedLinesMesh
  18876. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18877. */
  18878. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  18879. }
  18880. /**
  18881. * Defines the minimum contract an Edges renderer should follow.
  18882. */
  18883. export interface IEdgesRenderer extends IDisposable {
  18884. /**
  18885. * Gets or sets a boolean indicating if the edgesRenderer is active
  18886. */
  18887. isEnabled: boolean;
  18888. /**
  18889. * Renders the edges of the attached mesh,
  18890. */
  18891. render(): void;
  18892. /**
  18893. * Checks wether or not the edges renderer is ready to render.
  18894. * @return true if ready, otherwise false.
  18895. */
  18896. isReady(): boolean;
  18897. }
  18898. /**
  18899. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  18900. */
  18901. export class EdgesRenderer implements IEdgesRenderer {
  18902. /**
  18903. * Define the size of the edges with an orthographic camera
  18904. */
  18905. edgesWidthScalerForOrthographic: number;
  18906. /**
  18907. * Define the size of the edges with a perspective camera
  18908. */
  18909. edgesWidthScalerForPerspective: number;
  18910. protected _source: AbstractMesh;
  18911. protected _linesPositions: number[];
  18912. protected _linesNormals: number[];
  18913. protected _linesIndices: number[];
  18914. protected _epsilon: number;
  18915. protected _indicesCount: number;
  18916. protected _lineShader: ShaderMaterial;
  18917. protected _ib: DataBuffer;
  18918. protected _buffers: {
  18919. [key: string]: Nullable<VertexBuffer>;
  18920. };
  18921. protected _checkVerticesInsteadOfIndices: boolean;
  18922. private _meshRebuildObserver;
  18923. private _meshDisposeObserver;
  18924. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  18925. isEnabled: boolean;
  18926. /**
  18927. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  18928. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  18929. * @param source Mesh used to create edges
  18930. * @param epsilon sum of angles in adjacency to check for edge
  18931. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  18932. * @param generateEdgesLines - should generate Lines or only prepare resources.
  18933. */
  18934. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  18935. protected _prepareRessources(): void;
  18936. /** @hidden */ private _rebuild(): void;
  18937. /**
  18938. * Releases the required resources for the edges renderer
  18939. */
  18940. dispose(): void;
  18941. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  18942. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  18943. /**
  18944. * Checks if the pair of p0 and p1 is en edge
  18945. * @param faceIndex
  18946. * @param edge
  18947. * @param faceNormals
  18948. * @param p0
  18949. * @param p1
  18950. * @private
  18951. */
  18952. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  18953. /**
  18954. * push line into the position, normal and index buffer
  18955. * @protected
  18956. */
  18957. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  18958. /**
  18959. * Generates lines edges from adjacencjes
  18960. * @private
  18961. */ private _generateEdgesLines(): void;
  18962. /**
  18963. * Checks wether or not the edges renderer is ready to render.
  18964. * @return true if ready, otherwise false.
  18965. */
  18966. isReady(): boolean;
  18967. /**
  18968. * Renders the edges of the attached mesh,
  18969. */
  18970. render(): void;
  18971. }
  18972. /**
  18973. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  18974. */
  18975. export class LineEdgesRenderer extends EdgesRenderer {
  18976. /**
  18977. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  18978. * @param source LineMesh used to generate edges
  18979. * @param epsilon not important (specified angle for edge detection)
  18980. * @param checkVerticesInsteadOfIndices not important for LineMesh
  18981. */
  18982. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  18983. /**
  18984. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  18985. */ private _generateEdgesLines(): void;
  18986. }
  18987. }
  18988. declare module BABYLON {
  18989. /**
  18990. * This represents the object necessary to create a rendering group.
  18991. * This is exclusively used and created by the rendering manager.
  18992. * To modify the behavior, you use the available helpers in your scene or meshes.
  18993. * @hidden
  18994. */
  18995. export class RenderingGroup {
  18996. index: number;
  18997. private static _zeroVector;
  18998. private _scene;
  18999. private _opaqueSubMeshes;
  19000. private _transparentSubMeshes;
  19001. private _alphaTestSubMeshes;
  19002. private _depthOnlySubMeshes;
  19003. private _particleSystems;
  19004. private _spriteManagers;
  19005. private _opaqueSortCompareFn;
  19006. private _alphaTestSortCompareFn;
  19007. private _transparentSortCompareFn;
  19008. private _renderOpaque;
  19009. private _renderAlphaTest;
  19010. private _renderTransparent;
  19011. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19012. onBeforeTransparentRendering: () => void;
  19013. /**
  19014. * Set the opaque sort comparison function.
  19015. * If null the sub meshes will be render in the order they were created
  19016. */
  19017. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19018. /**
  19019. * Set the alpha test sort comparison function.
  19020. * If null the sub meshes will be render in the order they were created
  19021. */
  19022. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19023. /**
  19024. * Set the transparent sort comparison function.
  19025. * If null the sub meshes will be render in the order they were created
  19026. */
  19027. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19028. /**
  19029. * Creates a new rendering group.
  19030. * @param index The rendering group index
  19031. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19032. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19033. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19034. */
  19035. 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>);
  19036. /**
  19037. * Render all the sub meshes contained in the group.
  19038. * @param customRenderFunction Used to override the default render behaviour of the group.
  19039. * @returns true if rendered some submeshes.
  19040. */
  19041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19042. /**
  19043. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19044. * @param subMeshes The submeshes to render
  19045. */
  19046. private renderOpaqueSorted;
  19047. /**
  19048. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19049. * @param subMeshes The submeshes to render
  19050. */
  19051. private renderAlphaTestSorted;
  19052. /**
  19053. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19054. * @param subMeshes The submeshes to render
  19055. */
  19056. private renderTransparentSorted;
  19057. /**
  19058. * Renders the submeshes in a specified order.
  19059. * @param subMeshes The submeshes to sort before render
  19060. * @param sortCompareFn The comparison function use to sort
  19061. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19062. * @param transparent Specifies to activate blending if true
  19063. */
  19064. private static renderSorted;
  19065. /**
  19066. * Renders the submeshes in the order they were dispatched (no sort applied).
  19067. * @param subMeshes The submeshes to render
  19068. */
  19069. private static renderUnsorted;
  19070. /**
  19071. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19072. * are rendered back to front if in the same alpha index.
  19073. *
  19074. * @param a The first submesh
  19075. * @param b The second submesh
  19076. * @returns The result of the comparison
  19077. */
  19078. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19079. /**
  19080. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19081. * are rendered back to front.
  19082. *
  19083. * @param a The first submesh
  19084. * @param b The second submesh
  19085. * @returns The result of the comparison
  19086. */
  19087. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19088. /**
  19089. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19090. * are rendered front to back (prevent overdraw).
  19091. *
  19092. * @param a The first submesh
  19093. * @param b The second submesh
  19094. * @returns The result of the comparison
  19095. */
  19096. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19097. /**
  19098. * Resets the different lists of submeshes to prepare a new frame.
  19099. */
  19100. prepare(): void;
  19101. dispose(): void;
  19102. /**
  19103. * Inserts the submesh in its correct queue depending on its material.
  19104. * @param subMesh The submesh to dispatch
  19105. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19106. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19107. */
  19108. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19109. dispatchSprites(spriteManager: ISpriteManager): void;
  19110. dispatchParticles(particleSystem: IParticleSystem): void;
  19111. private _renderParticles;
  19112. private _renderSprites;
  19113. }
  19114. }
  19115. declare module BABYLON {
  19116. /**
  19117. * Interface describing the different options available in the rendering manager
  19118. * regarding Auto Clear between groups.
  19119. */
  19120. export interface IRenderingManagerAutoClearSetup {
  19121. /**
  19122. * Defines whether or not autoclear is enable.
  19123. */
  19124. autoClear: boolean;
  19125. /**
  19126. * Defines whether or not to autoclear the depth buffer.
  19127. */
  19128. depth: boolean;
  19129. /**
  19130. * Defines whether or not to autoclear the stencil buffer.
  19131. */
  19132. stencil: boolean;
  19133. }
  19134. /**
  19135. * This class is used by the onRenderingGroupObservable
  19136. */
  19137. export class RenderingGroupInfo {
  19138. /**
  19139. * The Scene that being rendered
  19140. */
  19141. scene: Scene;
  19142. /**
  19143. * The camera currently used for the rendering pass
  19144. */
  19145. camera: Nullable<Camera>;
  19146. /**
  19147. * The ID of the renderingGroup being processed
  19148. */
  19149. renderingGroupId: number;
  19150. }
  19151. /**
  19152. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19153. * It is enable to manage the different groups as well as the different necessary sort functions.
  19154. * This should not be used directly aside of the few static configurations
  19155. */
  19156. export class RenderingManager {
  19157. /**
  19158. * The max id used for rendering groups (not included)
  19159. */
  19160. static MAX_RENDERINGGROUPS: number;
  19161. /**
  19162. * The min id used for rendering groups (included)
  19163. */
  19164. static MIN_RENDERINGGROUPS: number;
  19165. /**
  19166. * Used to globally prevent autoclearing scenes.
  19167. */
  19168. static AUTOCLEAR: boolean;
  19169. /**
  19170. * @hidden
  19171. */ private _useSceneAutoClearSetup: boolean;
  19172. private _scene;
  19173. private _renderingGroups;
  19174. private _depthStencilBufferAlreadyCleaned;
  19175. private _autoClearDepthStencil;
  19176. private _customOpaqueSortCompareFn;
  19177. private _customAlphaTestSortCompareFn;
  19178. private _customTransparentSortCompareFn;
  19179. private _renderingGroupInfo;
  19180. /**
  19181. * Instantiates a new rendering group for a particular scene
  19182. * @param scene Defines the scene the groups belongs to
  19183. */
  19184. constructor(scene: Scene);
  19185. private _clearDepthStencilBuffer;
  19186. /**
  19187. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19188. * @hidden
  19189. */
  19190. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19191. /**
  19192. * Resets the different information of the group to prepare a new frame
  19193. * @hidden
  19194. */
  19195. reset(): void;
  19196. /**
  19197. * Dispose and release the group and its associated resources.
  19198. * @hidden
  19199. */
  19200. dispose(): void;
  19201. /**
  19202. * Clear the info related to rendering groups preventing retention points during dispose.
  19203. */
  19204. freeRenderingGroups(): void;
  19205. private _prepareRenderingGroup;
  19206. /**
  19207. * Add a sprite manager to the rendering manager in order to render it this frame.
  19208. * @param spriteManager Define the sprite manager to render
  19209. */
  19210. dispatchSprites(spriteManager: ISpriteManager): void;
  19211. /**
  19212. * Add a particle system to the rendering manager in order to render it this frame.
  19213. * @param particleSystem Define the particle system to render
  19214. */
  19215. dispatchParticles(particleSystem: IParticleSystem): void;
  19216. /**
  19217. * Add a submesh to the manager in order to render it this frame
  19218. * @param subMesh The submesh to dispatch
  19219. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19220. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19221. */
  19222. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19223. /**
  19224. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19225. * This allowed control for front to back rendering or reversly depending of the special needs.
  19226. *
  19227. * @param renderingGroupId The rendering group id corresponding to its index
  19228. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19229. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19230. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19231. */
  19232. 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;
  19233. /**
  19234. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19235. *
  19236. * @param renderingGroupId The rendering group id corresponding to its index
  19237. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19238. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19239. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19240. */
  19241. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19242. /**
  19243. * Gets the current auto clear configuration for one rendering group of the rendering
  19244. * manager.
  19245. * @param index the rendering group index to get the information for
  19246. * @returns The auto clear setup for the requested rendering group
  19247. */
  19248. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19249. }
  19250. }
  19251. declare module BABYLON {
  19252. /**
  19253. * This Helps creating a texture that will be created from a camera in your scene.
  19254. * It is basically a dynamic texture that could be used to create special effects for instance.
  19255. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19256. */
  19257. export class RenderTargetTexture extends Texture {
  19258. isCube: boolean;
  19259. /**
  19260. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19261. */
  19262. static readonly REFRESHRATE_RENDER_ONCE: number;
  19263. /**
  19264. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19265. */
  19266. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19267. /**
  19268. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19269. * the central point of your effect and can save a lot of performances.
  19270. */
  19271. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19272. /**
  19273. * Use this predicate to dynamically define the list of mesh you want to render.
  19274. * If set, the renderList property will be overwritten.
  19275. */
  19276. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19277. private _renderList;
  19278. /**
  19279. * Use this list to define the list of mesh you want to render.
  19280. */
  19281. renderList: Nullable<Array<AbstractMesh>>;
  19282. private _hookArray;
  19283. /**
  19284. * Define if particles should be rendered in your texture.
  19285. */
  19286. renderParticles: boolean;
  19287. /**
  19288. * Define if sprites should be rendered in your texture.
  19289. */
  19290. renderSprites: boolean;
  19291. /**
  19292. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19293. */
  19294. coordinatesMode: number;
  19295. /**
  19296. * Define the camera used to render the texture.
  19297. */
  19298. activeCamera: Nullable<Camera>;
  19299. /**
  19300. * Override the render function of the texture with your own one.
  19301. */
  19302. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19303. /**
  19304. * Define if camera post processes should be use while rendering the texture.
  19305. */
  19306. useCameraPostProcesses: boolean;
  19307. /**
  19308. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19309. */
  19310. ignoreCameraViewport: boolean;
  19311. private _postProcessManager;
  19312. private _postProcesses;
  19313. private _resizeObserver;
  19314. /**
  19315. * An event triggered when the texture is unbind.
  19316. */
  19317. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19318. /**
  19319. * An event triggered when the texture is unbind.
  19320. */
  19321. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19322. private _onAfterUnbindObserver;
  19323. /**
  19324. * Set a after unbind callback in the texture.
  19325. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19326. */
  19327. onAfterUnbind: () => void;
  19328. /**
  19329. * An event triggered before rendering the texture
  19330. */
  19331. onBeforeRenderObservable: Observable<number>;
  19332. private _onBeforeRenderObserver;
  19333. /**
  19334. * Set a before render callback in the texture.
  19335. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19336. */
  19337. onBeforeRender: (faceIndex: number) => void;
  19338. /**
  19339. * An event triggered after rendering the texture
  19340. */
  19341. onAfterRenderObservable: Observable<number>;
  19342. private _onAfterRenderObserver;
  19343. /**
  19344. * Set a after render callback in the texture.
  19345. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19346. */
  19347. onAfterRender: (faceIndex: number) => void;
  19348. /**
  19349. * An event triggered after the texture clear
  19350. */
  19351. onClearObservable: Observable<Engine>;
  19352. private _onClearObserver;
  19353. /**
  19354. * Set a clear callback in the texture.
  19355. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19356. */
  19357. onClear: (Engine: Engine) => void;
  19358. /**
  19359. * An event triggered when the texture is resized.
  19360. */
  19361. onResizeObservable: Observable<RenderTargetTexture>;
  19362. /**
  19363. * Define the clear color of the Render Target if it should be different from the scene.
  19364. */
  19365. clearColor: Color4;
  19366. protected _size: number | {
  19367. width: number;
  19368. height: number;
  19369. };
  19370. protected _initialSizeParameter: number | {
  19371. width: number;
  19372. height: number;
  19373. } | {
  19374. ratio: number;
  19375. };
  19376. protected _sizeRatio: Nullable<number>;
  19377. /** @hidden */ private _generateMipMaps: boolean;
  19378. protected _renderingManager: RenderingManager;
  19379. /** @hidden */ private _waitingRenderList: string[];
  19380. protected _doNotChangeAspectRatio: boolean;
  19381. protected _currentRefreshId: number;
  19382. protected _refreshRate: number;
  19383. protected _textureMatrix: Matrix;
  19384. protected _samples: number;
  19385. protected _renderTargetOptions: RenderTargetCreationOptions;
  19386. /**
  19387. * Gets render target creation options that were used.
  19388. */
  19389. readonly renderTargetOptions: RenderTargetCreationOptions;
  19390. protected _engine: Engine;
  19391. protected _onRatioRescale(): void;
  19392. /**
  19393. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19394. * It must define where the camera used to render the texture is set
  19395. */
  19396. boundingBoxPosition: Vector3;
  19397. private _boundingBoxSize;
  19398. /**
  19399. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19400. * When defined, the cubemap will switch to local mode
  19401. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19402. * @example https://www.babylonjs-playground.com/#RNASML
  19403. */
  19404. boundingBoxSize: Vector3;
  19405. /**
  19406. * In case the RTT has been created with a depth texture, get the associated
  19407. * depth texture.
  19408. * Otherwise, return null.
  19409. */
  19410. depthStencilTexture: Nullable<InternalTexture>;
  19411. /**
  19412. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19413. * or used a shadow, depth texture...
  19414. * @param name The friendly name of the texture
  19415. * @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)
  19416. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19417. * @param generateMipMaps True if mip maps need to be generated after render.
  19418. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19419. * @param type The type of the buffer in the RTT (int, half float, float...)
  19420. * @param isCube True if a cube texture needs to be created
  19421. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19422. * @param generateDepthBuffer True to generate a depth buffer
  19423. * @param generateStencilBuffer True to generate a stencil buffer
  19424. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19425. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19426. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19427. */
  19428. constructor(name: string, size: number | {
  19429. width: number;
  19430. height: number;
  19431. } | {
  19432. ratio: number;
  19433. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19434. /**
  19435. * Creates a depth stencil texture.
  19436. * This is only available in WebGL 2 or with the depth texture extension available.
  19437. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19438. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19439. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19440. */
  19441. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19442. private _processSizeParameter;
  19443. /**
  19444. * Define the number of samples to use in case of MSAA.
  19445. * It defaults to one meaning no MSAA has been enabled.
  19446. */
  19447. samples: number;
  19448. /**
  19449. * Resets the refresh counter of the texture and start bak from scratch.
  19450. * Could be useful to regenerate the texture if it is setup to render only once.
  19451. */
  19452. resetRefreshCounter(): void;
  19453. /**
  19454. * Define the refresh rate of the texture or the rendering frequency.
  19455. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19456. */
  19457. refreshRate: number;
  19458. /**
  19459. * Adds a post process to the render target rendering passes.
  19460. * @param postProcess define the post process to add
  19461. */
  19462. addPostProcess(postProcess: PostProcess): void;
  19463. /**
  19464. * Clear all the post processes attached to the render target
  19465. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19466. */
  19467. clearPostProcesses(dispose?: boolean): void;
  19468. /**
  19469. * Remove one of the post process from the list of attached post processes to the texture
  19470. * @param postProcess define the post process to remove from the list
  19471. */
  19472. removePostProcess(postProcess: PostProcess): void;
  19473. /** @hidden */ private _shouldRender(): boolean;
  19474. /**
  19475. * Gets the actual render size of the texture.
  19476. * @returns the width of the render size
  19477. */
  19478. getRenderSize(): number;
  19479. /**
  19480. * Gets the actual render width of the texture.
  19481. * @returns the width of the render size
  19482. */
  19483. getRenderWidth(): number;
  19484. /**
  19485. * Gets the actual render height of the texture.
  19486. * @returns the height of the render size
  19487. */
  19488. getRenderHeight(): number;
  19489. /**
  19490. * Get if the texture can be rescaled or not.
  19491. */
  19492. readonly canRescale: boolean;
  19493. /**
  19494. * Resize the texture using a ratio.
  19495. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19496. */
  19497. scale(ratio: number): void;
  19498. /**
  19499. * Get the texture reflection matrix used to rotate/transform the reflection.
  19500. * @returns the reflection matrix
  19501. */
  19502. getReflectionTextureMatrix(): Matrix;
  19503. /**
  19504. * Resize the texture to a new desired size.
  19505. * Be carrefull as it will recreate all the data in the new texture.
  19506. * @param size Define the new size. It can be:
  19507. * - a number for squared texture,
  19508. * - an object containing { width: number, height: number }
  19509. * - or an object containing a ratio { ratio: number }
  19510. */
  19511. resize(size: number | {
  19512. width: number;
  19513. height: number;
  19514. } | {
  19515. ratio: number;
  19516. }): void;
  19517. /**
  19518. * Renders all the objects from the render list into the texture.
  19519. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19520. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19521. */
  19522. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19523. private _bestReflectionRenderTargetDimension;
  19524. /**
  19525. * @hidden
  19526. * @param faceIndex face index to bind to if this is a cubetexture
  19527. */ private _bindFrameBuffer(faceIndex?: number): void;
  19528. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19529. private renderToTarget;
  19530. /**
  19531. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19532. * This allowed control for front to back rendering or reversly depending of the special needs.
  19533. *
  19534. * @param renderingGroupId The rendering group id corresponding to its index
  19535. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19536. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19537. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19538. */
  19539. 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;
  19540. /**
  19541. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19542. *
  19543. * @param renderingGroupId The rendering group id corresponding to its index
  19544. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19545. */
  19546. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19547. /**
  19548. * Clones the texture.
  19549. * @returns the cloned texture
  19550. */
  19551. clone(): RenderTargetTexture;
  19552. /**
  19553. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19554. * @returns The JSON representation of the texture
  19555. */
  19556. serialize(): any;
  19557. /**
  19558. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19559. */
  19560. disposeFramebufferObjects(): void;
  19561. /**
  19562. * Dispose the texture and release its associated resources.
  19563. */
  19564. dispose(): void;
  19565. /** @hidden */ private _rebuild(): void;
  19566. /**
  19567. * Clear the info related to rendering groups preventing retention point in material dispose.
  19568. */
  19569. freeRenderingGroups(): void;
  19570. /**
  19571. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19572. * @returns the view count
  19573. */
  19574. getViewCount(): number;
  19575. }
  19576. }
  19577. declare module BABYLON {
  19578. /**
  19579. * Base class for the main features of a material in Babylon.js
  19580. */
  19581. export class Material implements IAnimatable {
  19582. /**
  19583. * Returns the triangle fill mode
  19584. */
  19585. static readonly TriangleFillMode: number;
  19586. /**
  19587. * Returns the wireframe mode
  19588. */
  19589. static readonly WireFrameFillMode: number;
  19590. /**
  19591. * Returns the point fill mode
  19592. */
  19593. static readonly PointFillMode: number;
  19594. /**
  19595. * Returns the point list draw mode
  19596. */
  19597. static readonly PointListDrawMode: number;
  19598. /**
  19599. * Returns the line list draw mode
  19600. */
  19601. static readonly LineListDrawMode: number;
  19602. /**
  19603. * Returns the line loop draw mode
  19604. */
  19605. static readonly LineLoopDrawMode: number;
  19606. /**
  19607. * Returns the line strip draw mode
  19608. */
  19609. static readonly LineStripDrawMode: number;
  19610. /**
  19611. * Returns the triangle strip draw mode
  19612. */
  19613. static readonly TriangleStripDrawMode: number;
  19614. /**
  19615. * Returns the triangle fan draw mode
  19616. */
  19617. static readonly TriangleFanDrawMode: number;
  19618. /**
  19619. * Stores the clock-wise side orientation
  19620. */
  19621. static readonly ClockWiseSideOrientation: number;
  19622. /**
  19623. * Stores the counter clock-wise side orientation
  19624. */
  19625. static readonly CounterClockWiseSideOrientation: number;
  19626. /**
  19627. * The dirty texture flag value
  19628. */
  19629. static readonly TextureDirtyFlag: number;
  19630. /**
  19631. * The dirty light flag value
  19632. */
  19633. static readonly LightDirtyFlag: number;
  19634. /**
  19635. * The dirty fresnel flag value
  19636. */
  19637. static readonly FresnelDirtyFlag: number;
  19638. /**
  19639. * The dirty attribute flag value
  19640. */
  19641. static readonly AttributesDirtyFlag: number;
  19642. /**
  19643. * The dirty misc flag value
  19644. */
  19645. static readonly MiscDirtyFlag: number;
  19646. /**
  19647. * The all dirty flag value
  19648. */
  19649. static readonly AllDirtyFlag: number;
  19650. /**
  19651. * The ID of the material
  19652. */
  19653. id: string;
  19654. /**
  19655. * Gets or sets the unique id of the material
  19656. */
  19657. uniqueId: number;
  19658. /**
  19659. * The name of the material
  19660. */
  19661. name: string;
  19662. /**
  19663. * Gets or sets user defined metadata
  19664. */
  19665. metadata: any;
  19666. /**
  19667. * For internal use only. Please do not use.
  19668. */
  19669. reservedDataStore: any;
  19670. /**
  19671. * Specifies if the ready state should be checked on each call
  19672. */
  19673. checkReadyOnEveryCall: boolean;
  19674. /**
  19675. * Specifies if the ready state should be checked once
  19676. */
  19677. checkReadyOnlyOnce: boolean;
  19678. /**
  19679. * The state of the material
  19680. */
  19681. state: string;
  19682. /**
  19683. * The alpha value of the material
  19684. */
  19685. protected _alpha: number;
  19686. /**
  19687. * List of inspectable custom properties (used by the Inspector)
  19688. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19689. */
  19690. inspectableCustomProperties: IInspectable[];
  19691. /**
  19692. * Sets the alpha value of the material
  19693. */
  19694. /**
  19695. * Gets the alpha value of the material
  19696. */
  19697. alpha: number;
  19698. /**
  19699. * Specifies if back face culling is enabled
  19700. */
  19701. protected _backFaceCulling: boolean;
  19702. /**
  19703. * Sets the back-face culling state
  19704. */
  19705. /**
  19706. * Gets the back-face culling state
  19707. */
  19708. backFaceCulling: boolean;
  19709. /**
  19710. * Stores the value for side orientation
  19711. */
  19712. sideOrientation: number;
  19713. /**
  19714. * Callback triggered when the material is compiled
  19715. */
  19716. onCompiled: Nullable<(effect: Effect) => void>;
  19717. /**
  19718. * Callback triggered when an error occurs
  19719. */
  19720. onError: Nullable<(effect: Effect, errors: string) => void>;
  19721. /**
  19722. * Callback triggered to get the render target textures
  19723. */
  19724. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19725. /**
  19726. * Gets a boolean indicating that current material needs to register RTT
  19727. */
  19728. readonly hasRenderTargetTextures: boolean;
  19729. /**
  19730. * Specifies if the material should be serialized
  19731. */
  19732. doNotSerialize: boolean;
  19733. /**
  19734. * @hidden
  19735. */ private _storeEffectOnSubMeshes: boolean;
  19736. /**
  19737. * Stores the animations for the material
  19738. */
  19739. animations: Nullable<Array<Animation>>;
  19740. /**
  19741. * An event triggered when the material is disposed
  19742. */
  19743. onDisposeObservable: Observable<Material>;
  19744. /**
  19745. * An observer which watches for dispose events
  19746. */
  19747. private _onDisposeObserver;
  19748. private _onUnBindObservable;
  19749. /**
  19750. * Called during a dispose event
  19751. */
  19752. onDispose: () => void;
  19753. private _onBindObservable;
  19754. /**
  19755. * An event triggered when the material is bound
  19756. */
  19757. readonly onBindObservable: Observable<AbstractMesh>;
  19758. /**
  19759. * An observer which watches for bind events
  19760. */
  19761. private _onBindObserver;
  19762. /**
  19763. * Called during a bind event
  19764. */
  19765. onBind: (Mesh: AbstractMesh) => void;
  19766. /**
  19767. * An event triggered when the material is unbound
  19768. */
  19769. readonly onUnBindObservable: Observable<Material>;
  19770. /**
  19771. * Stores the value of the alpha mode
  19772. */
  19773. private _alphaMode;
  19774. /**
  19775. * Sets the value of the alpha mode.
  19776. *
  19777. * | Value | Type | Description |
  19778. * | --- | --- | --- |
  19779. * | 0 | ALPHA_DISABLE | |
  19780. * | 1 | ALPHA_ADD | |
  19781. * | 2 | ALPHA_COMBINE | |
  19782. * | 3 | ALPHA_SUBTRACT | |
  19783. * | 4 | ALPHA_MULTIPLY | |
  19784. * | 5 | ALPHA_MAXIMIZED | |
  19785. * | 6 | ALPHA_ONEONE | |
  19786. * | 7 | ALPHA_PREMULTIPLIED | |
  19787. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19788. * | 9 | ALPHA_INTERPOLATE | |
  19789. * | 10 | ALPHA_SCREENMODE | |
  19790. *
  19791. */
  19792. /**
  19793. * Gets the value of the alpha mode
  19794. */
  19795. alphaMode: number;
  19796. /**
  19797. * Stores the state of the need depth pre-pass value
  19798. */
  19799. private _needDepthPrePass;
  19800. /**
  19801. * Sets the need depth pre-pass value
  19802. */
  19803. /**
  19804. * Gets the depth pre-pass value
  19805. */
  19806. needDepthPrePass: boolean;
  19807. /**
  19808. * Specifies if depth writing should be disabled
  19809. */
  19810. disableDepthWrite: boolean;
  19811. /**
  19812. * Specifies if depth writing should be forced
  19813. */
  19814. forceDepthWrite: boolean;
  19815. /**
  19816. * Specifies if there should be a separate pass for culling
  19817. */
  19818. separateCullingPass: boolean;
  19819. /**
  19820. * Stores the state specifing if fog should be enabled
  19821. */
  19822. private _fogEnabled;
  19823. /**
  19824. * Sets the state for enabling fog
  19825. */
  19826. /**
  19827. * Gets the value of the fog enabled state
  19828. */
  19829. fogEnabled: boolean;
  19830. /**
  19831. * Stores the size of points
  19832. */
  19833. pointSize: number;
  19834. /**
  19835. * Stores the z offset value
  19836. */
  19837. zOffset: number;
  19838. /**
  19839. * Gets a value specifying if wireframe mode is enabled
  19840. */
  19841. /**
  19842. * Sets the state of wireframe mode
  19843. */
  19844. wireframe: boolean;
  19845. /**
  19846. * Gets the value specifying if point clouds are enabled
  19847. */
  19848. /**
  19849. * Sets the state of point cloud mode
  19850. */
  19851. pointsCloud: boolean;
  19852. /**
  19853. * Gets the material fill mode
  19854. */
  19855. /**
  19856. * Sets the material fill mode
  19857. */
  19858. fillMode: number;
  19859. /**
  19860. * @hidden
  19861. * Stores the effects for the material
  19862. */ private _effect: Nullable<Effect>;
  19863. /**
  19864. * @hidden
  19865. * Specifies if the material was previously ready
  19866. */ private _wasPreviouslyReady: boolean;
  19867. /**
  19868. * Specifies if uniform buffers should be used
  19869. */
  19870. private _useUBO;
  19871. /**
  19872. * Stores a reference to the scene
  19873. */
  19874. private _scene;
  19875. /**
  19876. * Stores the fill mode state
  19877. */
  19878. private _fillMode;
  19879. /**
  19880. * Specifies if the depth write state should be cached
  19881. */
  19882. private _cachedDepthWriteState;
  19883. /**
  19884. * Stores the uniform buffer
  19885. */
  19886. protected _uniformBuffer: UniformBuffer;
  19887. /** @hidden */ private _indexInSceneMaterialArray: number;
  19888. /** @hidden */
  19889. meshMap: Nullable<{
  19890. [id: string]: AbstractMesh | undefined;
  19891. }>;
  19892. /**
  19893. * Creates a material instance
  19894. * @param name defines the name of the material
  19895. * @param scene defines the scene to reference
  19896. * @param doNotAdd specifies if the material should be added to the scene
  19897. */
  19898. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  19899. /**
  19900. * Returns a string representation of the current material
  19901. * @param fullDetails defines a boolean indicating which levels of logging is desired
  19902. * @returns a string with material information
  19903. */
  19904. toString(fullDetails?: boolean): string;
  19905. /**
  19906. * Gets the class name of the material
  19907. * @returns a string with the class name of the material
  19908. */
  19909. getClassName(): string;
  19910. /**
  19911. * Specifies if updates for the material been locked
  19912. */
  19913. readonly isFrozen: boolean;
  19914. /**
  19915. * Locks updates for the material
  19916. */
  19917. freeze(): void;
  19918. /**
  19919. * Unlocks updates for the material
  19920. */
  19921. unfreeze(): void;
  19922. /**
  19923. * Specifies if the material is ready to be used
  19924. * @param mesh defines the mesh to check
  19925. * @param useInstances specifies if instances should be used
  19926. * @returns a boolean indicating if the material is ready to be used
  19927. */
  19928. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19929. /**
  19930. * Specifies that the submesh is ready to be used
  19931. * @param mesh defines the mesh to check
  19932. * @param subMesh defines which submesh to check
  19933. * @param useInstances specifies that instances should be used
  19934. * @returns a boolean indicating that the submesh is ready or not
  19935. */
  19936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19937. /**
  19938. * Returns the material effect
  19939. * @returns the effect associated with the material
  19940. */
  19941. getEffect(): Nullable<Effect>;
  19942. /**
  19943. * Returns the current scene
  19944. * @returns a Scene
  19945. */
  19946. getScene(): Scene;
  19947. /**
  19948. * Specifies if the material will require alpha blending
  19949. * @returns a boolean specifying if alpha blending is needed
  19950. */
  19951. needAlphaBlending(): boolean;
  19952. /**
  19953. * Specifies if the mesh will require alpha blending
  19954. * @param mesh defines the mesh to check
  19955. * @returns a boolean specifying if alpha blending is needed for the mesh
  19956. */
  19957. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  19958. /**
  19959. * Specifies if this material should be rendered in alpha test mode
  19960. * @returns a boolean specifying if an alpha test is needed.
  19961. */
  19962. needAlphaTesting(): boolean;
  19963. /**
  19964. * Gets the texture used for the alpha test
  19965. * @returns the texture to use for alpha testing
  19966. */
  19967. getAlphaTestTexture(): Nullable<BaseTexture>;
  19968. /**
  19969. * Marks the material to indicate that it needs to be re-calculated
  19970. */
  19971. markDirty(): void;
  19972. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  19973. /**
  19974. * Binds the material to the mesh
  19975. * @param world defines the world transformation matrix
  19976. * @param mesh defines the mesh to bind the material to
  19977. */
  19978. bind(world: Matrix, mesh?: Mesh): void;
  19979. /**
  19980. * Binds the submesh to the material
  19981. * @param world defines the world transformation matrix
  19982. * @param mesh defines the mesh containing the submesh
  19983. * @param subMesh defines the submesh to bind the material to
  19984. */
  19985. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19986. /**
  19987. * Binds the world matrix to the material
  19988. * @param world defines the world transformation matrix
  19989. */
  19990. bindOnlyWorldMatrix(world: Matrix): void;
  19991. /**
  19992. * Binds the scene's uniform buffer to the effect.
  19993. * @param effect defines the effect to bind to the scene uniform buffer
  19994. * @param sceneUbo defines the uniform buffer storing scene data
  19995. */
  19996. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  19997. /**
  19998. * Binds the view matrix to the effect
  19999. * @param effect defines the effect to bind the view matrix to
  20000. */
  20001. bindView(effect: Effect): void;
  20002. /**
  20003. * Binds the view projection matrix to the effect
  20004. * @param effect defines the effect to bind the view projection matrix to
  20005. */
  20006. bindViewProjection(effect: Effect): void;
  20007. /**
  20008. * Specifies if material alpha testing should be turned on for the mesh
  20009. * @param mesh defines the mesh to check
  20010. */
  20011. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20012. /**
  20013. * Processes to execute after binding the material to a mesh
  20014. * @param mesh defines the rendered mesh
  20015. */
  20016. protected _afterBind(mesh?: Mesh): void;
  20017. /**
  20018. * Unbinds the material from the mesh
  20019. */
  20020. unbind(): void;
  20021. /**
  20022. * Gets the active textures from the material
  20023. * @returns an array of textures
  20024. */
  20025. getActiveTextures(): BaseTexture[];
  20026. /**
  20027. * Specifies if the material uses a texture
  20028. * @param texture defines the texture to check against the material
  20029. * @returns a boolean specifying if the material uses the texture
  20030. */
  20031. hasTexture(texture: BaseTexture): boolean;
  20032. /**
  20033. * Makes a duplicate of the material, and gives it a new name
  20034. * @param name defines the new name for the duplicated material
  20035. * @returns the cloned material
  20036. */
  20037. clone(name: string): Nullable<Material>;
  20038. /**
  20039. * Gets the meshes bound to the material
  20040. * @returns an array of meshes bound to the material
  20041. */
  20042. getBindedMeshes(): AbstractMesh[];
  20043. /**
  20044. * Force shader compilation
  20045. * @param mesh defines the mesh associated with this material
  20046. * @param onCompiled defines a function to execute once the material is compiled
  20047. * @param options defines the options to configure the compilation
  20048. */
  20049. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20050. clipPlane: boolean;
  20051. }>): void;
  20052. /**
  20053. * Force shader compilation
  20054. * @param mesh defines the mesh that will use this material
  20055. * @param options defines additional options for compiling the shaders
  20056. * @returns a promise that resolves when the compilation completes
  20057. */
  20058. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20059. clipPlane: boolean;
  20060. }>): Promise<void>;
  20061. private static readonly _AllDirtyCallBack;
  20062. private static readonly _ImageProcessingDirtyCallBack;
  20063. private static readonly _TextureDirtyCallBack;
  20064. private static readonly _FresnelDirtyCallBack;
  20065. private static readonly _MiscDirtyCallBack;
  20066. private static readonly _LightsDirtyCallBack;
  20067. private static readonly _AttributeDirtyCallBack;
  20068. private static _FresnelAndMiscDirtyCallBack;
  20069. private static _TextureAndMiscDirtyCallBack;
  20070. private static readonly _DirtyCallbackArray;
  20071. private static readonly _RunDirtyCallBacks;
  20072. /**
  20073. * Marks a define in the material to indicate that it needs to be re-computed
  20074. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20075. */
  20076. markAsDirty(flag: number): void;
  20077. /**
  20078. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20079. * @param func defines a function which checks material defines against the submeshes
  20080. */
  20081. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20082. /**
  20083. * Indicates that we need to re-calculated for all submeshes
  20084. */
  20085. protected _markAllSubMeshesAsAllDirty(): void;
  20086. /**
  20087. * Indicates that image processing needs to be re-calculated for all submeshes
  20088. */
  20089. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20090. /**
  20091. * Indicates that textures need to be re-calculated for all submeshes
  20092. */
  20093. protected _markAllSubMeshesAsTexturesDirty(): void;
  20094. /**
  20095. * Indicates that fresnel needs to be re-calculated for all submeshes
  20096. */
  20097. protected _markAllSubMeshesAsFresnelDirty(): void;
  20098. /**
  20099. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20100. */
  20101. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20102. /**
  20103. * Indicates that lights need to be re-calculated for all submeshes
  20104. */
  20105. protected _markAllSubMeshesAsLightsDirty(): void;
  20106. /**
  20107. * Indicates that attributes need to be re-calculated for all submeshes
  20108. */
  20109. protected _markAllSubMeshesAsAttributesDirty(): void;
  20110. /**
  20111. * Indicates that misc needs to be re-calculated for all submeshes
  20112. */
  20113. protected _markAllSubMeshesAsMiscDirty(): void;
  20114. /**
  20115. * Indicates that textures and misc need to be re-calculated for all submeshes
  20116. */
  20117. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20118. /**
  20119. * Disposes the material
  20120. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20121. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20122. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20123. */
  20124. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20125. /** @hidden */
  20126. private releaseVertexArrayObject;
  20127. /**
  20128. * Serializes this material
  20129. * @returns the serialized material object
  20130. */
  20131. serialize(): any;
  20132. /**
  20133. * Creates a material from parsed material data
  20134. * @param parsedMaterial defines parsed material data
  20135. * @param scene defines the hosting scene
  20136. * @param rootUrl defines the root URL to use to load textures
  20137. * @returns a new material
  20138. */
  20139. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20140. }
  20141. }
  20142. declare module BABYLON {
  20143. /**
  20144. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20145. * separate meshes. This can be use to improve performances.
  20146. * @see http://doc.babylonjs.com/how_to/multi_materials
  20147. */
  20148. export class MultiMaterial extends Material {
  20149. private _subMaterials;
  20150. /**
  20151. * Gets or Sets the list of Materials used within the multi material.
  20152. * They need to be ordered according to the submeshes order in the associated mesh
  20153. */
  20154. subMaterials: Nullable<Material>[];
  20155. /**
  20156. * Function used to align with Node.getChildren()
  20157. * @returns the list of Materials used within the multi material
  20158. */
  20159. getChildren(): Nullable<Material>[];
  20160. /**
  20161. * Instantiates a new Multi Material
  20162. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20163. * separate meshes. This can be use to improve performances.
  20164. * @see http://doc.babylonjs.com/how_to/multi_materials
  20165. * @param name Define the name in the scene
  20166. * @param scene Define the scene the material belongs to
  20167. */
  20168. constructor(name: string, scene: Scene);
  20169. private _hookArray;
  20170. /**
  20171. * Get one of the submaterial by its index in the submaterials array
  20172. * @param index The index to look the sub material at
  20173. * @returns The Material if the index has been defined
  20174. */
  20175. getSubMaterial(index: number): Nullable<Material>;
  20176. /**
  20177. * Get the list of active textures for the whole sub materials list.
  20178. * @returns All the textures that will be used during the rendering
  20179. */
  20180. getActiveTextures(): BaseTexture[];
  20181. /**
  20182. * Gets the current class name of the material e.g. "MultiMaterial"
  20183. * Mainly use in serialization.
  20184. * @returns the class name
  20185. */
  20186. getClassName(): string;
  20187. /**
  20188. * Checks if the material is ready to render the requested sub mesh
  20189. * @param mesh Define the mesh the submesh belongs to
  20190. * @param subMesh Define the sub mesh to look readyness for
  20191. * @param useInstances Define whether or not the material is used with instances
  20192. * @returns true if ready, otherwise false
  20193. */
  20194. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20195. /**
  20196. * Clones the current material and its related sub materials
  20197. * @param name Define the name of the newly cloned material
  20198. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20199. * @returns the cloned material
  20200. */
  20201. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20202. /**
  20203. * Serializes the materials into a JSON representation.
  20204. * @returns the JSON representation
  20205. */
  20206. serialize(): any;
  20207. /**
  20208. * Dispose the material and release its associated resources
  20209. * @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)
  20210. * @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)
  20211. * @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)
  20212. */
  20213. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20214. /**
  20215. * Creates a MultiMaterial from parsed MultiMaterial data.
  20216. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20217. * @param scene defines the hosting scene
  20218. * @returns a new MultiMaterial
  20219. */
  20220. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20221. }
  20222. }
  20223. declare module BABYLON {
  20224. /**
  20225. * Base class for submeshes
  20226. */
  20227. export class BaseSubMesh {
  20228. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20229. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20230. /**
  20231. * Gets associated effect
  20232. */
  20233. readonly effect: Nullable<Effect>;
  20234. /**
  20235. * Sets associated effect (effect used to render this submesh)
  20236. * @param effect defines the effect to associate with
  20237. * @param defines defines the set of defines used to compile this effect
  20238. */
  20239. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20240. }
  20241. /**
  20242. * Defines a subdivision inside a mesh
  20243. */
  20244. export class SubMesh extends BaseSubMesh implements ICullable {
  20245. /** the material index to use */
  20246. materialIndex: number;
  20247. /** vertex index start */
  20248. verticesStart: number;
  20249. /** vertices count */
  20250. verticesCount: number;
  20251. /** index start */
  20252. indexStart: number;
  20253. /** indices count */
  20254. indexCount: number;
  20255. /** @hidden */ private _linesIndexCount: number;
  20256. private _mesh;
  20257. private _renderingMesh;
  20258. private _boundingInfo;
  20259. private _linesIndexBuffer;
  20260. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20261. /** @hidden */ private _trianglePlanes: Plane[];
  20262. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20263. /** @hidden */ private _renderId: number;
  20264. /** @hidden */ private _alphaIndex: number;
  20265. /** @hidden */ private _distanceToCamera: number;
  20266. /** @hidden */ private _id: number;
  20267. private _currentMaterial;
  20268. /**
  20269. * Add a new submesh to a mesh
  20270. * @param materialIndex defines the material index to use
  20271. * @param verticesStart defines vertex index start
  20272. * @param verticesCount defines vertices count
  20273. * @param indexStart defines index start
  20274. * @param indexCount defines indices count
  20275. * @param mesh defines the parent mesh
  20276. * @param renderingMesh defines an optional rendering mesh
  20277. * @param createBoundingBox defines if bounding box should be created for this submesh
  20278. * @returns the new submesh
  20279. */
  20280. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20281. /**
  20282. * Creates a new submesh
  20283. * @param materialIndex defines the material index to use
  20284. * @param verticesStart defines vertex index start
  20285. * @param verticesCount defines vertices count
  20286. * @param indexStart defines index start
  20287. * @param indexCount defines indices count
  20288. * @param mesh defines the parent mesh
  20289. * @param renderingMesh defines an optional rendering mesh
  20290. * @param createBoundingBox defines if bounding box should be created for this submesh
  20291. */
  20292. constructor(
  20293. /** the material index to use */
  20294. materialIndex: number,
  20295. /** vertex index start */
  20296. verticesStart: number,
  20297. /** vertices count */
  20298. verticesCount: number,
  20299. /** index start */
  20300. indexStart: number,
  20301. /** indices count */
  20302. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20303. /**
  20304. * Returns true if this submesh covers the entire parent mesh
  20305. * @ignorenaming
  20306. */
  20307. readonly IsGlobal: boolean;
  20308. /**
  20309. * Returns the submesh BoudingInfo object
  20310. * @returns current bounding info (or mesh's one if the submesh is global)
  20311. */
  20312. getBoundingInfo(): BoundingInfo;
  20313. /**
  20314. * Sets the submesh BoundingInfo
  20315. * @param boundingInfo defines the new bounding info to use
  20316. * @returns the SubMesh
  20317. */
  20318. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20319. /**
  20320. * Returns the mesh of the current submesh
  20321. * @return the parent mesh
  20322. */
  20323. getMesh(): AbstractMesh;
  20324. /**
  20325. * Returns the rendering mesh of the submesh
  20326. * @returns the rendering mesh (could be different from parent mesh)
  20327. */
  20328. getRenderingMesh(): Mesh;
  20329. /**
  20330. * Returns the submesh material
  20331. * @returns null or the current material
  20332. */
  20333. getMaterial(): Nullable<Material>;
  20334. /**
  20335. * Sets a new updated BoundingInfo object to the submesh
  20336. * @param data defines an optional position array to use to determine the bounding info
  20337. * @returns the SubMesh
  20338. */
  20339. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20340. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20341. /**
  20342. * Updates the submesh BoundingInfo
  20343. * @param world defines the world matrix to use to update the bounding info
  20344. * @returns the submesh
  20345. */
  20346. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20347. /**
  20348. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20349. * @param frustumPlanes defines the frustum planes
  20350. * @returns true if the submesh is intersecting with the frustum
  20351. */
  20352. isInFrustum(frustumPlanes: Plane[]): boolean;
  20353. /**
  20354. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20355. * @param frustumPlanes defines the frustum planes
  20356. * @returns true if the submesh is inside the frustum
  20357. */
  20358. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20359. /**
  20360. * Renders the submesh
  20361. * @param enableAlphaMode defines if alpha needs to be used
  20362. * @returns the submesh
  20363. */
  20364. render(enableAlphaMode: boolean): SubMesh;
  20365. /**
  20366. * @hidden
  20367. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20368. /**
  20369. * Checks if the submesh intersects with a ray
  20370. * @param ray defines the ray to test
  20371. * @returns true is the passed ray intersects the submesh bounding box
  20372. */
  20373. canIntersects(ray: Ray): boolean;
  20374. /**
  20375. * Intersects current submesh with a ray
  20376. * @param ray defines the ray to test
  20377. * @param positions defines mesh's positions array
  20378. * @param indices defines mesh's indices array
  20379. * @param fastCheck defines if only bounding info should be used
  20380. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20381. * @returns intersection info or null if no intersection
  20382. */
  20383. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20384. /** @hidden */
  20385. private _intersectLines;
  20386. /** @hidden */
  20387. private _intersectUnIndexedLines;
  20388. /** @hidden */
  20389. private _intersectTriangles;
  20390. /** @hidden */
  20391. private _intersectUnIndexedTriangles;
  20392. /** @hidden */ private _rebuild(): void;
  20393. /**
  20394. * Creates a new submesh from the passed mesh
  20395. * @param newMesh defines the new hosting mesh
  20396. * @param newRenderingMesh defines an optional rendering mesh
  20397. * @returns the new submesh
  20398. */
  20399. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20400. /**
  20401. * Release associated resources
  20402. */
  20403. dispose(): void;
  20404. /**
  20405. * Gets the class name
  20406. * @returns the string "SubMesh".
  20407. */
  20408. getClassName(): string;
  20409. /**
  20410. * Creates a new submesh from indices data
  20411. * @param materialIndex the index of the main mesh material
  20412. * @param startIndex the index where to start the copy in the mesh indices array
  20413. * @param indexCount the number of indices to copy then from the startIndex
  20414. * @param mesh the main mesh to create the submesh from
  20415. * @param renderingMesh the optional rendering mesh
  20416. * @returns a new submesh
  20417. */
  20418. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20419. }
  20420. }
  20421. declare module BABYLON {
  20422. /**
  20423. * Class used to represent data loading progression
  20424. */
  20425. export class SceneLoaderFlags {
  20426. private static _ForceFullSceneLoadingForIncremental;
  20427. private static _ShowLoadingScreen;
  20428. private static _CleanBoneMatrixWeights;
  20429. private static _loggingLevel;
  20430. /**
  20431. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20432. */
  20433. static ForceFullSceneLoadingForIncremental: boolean;
  20434. /**
  20435. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20436. */
  20437. static ShowLoadingScreen: boolean;
  20438. /**
  20439. * Defines the current logging level (while loading the scene)
  20440. * @ignorenaming
  20441. */
  20442. static loggingLevel: number;
  20443. /**
  20444. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20445. */
  20446. static CleanBoneMatrixWeights: boolean;
  20447. }
  20448. }
  20449. declare module BABYLON {
  20450. /**
  20451. * Class used to store geometry data (vertex buffers + index buffer)
  20452. */
  20453. export class Geometry implements IGetSetVerticesData {
  20454. /**
  20455. * Gets or sets the ID of the geometry
  20456. */
  20457. id: string;
  20458. /**
  20459. * Gets or sets the unique ID of the geometry
  20460. */
  20461. uniqueId: number;
  20462. /**
  20463. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20464. */
  20465. delayLoadState: number;
  20466. /**
  20467. * Gets the file containing the data to load when running in delay load state
  20468. */
  20469. delayLoadingFile: Nullable<string>;
  20470. /**
  20471. * Callback called when the geometry is updated
  20472. */
  20473. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20474. private _scene;
  20475. private _engine;
  20476. private _meshes;
  20477. private _totalVertices;
  20478. /** @hidden */ private _indices: IndicesArray;
  20479. /** @hidden */ private _vertexBuffers: {
  20480. [key: string]: VertexBuffer;
  20481. };
  20482. private _isDisposed;
  20483. private _extend;
  20484. private _boundingBias;
  20485. /** @hidden */ private _delayInfo: Array<string>;
  20486. private _indexBuffer;
  20487. private _indexBufferIsUpdatable;
  20488. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20489. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20490. /** @hidden */ private _softwareSkinningFrameId: number;
  20491. private _vertexArrayObjects;
  20492. private _updatable;
  20493. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20494. /**
  20495. * 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
  20496. */
  20497. /**
  20498. * 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
  20499. */
  20500. boundingBias: Vector2;
  20501. /**
  20502. * Static function used to attach a new empty geometry to a mesh
  20503. * @param mesh defines the mesh to attach the geometry to
  20504. * @returns the new Geometry
  20505. */
  20506. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20507. /**
  20508. * Creates a new geometry
  20509. * @param id defines the unique ID
  20510. * @param scene defines the hosting scene
  20511. * @param vertexData defines the VertexData used to get geometry data
  20512. * @param updatable defines if geometry must be updatable (false by default)
  20513. * @param mesh defines the mesh that will be associated with the geometry
  20514. */
  20515. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20516. /**
  20517. * Gets the current extend of the geometry
  20518. */
  20519. readonly extend: {
  20520. minimum: Vector3;
  20521. maximum: Vector3;
  20522. };
  20523. /**
  20524. * Gets the hosting scene
  20525. * @returns the hosting Scene
  20526. */
  20527. getScene(): Scene;
  20528. /**
  20529. * Gets the hosting engine
  20530. * @returns the hosting Engine
  20531. */
  20532. getEngine(): Engine;
  20533. /**
  20534. * Defines if the geometry is ready to use
  20535. * @returns true if the geometry is ready to be used
  20536. */
  20537. isReady(): boolean;
  20538. /**
  20539. * Gets a value indicating that the geometry should not be serialized
  20540. */
  20541. readonly doNotSerialize: boolean;
  20542. /** @hidden */ private _rebuild(): void;
  20543. /**
  20544. * Affects all geometry data in one call
  20545. * @param vertexData defines the geometry data
  20546. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20547. */
  20548. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20549. /**
  20550. * Set specific vertex data
  20551. * @param kind defines the data kind (Position, normal, etc...)
  20552. * @param data defines the vertex data to use
  20553. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20554. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20555. */
  20556. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20557. /**
  20558. * Removes a specific vertex data
  20559. * @param kind defines the data kind (Position, normal, etc...)
  20560. */
  20561. removeVerticesData(kind: string): void;
  20562. /**
  20563. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20564. * @param buffer defines the vertex buffer to use
  20565. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20566. */
  20567. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20568. /**
  20569. * Update a specific vertex buffer
  20570. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20571. * It will do nothing if the buffer is not updatable
  20572. * @param kind defines the data kind (Position, normal, etc...)
  20573. * @param data defines the data to use
  20574. * @param offset defines the offset in the target buffer where to store the data
  20575. * @param useBytes set to true if the offset is in bytes
  20576. */
  20577. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20578. /**
  20579. * Update a specific vertex buffer
  20580. * This function will create a new buffer if the current one is not updatable
  20581. * @param kind defines the data kind (Position, normal, etc...)
  20582. * @param data defines the data to use
  20583. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20584. */
  20585. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20586. private _updateBoundingInfo;
  20587. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20588. /**
  20589. * Gets total number of vertices
  20590. * @returns the total number of vertices
  20591. */
  20592. getTotalVertices(): number;
  20593. /**
  20594. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20595. * @param kind defines the data kind (Position, normal, etc...)
  20596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20598. * @returns a float array containing vertex data
  20599. */
  20600. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20601. /**
  20602. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20603. * @param kind defines the data kind (Position, normal, etc...)
  20604. * @returns true if the vertex buffer with the specified kind is updatable
  20605. */
  20606. isVertexBufferUpdatable(kind: string): boolean;
  20607. /**
  20608. * Gets a specific vertex buffer
  20609. * @param kind defines the data kind (Position, normal, etc...)
  20610. * @returns a VertexBuffer
  20611. */
  20612. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20613. /**
  20614. * Returns all vertex buffers
  20615. * @return an object holding all vertex buffers indexed by kind
  20616. */
  20617. getVertexBuffers(): Nullable<{
  20618. [key: string]: VertexBuffer;
  20619. }>;
  20620. /**
  20621. * Gets a boolean indicating if specific vertex buffer is present
  20622. * @param kind defines the data kind (Position, normal, etc...)
  20623. * @returns true if data is present
  20624. */
  20625. isVerticesDataPresent(kind: string): boolean;
  20626. /**
  20627. * Gets a list of all attached data kinds (Position, normal, etc...)
  20628. * @returns a list of string containing all kinds
  20629. */
  20630. getVerticesDataKinds(): string[];
  20631. /**
  20632. * Update index buffer
  20633. * @param indices defines the indices to store in the index buffer
  20634. * @param offset defines the offset in the target buffer where to store the data
  20635. * @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)
  20636. */
  20637. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20638. /**
  20639. * Creates a new index buffer
  20640. * @param indices defines the indices to store in the index buffer
  20641. * @param totalVertices defines the total number of vertices (could be null)
  20642. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20643. */
  20644. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20645. /**
  20646. * Return the total number of indices
  20647. * @returns the total number of indices
  20648. */
  20649. getTotalIndices(): number;
  20650. /**
  20651. * Gets the index buffer array
  20652. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20653. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20654. * @returns the index buffer array
  20655. */
  20656. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20657. /**
  20658. * Gets the index buffer
  20659. * @return the index buffer
  20660. */
  20661. getIndexBuffer(): Nullable<DataBuffer>;
  20662. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20663. /**
  20664. * Release the associated resources for a specific mesh
  20665. * @param mesh defines the source mesh
  20666. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20667. */
  20668. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20669. /**
  20670. * Apply current geometry to a given mesh
  20671. * @param mesh defines the mesh to apply geometry to
  20672. */
  20673. applyToMesh(mesh: Mesh): void;
  20674. private _updateExtend;
  20675. private _applyToMesh;
  20676. private notifyUpdate;
  20677. /**
  20678. * Load the geometry if it was flagged as delay loaded
  20679. * @param scene defines the hosting scene
  20680. * @param onLoaded defines a callback called when the geometry is loaded
  20681. */
  20682. load(scene: Scene, onLoaded?: () => void): void;
  20683. private _queueLoad;
  20684. /**
  20685. * Invert the geometry to move from a right handed system to a left handed one.
  20686. */
  20687. toLeftHanded(): void;
  20688. /** @hidden */ private _resetPointsArrayCache(): void;
  20689. /** @hidden */ private _generatePointsArray(): boolean;
  20690. /**
  20691. * Gets a value indicating if the geometry is disposed
  20692. * @returns true if the geometry was disposed
  20693. */
  20694. isDisposed(): boolean;
  20695. private _disposeVertexArrayObjects;
  20696. /**
  20697. * Free all associated resources
  20698. */
  20699. dispose(): void;
  20700. /**
  20701. * Clone the current geometry into a new geometry
  20702. * @param id defines the unique ID of the new geometry
  20703. * @returns a new geometry object
  20704. */
  20705. copy(id: string): Geometry;
  20706. /**
  20707. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20708. * @return a JSON representation of the current geometry data (without the vertices data)
  20709. */
  20710. serialize(): any;
  20711. private toNumberArray;
  20712. /**
  20713. * Serialize all vertices data into a JSON oject
  20714. * @returns a JSON representation of the current geometry data
  20715. */
  20716. serializeVerticeData(): any;
  20717. /**
  20718. * Extracts a clone of a mesh geometry
  20719. * @param mesh defines the source mesh
  20720. * @param id defines the unique ID of the new geometry object
  20721. * @returns the new geometry object
  20722. */
  20723. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20724. /**
  20725. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20726. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20727. * Be aware Math.random() could cause collisions, but:
  20728. * "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"
  20729. * @returns a string containing a new GUID
  20730. */
  20731. static RandomId(): string;
  20732. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20733. private static _CleanMatricesWeights;
  20734. /**
  20735. * Create a new geometry from persisted data (Using .babylon file format)
  20736. * @param parsedVertexData defines the persisted data
  20737. * @param scene defines the hosting scene
  20738. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20739. * @returns the new geometry object
  20740. */
  20741. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20742. }
  20743. }
  20744. declare module BABYLON {
  20745. /**
  20746. * Define an interface for all classes that will get and set the data on vertices
  20747. */
  20748. export interface IGetSetVerticesData {
  20749. /**
  20750. * Gets a boolean indicating if specific vertex data is present
  20751. * @param kind defines the vertex data kind to use
  20752. * @returns true is data kind is present
  20753. */
  20754. isVerticesDataPresent(kind: string): boolean;
  20755. /**
  20756. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20757. * @param kind defines the data kind (Position, normal, etc...)
  20758. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20760. * @returns a float array containing vertex data
  20761. */
  20762. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20763. /**
  20764. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20765. * @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.
  20766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20767. * @returns the indices array or an empty array if the mesh has no geometry
  20768. */
  20769. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20770. /**
  20771. * Set specific vertex data
  20772. * @param kind defines the data kind (Position, normal, etc...)
  20773. * @param data defines the vertex data to use
  20774. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20775. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20776. */
  20777. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20778. /**
  20779. * Update a specific associated vertex buffer
  20780. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20781. * - VertexBuffer.PositionKind
  20782. * - VertexBuffer.UVKind
  20783. * - VertexBuffer.UV2Kind
  20784. * - VertexBuffer.UV3Kind
  20785. * - VertexBuffer.UV4Kind
  20786. * - VertexBuffer.UV5Kind
  20787. * - VertexBuffer.UV6Kind
  20788. * - VertexBuffer.ColorKind
  20789. * - VertexBuffer.MatricesIndicesKind
  20790. * - VertexBuffer.MatricesIndicesExtraKind
  20791. * - VertexBuffer.MatricesWeightsKind
  20792. * - VertexBuffer.MatricesWeightsExtraKind
  20793. * @param data defines the data source
  20794. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20795. * @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)
  20796. */
  20797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20798. /**
  20799. * Creates a new index buffer
  20800. * @param indices defines the indices to store in the index buffer
  20801. * @param totalVertices defines the total number of vertices (could be null)
  20802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20803. */
  20804. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20805. }
  20806. /**
  20807. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20808. */
  20809. export class VertexData {
  20810. /**
  20811. * Mesh side orientation : usually the external or front surface
  20812. */
  20813. static readonly FRONTSIDE: number;
  20814. /**
  20815. * Mesh side orientation : usually the internal or back surface
  20816. */
  20817. static readonly BACKSIDE: number;
  20818. /**
  20819. * Mesh side orientation : both internal and external or front and back surfaces
  20820. */
  20821. static readonly DOUBLESIDE: number;
  20822. /**
  20823. * Mesh side orientation : by default, `FRONTSIDE`
  20824. */
  20825. static readonly DEFAULTSIDE: number;
  20826. /**
  20827. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20828. */
  20829. positions: Nullable<FloatArray>;
  20830. /**
  20831. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20832. */
  20833. normals: Nullable<FloatArray>;
  20834. /**
  20835. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20836. */
  20837. tangents: Nullable<FloatArray>;
  20838. /**
  20839. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20840. */
  20841. uvs: Nullable<FloatArray>;
  20842. /**
  20843. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20844. */
  20845. uvs2: Nullable<FloatArray>;
  20846. /**
  20847. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20848. */
  20849. uvs3: Nullable<FloatArray>;
  20850. /**
  20851. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20852. */
  20853. uvs4: Nullable<FloatArray>;
  20854. /**
  20855. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20856. */
  20857. uvs5: Nullable<FloatArray>;
  20858. /**
  20859. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20860. */
  20861. uvs6: Nullable<FloatArray>;
  20862. /**
  20863. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20864. */
  20865. colors: Nullable<FloatArray>;
  20866. /**
  20867. * 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).
  20868. */
  20869. matricesIndices: Nullable<FloatArray>;
  20870. /**
  20871. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20872. */
  20873. matricesWeights: Nullable<FloatArray>;
  20874. /**
  20875. * An array extending the number of possible indices
  20876. */
  20877. matricesIndicesExtra: Nullable<FloatArray>;
  20878. /**
  20879. * An array extending the number of possible weights when the number of indices is extended
  20880. */
  20881. matricesWeightsExtra: Nullable<FloatArray>;
  20882. /**
  20883. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20884. */
  20885. indices: Nullable<IndicesArray>;
  20886. /**
  20887. * Uses the passed data array to set the set the values for the specified kind of data
  20888. * @param data a linear array of floating numbers
  20889. * @param kind the type of data that is being set, eg positions, colors etc
  20890. */
  20891. set(data: FloatArray, kind: string): void;
  20892. /**
  20893. * Associates the vertexData to the passed Mesh.
  20894. * Sets it as updatable or not (default `false`)
  20895. * @param mesh the mesh the vertexData is applied to
  20896. * @param updatable when used and having the value true allows new data to update the vertexData
  20897. * @returns the VertexData
  20898. */
  20899. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20900. /**
  20901. * Associates the vertexData to the passed Geometry.
  20902. * Sets it as updatable or not (default `false`)
  20903. * @param geometry the geometry the vertexData is applied to
  20904. * @param updatable when used and having the value true allows new data to update the vertexData
  20905. * @returns VertexData
  20906. */
  20907. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20908. /**
  20909. * Updates the associated mesh
  20910. * @param mesh the mesh to be updated
  20911. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20912. * @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
  20913. * @returns VertexData
  20914. */
  20915. updateMesh(mesh: Mesh): VertexData;
  20916. /**
  20917. * Updates the associated geometry
  20918. * @param geometry the geometry to be updated
  20919. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20920. * @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
  20921. * @returns VertexData.
  20922. */
  20923. updateGeometry(geometry: Geometry): VertexData;
  20924. private _applyTo;
  20925. private _update;
  20926. /**
  20927. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20928. * @param matrix the transforming matrix
  20929. * @returns the VertexData
  20930. */
  20931. transform(matrix: Matrix): VertexData;
  20932. /**
  20933. * Merges the passed VertexData into the current one
  20934. * @param other the VertexData to be merged into the current one
  20935. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  20936. * @returns the modified VertexData
  20937. */
  20938. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  20939. private _mergeElement;
  20940. private _validate;
  20941. /**
  20942. * Serializes the VertexData
  20943. * @returns a serialized object
  20944. */
  20945. serialize(): any;
  20946. /**
  20947. * Extracts the vertexData from a mesh
  20948. * @param mesh the mesh from which to extract the VertexData
  20949. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20950. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20951. * @returns the object VertexData associated to the passed mesh
  20952. */
  20953. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20954. /**
  20955. * Extracts the vertexData from the geometry
  20956. * @param geometry the geometry from which to extract the VertexData
  20957. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20958. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20959. * @returns the object VertexData associated to the passed mesh
  20960. */
  20961. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20962. private static _ExtractFrom;
  20963. /**
  20964. * Creates the VertexData for a Ribbon
  20965. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20966. * * pathArray array of paths, each of which an array of successive Vector3
  20967. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20968. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20969. * * 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
  20970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20971. * * 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)
  20972. * * 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)
  20973. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  20974. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  20975. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  20976. * @returns the VertexData of the ribbon
  20977. */
  20978. static CreateRibbon(options: {
  20979. pathArray: Vector3[][];
  20980. closeArray?: boolean;
  20981. closePath?: boolean;
  20982. offset?: number;
  20983. sideOrientation?: number;
  20984. frontUVs?: Vector4;
  20985. backUVs?: Vector4;
  20986. invertUV?: boolean;
  20987. uvs?: Vector2[];
  20988. colors?: Color4[];
  20989. }): VertexData;
  20990. /**
  20991. * Creates the VertexData for a box
  20992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20993. * * size sets the width, height and depth of the box to the value of size, optional default 1
  20994. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  20995. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  20996. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  20997. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  20998. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  20999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21000. * * 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)
  21001. * * 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)
  21002. * @returns the VertexData of the box
  21003. */
  21004. static CreateBox(options: {
  21005. size?: number;
  21006. width?: number;
  21007. height?: number;
  21008. depth?: number;
  21009. faceUV?: Vector4[];
  21010. faceColors?: Color4[];
  21011. sideOrientation?: number;
  21012. frontUVs?: Vector4;
  21013. backUVs?: Vector4;
  21014. }): VertexData;
  21015. /**
  21016. * Creates the VertexData for a tiled box
  21017. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21018. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21019. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21020. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21022. * @returns the VertexData of the box
  21023. */
  21024. static CreateTiledBox(options: {
  21025. pattern?: number;
  21026. width?: number;
  21027. height?: number;
  21028. depth?: number;
  21029. tileSize?: number;
  21030. tileWidth?: number;
  21031. tileHeight?: number;
  21032. alignHorizontal?: number;
  21033. alignVertical?: number;
  21034. faceUV?: Vector4[];
  21035. faceColors?: Color4[];
  21036. sideOrientation?: number;
  21037. }): VertexData;
  21038. /**
  21039. * Creates the VertexData for a tiled plane
  21040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21041. * * pattern a limited pattern arrangement depending on the number
  21042. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21043. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21044. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21046. * * 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)
  21047. * * 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)
  21048. * @returns the VertexData of the tiled plane
  21049. */
  21050. static CreateTiledPlane(options: {
  21051. pattern?: number;
  21052. tileSize?: number;
  21053. tileWidth?: number;
  21054. tileHeight?: number;
  21055. size?: number;
  21056. width?: number;
  21057. height?: number;
  21058. alignHorizontal?: number;
  21059. alignVertical?: number;
  21060. sideOrientation?: number;
  21061. frontUVs?: Vector4;
  21062. backUVs?: Vector4;
  21063. }): VertexData;
  21064. /**
  21065. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21066. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21067. * * segments sets the number of horizontal strips optional, default 32
  21068. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21069. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21070. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21071. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21072. * * 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
  21073. * * 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
  21074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21075. * * 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)
  21076. * * 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)
  21077. * @returns the VertexData of the ellipsoid
  21078. */
  21079. static CreateSphere(options: {
  21080. segments?: number;
  21081. diameter?: number;
  21082. diameterX?: number;
  21083. diameterY?: number;
  21084. diameterZ?: number;
  21085. arc?: number;
  21086. slice?: number;
  21087. sideOrientation?: number;
  21088. frontUVs?: Vector4;
  21089. backUVs?: Vector4;
  21090. }): VertexData;
  21091. /**
  21092. * Creates the VertexData for a cylinder, cone or prism
  21093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21094. * * height sets the height (y direction) of the cylinder, optional, default 2
  21095. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21096. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21097. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21098. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21099. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21100. * * 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
  21101. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21102. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21103. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21104. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21106. * * 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)
  21107. * * 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)
  21108. * @returns the VertexData of the cylinder, cone or prism
  21109. */
  21110. static CreateCylinder(options: {
  21111. height?: number;
  21112. diameterTop?: number;
  21113. diameterBottom?: number;
  21114. diameter?: number;
  21115. tessellation?: number;
  21116. subdivisions?: number;
  21117. arc?: number;
  21118. faceColors?: Color4[];
  21119. faceUV?: Vector4[];
  21120. hasRings?: boolean;
  21121. enclose?: boolean;
  21122. sideOrientation?: number;
  21123. frontUVs?: Vector4;
  21124. backUVs?: Vector4;
  21125. }): VertexData;
  21126. /**
  21127. * Creates the VertexData for a torus
  21128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21129. * * diameter the diameter of the torus, optional default 1
  21130. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21133. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21134. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21135. * @returns the VertexData of the torus
  21136. */
  21137. static CreateTorus(options: {
  21138. diameter?: number;
  21139. thickness?: number;
  21140. tessellation?: number;
  21141. sideOrientation?: number;
  21142. frontUVs?: Vector4;
  21143. backUVs?: Vector4;
  21144. }): VertexData;
  21145. /**
  21146. * Creates the VertexData of the LineSystem
  21147. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21148. * - lines an array of lines, each line being an array of successive Vector3
  21149. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21150. * @returns the VertexData of the LineSystem
  21151. */
  21152. static CreateLineSystem(options: {
  21153. lines: Vector3[][];
  21154. colors?: Nullable<Color4[][]>;
  21155. }): VertexData;
  21156. /**
  21157. * Create the VertexData for a DashedLines
  21158. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21159. * - points an array successive Vector3
  21160. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21161. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21162. * - dashNb the intended total number of dashes, optional, default 200
  21163. * @returns the VertexData for the DashedLines
  21164. */
  21165. static CreateDashedLines(options: {
  21166. points: Vector3[];
  21167. dashSize?: number;
  21168. gapSize?: number;
  21169. dashNb?: number;
  21170. }): VertexData;
  21171. /**
  21172. * Creates the VertexData for a Ground
  21173. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21174. * - width the width (x direction) of the ground, optional, default 1
  21175. * - height the height (z direction) of the ground, optional, default 1
  21176. * - subdivisions the number of subdivisions per side, optional, default 1
  21177. * @returns the VertexData of the Ground
  21178. */
  21179. static CreateGround(options: {
  21180. width?: number;
  21181. height?: number;
  21182. subdivisions?: number;
  21183. subdivisionsX?: number;
  21184. subdivisionsY?: number;
  21185. }): VertexData;
  21186. /**
  21187. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21188. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21189. * * xmin the ground minimum X coordinate, optional, default -1
  21190. * * zmin the ground minimum Z coordinate, optional, default -1
  21191. * * xmax the ground maximum X coordinate, optional, default 1
  21192. * * zmax the ground maximum Z coordinate, optional, default 1
  21193. * * 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}
  21194. * * 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}
  21195. * @returns the VertexData of the TiledGround
  21196. */
  21197. static CreateTiledGround(options: {
  21198. xmin: number;
  21199. zmin: number;
  21200. xmax: number;
  21201. zmax: number;
  21202. subdivisions?: {
  21203. w: number;
  21204. h: number;
  21205. };
  21206. precision?: {
  21207. w: number;
  21208. h: number;
  21209. };
  21210. }): VertexData;
  21211. /**
  21212. * Creates the VertexData of the Ground designed from a heightmap
  21213. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21214. * * width the width (x direction) of the ground
  21215. * * height the height (z direction) of the ground
  21216. * * subdivisions the number of subdivisions per side
  21217. * * minHeight the minimum altitude on the ground, optional, default 0
  21218. * * maxHeight the maximum altitude on the ground, optional default 1
  21219. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21220. * * buffer the array holding the image color data
  21221. * * bufferWidth the width of image
  21222. * * bufferHeight the height of image
  21223. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21224. * @returns the VertexData of the Ground designed from a heightmap
  21225. */
  21226. static CreateGroundFromHeightMap(options: {
  21227. width: number;
  21228. height: number;
  21229. subdivisions: number;
  21230. minHeight: number;
  21231. maxHeight: number;
  21232. colorFilter: Color3;
  21233. buffer: Uint8Array;
  21234. bufferWidth: number;
  21235. bufferHeight: number;
  21236. alphaFilter: number;
  21237. }): VertexData;
  21238. /**
  21239. * Creates the VertexData for a Plane
  21240. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21241. * * size sets the width and height of the plane to the value of size, optional default 1
  21242. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21243. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21245. * * 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)
  21246. * * 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)
  21247. * @returns the VertexData of the box
  21248. */
  21249. static CreatePlane(options: {
  21250. size?: number;
  21251. width?: number;
  21252. height?: number;
  21253. sideOrientation?: number;
  21254. frontUVs?: Vector4;
  21255. backUVs?: Vector4;
  21256. }): VertexData;
  21257. /**
  21258. * Creates the VertexData of the Disc or regular Polygon
  21259. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21260. * * radius the radius of the disc, optional default 0.5
  21261. * * tessellation the number of polygon sides, optional, default 64
  21262. * * 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
  21263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21264. * * 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)
  21265. * * 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)
  21266. * @returns the VertexData of the box
  21267. */
  21268. static CreateDisc(options: {
  21269. radius?: number;
  21270. tessellation?: number;
  21271. arc?: number;
  21272. sideOrientation?: number;
  21273. frontUVs?: Vector4;
  21274. backUVs?: Vector4;
  21275. }): VertexData;
  21276. /**
  21277. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21278. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21279. * @param polygon a mesh built from polygonTriangulation.build()
  21280. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21281. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21282. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21283. * @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)
  21284. * @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)
  21285. * @returns the VertexData of the Polygon
  21286. */
  21287. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21288. /**
  21289. * Creates the VertexData of the IcoSphere
  21290. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21291. * * radius the radius of the IcoSphere, optional default 1
  21292. * * radiusX allows stretching in the x direction, optional, default radius
  21293. * * radiusY allows stretching in the y direction, optional, default radius
  21294. * * radiusZ allows stretching in the z direction, optional, default radius
  21295. * * flat when true creates a flat shaded mesh, optional, default true
  21296. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21298. * * 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)
  21299. * * 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)
  21300. * @returns the VertexData of the IcoSphere
  21301. */
  21302. static CreateIcoSphere(options: {
  21303. radius?: number;
  21304. radiusX?: number;
  21305. radiusY?: number;
  21306. radiusZ?: number;
  21307. flat?: boolean;
  21308. subdivisions?: number;
  21309. sideOrientation?: number;
  21310. frontUVs?: Vector4;
  21311. backUVs?: Vector4;
  21312. }): VertexData;
  21313. /**
  21314. * Creates the VertexData for a Polyhedron
  21315. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21316. * * type provided types are:
  21317. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21318. * * 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)
  21319. * * size the size of the IcoSphere, optional default 1
  21320. * * sizeX allows stretching in the x direction, optional, default size
  21321. * * sizeY allows stretching in the y direction, optional, default size
  21322. * * sizeZ allows stretching in the z direction, optional, default size
  21323. * * 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
  21324. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21325. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21326. * * flat when true creates a flat shaded mesh, optional, default true
  21327. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21329. * * 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)
  21330. * * 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)
  21331. * @returns the VertexData of the Polyhedron
  21332. */
  21333. static CreatePolyhedron(options: {
  21334. type?: number;
  21335. size?: number;
  21336. sizeX?: number;
  21337. sizeY?: number;
  21338. sizeZ?: number;
  21339. custom?: any;
  21340. faceUV?: Vector4[];
  21341. faceColors?: Color4[];
  21342. flat?: boolean;
  21343. sideOrientation?: number;
  21344. frontUVs?: Vector4;
  21345. backUVs?: Vector4;
  21346. }): VertexData;
  21347. /**
  21348. * Creates the VertexData for a TorusKnot
  21349. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21350. * * radius the radius of the torus knot, optional, default 2
  21351. * * tube the thickness of the tube, optional, default 0.5
  21352. * * radialSegments the number of sides on each tube segments, optional, default 32
  21353. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21354. * * p the number of windings around the z axis, optional, default 2
  21355. * * q the number of windings around the x axis, optional, default 3
  21356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21357. * * 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)
  21358. * * 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)
  21359. * @returns the VertexData of the Torus Knot
  21360. */
  21361. static CreateTorusKnot(options: {
  21362. radius?: number;
  21363. tube?: number;
  21364. radialSegments?: number;
  21365. tubularSegments?: number;
  21366. p?: number;
  21367. q?: number;
  21368. sideOrientation?: number;
  21369. frontUVs?: Vector4;
  21370. backUVs?: Vector4;
  21371. }): VertexData;
  21372. /**
  21373. * Compute normals for given positions and indices
  21374. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21375. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21376. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21377. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21378. * * facetNormals : optional array of facet normals (vector3)
  21379. * * facetPositions : optional array of facet positions (vector3)
  21380. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21381. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21382. * * bInfo : optional bounding info, required for facetPartitioning computation
  21383. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21384. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21385. * * useRightHandedSystem: optional boolean to for right handed system computation
  21386. * * depthSort : optional boolean to enable the facet depth sort computation
  21387. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21388. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21389. */
  21390. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21391. facetNormals?: any;
  21392. facetPositions?: any;
  21393. facetPartitioning?: any;
  21394. ratio?: number;
  21395. bInfo?: any;
  21396. bbSize?: Vector3;
  21397. subDiv?: any;
  21398. useRightHandedSystem?: boolean;
  21399. depthSort?: boolean;
  21400. distanceTo?: Vector3;
  21401. depthSortedFacets?: any;
  21402. }): void;
  21403. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21404. /**
  21405. * Applies VertexData created from the imported parameters to the geometry
  21406. * @param parsedVertexData the parsed data from an imported file
  21407. * @param geometry the geometry to apply the VertexData to
  21408. */
  21409. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21410. }
  21411. }
  21412. declare module BABYLON {
  21413. /**
  21414. * Defines a target to use with MorphTargetManager
  21415. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21416. */
  21417. export class MorphTarget implements IAnimatable {
  21418. /** defines the name of the target */
  21419. name: string;
  21420. /**
  21421. * Gets or sets the list of animations
  21422. */
  21423. animations: Animation[];
  21424. private _scene;
  21425. private _positions;
  21426. private _normals;
  21427. private _tangents;
  21428. private _uvs;
  21429. private _influence;
  21430. /**
  21431. * Observable raised when the influence changes
  21432. */
  21433. onInfluenceChanged: Observable<boolean>;
  21434. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21435. /**
  21436. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21437. */
  21438. influence: number;
  21439. /**
  21440. * Gets or sets the id of the morph Target
  21441. */
  21442. id: string;
  21443. private _animationPropertiesOverride;
  21444. /**
  21445. * Gets or sets the animation properties override
  21446. */
  21447. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21448. /**
  21449. * Creates a new MorphTarget
  21450. * @param name defines the name of the target
  21451. * @param influence defines the influence to use
  21452. * @param scene defines the scene the morphtarget belongs to
  21453. */
  21454. constructor(
  21455. /** defines the name of the target */
  21456. name: string, influence?: number, scene?: Nullable<Scene>);
  21457. /**
  21458. * Gets a boolean defining if the target contains position data
  21459. */
  21460. readonly hasPositions: boolean;
  21461. /**
  21462. * Gets a boolean defining if the target contains normal data
  21463. */
  21464. readonly hasNormals: boolean;
  21465. /**
  21466. * Gets a boolean defining if the target contains tangent data
  21467. */
  21468. readonly hasTangents: boolean;
  21469. /**
  21470. * Gets a boolean defining if the target contains texture coordinates data
  21471. */
  21472. readonly hasUVs: boolean;
  21473. /**
  21474. * Affects position data to this target
  21475. * @param data defines the position data to use
  21476. */
  21477. setPositions(data: Nullable<FloatArray>): void;
  21478. /**
  21479. * Gets the position data stored in this target
  21480. * @returns a FloatArray containing the position data (or null if not present)
  21481. */
  21482. getPositions(): Nullable<FloatArray>;
  21483. /**
  21484. * Affects normal data to this target
  21485. * @param data defines the normal data to use
  21486. */
  21487. setNormals(data: Nullable<FloatArray>): void;
  21488. /**
  21489. * Gets the normal data stored in this target
  21490. * @returns a FloatArray containing the normal data (or null if not present)
  21491. */
  21492. getNormals(): Nullable<FloatArray>;
  21493. /**
  21494. * Affects tangent data to this target
  21495. * @param data defines the tangent data to use
  21496. */
  21497. setTangents(data: Nullable<FloatArray>): void;
  21498. /**
  21499. * Gets the tangent data stored in this target
  21500. * @returns a FloatArray containing the tangent data (or null if not present)
  21501. */
  21502. getTangents(): Nullable<FloatArray>;
  21503. /**
  21504. * Affects texture coordinates data to this target
  21505. * @param data defines the texture coordinates data to use
  21506. */
  21507. setUVs(data: Nullable<FloatArray>): void;
  21508. /**
  21509. * Gets the texture coordinates data stored in this target
  21510. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21511. */
  21512. getUVs(): Nullable<FloatArray>;
  21513. /**
  21514. * Serializes the current target into a Serialization object
  21515. * @returns the serialized object
  21516. */
  21517. serialize(): any;
  21518. /**
  21519. * Returns the string "MorphTarget"
  21520. * @returns "MorphTarget"
  21521. */
  21522. getClassName(): string;
  21523. /**
  21524. * Creates a new target from serialized data
  21525. * @param serializationObject defines the serialized data to use
  21526. * @returns a new MorphTarget
  21527. */
  21528. static Parse(serializationObject: any): MorphTarget;
  21529. /**
  21530. * Creates a MorphTarget from mesh data
  21531. * @param mesh defines the source mesh
  21532. * @param name defines the name to use for the new target
  21533. * @param influence defines the influence to attach to the target
  21534. * @returns a new MorphTarget
  21535. */
  21536. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21537. }
  21538. }
  21539. declare module BABYLON {
  21540. /**
  21541. * This class is used to deform meshes using morphing between different targets
  21542. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21543. */
  21544. export class MorphTargetManager {
  21545. private _targets;
  21546. private _targetInfluenceChangedObservers;
  21547. private _targetDataLayoutChangedObservers;
  21548. private _activeTargets;
  21549. private _scene;
  21550. private _influences;
  21551. private _supportsNormals;
  21552. private _supportsTangents;
  21553. private _supportsUVs;
  21554. private _vertexCount;
  21555. private _uniqueId;
  21556. private _tempInfluences;
  21557. /**
  21558. * Gets or sets a boolean indicating if normals must be morphed
  21559. */
  21560. enableNormalMorphing: boolean;
  21561. /**
  21562. * Gets or sets a boolean indicating if tangents must be morphed
  21563. */
  21564. enableTangentMorphing: boolean;
  21565. /**
  21566. * Gets or sets a boolean indicating if UV must be morphed
  21567. */
  21568. enableUVMorphing: boolean;
  21569. /**
  21570. * Creates a new MorphTargetManager
  21571. * @param scene defines the current scene
  21572. */
  21573. constructor(scene?: Nullable<Scene>);
  21574. /**
  21575. * Gets the unique ID of this manager
  21576. */
  21577. readonly uniqueId: number;
  21578. /**
  21579. * Gets the number of vertices handled by this manager
  21580. */
  21581. readonly vertexCount: number;
  21582. /**
  21583. * Gets a boolean indicating if this manager supports morphing of normals
  21584. */
  21585. readonly supportsNormals: boolean;
  21586. /**
  21587. * Gets a boolean indicating if this manager supports morphing of tangents
  21588. */
  21589. readonly supportsTangents: boolean;
  21590. /**
  21591. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21592. */
  21593. readonly supportsUVs: boolean;
  21594. /**
  21595. * Gets the number of targets stored in this manager
  21596. */
  21597. readonly numTargets: number;
  21598. /**
  21599. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21600. */
  21601. readonly numInfluencers: number;
  21602. /**
  21603. * Gets the list of influences (one per target)
  21604. */
  21605. readonly influences: Float32Array;
  21606. /**
  21607. * Gets the active target at specified index. An active target is a target with an influence > 0
  21608. * @param index defines the index to check
  21609. * @returns the requested target
  21610. */
  21611. getActiveTarget(index: number): MorphTarget;
  21612. /**
  21613. * Gets the target at specified index
  21614. * @param index defines the index to check
  21615. * @returns the requested target
  21616. */
  21617. getTarget(index: number): MorphTarget;
  21618. /**
  21619. * Add a new target to this manager
  21620. * @param target defines the target to add
  21621. */
  21622. addTarget(target: MorphTarget): void;
  21623. /**
  21624. * Removes a target from the manager
  21625. * @param target defines the target to remove
  21626. */
  21627. removeTarget(target: MorphTarget): void;
  21628. /**
  21629. * Serializes the current manager into a Serialization object
  21630. * @returns the serialized object
  21631. */
  21632. serialize(): any;
  21633. private _syncActiveTargets;
  21634. /**
  21635. * Syncrhonize the targets with all the meshes using this morph target manager
  21636. */
  21637. synchronize(): void;
  21638. /**
  21639. * Creates a new MorphTargetManager from serialized data
  21640. * @param serializationObject defines the serialized data
  21641. * @param scene defines the hosting scene
  21642. * @returns the new MorphTargetManager
  21643. */
  21644. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21645. }
  21646. }
  21647. declare module BABYLON {
  21648. /**
  21649. * Class used to represent a specific level of detail of a mesh
  21650. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21651. */
  21652. export class MeshLODLevel {
  21653. /** Defines the distance where this level should star being displayed */
  21654. distance: number;
  21655. /** Defines the mesh to use to render this level */
  21656. mesh: Nullable<Mesh>;
  21657. /**
  21658. * Creates a new LOD level
  21659. * @param distance defines the distance where this level should star being displayed
  21660. * @param mesh defines the mesh to use to render this level
  21661. */
  21662. constructor(
  21663. /** Defines the distance where this level should star being displayed */
  21664. distance: number,
  21665. /** Defines the mesh to use to render this level */
  21666. mesh: Nullable<Mesh>);
  21667. }
  21668. }
  21669. declare module BABYLON {
  21670. /**
  21671. * Mesh representing the gorund
  21672. */
  21673. export class GroundMesh extends Mesh {
  21674. /** If octree should be generated */
  21675. generateOctree: boolean;
  21676. private _heightQuads;
  21677. /** @hidden */ private _subdivisionsX: number;
  21678. /** @hidden */ private _subdivisionsY: number;
  21679. /** @hidden */ private _width: number;
  21680. /** @hidden */ private _height: number;
  21681. /** @hidden */ private _minX: number;
  21682. /** @hidden */ private _maxX: number;
  21683. /** @hidden */ private _minZ: number;
  21684. /** @hidden */ private _maxZ: number;
  21685. constructor(name: string, scene: Scene);
  21686. /**
  21687. * "GroundMesh"
  21688. * @returns "GroundMesh"
  21689. */
  21690. getClassName(): string;
  21691. /**
  21692. * The minimum of x and y subdivisions
  21693. */
  21694. readonly subdivisions: number;
  21695. /**
  21696. * X subdivisions
  21697. */
  21698. readonly subdivisionsX: number;
  21699. /**
  21700. * Y subdivisions
  21701. */
  21702. readonly subdivisionsY: number;
  21703. /**
  21704. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21705. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21706. * @param chunksCount the number of subdivisions for x and y
  21707. * @param octreeBlocksSize (Default: 32)
  21708. */
  21709. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21710. /**
  21711. * Returns a height (y) value in the Worl system :
  21712. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21713. * @param x x coordinate
  21714. * @param z z coordinate
  21715. * @returns the ground y position if (x, z) are outside the ground surface.
  21716. */
  21717. getHeightAtCoordinates(x: number, z: number): number;
  21718. /**
  21719. * Returns a normalized vector (Vector3) orthogonal to the ground
  21720. * at the ground coordinates (x, z) expressed in the World system.
  21721. * @param x x coordinate
  21722. * @param z z coordinate
  21723. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21724. */
  21725. getNormalAtCoordinates(x: number, z: number): Vector3;
  21726. /**
  21727. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21728. * at the ground coordinates (x, z) expressed in the World system.
  21729. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21730. * @param x x coordinate
  21731. * @param z z coordinate
  21732. * @param ref vector to store the result
  21733. * @returns the GroundMesh.
  21734. */
  21735. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21736. /**
  21737. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21738. * if the ground has been updated.
  21739. * This can be used in the render loop.
  21740. * @returns the GroundMesh.
  21741. */
  21742. updateCoordinateHeights(): GroundMesh;
  21743. private _getFacetAt;
  21744. private _initHeightQuads;
  21745. private _computeHeightQuads;
  21746. /**
  21747. * Serializes this ground mesh
  21748. * @param serializationObject object to write serialization to
  21749. */
  21750. serialize(serializationObject: any): void;
  21751. /**
  21752. * Parses a serialized ground mesh
  21753. * @param parsedMesh the serialized mesh
  21754. * @param scene the scene to create the ground mesh in
  21755. * @returns the created ground mesh
  21756. */
  21757. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21758. }
  21759. }
  21760. declare module BABYLON {
  21761. /**
  21762. * Interface for Physics-Joint data
  21763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21764. */
  21765. export interface PhysicsJointData {
  21766. /**
  21767. * The main pivot of the joint
  21768. */
  21769. mainPivot?: Vector3;
  21770. /**
  21771. * The connected pivot of the joint
  21772. */
  21773. connectedPivot?: Vector3;
  21774. /**
  21775. * The main axis of the joint
  21776. */
  21777. mainAxis?: Vector3;
  21778. /**
  21779. * The connected axis of the joint
  21780. */
  21781. connectedAxis?: Vector3;
  21782. /**
  21783. * The collision of the joint
  21784. */
  21785. collision?: boolean;
  21786. /**
  21787. * Native Oimo/Cannon/Energy data
  21788. */
  21789. nativeParams?: any;
  21790. }
  21791. /**
  21792. * This is a holder class for the physics joint created by the physics plugin
  21793. * It holds a set of functions to control the underlying joint
  21794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21795. */
  21796. export class PhysicsJoint {
  21797. /**
  21798. * The type of the physics joint
  21799. */
  21800. type: number;
  21801. /**
  21802. * The data for the physics joint
  21803. */
  21804. jointData: PhysicsJointData;
  21805. private _physicsJoint;
  21806. protected _physicsPlugin: IPhysicsEnginePlugin;
  21807. /**
  21808. * Initializes the physics joint
  21809. * @param type The type of the physics joint
  21810. * @param jointData The data for the physics joint
  21811. */
  21812. constructor(
  21813. /**
  21814. * The type of the physics joint
  21815. */
  21816. type: number,
  21817. /**
  21818. * The data for the physics joint
  21819. */
  21820. jointData: PhysicsJointData);
  21821. /**
  21822. * Gets the physics joint
  21823. */
  21824. /**
  21825. * Sets the physics joint
  21826. */
  21827. physicsJoint: any;
  21828. /**
  21829. * Sets the physics plugin
  21830. */
  21831. physicsPlugin: IPhysicsEnginePlugin;
  21832. /**
  21833. * Execute a function that is physics-plugin specific.
  21834. * @param {Function} func the function that will be executed.
  21835. * It accepts two parameters: the physics world and the physics joint
  21836. */
  21837. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  21838. /**
  21839. * Distance-Joint type
  21840. */
  21841. static DistanceJoint: number;
  21842. /**
  21843. * Hinge-Joint type
  21844. */
  21845. static HingeJoint: number;
  21846. /**
  21847. * Ball-and-Socket joint type
  21848. */
  21849. static BallAndSocketJoint: number;
  21850. /**
  21851. * Wheel-Joint type
  21852. */
  21853. static WheelJoint: number;
  21854. /**
  21855. * Slider-Joint type
  21856. */
  21857. static SliderJoint: number;
  21858. /**
  21859. * Prismatic-Joint type
  21860. */
  21861. static PrismaticJoint: number;
  21862. /**
  21863. * Universal-Joint type
  21864. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  21865. */
  21866. static UniversalJoint: number;
  21867. /**
  21868. * Hinge-Joint 2 type
  21869. */
  21870. static Hinge2Joint: number;
  21871. /**
  21872. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  21873. */
  21874. static PointToPointJoint: number;
  21875. /**
  21876. * Spring-Joint type
  21877. */
  21878. static SpringJoint: number;
  21879. /**
  21880. * Lock-Joint type
  21881. */
  21882. static LockJoint: number;
  21883. }
  21884. /**
  21885. * A class representing a physics distance joint
  21886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21887. */
  21888. export class DistanceJoint extends PhysicsJoint {
  21889. /**
  21890. *
  21891. * @param jointData The data for the Distance-Joint
  21892. */
  21893. constructor(jointData: DistanceJointData);
  21894. /**
  21895. * Update the predefined distance.
  21896. * @param maxDistance The maximum preferred distance
  21897. * @param minDistance The minimum preferred distance
  21898. */
  21899. updateDistance(maxDistance: number, minDistance?: number): void;
  21900. }
  21901. /**
  21902. * Represents a Motor-Enabled Joint
  21903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21904. */
  21905. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  21906. /**
  21907. * Initializes the Motor-Enabled Joint
  21908. * @param type The type of the joint
  21909. * @param jointData The physica joint data for the joint
  21910. */
  21911. constructor(type: number, jointData: PhysicsJointData);
  21912. /**
  21913. * Set the motor values.
  21914. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21915. * @param force the force to apply
  21916. * @param maxForce max force for this motor.
  21917. */
  21918. setMotor(force?: number, maxForce?: number): void;
  21919. /**
  21920. * Set the motor's limits.
  21921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21922. * @param upperLimit The upper limit of the motor
  21923. * @param lowerLimit The lower limit of the motor
  21924. */
  21925. setLimit(upperLimit: number, lowerLimit?: number): void;
  21926. }
  21927. /**
  21928. * This class represents a single physics Hinge-Joint
  21929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21930. */
  21931. export class HingeJoint extends MotorEnabledJoint {
  21932. /**
  21933. * Initializes the Hinge-Joint
  21934. * @param jointData The joint data for the Hinge-Joint
  21935. */
  21936. constructor(jointData: PhysicsJointData);
  21937. /**
  21938. * Set the motor values.
  21939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21940. * @param {number} force the force to apply
  21941. * @param {number} maxForce max force for this motor.
  21942. */
  21943. setMotor(force?: number, maxForce?: number): void;
  21944. /**
  21945. * Set the motor's limits.
  21946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21947. * @param upperLimit The upper limit of the motor
  21948. * @param lowerLimit The lower limit of the motor
  21949. */
  21950. setLimit(upperLimit: number, lowerLimit?: number): void;
  21951. }
  21952. /**
  21953. * This class represents a dual hinge physics joint (same as wheel joint)
  21954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21955. */
  21956. export class Hinge2Joint extends MotorEnabledJoint {
  21957. /**
  21958. * Initializes the Hinge2-Joint
  21959. * @param jointData The joint data for the Hinge2-Joint
  21960. */
  21961. constructor(jointData: PhysicsJointData);
  21962. /**
  21963. * Set the motor values.
  21964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21965. * @param {number} targetSpeed the speed the motor is to reach
  21966. * @param {number} maxForce max force for this motor.
  21967. * @param {motorIndex} the motor's index, 0 or 1.
  21968. */
  21969. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  21970. /**
  21971. * Set the motor limits.
  21972. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21973. * @param {number} upperLimit the upper limit
  21974. * @param {number} lowerLimit lower limit
  21975. * @param {motorIndex} the motor's index, 0 or 1.
  21976. */
  21977. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  21978. }
  21979. /**
  21980. * Interface for a motor enabled joint
  21981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21982. */
  21983. export interface IMotorEnabledJoint {
  21984. /**
  21985. * Physics joint
  21986. */
  21987. physicsJoint: any;
  21988. /**
  21989. * Sets the motor of the motor-enabled joint
  21990. * @param force The force of the motor
  21991. * @param maxForce The maximum force of the motor
  21992. * @param motorIndex The index of the motor
  21993. */
  21994. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  21995. /**
  21996. * Sets the limit of the motor
  21997. * @param upperLimit The upper limit of the motor
  21998. * @param lowerLimit The lower limit of the motor
  21999. * @param motorIndex The index of the motor
  22000. */
  22001. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22002. }
  22003. /**
  22004. * Joint data for a Distance-Joint
  22005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22006. */
  22007. export interface DistanceJointData extends PhysicsJointData {
  22008. /**
  22009. * Max distance the 2 joint objects can be apart
  22010. */
  22011. maxDistance: number;
  22012. }
  22013. /**
  22014. * Joint data from a spring joint
  22015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22016. */
  22017. export interface SpringJointData extends PhysicsJointData {
  22018. /**
  22019. * Length of the spring
  22020. */
  22021. length: number;
  22022. /**
  22023. * Stiffness of the spring
  22024. */
  22025. stiffness: number;
  22026. /**
  22027. * Damping of the spring
  22028. */
  22029. damping: number;
  22030. /** this callback will be called when applying the force to the impostors. */
  22031. forceApplicationCallback: () => void;
  22032. }
  22033. }
  22034. declare module BABYLON {
  22035. /**
  22036. * Holds the data for the raycast result
  22037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22038. */
  22039. export class PhysicsRaycastResult {
  22040. private _hasHit;
  22041. private _hitDistance;
  22042. private _hitNormalWorld;
  22043. private _hitPointWorld;
  22044. private _rayFromWorld;
  22045. private _rayToWorld;
  22046. /**
  22047. * Gets if there was a hit
  22048. */
  22049. readonly hasHit: boolean;
  22050. /**
  22051. * Gets the distance from the hit
  22052. */
  22053. readonly hitDistance: number;
  22054. /**
  22055. * Gets the hit normal/direction in the world
  22056. */
  22057. readonly hitNormalWorld: Vector3;
  22058. /**
  22059. * Gets the hit point in the world
  22060. */
  22061. readonly hitPointWorld: Vector3;
  22062. /**
  22063. * Gets the ray "start point" of the ray in the world
  22064. */
  22065. readonly rayFromWorld: Vector3;
  22066. /**
  22067. * Gets the ray "end point" of the ray in the world
  22068. */
  22069. readonly rayToWorld: Vector3;
  22070. /**
  22071. * Sets the hit data (normal & point in world space)
  22072. * @param hitNormalWorld defines the normal in world space
  22073. * @param hitPointWorld defines the point in world space
  22074. */
  22075. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22076. /**
  22077. * Sets the distance from the start point to the hit point
  22078. * @param distance
  22079. */
  22080. setHitDistance(distance: number): void;
  22081. /**
  22082. * Calculates the distance manually
  22083. */
  22084. calculateHitDistance(): void;
  22085. /**
  22086. * Resets all the values to default
  22087. * @param from The from point on world space
  22088. * @param to The to point on world space
  22089. */
  22090. reset(from?: Vector3, to?: Vector3): void;
  22091. }
  22092. /**
  22093. * Interface for the size containing width and height
  22094. */
  22095. interface IXYZ {
  22096. /**
  22097. * X
  22098. */
  22099. x: number;
  22100. /**
  22101. * Y
  22102. */
  22103. y: number;
  22104. /**
  22105. * Z
  22106. */
  22107. z: number;
  22108. }
  22109. }
  22110. declare module BABYLON {
  22111. /**
  22112. * Interface used to describe a physics joint
  22113. */
  22114. export interface PhysicsImpostorJoint {
  22115. /** Defines the main impostor to which the joint is linked */
  22116. mainImpostor: PhysicsImpostor;
  22117. /** Defines the impostor that is connected to the main impostor using this joint */
  22118. connectedImpostor: PhysicsImpostor;
  22119. /** Defines the joint itself */
  22120. joint: PhysicsJoint;
  22121. }
  22122. /** @hidden */
  22123. export interface IPhysicsEnginePlugin {
  22124. world: any;
  22125. name: string;
  22126. setGravity(gravity: Vector3): void;
  22127. setTimeStep(timeStep: number): void;
  22128. getTimeStep(): number;
  22129. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22130. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22131. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22132. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22133. removePhysicsBody(impostor: PhysicsImpostor): void;
  22134. generateJoint(joint: PhysicsImpostorJoint): void;
  22135. removeJoint(joint: PhysicsImpostorJoint): void;
  22136. isSupported(): boolean;
  22137. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22138. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22139. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22140. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22141. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22142. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22143. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22144. getBodyMass(impostor: PhysicsImpostor): number;
  22145. getBodyFriction(impostor: PhysicsImpostor): number;
  22146. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22147. getBodyRestitution(impostor: PhysicsImpostor): number;
  22148. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22149. getBodyPressure?(impostor: PhysicsImpostor): number;
  22150. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22151. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22152. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22153. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22154. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22155. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22156. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22157. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22158. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22159. sleepBody(impostor: PhysicsImpostor): void;
  22160. wakeUpBody(impostor: PhysicsImpostor): void;
  22161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22162. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22163. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22164. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22165. getRadius(impostor: PhysicsImpostor): number;
  22166. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22167. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22168. dispose(): void;
  22169. }
  22170. /**
  22171. * Interface used to define a physics engine
  22172. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22173. */
  22174. export interface IPhysicsEngine {
  22175. /**
  22176. * Gets the gravity vector used by the simulation
  22177. */
  22178. gravity: Vector3;
  22179. /**
  22180. * Sets the gravity vector used by the simulation
  22181. * @param gravity defines the gravity vector to use
  22182. */
  22183. setGravity(gravity: Vector3): void;
  22184. /**
  22185. * Set the time step of the physics engine.
  22186. * Default is 1/60.
  22187. * To slow it down, enter 1/600 for example.
  22188. * To speed it up, 1/30
  22189. * @param newTimeStep the new timestep to apply to this world.
  22190. */
  22191. setTimeStep(newTimeStep: number): void;
  22192. /**
  22193. * Get the time step of the physics engine.
  22194. * @returns the current time step
  22195. */
  22196. getTimeStep(): number;
  22197. /**
  22198. * Release all resources
  22199. */
  22200. dispose(): void;
  22201. /**
  22202. * Gets the name of the current physics plugin
  22203. * @returns the name of the plugin
  22204. */
  22205. getPhysicsPluginName(): string;
  22206. /**
  22207. * Adding a new impostor for the impostor tracking.
  22208. * This will be done by the impostor itself.
  22209. * @param impostor the impostor to add
  22210. */
  22211. addImpostor(impostor: PhysicsImpostor): void;
  22212. /**
  22213. * Remove an impostor from the engine.
  22214. * This impostor and its mesh will not longer be updated by the physics engine.
  22215. * @param impostor the impostor to remove
  22216. */
  22217. removeImpostor(impostor: PhysicsImpostor): void;
  22218. /**
  22219. * Add a joint to the physics engine
  22220. * @param mainImpostor defines the main impostor to which the joint is added.
  22221. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22222. * @param joint defines the joint that will connect both impostors.
  22223. */
  22224. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22225. /**
  22226. * Removes a joint from the simulation
  22227. * @param mainImpostor defines the impostor used with the joint
  22228. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22229. * @param joint defines the joint to remove
  22230. */
  22231. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22232. /**
  22233. * Gets the current plugin used to run the simulation
  22234. * @returns current plugin
  22235. */
  22236. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22237. /**
  22238. * Gets the list of physic impostors
  22239. * @returns an array of PhysicsImpostor
  22240. */
  22241. getImpostors(): Array<PhysicsImpostor>;
  22242. /**
  22243. * Gets the impostor for a physics enabled object
  22244. * @param object defines the object impersonated by the impostor
  22245. * @returns the PhysicsImpostor or null if not found
  22246. */
  22247. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22248. /**
  22249. * Gets the impostor for a physics body object
  22250. * @param body defines physics body used by the impostor
  22251. * @returns the PhysicsImpostor or null if not found
  22252. */
  22253. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22254. /**
  22255. * Does a raycast in the physics world
  22256. * @param from when should the ray start?
  22257. * @param to when should the ray end?
  22258. * @returns PhysicsRaycastResult
  22259. */
  22260. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22261. /**
  22262. * Called by the scene. No need to call it.
  22263. * @param delta defines the timespam between frames
  22264. */ private _step(delta: number): void;
  22265. }
  22266. }
  22267. declare module BABYLON {
  22268. /**
  22269. * The interface for the physics imposter parameters
  22270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22271. */
  22272. export interface PhysicsImpostorParameters {
  22273. /**
  22274. * The mass of the physics imposter
  22275. */
  22276. mass: number;
  22277. /**
  22278. * The friction of the physics imposter
  22279. */
  22280. friction?: number;
  22281. /**
  22282. * The coefficient of restitution of the physics imposter
  22283. */
  22284. restitution?: number;
  22285. /**
  22286. * The native options of the physics imposter
  22287. */
  22288. nativeOptions?: any;
  22289. /**
  22290. * Specifies if the parent should be ignored
  22291. */
  22292. ignoreParent?: boolean;
  22293. /**
  22294. * Specifies if bi-directional transformations should be disabled
  22295. */
  22296. disableBidirectionalTransformation?: boolean;
  22297. /**
  22298. * The pressure inside the physics imposter, soft object only
  22299. */
  22300. pressure?: number;
  22301. /**
  22302. * The stiffness the physics imposter, soft object only
  22303. */
  22304. stiffness?: number;
  22305. /**
  22306. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22307. */
  22308. velocityIterations?: number;
  22309. /**
  22310. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22311. */
  22312. positionIterations?: number;
  22313. /**
  22314. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22315. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22316. * Add to fix multiple points
  22317. */
  22318. fixedPoints?: number;
  22319. /**
  22320. * The collision margin around a soft object
  22321. */
  22322. margin?: number;
  22323. /**
  22324. * The collision margin around a soft object
  22325. */
  22326. damping?: number;
  22327. /**
  22328. * The path for a rope based on an extrusion
  22329. */
  22330. path?: any;
  22331. /**
  22332. * The shape of an extrusion used for a rope based on an extrusion
  22333. */
  22334. shape?: any;
  22335. }
  22336. /**
  22337. * Interface for a physics-enabled object
  22338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22339. */
  22340. export interface IPhysicsEnabledObject {
  22341. /**
  22342. * The position of the physics-enabled object
  22343. */
  22344. position: Vector3;
  22345. /**
  22346. * The rotation of the physics-enabled object
  22347. */
  22348. rotationQuaternion: Nullable<Quaternion>;
  22349. /**
  22350. * The scale of the physics-enabled object
  22351. */
  22352. scaling: Vector3;
  22353. /**
  22354. * The rotation of the physics-enabled object
  22355. */
  22356. rotation?: Vector3;
  22357. /**
  22358. * The parent of the physics-enabled object
  22359. */
  22360. parent?: any;
  22361. /**
  22362. * The bounding info of the physics-enabled object
  22363. * @returns The bounding info of the physics-enabled object
  22364. */
  22365. getBoundingInfo(): BoundingInfo;
  22366. /**
  22367. * Computes the world matrix
  22368. * @param force Specifies if the world matrix should be computed by force
  22369. * @returns A world matrix
  22370. */
  22371. computeWorldMatrix(force: boolean): Matrix;
  22372. /**
  22373. * Gets the world matrix
  22374. * @returns A world matrix
  22375. */
  22376. getWorldMatrix?(): Matrix;
  22377. /**
  22378. * Gets the child meshes
  22379. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22380. * @returns An array of abstract meshes
  22381. */
  22382. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22383. /**
  22384. * Gets the vertex data
  22385. * @param kind The type of vertex data
  22386. * @returns A nullable array of numbers, or a float32 array
  22387. */
  22388. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22389. /**
  22390. * Gets the indices from the mesh
  22391. * @returns A nullable array of index arrays
  22392. */
  22393. getIndices?(): Nullable<IndicesArray>;
  22394. /**
  22395. * Gets the scene from the mesh
  22396. * @returns the indices array or null
  22397. */
  22398. getScene?(): Scene;
  22399. /**
  22400. * Gets the absolute position from the mesh
  22401. * @returns the absolute position
  22402. */
  22403. getAbsolutePosition(): Vector3;
  22404. /**
  22405. * Gets the absolute pivot point from the mesh
  22406. * @returns the absolute pivot point
  22407. */
  22408. getAbsolutePivotPoint(): Vector3;
  22409. /**
  22410. * Rotates the mesh
  22411. * @param axis The axis of rotation
  22412. * @param amount The amount of rotation
  22413. * @param space The space of the rotation
  22414. * @returns The rotation transform node
  22415. */
  22416. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22417. /**
  22418. * Translates the mesh
  22419. * @param axis The axis of translation
  22420. * @param distance The distance of translation
  22421. * @param space The space of the translation
  22422. * @returns The transform node
  22423. */
  22424. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22425. /**
  22426. * Sets the absolute position of the mesh
  22427. * @param absolutePosition The absolute position of the mesh
  22428. * @returns The transform node
  22429. */
  22430. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22431. /**
  22432. * Gets the class name of the mesh
  22433. * @returns The class name
  22434. */
  22435. getClassName(): string;
  22436. }
  22437. /**
  22438. * Represents a physics imposter
  22439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22440. */
  22441. export class PhysicsImpostor {
  22442. /**
  22443. * The physics-enabled object used as the physics imposter
  22444. */
  22445. object: IPhysicsEnabledObject;
  22446. /**
  22447. * The type of the physics imposter
  22448. */
  22449. type: number;
  22450. private _options;
  22451. private _scene?;
  22452. /**
  22453. * The default object size of the imposter
  22454. */
  22455. static DEFAULT_OBJECT_SIZE: Vector3;
  22456. /**
  22457. * The identity quaternion of the imposter
  22458. */
  22459. static IDENTITY_QUATERNION: Quaternion;
  22460. /** @hidden */ private _pluginData: any;
  22461. private _physicsEngine;
  22462. private _physicsBody;
  22463. private _bodyUpdateRequired;
  22464. private _onBeforePhysicsStepCallbacks;
  22465. private _onAfterPhysicsStepCallbacks;
  22466. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22467. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22468. otherImpostors: Array<PhysicsImpostor>;
  22469. }>;
  22470. private _deltaPosition;
  22471. private _deltaRotation;
  22472. private _deltaRotationConjugated;
  22473. /** @hidden */ private _isFromLine: boolean;
  22474. private _parent;
  22475. private _isDisposed;
  22476. private static _tmpVecs;
  22477. private static _tmpQuat;
  22478. /**
  22479. * Specifies if the physics imposter is disposed
  22480. */
  22481. readonly isDisposed: boolean;
  22482. /**
  22483. * Gets the mass of the physics imposter
  22484. */
  22485. mass: number;
  22486. /**
  22487. * Gets the coefficient of friction
  22488. */
  22489. /**
  22490. * Sets the coefficient of friction
  22491. */
  22492. friction: number;
  22493. /**
  22494. * Gets the coefficient of restitution
  22495. */
  22496. /**
  22497. * Sets the coefficient of restitution
  22498. */
  22499. restitution: number;
  22500. /**
  22501. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22502. */
  22503. /**
  22504. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22505. */
  22506. pressure: number;
  22507. /**
  22508. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22509. */
  22510. /**
  22511. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22512. */
  22513. stiffness: number;
  22514. /**
  22515. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22516. */
  22517. /**
  22518. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22519. */
  22520. velocityIterations: number;
  22521. /**
  22522. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22523. */
  22524. /**
  22525. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22526. */
  22527. positionIterations: number;
  22528. /**
  22529. * The unique id of the physics imposter
  22530. * set by the physics engine when adding this impostor to the array
  22531. */
  22532. uniqueId: number;
  22533. /**
  22534. * @hidden
  22535. */
  22536. soft: boolean;
  22537. /**
  22538. * @hidden
  22539. */
  22540. segments: number;
  22541. private _joints;
  22542. /**
  22543. * Initializes the physics imposter
  22544. * @param object The physics-enabled object used as the physics imposter
  22545. * @param type The type of the physics imposter
  22546. * @param _options The options for the physics imposter
  22547. * @param _scene The Babylon scene
  22548. */
  22549. constructor(
  22550. /**
  22551. * The physics-enabled object used as the physics imposter
  22552. */
  22553. object: IPhysicsEnabledObject,
  22554. /**
  22555. * The type of the physics imposter
  22556. */
  22557. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22558. /**
  22559. * This function will completly initialize this impostor.
  22560. * It will create a new body - but only if this mesh has no parent.
  22561. * If it has, this impostor will not be used other than to define the impostor
  22562. * of the child mesh.
  22563. * @hidden
  22564. */ private _init(): void;
  22565. private _getPhysicsParent;
  22566. /**
  22567. * Should a new body be generated.
  22568. * @returns boolean specifying if body initialization is required
  22569. */
  22570. isBodyInitRequired(): boolean;
  22571. /**
  22572. * Sets the updated scaling
  22573. * @param updated Specifies if the scaling is updated
  22574. */
  22575. setScalingUpdated(): void;
  22576. /**
  22577. * Force a regeneration of this or the parent's impostor's body.
  22578. * Use under cautious - This will remove all joints already implemented.
  22579. */
  22580. forceUpdate(): void;
  22581. /**
  22582. * Gets the body that holds this impostor. Either its own, or its parent.
  22583. */
  22584. /**
  22585. * Set the physics body. Used mainly by the physics engine/plugin
  22586. */
  22587. physicsBody: any;
  22588. /**
  22589. * Get the parent of the physics imposter
  22590. * @returns Physics imposter or null
  22591. */
  22592. /**
  22593. * Sets the parent of the physics imposter
  22594. */
  22595. parent: Nullable<PhysicsImpostor>;
  22596. /**
  22597. * Resets the update flags
  22598. */
  22599. resetUpdateFlags(): void;
  22600. /**
  22601. * Gets the object extend size
  22602. * @returns the object extend size
  22603. */
  22604. getObjectExtendSize(): Vector3;
  22605. /**
  22606. * Gets the object center
  22607. * @returns The object center
  22608. */
  22609. getObjectCenter(): Vector3;
  22610. /**
  22611. * Get a specific parametes from the options parameter
  22612. * @param paramName The object parameter name
  22613. * @returns The object parameter
  22614. */
  22615. getParam(paramName: string): any;
  22616. /**
  22617. * Sets a specific parameter in the options given to the physics plugin
  22618. * @param paramName The parameter name
  22619. * @param value The value of the parameter
  22620. */
  22621. setParam(paramName: string, value: number): void;
  22622. /**
  22623. * Specifically change the body's mass option. Won't recreate the physics body object
  22624. * @param mass The mass of the physics imposter
  22625. */
  22626. setMass(mass: number): void;
  22627. /**
  22628. * Gets the linear velocity
  22629. * @returns linear velocity or null
  22630. */
  22631. getLinearVelocity(): Nullable<Vector3>;
  22632. /**
  22633. * Sets the linear velocity
  22634. * @param velocity linear velocity or null
  22635. */
  22636. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22637. /**
  22638. * Gets the angular velocity
  22639. * @returns angular velocity or null
  22640. */
  22641. getAngularVelocity(): Nullable<Vector3>;
  22642. /**
  22643. * Sets the angular velocity
  22644. * @param velocity The velocity or null
  22645. */
  22646. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22647. /**
  22648. * Execute a function with the physics plugin native code
  22649. * Provide a function the will have two variables - the world object and the physics body object
  22650. * @param func The function to execute with the physics plugin native code
  22651. */
  22652. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22653. /**
  22654. * Register a function that will be executed before the physics world is stepping forward
  22655. * @param func The function to execute before the physics world is stepped forward
  22656. */
  22657. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22658. /**
  22659. * Unregister a function that will be executed before the physics world is stepping forward
  22660. * @param func The function to execute before the physics world is stepped forward
  22661. */
  22662. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22663. /**
  22664. * Register a function that will be executed after the physics step
  22665. * @param func The function to execute after physics step
  22666. */
  22667. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22668. /**
  22669. * Unregisters a function that will be executed after the physics step
  22670. * @param func The function to execute after physics step
  22671. */
  22672. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22673. /**
  22674. * register a function that will be executed when this impostor collides against a different body
  22675. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22676. * @param func Callback that is executed on collision
  22677. */
  22678. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22679. /**
  22680. * Unregisters the physics imposter on contact
  22681. * @param collideAgainst The physics object to collide against
  22682. * @param func Callback to execute on collision
  22683. */
  22684. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22685. private _tmpQuat;
  22686. private _tmpQuat2;
  22687. /**
  22688. * Get the parent rotation
  22689. * @returns The parent rotation
  22690. */
  22691. getParentsRotation(): Quaternion;
  22692. /**
  22693. * this function is executed by the physics engine.
  22694. */
  22695. beforeStep: () => void;
  22696. /**
  22697. * this function is executed by the physics engine
  22698. */
  22699. afterStep: () => void;
  22700. /**
  22701. * Legacy collision detection event support
  22702. */
  22703. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22704. /**
  22705. * event and body object due to cannon's event-based architecture.
  22706. */
  22707. onCollide: (e: {
  22708. body: any;
  22709. }) => void;
  22710. /**
  22711. * Apply a force
  22712. * @param force The force to apply
  22713. * @param contactPoint The contact point for the force
  22714. * @returns The physics imposter
  22715. */
  22716. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22717. /**
  22718. * Apply an impulse
  22719. * @param force The impulse force
  22720. * @param contactPoint The contact point for the impulse force
  22721. * @returns The physics imposter
  22722. */
  22723. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22724. /**
  22725. * A help function to create a joint
  22726. * @param otherImpostor A physics imposter used to create a joint
  22727. * @param jointType The type of joint
  22728. * @param jointData The data for the joint
  22729. * @returns The physics imposter
  22730. */
  22731. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22732. /**
  22733. * Add a joint to this impostor with a different impostor
  22734. * @param otherImpostor A physics imposter used to add a joint
  22735. * @param joint The joint to add
  22736. * @returns The physics imposter
  22737. */
  22738. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22739. /**
  22740. * Add an anchor to a cloth impostor
  22741. * @param otherImpostor rigid impostor to anchor to
  22742. * @param width ratio across width from 0 to 1
  22743. * @param height ratio up height from 0 to 1
  22744. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22745. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22746. * @returns impostor the soft imposter
  22747. */
  22748. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22749. /**
  22750. * Add a hook to a rope impostor
  22751. * @param otherImpostor rigid impostor to anchor to
  22752. * @param length ratio across rope from 0 to 1
  22753. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22754. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22755. * @returns impostor the rope imposter
  22756. */
  22757. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22758. /**
  22759. * Will keep this body still, in a sleep mode.
  22760. * @returns the physics imposter
  22761. */
  22762. sleep(): PhysicsImpostor;
  22763. /**
  22764. * Wake the body up.
  22765. * @returns The physics imposter
  22766. */
  22767. wakeUp(): PhysicsImpostor;
  22768. /**
  22769. * Clones the physics imposter
  22770. * @param newObject The physics imposter clones to this physics-enabled object
  22771. * @returns A nullable physics imposter
  22772. */
  22773. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22774. /**
  22775. * Disposes the physics imposter
  22776. */
  22777. dispose(): void;
  22778. /**
  22779. * Sets the delta position
  22780. * @param position The delta position amount
  22781. */
  22782. setDeltaPosition(position: Vector3): void;
  22783. /**
  22784. * Sets the delta rotation
  22785. * @param rotation The delta rotation amount
  22786. */
  22787. setDeltaRotation(rotation: Quaternion): void;
  22788. /**
  22789. * Gets the box size of the physics imposter and stores the result in the input parameter
  22790. * @param result Stores the box size
  22791. * @returns The physics imposter
  22792. */
  22793. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22794. /**
  22795. * Gets the radius of the physics imposter
  22796. * @returns Radius of the physics imposter
  22797. */
  22798. getRadius(): number;
  22799. /**
  22800. * Sync a bone with this impostor
  22801. * @param bone The bone to sync to the impostor.
  22802. * @param boneMesh The mesh that the bone is influencing.
  22803. * @param jointPivot The pivot of the joint / bone in local space.
  22804. * @param distToJoint Optional distance from the impostor to the joint.
  22805. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22806. */
  22807. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22808. /**
  22809. * Sync impostor to a bone
  22810. * @param bone The bone that the impostor will be synced to.
  22811. * @param boneMesh The mesh that the bone is influencing.
  22812. * @param jointPivot The pivot of the joint / bone in local space.
  22813. * @param distToJoint Optional distance from the impostor to the joint.
  22814. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22815. * @param boneAxis Optional vector3 axis the bone is aligned with
  22816. */
  22817. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22818. /**
  22819. * No-Imposter type
  22820. */
  22821. static NoImpostor: number;
  22822. /**
  22823. * Sphere-Imposter type
  22824. */
  22825. static SphereImpostor: number;
  22826. /**
  22827. * Box-Imposter type
  22828. */
  22829. static BoxImpostor: number;
  22830. /**
  22831. * Plane-Imposter type
  22832. */
  22833. static PlaneImpostor: number;
  22834. /**
  22835. * Mesh-imposter type
  22836. */
  22837. static MeshImpostor: number;
  22838. /**
  22839. * Capsule-Impostor type (Ammo.js plugin only)
  22840. */
  22841. static CapsuleImpostor: number;
  22842. /**
  22843. * Cylinder-Imposter type
  22844. */
  22845. static CylinderImpostor: number;
  22846. /**
  22847. * Particle-Imposter type
  22848. */
  22849. static ParticleImpostor: number;
  22850. /**
  22851. * Heightmap-Imposter type
  22852. */
  22853. static HeightmapImpostor: number;
  22854. /**
  22855. * ConvexHull-Impostor type (Ammo.js plugin only)
  22856. */
  22857. static ConvexHullImpostor: number;
  22858. /**
  22859. * Rope-Imposter type
  22860. */
  22861. static RopeImpostor: number;
  22862. /**
  22863. * Cloth-Imposter type
  22864. */
  22865. static ClothImpostor: number;
  22866. /**
  22867. * Softbody-Imposter type
  22868. */
  22869. static SoftbodyImpostor: number;
  22870. }
  22871. }
  22872. declare module BABYLON {
  22873. /**
  22874. * @hidden
  22875. **/
  22876. export class _CreationDataStorage {
  22877. closePath?: boolean;
  22878. closeArray?: boolean;
  22879. idx: number[];
  22880. dashSize: number;
  22881. gapSize: number;
  22882. path3D: Path3D;
  22883. pathArray: Vector3[][];
  22884. arc: number;
  22885. radius: number;
  22886. cap: number;
  22887. tessellation: number;
  22888. }
  22889. /**
  22890. * @hidden
  22891. **/ private class _InstanceDataStorage {
  22892. visibleInstances: any;
  22893. batchCache: _InstancesBatch;
  22894. instancesBufferSize: number;
  22895. instancesBuffer: Nullable<Buffer>;
  22896. instancesData: Float32Array;
  22897. overridenInstanceCount: number;
  22898. isFrozen: boolean;
  22899. previousBatch: Nullable<_InstancesBatch>;
  22900. hardwareInstancedRendering: boolean;
  22901. sideOrientation: number;
  22902. }
  22903. /**
  22904. * @hidden
  22905. **/
  22906. export class _InstancesBatch {
  22907. mustReturn: boolean;
  22908. visibleInstances: Nullable<InstancedMesh[]>[];
  22909. renderSelf: boolean[];
  22910. hardwareInstancedRendering: boolean[];
  22911. }
  22912. /**
  22913. * Class used to represent renderable models
  22914. */
  22915. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22916. /**
  22917. * Mesh side orientation : usually the external or front surface
  22918. */
  22919. static readonly FRONTSIDE: number;
  22920. /**
  22921. * Mesh side orientation : usually the internal or back surface
  22922. */
  22923. static readonly BACKSIDE: number;
  22924. /**
  22925. * Mesh side orientation : both internal and external or front and back surfaces
  22926. */
  22927. static readonly DOUBLESIDE: number;
  22928. /**
  22929. * Mesh side orientation : by default, `FRONTSIDE`
  22930. */
  22931. static readonly DEFAULTSIDE: number;
  22932. /**
  22933. * Mesh cap setting : no cap
  22934. */
  22935. static readonly NO_CAP: number;
  22936. /**
  22937. * Mesh cap setting : one cap at the beginning of the mesh
  22938. */
  22939. static readonly CAP_START: number;
  22940. /**
  22941. * Mesh cap setting : one cap at the end of the mesh
  22942. */
  22943. static readonly CAP_END: number;
  22944. /**
  22945. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  22946. */
  22947. static readonly CAP_ALL: number;
  22948. /**
  22949. * Mesh pattern setting : no flip or rotate
  22950. */
  22951. static readonly NO_FLIP: number;
  22952. /**
  22953. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  22954. */
  22955. static readonly FLIP_TILE: number;
  22956. /**
  22957. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  22958. */
  22959. static readonly ROTATE_TILE: number;
  22960. /**
  22961. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  22962. */
  22963. static readonly FLIP_ROW: number;
  22964. /**
  22965. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  22966. */
  22967. static readonly ROTATE_ROW: number;
  22968. /**
  22969. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  22970. */
  22971. static readonly FLIP_N_ROTATE_TILE: number;
  22972. /**
  22973. * Mesh pattern setting : rotate pattern and rotate
  22974. */
  22975. static readonly FLIP_N_ROTATE_ROW: number;
  22976. /**
  22977. * Mesh tile positioning : part tiles same on left/right or top/bottom
  22978. */
  22979. static readonly CENTER: number;
  22980. /**
  22981. * Mesh tile positioning : part tiles on left
  22982. */
  22983. static readonly LEFT: number;
  22984. /**
  22985. * Mesh tile positioning : part tiles on right
  22986. */
  22987. static readonly RIGHT: number;
  22988. /**
  22989. * Mesh tile positioning : part tiles on top
  22990. */
  22991. static readonly TOP: number;
  22992. /**
  22993. * Mesh tile positioning : part tiles on bottom
  22994. */
  22995. static readonly BOTTOM: number;
  22996. /**
  22997. * Gets the default side orientation.
  22998. * @param orientation the orientation to value to attempt to get
  22999. * @returns the default orientation
  23000. * @hidden
  23001. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23002. private _internalMeshDataInfo;
  23003. /**
  23004. * An event triggered before rendering the mesh
  23005. */
  23006. readonly onBeforeRenderObservable: Observable<Mesh>;
  23007. /**
  23008. * An event triggered before binding the mesh
  23009. */
  23010. readonly onBeforeBindObservable: Observable<Mesh>;
  23011. /**
  23012. * An event triggered after rendering the mesh
  23013. */
  23014. readonly onAfterRenderObservable: Observable<Mesh>;
  23015. /**
  23016. * An event triggered before drawing the mesh
  23017. */
  23018. readonly onBeforeDrawObservable: Observable<Mesh>;
  23019. private _onBeforeDrawObserver;
  23020. /**
  23021. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23022. */
  23023. onBeforeDraw: () => void;
  23024. /**
  23025. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23026. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23027. */
  23028. delayLoadState: number;
  23029. /**
  23030. * Gets the list of instances created from this mesh
  23031. * it is not supposed to be modified manually.
  23032. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23033. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23034. */
  23035. instances: InstancedMesh[];
  23036. /**
  23037. * Gets the file containing delay loading data for this mesh
  23038. */
  23039. delayLoadingFile: string;
  23040. /** @hidden */ private _binaryInfo: any;
  23041. /**
  23042. * User defined function used to change how LOD level selection is done
  23043. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23044. */
  23045. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23046. /**
  23047. * Gets or sets the morph target manager
  23048. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23049. */
  23050. morphTargetManager: Nullable<MorphTargetManager>;
  23051. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23052. /** @hidden */ private _geometry: Nullable<Geometry>;
  23053. /** @hidden */ private _delayInfo: Array<string>;
  23054. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23055. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23056. private _effectiveMaterial;
  23057. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23058. /** @hidden */ private _originalBuilderSideOrientation: number;
  23059. /**
  23060. * Use this property to change the original side orientation defined at construction time
  23061. */
  23062. overrideMaterialSideOrientation: Nullable<number>;
  23063. /**
  23064. * Gets the source mesh (the one used to clone this one from)
  23065. */
  23066. readonly source: Nullable<Mesh>;
  23067. /**
  23068. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23069. */
  23070. isUnIndexed: boolean;
  23071. /**
  23072. * @constructor
  23073. * @param name The value used by scene.getMeshByName() to do a lookup.
  23074. * @param scene The scene to add this mesh to.
  23075. * @param parent The parent of this mesh, if it has one
  23076. * @param source An optional Mesh from which geometry is shared, cloned.
  23077. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23078. * When false, achieved by calling a clone(), also passing False.
  23079. * This will make creation of children, recursive.
  23080. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23081. */
  23082. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23083. /**
  23084. * Gets the class name
  23085. * @returns the string "Mesh".
  23086. */
  23087. getClassName(): string;
  23088. /** @hidden */ protected readonly _isMesh: boolean;
  23089. /**
  23090. * Returns a description of this mesh
  23091. * @param fullDetails define if full details about this mesh must be used
  23092. * @returns a descriptive string representing this mesh
  23093. */
  23094. toString(fullDetails?: boolean): string;
  23095. /** @hidden */ private _unBindEffect(): void;
  23096. /**
  23097. * Gets a boolean indicating if this mesh has LOD
  23098. */
  23099. readonly hasLODLevels: boolean;
  23100. /**
  23101. * Gets the list of MeshLODLevel associated with the current mesh
  23102. * @returns an array of MeshLODLevel
  23103. */
  23104. getLODLevels(): MeshLODLevel[];
  23105. private _sortLODLevels;
  23106. /**
  23107. * Add a mesh as LOD level triggered at the given distance.
  23108. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23109. * @param distance The distance from the center of the object to show this level
  23110. * @param mesh The mesh to be added as LOD level (can be null)
  23111. * @return This mesh (for chaining)
  23112. */
  23113. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23114. /**
  23115. * Returns the LOD level mesh at the passed distance or null if not found.
  23116. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23117. * @param distance The distance from the center of the object to show this level
  23118. * @returns a Mesh or `null`
  23119. */
  23120. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23121. /**
  23122. * Remove a mesh from the LOD array
  23123. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23124. * @param mesh defines the mesh to be removed
  23125. * @return This mesh (for chaining)
  23126. */
  23127. removeLODLevel(mesh: Mesh): Mesh;
  23128. /**
  23129. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23130. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23131. * @param camera defines the camera to use to compute distance
  23132. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23133. * @return This mesh (for chaining)
  23134. */
  23135. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23136. /**
  23137. * Gets the mesh internal Geometry object
  23138. */
  23139. readonly geometry: Nullable<Geometry>;
  23140. /**
  23141. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23142. * @returns the total number of vertices
  23143. */
  23144. getTotalVertices(): number;
  23145. /**
  23146. * Returns the content of an associated vertex buffer
  23147. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23148. * - VertexBuffer.PositionKind
  23149. * - VertexBuffer.UVKind
  23150. * - VertexBuffer.UV2Kind
  23151. * - VertexBuffer.UV3Kind
  23152. * - VertexBuffer.UV4Kind
  23153. * - VertexBuffer.UV5Kind
  23154. * - VertexBuffer.UV6Kind
  23155. * - VertexBuffer.ColorKind
  23156. * - VertexBuffer.MatricesIndicesKind
  23157. * - VertexBuffer.MatricesIndicesExtraKind
  23158. * - VertexBuffer.MatricesWeightsKind
  23159. * - VertexBuffer.MatricesWeightsExtraKind
  23160. * @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
  23161. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23162. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23163. */
  23164. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23165. /**
  23166. * Returns the mesh VertexBuffer object from the requested `kind`
  23167. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23168. * - VertexBuffer.PositionKind
  23169. * - VertexBuffer.NormalKind
  23170. * - VertexBuffer.UVKind
  23171. * - VertexBuffer.UV2Kind
  23172. * - VertexBuffer.UV3Kind
  23173. * - VertexBuffer.UV4Kind
  23174. * - VertexBuffer.UV5Kind
  23175. * - VertexBuffer.UV6Kind
  23176. * - VertexBuffer.ColorKind
  23177. * - VertexBuffer.MatricesIndicesKind
  23178. * - VertexBuffer.MatricesIndicesExtraKind
  23179. * - VertexBuffer.MatricesWeightsKind
  23180. * - VertexBuffer.MatricesWeightsExtraKind
  23181. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23182. */
  23183. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23184. /**
  23185. * Tests if a specific vertex buffer is associated with this mesh
  23186. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23187. * - VertexBuffer.PositionKind
  23188. * - VertexBuffer.NormalKind
  23189. * - VertexBuffer.UVKind
  23190. * - VertexBuffer.UV2Kind
  23191. * - VertexBuffer.UV3Kind
  23192. * - VertexBuffer.UV4Kind
  23193. * - VertexBuffer.UV5Kind
  23194. * - VertexBuffer.UV6Kind
  23195. * - VertexBuffer.ColorKind
  23196. * - VertexBuffer.MatricesIndicesKind
  23197. * - VertexBuffer.MatricesIndicesExtraKind
  23198. * - VertexBuffer.MatricesWeightsKind
  23199. * - VertexBuffer.MatricesWeightsExtraKind
  23200. * @returns a boolean
  23201. */
  23202. isVerticesDataPresent(kind: string): boolean;
  23203. /**
  23204. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23205. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23206. * - VertexBuffer.PositionKind
  23207. * - VertexBuffer.UVKind
  23208. * - VertexBuffer.UV2Kind
  23209. * - VertexBuffer.UV3Kind
  23210. * - VertexBuffer.UV4Kind
  23211. * - VertexBuffer.UV5Kind
  23212. * - VertexBuffer.UV6Kind
  23213. * - VertexBuffer.ColorKind
  23214. * - VertexBuffer.MatricesIndicesKind
  23215. * - VertexBuffer.MatricesIndicesExtraKind
  23216. * - VertexBuffer.MatricesWeightsKind
  23217. * - VertexBuffer.MatricesWeightsExtraKind
  23218. * @returns a boolean
  23219. */
  23220. isVertexBufferUpdatable(kind: string): boolean;
  23221. /**
  23222. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23223. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23224. * - VertexBuffer.PositionKind
  23225. * - VertexBuffer.NormalKind
  23226. * - VertexBuffer.UVKind
  23227. * - VertexBuffer.UV2Kind
  23228. * - VertexBuffer.UV3Kind
  23229. * - VertexBuffer.UV4Kind
  23230. * - VertexBuffer.UV5Kind
  23231. * - VertexBuffer.UV6Kind
  23232. * - VertexBuffer.ColorKind
  23233. * - VertexBuffer.MatricesIndicesKind
  23234. * - VertexBuffer.MatricesIndicesExtraKind
  23235. * - VertexBuffer.MatricesWeightsKind
  23236. * - VertexBuffer.MatricesWeightsExtraKind
  23237. * @returns an array of strings
  23238. */
  23239. getVerticesDataKinds(): string[];
  23240. /**
  23241. * Returns a positive integer : the total number of indices in this mesh geometry.
  23242. * @returns the numner of indices or zero if the mesh has no geometry.
  23243. */
  23244. getTotalIndices(): number;
  23245. /**
  23246. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23247. * @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.
  23248. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23249. * @returns the indices array or an empty array if the mesh has no geometry
  23250. */
  23251. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23252. readonly isBlocked: boolean;
  23253. /**
  23254. * Determine if the current mesh is ready to be rendered
  23255. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23256. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23257. * @returns true if all associated assets are ready (material, textures, shaders)
  23258. */
  23259. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23260. /**
  23261. * 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.
  23262. */
  23263. readonly areNormalsFrozen: boolean;
  23264. /**
  23265. * 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.
  23266. * @returns the current mesh
  23267. */
  23268. freezeNormals(): Mesh;
  23269. /**
  23270. * 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
  23271. * @returns the current mesh
  23272. */
  23273. unfreezeNormals(): Mesh;
  23274. /**
  23275. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23276. */
  23277. overridenInstanceCount: number;
  23278. /** @hidden */ private _preActivate(): Mesh;
  23279. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23280. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23281. /**
  23282. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23283. * This means the mesh underlying bounding box and sphere are recomputed.
  23284. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23285. * @returns the current mesh
  23286. */
  23287. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23288. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23289. /**
  23290. * This function will subdivide the mesh into multiple submeshes
  23291. * @param count defines the expected number of submeshes
  23292. */
  23293. subdivide(count: number): void;
  23294. /**
  23295. * Copy a FloatArray into a specific associated vertex buffer
  23296. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23297. * - VertexBuffer.PositionKind
  23298. * - VertexBuffer.UVKind
  23299. * - VertexBuffer.UV2Kind
  23300. * - VertexBuffer.UV3Kind
  23301. * - VertexBuffer.UV4Kind
  23302. * - VertexBuffer.UV5Kind
  23303. * - VertexBuffer.UV6Kind
  23304. * - VertexBuffer.ColorKind
  23305. * - VertexBuffer.MatricesIndicesKind
  23306. * - VertexBuffer.MatricesIndicesExtraKind
  23307. * - VertexBuffer.MatricesWeightsKind
  23308. * - VertexBuffer.MatricesWeightsExtraKind
  23309. * @param data defines the data source
  23310. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23311. * @param stride defines the data stride size (can be null)
  23312. * @returns the current mesh
  23313. */
  23314. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23315. /**
  23316. * Flags an associated vertex buffer as updatable
  23317. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23318. * - VertexBuffer.PositionKind
  23319. * - VertexBuffer.UVKind
  23320. * - VertexBuffer.UV2Kind
  23321. * - VertexBuffer.UV3Kind
  23322. * - VertexBuffer.UV4Kind
  23323. * - VertexBuffer.UV5Kind
  23324. * - VertexBuffer.UV6Kind
  23325. * - VertexBuffer.ColorKind
  23326. * - VertexBuffer.MatricesIndicesKind
  23327. * - VertexBuffer.MatricesIndicesExtraKind
  23328. * - VertexBuffer.MatricesWeightsKind
  23329. * - VertexBuffer.MatricesWeightsExtraKind
  23330. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23331. */
  23332. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23333. /**
  23334. * Sets the mesh global Vertex Buffer
  23335. * @param buffer defines the buffer to use
  23336. * @returns the current mesh
  23337. */
  23338. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23339. /**
  23340. * Update a specific associated vertex buffer
  23341. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23342. * - VertexBuffer.PositionKind
  23343. * - VertexBuffer.UVKind
  23344. * - VertexBuffer.UV2Kind
  23345. * - VertexBuffer.UV3Kind
  23346. * - VertexBuffer.UV4Kind
  23347. * - VertexBuffer.UV5Kind
  23348. * - VertexBuffer.UV6Kind
  23349. * - VertexBuffer.ColorKind
  23350. * - VertexBuffer.MatricesIndicesKind
  23351. * - VertexBuffer.MatricesIndicesExtraKind
  23352. * - VertexBuffer.MatricesWeightsKind
  23353. * - VertexBuffer.MatricesWeightsExtraKind
  23354. * @param data defines the data source
  23355. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23356. * @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)
  23357. * @returns the current mesh
  23358. */
  23359. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23360. /**
  23361. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23362. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23363. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23364. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23365. * @returns the current mesh
  23366. */
  23367. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23368. /**
  23369. * Creates a un-shared specific occurence of the geometry for the mesh.
  23370. * @returns the current mesh
  23371. */
  23372. makeGeometryUnique(): Mesh;
  23373. /**
  23374. * Set the index buffer of this mesh
  23375. * @param indices defines the source data
  23376. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23377. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23378. * @returns the current mesh
  23379. */
  23380. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23381. /**
  23382. * Update the current index buffer
  23383. * @param indices defines the source data
  23384. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23385. * @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)
  23386. * @returns the current mesh
  23387. */
  23388. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23389. /**
  23390. * Invert the geometry to move from a right handed system to a left handed one.
  23391. * @returns the current mesh
  23392. */
  23393. toLeftHanded(): Mesh;
  23394. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23395. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23396. /**
  23397. * Registers for this mesh a javascript function called just before the rendering process
  23398. * @param func defines the function to call before rendering this mesh
  23399. * @returns the current mesh
  23400. */
  23401. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23402. /**
  23403. * Disposes a previously registered javascript function called before the rendering
  23404. * @param func defines the function to remove
  23405. * @returns the current mesh
  23406. */
  23407. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23408. /**
  23409. * Registers for this mesh a javascript function called just after the rendering is complete
  23410. * @param func defines the function to call after rendering this mesh
  23411. * @returns the current mesh
  23412. */
  23413. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23414. /**
  23415. * Disposes a previously registered javascript function called after the rendering.
  23416. * @param func defines the function to remove
  23417. * @returns the current mesh
  23418. */
  23419. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23420. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23421. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23422. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23423. /** @hidden */ private _rebuild(): void;
  23424. /** @hidden */ private _freeze(): void;
  23425. /** @hidden */ private _unFreeze(): void;
  23426. /**
  23427. * 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
  23428. * @param subMesh defines the subMesh to render
  23429. * @param enableAlphaMode defines if alpha mode can be changed
  23430. * @returns the current mesh
  23431. */
  23432. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23433. private _onBeforeDraw;
  23434. /**
  23435. * Renormalize the mesh and patch it up if there are no weights
  23436. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23437. * However in the case of zero weights then we set just a single influence to 1.
  23438. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23439. */
  23440. cleanMatrixWeights(): void;
  23441. private normalizeSkinFourWeights;
  23442. private normalizeSkinWeightsAndExtra;
  23443. /**
  23444. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23445. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23446. * the user know there was an issue with importing the mesh
  23447. * @returns a validation object with skinned, valid and report string
  23448. */
  23449. validateSkinning(): {
  23450. skinned: boolean;
  23451. valid: boolean;
  23452. report: string;
  23453. };
  23454. /** @hidden */ private _checkDelayState(): Mesh;
  23455. private _queueLoad;
  23456. /**
  23457. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23458. * A mesh is in the frustum if its bounding box intersects the frustum
  23459. * @param frustumPlanes defines the frustum to test
  23460. * @returns true if the mesh is in the frustum planes
  23461. */
  23462. isInFrustum(frustumPlanes: Plane[]): boolean;
  23463. /**
  23464. * Sets the mesh material by the material or multiMaterial `id` property
  23465. * @param id is a string identifying the material or the multiMaterial
  23466. * @returns the current mesh
  23467. */
  23468. setMaterialByID(id: string): Mesh;
  23469. /**
  23470. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23471. * @returns an array of IAnimatable
  23472. */
  23473. getAnimatables(): IAnimatable[];
  23474. /**
  23475. * Modifies the mesh geometry according to the passed transformation matrix.
  23476. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23477. * The mesh normals are modified using the same transformation.
  23478. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23479. * @param transform defines the transform matrix to use
  23480. * @see http://doc.babylonjs.com/resources/baking_transformations
  23481. * @returns the current mesh
  23482. */
  23483. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23484. /**
  23485. * Modifies the mesh geometry according to its own current World Matrix.
  23486. * The mesh World Matrix is then reset.
  23487. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23488. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23489. * @see http://doc.babylonjs.com/resources/baking_transformations
  23490. * @returns the current mesh
  23491. */
  23492. bakeCurrentTransformIntoVertices(): Mesh;
  23493. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23494. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23495. /** @hidden */ private _generatePointsArray(): boolean;
  23496. /**
  23497. * Returns a new Mesh object generated from the current mesh properties.
  23498. * This method must not get confused with createInstance()
  23499. * @param name is a string, the name given to the new mesh
  23500. * @param newParent can be any Node object (default `null`)
  23501. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23502. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23503. * @returns a new mesh
  23504. */
  23505. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23506. /**
  23507. * Releases resources associated with this mesh.
  23508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23510. */
  23511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23512. /**
  23513. * Modifies the mesh geometry according to a displacement map.
  23514. * 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.
  23515. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23516. * @param url is a string, the URL from the image file is to be downloaded.
  23517. * @param minHeight is the lower limit of the displacement.
  23518. * @param maxHeight is the upper limit of the displacement.
  23519. * @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.
  23520. * @param uvOffset is an optional vector2 used to offset UV.
  23521. * @param uvScale is an optional vector2 used to scale UV.
  23522. * @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.
  23523. * @returns the Mesh.
  23524. */
  23525. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23526. /**
  23527. * Modifies the mesh geometry according to a displacementMap buffer.
  23528. * 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.
  23529. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23530. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23531. * @param heightMapWidth is the width of the buffer image.
  23532. * @param heightMapHeight is the height of the buffer image.
  23533. * @param minHeight is the lower limit of the displacement.
  23534. * @param maxHeight is the upper limit of the displacement.
  23535. * @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.
  23536. * @param uvOffset is an optional vector2 used to offset UV.
  23537. * @param uvScale is an optional vector2 used to scale UV.
  23538. * @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.
  23539. * @returns the Mesh.
  23540. */
  23541. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23542. /**
  23543. * Modify the mesh to get a flat shading rendering.
  23544. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23545. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23546. * @returns current mesh
  23547. */
  23548. convertToFlatShadedMesh(): Mesh;
  23549. /**
  23550. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23551. * In other words, more vertices, no more indices and a single bigger VBO.
  23552. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23553. * @returns current mesh
  23554. */
  23555. convertToUnIndexedMesh(): Mesh;
  23556. /**
  23557. * Inverses facet orientations.
  23558. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23559. * @param flipNormals will also inverts the normals
  23560. * @returns current mesh
  23561. */
  23562. flipFaces(flipNormals?: boolean): Mesh;
  23563. /**
  23564. * Increase the number of facets and hence vertices in a mesh
  23565. * Vertex normals are interpolated from existing vertex normals
  23566. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23567. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23568. */
  23569. increaseVertices(numberPerEdge: number): void;
  23570. /**
  23571. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23572. * This will undo any application of covertToFlatShadedMesh
  23573. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23574. */
  23575. forceSharedVertices(): void;
  23576. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23577. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23578. /**
  23579. * Creates a new InstancedMesh object from the mesh model.
  23580. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23581. * @param name defines the name of the new instance
  23582. * @returns a new InstancedMesh
  23583. */
  23584. createInstance(name: string): InstancedMesh;
  23585. /**
  23586. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23587. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23588. * @returns the current mesh
  23589. */
  23590. synchronizeInstances(): Mesh;
  23591. /**
  23592. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23593. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23594. * This should be used together with the simplification to avoid disappearing triangles.
  23595. * @param successCallback an optional success callback to be called after the optimization finished.
  23596. * @returns the current mesh
  23597. */
  23598. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23599. /**
  23600. * Serialize current mesh
  23601. * @param serializationObject defines the object which will receive the serialization data
  23602. */
  23603. serialize(serializationObject: any): void;
  23604. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23605. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23606. /**
  23607. * Returns a new Mesh object parsed from the source provided.
  23608. * @param parsedMesh is the source
  23609. * @param scene defines the hosting scene
  23610. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23611. * @returns a new Mesh
  23612. */
  23613. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23614. /**
  23615. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23616. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23617. * @param name defines the name of the mesh to create
  23618. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23619. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23620. * @param closePath creates a seam between the first and the last points of each path of the path array
  23621. * @param offset is taken in account only if the `pathArray` is containing a single path
  23622. * @param scene defines the hosting scene
  23623. * @param updatable defines if the mesh must be flagged as updatable
  23624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23625. * @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)
  23626. * @returns a new Mesh
  23627. */
  23628. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23629. /**
  23630. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23631. * @param name defines the name of the mesh to create
  23632. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23633. * @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
  23634. * @param scene defines the hosting scene
  23635. * @param updatable defines if the mesh must be flagged as updatable
  23636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23637. * @returns a new Mesh
  23638. */
  23639. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23640. /**
  23641. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23642. * @param name defines the name of the mesh to create
  23643. * @param size sets the size (float) of each box side (default 1)
  23644. * @param scene defines the hosting scene
  23645. * @param updatable defines if the mesh must be flagged as updatable
  23646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23647. * @returns a new Mesh
  23648. */
  23649. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23650. /**
  23651. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23652. * @param name defines the name of the mesh to create
  23653. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23654. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23655. * @param scene defines the hosting scene
  23656. * @param updatable defines if the mesh must be flagged as updatable
  23657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23658. * @returns a new Mesh
  23659. */
  23660. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23661. /**
  23662. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23663. * @param name defines the name of the mesh to create
  23664. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23665. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23666. * @param scene defines the hosting scene
  23667. * @returns a new Mesh
  23668. */
  23669. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23670. /**
  23671. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23672. * @param name defines the name of the mesh to create
  23673. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23674. * @param diameterTop set the top cap diameter (floats, default 1)
  23675. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23676. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23677. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23678. * @param scene defines the hosting scene
  23679. * @param updatable defines if the mesh must be flagged as updatable
  23680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23681. * @returns a new Mesh
  23682. */
  23683. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23684. /**
  23685. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23686. * @param name defines the name of the mesh to create
  23687. * @param diameter sets the diameter size (float) of the torus (default 1)
  23688. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23689. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23690. * @param scene defines the hosting scene
  23691. * @param updatable defines if the mesh must be flagged as updatable
  23692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23693. * @returns a new Mesh
  23694. */
  23695. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23696. /**
  23697. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23698. * @param name defines the name of the mesh to create
  23699. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23700. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23701. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23702. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23703. * @param p the number of windings on X axis (positive integers, default 2)
  23704. * @param q the number of windings on Y axis (positive integers, default 3)
  23705. * @param scene defines the hosting scene
  23706. * @param updatable defines if the mesh must be flagged as updatable
  23707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23708. * @returns a new Mesh
  23709. */
  23710. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23711. /**
  23712. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23713. * @param name defines the name of the mesh to create
  23714. * @param points is an array successive Vector3
  23715. * @param scene defines the hosting scene
  23716. * @param updatable defines if the mesh must be flagged as updatable
  23717. * @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).
  23718. * @returns a new Mesh
  23719. */
  23720. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23721. /**
  23722. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23723. * @param name defines the name of the mesh to create
  23724. * @param points is an array successive Vector3
  23725. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23726. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23727. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23728. * @param scene defines the hosting scene
  23729. * @param updatable defines if the mesh must be flagged as updatable
  23730. * @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)
  23731. * @returns a new Mesh
  23732. */
  23733. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23734. /**
  23735. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23736. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23737. * 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.
  23738. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23739. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23740. * Remember you can only change the shape positions, not their number when updating a polygon.
  23741. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23742. * @param name defines the name of the mesh to create
  23743. * @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
  23744. * @param scene defines the hosting scene
  23745. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23746. * @param updatable defines if the mesh must be flagged as updatable
  23747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23748. * @param earcutInjection can be used to inject your own earcut reference
  23749. * @returns a new Mesh
  23750. */
  23751. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23752. /**
  23753. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23754. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23755. * @param name defines the name of the mesh to create
  23756. * @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
  23757. * @param depth defines the height of extrusion
  23758. * @param scene defines the hosting scene
  23759. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23760. * @param updatable defines if the mesh must be flagged as updatable
  23761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23762. * @param earcutInjection can be used to inject your own earcut reference
  23763. * @returns a new Mesh
  23764. */
  23765. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23766. /**
  23767. * Creates an extruded shape mesh.
  23768. * 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
  23769. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23770. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23771. * @param name defines the name of the mesh to create
  23772. * @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
  23773. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23774. * @param scale is the value to scale the shape
  23775. * @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
  23776. * @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
  23777. * @param scene defines the hosting scene
  23778. * @param updatable defines if the mesh must be flagged as updatable
  23779. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23780. * @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)
  23781. * @returns a new Mesh
  23782. */
  23783. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23784. /**
  23785. * Creates an custom extruded shape mesh.
  23786. * The custom extrusion is a parametric shape.
  23787. * It has no predefined shape. Its final shape will depend on the input parameters.
  23788. * Please consider using the same method from the MeshBuilder class instead
  23789. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23790. * @param name defines the name of the mesh to create
  23791. * @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
  23792. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23793. * @param scaleFunction is a custom Javascript function called on each path point
  23794. * @param rotationFunction is a custom Javascript function called on each path point
  23795. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23796. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  23797. * @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
  23798. * @param scene defines the hosting scene
  23799. * @param updatable defines if the mesh must be flagged as updatable
  23800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23801. * @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)
  23802. * @returns a new Mesh
  23803. */
  23804. 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;
  23805. /**
  23806. * Creates lathe mesh.
  23807. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23808. * Please consider using the same method from the MeshBuilder class instead
  23809. * @param name defines the name of the mesh to create
  23810. * @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
  23811. * @param radius is the radius value of the lathe
  23812. * @param tessellation is the side number of the lathe.
  23813. * @param scene defines the hosting scene
  23814. * @param updatable defines if the mesh must be flagged as updatable
  23815. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23816. * @returns a new Mesh
  23817. */
  23818. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23819. /**
  23820. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  23821. * @param name defines the name of the mesh to create
  23822. * @param size sets the size (float) of both sides of the plane at once (default 1)
  23823. * @param scene defines the hosting scene
  23824. * @param updatable defines if the mesh must be flagged as updatable
  23825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23826. * @returns a new Mesh
  23827. */
  23828. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23829. /**
  23830. * Creates a ground mesh.
  23831. * Please consider using the same method from the MeshBuilder class instead
  23832. * @param name defines the name of the mesh to create
  23833. * @param width set the width of the ground
  23834. * @param height set the height of the ground
  23835. * @param subdivisions sets the number of subdivisions per side
  23836. * @param scene defines the hosting scene
  23837. * @param updatable defines if the mesh must be flagged as updatable
  23838. * @returns a new Mesh
  23839. */
  23840. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23841. /**
  23842. * Creates a tiled ground mesh.
  23843. * Please consider using the same method from the MeshBuilder class instead
  23844. * @param name defines the name of the mesh to create
  23845. * @param xmin set the ground minimum X coordinate
  23846. * @param zmin set the ground minimum Y coordinate
  23847. * @param xmax set the ground maximum X coordinate
  23848. * @param zmax set the ground maximum Z coordinate
  23849. * @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
  23850. * @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
  23851. * @param scene defines the hosting scene
  23852. * @param updatable defines if the mesh must be flagged as updatable
  23853. * @returns a new Mesh
  23854. */
  23855. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23856. w: number;
  23857. h: number;
  23858. }, precision: {
  23859. w: number;
  23860. h: number;
  23861. }, scene: Scene, updatable?: boolean): Mesh;
  23862. /**
  23863. * Creates a ground mesh from a height map.
  23864. * Please consider using the same method from the MeshBuilder class instead
  23865. * @see http://doc.babylonjs.com/babylon101/height_map
  23866. * @param name defines the name of the mesh to create
  23867. * @param url sets the URL of the height map image resource
  23868. * @param width set the ground width size
  23869. * @param height set the ground height size
  23870. * @param subdivisions sets the number of subdivision per side
  23871. * @param minHeight is the minimum altitude on the ground
  23872. * @param maxHeight is the maximum altitude on the ground
  23873. * @param scene defines the hosting scene
  23874. * @param updatable defines if the mesh must be flagged as updatable
  23875. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  23876. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23877. * @returns a new Mesh
  23878. */
  23879. 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;
  23880. /**
  23881. * Creates a tube mesh.
  23882. * The tube is a parametric shape.
  23883. * It has no predefined shape. Its final shape will depend on the input parameters.
  23884. * Please consider using the same method from the MeshBuilder class instead
  23885. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23886. * @param name defines the name of the mesh to create
  23887. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  23888. * @param radius sets the tube radius size
  23889. * @param tessellation is the number of sides on the tubular surface
  23890. * @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
  23891. * @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
  23892. * @param scene defines the hosting scene
  23893. * @param updatable defines if the mesh must be flagged as updatable
  23894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23895. * @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)
  23896. * @returns a new Mesh
  23897. */
  23898. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23899. (i: number, distance: number): number;
  23900. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23901. /**
  23902. * Creates a polyhedron mesh.
  23903. * Please consider using the same method from the MeshBuilder class instead.
  23904. * * 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
  23905. * * The parameter `size` (positive float, default 1) sets the polygon size
  23906. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23907. * * 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`
  23908. * * 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
  23909. * * 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)`)
  23910. * * 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
  23911. * * 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
  23912. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23913. * * 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
  23914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23915. * @param name defines the name of the mesh to create
  23916. * @param options defines the options used to create the mesh
  23917. * @param scene defines the hosting scene
  23918. * @returns a new Mesh
  23919. */
  23920. static CreatePolyhedron(name: string, options: {
  23921. type?: number;
  23922. size?: number;
  23923. sizeX?: number;
  23924. sizeY?: number;
  23925. sizeZ?: number;
  23926. custom?: any;
  23927. faceUV?: Vector4[];
  23928. faceColors?: Color4[];
  23929. updatable?: boolean;
  23930. sideOrientation?: number;
  23931. }, scene: Scene): Mesh;
  23932. /**
  23933. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23934. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23935. * * 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`)
  23936. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23937. * * 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
  23938. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23939. * * 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
  23940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23941. * @param name defines the name of the mesh
  23942. * @param options defines the options used to create the mesh
  23943. * @param scene defines the hosting scene
  23944. * @returns a new Mesh
  23945. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23946. */
  23947. static CreateIcoSphere(name: string, options: {
  23948. radius?: number;
  23949. flat?: boolean;
  23950. subdivisions?: number;
  23951. sideOrientation?: number;
  23952. updatable?: boolean;
  23953. }, scene: Scene): Mesh;
  23954. /**
  23955. * Creates a decal mesh.
  23956. * Please consider using the same method from the MeshBuilder class instead.
  23957. * A decal is a mesh usually applied as a model onto the surface of another mesh
  23958. * @param name defines the name of the mesh
  23959. * @param sourceMesh defines the mesh receiving the decal
  23960. * @param position sets the position of the decal in world coordinates
  23961. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  23962. * @param size sets the decal scaling
  23963. * @param angle sets the angle to rotate the decal
  23964. * @returns a new Mesh
  23965. */
  23966. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  23967. /**
  23968. * Prepare internal position array for software CPU skinning
  23969. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  23970. */
  23971. setPositionsForCPUSkinning(): Float32Array;
  23972. /**
  23973. * Prepare internal normal array for software CPU skinning
  23974. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  23975. */
  23976. setNormalsForCPUSkinning(): Float32Array;
  23977. /**
  23978. * Updates the vertex buffer by applying transformation from the bones
  23979. * @param skeleton defines the skeleton to apply to current mesh
  23980. * @returns the current mesh
  23981. */
  23982. applySkeleton(skeleton: Skeleton): Mesh;
  23983. /**
  23984. * 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
  23985. * @param meshes defines the list of meshes to scan
  23986. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  23987. */
  23988. static MinMax(meshes: AbstractMesh[]): {
  23989. min: Vector3;
  23990. max: Vector3;
  23991. };
  23992. /**
  23993. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  23994. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  23995. * @returns a vector3
  23996. */
  23997. static Center(meshesOrMinMaxVector: {
  23998. min: Vector3;
  23999. max: Vector3;
  24000. } | AbstractMesh[]): Vector3;
  24001. /**
  24002. * Merge the array of meshes into a single mesh for performance reasons.
  24003. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24004. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24005. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24006. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24007. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24008. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24009. * @returns a new mesh
  24010. */
  24011. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24012. /** @hidden */
  24013. addInstance(instance: InstancedMesh): void;
  24014. /** @hidden */
  24015. removeInstance(instance: InstancedMesh): void;
  24016. }
  24017. }
  24018. declare module BABYLON {
  24019. /**
  24020. * This is the base class of all the camera used in the application.
  24021. * @see http://doc.babylonjs.com/features/cameras
  24022. */
  24023. export class Camera extends Node {
  24024. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24025. /**
  24026. * This is the default projection mode used by the cameras.
  24027. * It helps recreating a feeling of perspective and better appreciate depth.
  24028. * This is the best way to simulate real life cameras.
  24029. */
  24030. static readonly PERSPECTIVE_CAMERA: number;
  24031. /**
  24032. * This helps creating camera with an orthographic mode.
  24033. * 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.
  24034. */
  24035. static readonly ORTHOGRAPHIC_CAMERA: number;
  24036. /**
  24037. * This is the default FOV mode for perspective cameras.
  24038. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24039. */
  24040. static readonly FOVMODE_VERTICAL_FIXED: number;
  24041. /**
  24042. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24043. */
  24044. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24045. /**
  24046. * This specifies ther is no need for a camera rig.
  24047. * Basically only one eye is rendered corresponding to the camera.
  24048. */
  24049. static readonly RIG_MODE_NONE: number;
  24050. /**
  24051. * Simulates a camera Rig with one blue eye and one red eye.
  24052. * This can be use with 3d blue and red glasses.
  24053. */
  24054. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24055. /**
  24056. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24057. */
  24058. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24059. /**
  24060. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24061. */
  24062. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24063. /**
  24064. * Defines that both eyes of the camera will be rendered over under each other.
  24065. */
  24066. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24067. /**
  24068. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24069. */
  24070. static readonly RIG_MODE_VR: number;
  24071. /**
  24072. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24073. */
  24074. static readonly RIG_MODE_WEBVR: number;
  24075. /**
  24076. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24077. */
  24078. static readonly RIG_MODE_CUSTOM: number;
  24079. /**
  24080. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24081. */
  24082. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24083. /**
  24084. * Define the input manager associated with the camera.
  24085. */
  24086. inputs: CameraInputsManager<Camera>;
  24087. /** @hidden */ private _position: Vector3;
  24088. /**
  24089. * Define the current local position of the camera in the scene
  24090. */
  24091. position: Vector3;
  24092. /**
  24093. * The vector the camera should consider as up.
  24094. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24095. */
  24096. upVector: Vector3;
  24097. /**
  24098. * Define the current limit on the left side for an orthographic camera
  24099. * In scene unit
  24100. */
  24101. orthoLeft: Nullable<number>;
  24102. /**
  24103. * Define the current limit on the right side for an orthographic camera
  24104. * In scene unit
  24105. */
  24106. orthoRight: Nullable<number>;
  24107. /**
  24108. * Define the current limit on the bottom side for an orthographic camera
  24109. * In scene unit
  24110. */
  24111. orthoBottom: Nullable<number>;
  24112. /**
  24113. * Define the current limit on the top side for an orthographic camera
  24114. * In scene unit
  24115. */
  24116. orthoTop: Nullable<number>;
  24117. /**
  24118. * Field Of View is set in Radians. (default is 0.8)
  24119. */
  24120. fov: number;
  24121. /**
  24122. * Define the minimum distance the camera can see from.
  24123. * This is important to note that the depth buffer are not infinite and the closer it starts
  24124. * the more your scene might encounter depth fighting issue.
  24125. */
  24126. minZ: number;
  24127. /**
  24128. * Define the maximum distance the camera can see to.
  24129. * This is important to note that the depth buffer are not infinite and the further it end
  24130. * the more your scene might encounter depth fighting issue.
  24131. */
  24132. maxZ: number;
  24133. /**
  24134. * Define the default inertia of the camera.
  24135. * This helps giving a smooth feeling to the camera movement.
  24136. */
  24137. inertia: number;
  24138. /**
  24139. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24140. */
  24141. mode: number;
  24142. /**
  24143. * Define wether the camera is intermediate.
  24144. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24145. */
  24146. isIntermediate: boolean;
  24147. /**
  24148. * Define the viewport of the camera.
  24149. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24150. */
  24151. viewport: Viewport;
  24152. /**
  24153. * Restricts the camera to viewing objects with the same layerMask.
  24154. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24155. */
  24156. layerMask: number;
  24157. /**
  24158. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24159. */
  24160. fovMode: number;
  24161. /**
  24162. * Rig mode of the camera.
  24163. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24164. * This is normally controlled byt the camera themselves as internal use.
  24165. */
  24166. cameraRigMode: number;
  24167. /**
  24168. * Defines the distance between both "eyes" in case of a RIG
  24169. */
  24170. interaxialDistance: number;
  24171. /**
  24172. * Defines if stereoscopic rendering is done side by side or over under.
  24173. */
  24174. isStereoscopicSideBySide: boolean;
  24175. /**
  24176. * 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
  24177. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24178. * else in the scene. (Eg. security camera)
  24179. *
  24180. * 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)
  24181. */
  24182. customRenderTargets: RenderTargetTexture[];
  24183. /**
  24184. * When set, the camera will render to this render target instead of the default canvas
  24185. *
  24186. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24187. */
  24188. outputRenderTarget: Nullable<RenderTargetTexture>;
  24189. /**
  24190. * Observable triggered when the camera view matrix has changed.
  24191. */
  24192. onViewMatrixChangedObservable: Observable<Camera>;
  24193. /**
  24194. * Observable triggered when the camera Projection matrix has changed.
  24195. */
  24196. onProjectionMatrixChangedObservable: Observable<Camera>;
  24197. /**
  24198. * Observable triggered when the inputs have been processed.
  24199. */
  24200. onAfterCheckInputsObservable: Observable<Camera>;
  24201. /**
  24202. * Observable triggered when reset has been called and applied to the camera.
  24203. */
  24204. onRestoreStateObservable: Observable<Camera>;
  24205. /** @hidden */ private _cameraRigParams: any;
  24206. /** @hidden */ private _rigCameras: Camera[];
  24207. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24208. protected _webvrViewMatrix: Matrix;
  24209. /** @hidden */ private _skipRendering: boolean;
  24210. /** @hidden */ private _projectionMatrix: Matrix;
  24211. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24212. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24213. protected _globalPosition: Vector3;
  24214. /** @hidden */ private _computedViewMatrix: Matrix;
  24215. private _doNotComputeProjectionMatrix;
  24216. private _transformMatrix;
  24217. private _frustumPlanes;
  24218. private _refreshFrustumPlanes;
  24219. private _storedFov;
  24220. private _stateStored;
  24221. /**
  24222. * Instantiates a new camera object.
  24223. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24224. * @see http://doc.babylonjs.com/features/cameras
  24225. * @param name Defines the name of the camera in the scene
  24226. * @param position Defines the position of the camera
  24227. * @param scene Defines the scene the camera belongs too
  24228. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24229. */
  24230. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24231. /**
  24232. * Store current camera state (fov, position, etc..)
  24233. * @returns the camera
  24234. */
  24235. storeState(): Camera;
  24236. /**
  24237. * Restores the camera state values if it has been stored. You must call storeState() first
  24238. */
  24239. protected _restoreStateValues(): boolean;
  24240. /**
  24241. * Restored camera state. You must call storeState() first.
  24242. * @returns true if restored and false otherwise
  24243. */
  24244. restoreState(): boolean;
  24245. /**
  24246. * Gets the class name of the camera.
  24247. * @returns the class name
  24248. */
  24249. getClassName(): string;
  24250. /** @hidden */ protected readonly _isCamera: boolean;
  24251. /**
  24252. * Gets a string representation of the camera useful for debug purpose.
  24253. * @param fullDetails Defines that a more verboe level of logging is required
  24254. * @returns the string representation
  24255. */
  24256. toString(fullDetails?: boolean): string;
  24257. /**
  24258. * Gets the current world space position of the camera.
  24259. */
  24260. readonly globalPosition: Vector3;
  24261. /**
  24262. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24263. * @returns the active meshe list
  24264. */
  24265. getActiveMeshes(): SmartArray<AbstractMesh>;
  24266. /**
  24267. * Check wether a mesh is part of the current active mesh list of the camera
  24268. * @param mesh Defines the mesh to check
  24269. * @returns true if active, false otherwise
  24270. */
  24271. isActiveMesh(mesh: Mesh): boolean;
  24272. /**
  24273. * Is this camera ready to be used/rendered
  24274. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24275. * @return true if the camera is ready
  24276. */
  24277. isReady(completeCheck?: boolean): boolean;
  24278. /** @hidden */ private _initCache(): void;
  24279. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24280. /** @hidden */ private _isSynchronized(): boolean;
  24281. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24282. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24283. /**
  24284. * Attach the input controls to a specific dom element to get the input from.
  24285. * @param element Defines the element the controls should be listened from
  24286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24287. */
  24288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24289. /**
  24290. * Detach the current controls from the specified dom element.
  24291. * @param element Defines the element to stop listening the inputs from
  24292. */
  24293. detachControl(element: HTMLElement): void;
  24294. /**
  24295. * Update the camera state according to the different inputs gathered during the frame.
  24296. */
  24297. update(): void;
  24298. /** @hidden */ private _checkInputs(): void;
  24299. /** @hidden */
  24300. readonly rigCameras: Camera[];
  24301. /**
  24302. * Gets the post process used by the rig cameras
  24303. */
  24304. readonly rigPostProcess: Nullable<PostProcess>;
  24305. /**
  24306. * Internal, gets the first post proces.
  24307. * @returns the first post process to be run on this camera.
  24308. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24309. private _cascadePostProcessesToRigCams;
  24310. /**
  24311. * Attach a post process to the camera.
  24312. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24313. * @param postProcess The post process to attach to the camera
  24314. * @param insertAt The position of the post process in case several of them are in use in the scene
  24315. * @returns the position the post process has been inserted at
  24316. */
  24317. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24318. /**
  24319. * Detach a post process to the camera.
  24320. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24321. * @param postProcess The post process to detach from the camera
  24322. */
  24323. detachPostProcess(postProcess: PostProcess): void;
  24324. /**
  24325. * Gets the current world matrix of the camera
  24326. */
  24327. getWorldMatrix(): Matrix;
  24328. /** @hidden */ private _getViewMatrix(): Matrix;
  24329. /**
  24330. * Gets the current view matrix of the camera.
  24331. * @param force forces the camera to recompute the matrix without looking at the cached state
  24332. * @returns the view matrix
  24333. */
  24334. getViewMatrix(force?: boolean): Matrix;
  24335. /**
  24336. * Freeze the projection matrix.
  24337. * It will prevent the cache check of the camera projection compute and can speed up perf
  24338. * if no parameter of the camera are meant to change
  24339. * @param projection Defines manually a projection if necessary
  24340. */
  24341. freezeProjectionMatrix(projection?: Matrix): void;
  24342. /**
  24343. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24344. */
  24345. unfreezeProjectionMatrix(): void;
  24346. /**
  24347. * Gets the current projection matrix of the camera.
  24348. * @param force forces the camera to recompute the matrix without looking at the cached state
  24349. * @returns the projection matrix
  24350. */
  24351. getProjectionMatrix(force?: boolean): Matrix;
  24352. /**
  24353. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24354. * @returns a Matrix
  24355. */
  24356. getTransformationMatrix(): Matrix;
  24357. private _updateFrustumPlanes;
  24358. /**
  24359. * Checks if a cullable object (mesh...) is in the camera frustum
  24360. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24361. * @param target The object to check
  24362. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24363. * @returns true if the object is in frustum otherwise false
  24364. */
  24365. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24366. /**
  24367. * Checks if a cullable object (mesh...) is in the camera frustum
  24368. * Unlike isInFrustum this cheks the full bounding box
  24369. * @param target The object to check
  24370. * @returns true if the object is in frustum otherwise false
  24371. */
  24372. isCompletelyInFrustum(target: ICullable): boolean;
  24373. /**
  24374. * Gets a ray in the forward direction from the camera.
  24375. * @param length Defines the length of the ray to create
  24376. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24377. * @param origin Defines the start point of the ray which defaults to the camera position
  24378. * @returns the forward ray
  24379. */
  24380. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24381. /**
  24382. * Releases resources associated with this node.
  24383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24385. */
  24386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24387. /** @hidden */ private _isLeftCamera: boolean;
  24388. /**
  24389. * Gets the left camera of a rig setup in case of Rigged Camera
  24390. */
  24391. readonly isLeftCamera: boolean;
  24392. /** @hidden */ private _isRightCamera: boolean;
  24393. /**
  24394. * Gets the right camera of a rig setup in case of Rigged Camera
  24395. */
  24396. readonly isRightCamera: boolean;
  24397. /**
  24398. * Gets the left camera of a rig setup in case of Rigged Camera
  24399. */
  24400. readonly leftCamera: Nullable<FreeCamera>;
  24401. /**
  24402. * Gets the right camera of a rig setup in case of Rigged Camera
  24403. */
  24404. readonly rightCamera: Nullable<FreeCamera>;
  24405. /**
  24406. * Gets the left camera target of a rig setup in case of Rigged Camera
  24407. * @returns the target position
  24408. */
  24409. getLeftTarget(): Nullable<Vector3>;
  24410. /**
  24411. * Gets the right camera target of a rig setup in case of Rigged Camera
  24412. * @returns the target position
  24413. */
  24414. getRightTarget(): Nullable<Vector3>;
  24415. /**
  24416. * @hidden
  24417. */
  24418. setCameraRigMode(mode: number, rigParams: any): void;
  24419. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24420. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24421. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24422. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24423. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24424. protected _updateCameraRotationMatrix(): void;
  24425. protected _updateWebVRCameraRotationMatrix(): void;
  24426. /**
  24427. * This function MUST be overwritten by the different WebVR cameras available.
  24428. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24429. * @hidden
  24430. */ private _getWebVRProjectionMatrix(): Matrix;
  24431. /**
  24432. * This function MUST be overwritten by the different WebVR cameras available.
  24433. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24434. * @hidden
  24435. */ private _getWebVRViewMatrix(): Matrix;
  24436. /** @hidden */
  24437. setCameraRigParameter(name: string, value: any): void;
  24438. /**
  24439. * needs to be overridden by children so sub has required properties to be copied
  24440. * @hidden
  24441. */
  24442. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24443. /**
  24444. * May need to be overridden by children
  24445. * @hidden
  24446. */ private _updateRigCameras(): void;
  24447. /** @hidden */ private _setupInputs(): void;
  24448. /**
  24449. * Serialiaze the camera setup to a json represention
  24450. * @returns the JSON representation
  24451. */
  24452. serialize(): any;
  24453. /**
  24454. * Clones the current camera.
  24455. * @param name The cloned camera name
  24456. * @returns the cloned camera
  24457. */
  24458. clone(name: string): Camera;
  24459. /**
  24460. * Gets the direction of the camera relative to a given local axis.
  24461. * @param localAxis Defines the reference axis to provide a relative direction.
  24462. * @return the direction
  24463. */
  24464. getDirection(localAxis: Vector3): Vector3;
  24465. /**
  24466. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24467. * @param localAxis Defines the reference axis to provide a relative direction.
  24468. * @param result Defines the vector to store the result in
  24469. */
  24470. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24471. /**
  24472. * Gets a camera constructor for a given camera type
  24473. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24474. * @param name The name of the camera the result will be able to instantiate
  24475. * @param scene The scene the result will construct the camera in
  24476. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24477. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24478. * @returns a factory method to construc the camera
  24479. */
  24480. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24481. /**
  24482. * Compute the world matrix of the camera.
  24483. * @returns the camera workd matrix
  24484. */
  24485. computeWorldMatrix(): Matrix;
  24486. /**
  24487. * Parse a JSON and creates the camera from the parsed information
  24488. * @param parsedCamera The JSON to parse
  24489. * @param scene The scene to instantiate the camera in
  24490. * @returns the newly constructed camera
  24491. */
  24492. static Parse(parsedCamera: any, scene: Scene): Camera;
  24493. }
  24494. }
  24495. declare module BABYLON {
  24496. /**
  24497. * Class containing static functions to help procedurally build meshes
  24498. */
  24499. export class DiscBuilder {
  24500. /**
  24501. * Creates a plane polygonal mesh. By default, this is a disc
  24502. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24503. * * 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
  24504. * * 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
  24505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24506. * * 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
  24507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24508. * @param name defines the name of the mesh
  24509. * @param options defines the options used to create the mesh
  24510. * @param scene defines the hosting scene
  24511. * @returns the plane polygonal mesh
  24512. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24513. */
  24514. static CreateDisc(name: string, options: {
  24515. radius?: number;
  24516. tessellation?: number;
  24517. arc?: number;
  24518. updatable?: boolean;
  24519. sideOrientation?: number;
  24520. frontUVs?: Vector4;
  24521. backUVs?: Vector4;
  24522. }, scene?: Nullable<Scene>): Mesh;
  24523. }
  24524. }
  24525. declare module BABYLON {
  24526. /**
  24527. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24528. *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.
  24529. * The SPS is also a particle system. It provides some methods to manage the particles.
  24530. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24531. *
  24532. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24533. */
  24534. export class SolidParticleSystem implements IDisposable {
  24535. /**
  24536. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24537. * Example : var p = SPS.particles[i];
  24538. */
  24539. particles: SolidParticle[];
  24540. /**
  24541. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24542. */
  24543. nbParticles: number;
  24544. /**
  24545. * If the particles must ever face the camera (default false). Useful for planar particles.
  24546. */
  24547. billboard: boolean;
  24548. /**
  24549. * Recompute normals when adding a shape
  24550. */
  24551. recomputeNormals: boolean;
  24552. /**
  24553. * This a counter ofr your own usage. It's not set by any SPS functions.
  24554. */
  24555. counter: number;
  24556. /**
  24557. * The SPS name. This name is also given to the underlying mesh.
  24558. */
  24559. name: string;
  24560. /**
  24561. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24562. */
  24563. mesh: Mesh;
  24564. /**
  24565. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24566. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24567. */
  24568. vars: any;
  24569. /**
  24570. * This array is populated when the SPS is set as 'pickable'.
  24571. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24572. * Each element of this array is an object `{idx: int, faceId: int}`.
  24573. * `idx` is the picked particle index in the `SPS.particles` array
  24574. * `faceId` is the picked face index counted within this particle.
  24575. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24576. */
  24577. pickedParticles: {
  24578. idx: number;
  24579. faceId: number;
  24580. }[];
  24581. /**
  24582. * This array is populated when `enableDepthSort` is set to true.
  24583. * Each element of this array is an instance of the class DepthSortedParticle.
  24584. */
  24585. depthSortedParticles: DepthSortedParticle[];
  24586. /**
  24587. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24588. * @hidden
  24589. */ private _bSphereOnly: boolean;
  24590. /**
  24591. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24592. * @hidden
  24593. */ private _bSphereRadiusFactor: number;
  24594. private _scene;
  24595. private _positions;
  24596. private _indices;
  24597. private _normals;
  24598. private _colors;
  24599. private _uvs;
  24600. private _indices32;
  24601. private _positions32;
  24602. private _normals32;
  24603. private _fixedNormal32;
  24604. private _colors32;
  24605. private _uvs32;
  24606. private _index;
  24607. private _updatable;
  24608. private _pickable;
  24609. private _isVisibilityBoxLocked;
  24610. private _alwaysVisible;
  24611. private _depthSort;
  24612. private _shapeCounter;
  24613. private _copy;
  24614. private _color;
  24615. private _computeParticleColor;
  24616. private _computeParticleTexture;
  24617. private _computeParticleRotation;
  24618. private _computeParticleVertex;
  24619. private _computeBoundingBox;
  24620. private _depthSortParticles;
  24621. private _camera;
  24622. private _mustUnrotateFixedNormals;
  24623. private _particlesIntersect;
  24624. private _needs32Bits;
  24625. /**
  24626. * Creates a SPS (Solid Particle System) object.
  24627. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24628. * @param scene (Scene) is the scene in which the SPS is added.
  24629. * @param options defines the options of the sps e.g.
  24630. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24631. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24632. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24633. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24634. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24635. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24636. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24637. */
  24638. constructor(name: string, scene: Scene, options?: {
  24639. updatable?: boolean;
  24640. isPickable?: boolean;
  24641. enableDepthSort?: boolean;
  24642. particleIntersection?: boolean;
  24643. boundingSphereOnly?: boolean;
  24644. bSphereRadiusFactor?: number;
  24645. });
  24646. /**
  24647. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24648. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24649. * @returns the created mesh
  24650. */
  24651. buildMesh(): Mesh;
  24652. /**
  24653. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24654. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24655. * Thus the particles generated from `digest()` have their property `position` set yet.
  24656. * @param mesh ( Mesh ) is the mesh to be digested
  24657. * @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
  24658. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24659. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24660. * @returns the current SPS
  24661. */
  24662. digest(mesh: Mesh, options?: {
  24663. facetNb?: number;
  24664. number?: number;
  24665. delta?: number;
  24666. }): SolidParticleSystem;
  24667. private _unrotateFixedNormals;
  24668. private _resetCopy;
  24669. private _meshBuilder;
  24670. private _posToShape;
  24671. private _uvsToShapeUV;
  24672. private _addParticle;
  24673. /**
  24674. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24675. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24676. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24677. * @param nb (positive integer) the number of particles to be created from this model
  24678. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24679. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24680. * @returns the number of shapes in the system
  24681. */
  24682. addShape(mesh: Mesh, nb: number, options?: {
  24683. positionFunction?: any;
  24684. vertexFunction?: any;
  24685. }): number;
  24686. private _rebuildParticle;
  24687. /**
  24688. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24689. * @returns the SPS.
  24690. */
  24691. rebuildMesh(): SolidParticleSystem;
  24692. /**
  24693. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24694. * This method calls `updateParticle()` for each particle of the SPS.
  24695. * For an animated SPS, it is usually called within the render loop.
  24696. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24697. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24698. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24699. * @returns the SPS.
  24700. */
  24701. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24702. /**
  24703. * Disposes the SPS.
  24704. */
  24705. dispose(): void;
  24706. /**
  24707. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24708. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24709. * @returns the SPS.
  24710. */
  24711. refreshVisibleSize(): SolidParticleSystem;
  24712. /**
  24713. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24714. * @param size the size (float) of the visibility box
  24715. * note : this doesn't lock the SPS mesh bounding box.
  24716. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24717. */
  24718. setVisibilityBox(size: number): void;
  24719. /**
  24720. * Gets whether the SPS as always visible or not
  24721. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24722. */
  24723. /**
  24724. * Sets the SPS as always visible or not
  24725. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24726. */
  24727. isAlwaysVisible: boolean;
  24728. /**
  24729. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24730. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24731. */
  24732. /**
  24733. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24734. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24735. */
  24736. isVisibilityBoxLocked: boolean;
  24737. /**
  24738. * Tells to `setParticles()` to compute the particle rotations or not.
  24739. * Default value : true. The SPS is faster when it's set to false.
  24740. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24741. */
  24742. /**
  24743. * Gets if `setParticles()` computes the particle rotations or not.
  24744. * Default value : true. The SPS is faster when it's set to false.
  24745. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24746. */
  24747. computeParticleRotation: boolean;
  24748. /**
  24749. * Tells to `setParticles()` to compute the particle colors or not.
  24750. * Default value : true. The SPS is faster when it's set to false.
  24751. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24752. */
  24753. /**
  24754. * Gets if `setParticles()` computes the particle colors or not.
  24755. * Default value : true. The SPS is faster when it's set to false.
  24756. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24757. */
  24758. computeParticleColor: boolean;
  24759. /**
  24760. * Gets if `setParticles()` computes the particle textures or not.
  24761. * Default value : true. The SPS is faster when it's set to false.
  24762. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24763. */
  24764. computeParticleTexture: boolean;
  24765. /**
  24766. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24767. * Default value : false. The SPS is faster when it's set to false.
  24768. * Note : the particle custom vertex positions aren't stored values.
  24769. */
  24770. /**
  24771. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24772. * Default value : false. The SPS is faster when it's set to false.
  24773. * Note : the particle custom vertex positions aren't stored values.
  24774. */
  24775. computeParticleVertex: boolean;
  24776. /**
  24777. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24778. */
  24779. /**
  24780. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24781. */
  24782. computeBoundingBox: boolean;
  24783. /**
  24784. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24785. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24786. * Default : `true`
  24787. */
  24788. /**
  24789. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24790. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24791. * Default : `true`
  24792. */
  24793. depthSortParticles: boolean;
  24794. /**
  24795. * This function does nothing. It may be overwritten to set all the particle first values.
  24796. * The SPS doesn't call this function, you may have to call it by your own.
  24797. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24798. */
  24799. initParticles(): void;
  24800. /**
  24801. * This function does nothing. It may be overwritten to recycle a particle.
  24802. * The SPS doesn't call this function, you may have to call it by your own.
  24803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24804. * @param particle The particle to recycle
  24805. * @returns the recycled particle
  24806. */
  24807. recycleParticle(particle: SolidParticle): SolidParticle;
  24808. /**
  24809. * Updates a particle : this function should be overwritten by the user.
  24810. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24811. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24812. * @example : just set a particle position or velocity and recycle conditions
  24813. * @param particle The particle to update
  24814. * @returns the updated particle
  24815. */
  24816. updateParticle(particle: SolidParticle): SolidParticle;
  24817. /**
  24818. * Updates a vertex of a particle : it can be overwritten by the user.
  24819. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24820. * @param particle the current particle
  24821. * @param vertex the current index of the current particle
  24822. * @param pt the index of the current vertex in the particle shape
  24823. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  24824. * @example : just set a vertex particle position
  24825. * @returns the updated vertex
  24826. */
  24827. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24828. /**
  24829. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24830. * This does nothing and may be overwritten by the user.
  24831. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24832. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24833. * @param update the boolean update value actually passed to setParticles()
  24834. */
  24835. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24836. /**
  24837. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24838. * This will be passed three parameters.
  24839. * This does nothing and may be overwritten by the user.
  24840. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24841. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24842. * @param update the boolean update value actually passed to setParticles()
  24843. */
  24844. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24845. }
  24846. }
  24847. declare module BABYLON {
  24848. /**
  24849. * Represents one particle of a solid particle system.
  24850. */
  24851. export class SolidParticle {
  24852. /**
  24853. * particle global index
  24854. */
  24855. idx: number;
  24856. /**
  24857. * The color of the particle
  24858. */
  24859. color: Nullable<Color4>;
  24860. /**
  24861. * The world space position of the particle.
  24862. */
  24863. position: Vector3;
  24864. /**
  24865. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24866. */
  24867. rotation: Vector3;
  24868. /**
  24869. * The world space rotation quaternion of the particle.
  24870. */
  24871. rotationQuaternion: Nullable<Quaternion>;
  24872. /**
  24873. * The scaling of the particle.
  24874. */
  24875. scaling: Vector3;
  24876. /**
  24877. * The uvs of the particle.
  24878. */
  24879. uvs: Vector4;
  24880. /**
  24881. * The current speed of the particle.
  24882. */
  24883. velocity: Vector3;
  24884. /**
  24885. * The pivot point in the particle local space.
  24886. */
  24887. pivot: Vector3;
  24888. /**
  24889. * Must the particle be translated from its pivot point in its local space ?
  24890. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24891. * Default : false
  24892. */
  24893. translateFromPivot: boolean;
  24894. /**
  24895. * Is the particle active or not ?
  24896. */
  24897. alive: boolean;
  24898. /**
  24899. * Is the particle visible or not ?
  24900. */
  24901. isVisible: boolean;
  24902. /**
  24903. * Index of this particle in the global "positions" array (Internal use)
  24904. * @hidden
  24905. */ private _pos: number;
  24906. /**
  24907. * @hidden Index of this particle in the global "indices" array (Internal use)
  24908. */ private _ind: number;
  24909. /**
  24910. * @hidden ModelShape of this particle (Internal use)
  24911. */ private _model: ModelShape;
  24912. /**
  24913. * ModelShape id of this particle
  24914. */
  24915. shapeId: number;
  24916. /**
  24917. * Index of the particle in its shape id (Internal use)
  24918. */
  24919. idxInShape: number;
  24920. /**
  24921. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24922. */ private _modelBoundingInfo: BoundingInfo;
  24923. /**
  24924. * @hidden Particle BoundingInfo object (Internal use)
  24925. */ private _boundingInfo: BoundingInfo;
  24926. /**
  24927. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24928. */ private _sps: SolidParticleSystem;
  24929. /**
  24930. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24931. */ private _stillInvisible: boolean;
  24932. /**
  24933. * @hidden Last computed particle rotation matrix
  24934. */ private _rotationMatrix: number[];
  24935. /**
  24936. * Parent particle Id, if any.
  24937. * Default null.
  24938. */
  24939. parentId: Nullable<number>;
  24940. /**
  24941. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24942. * The possible values are :
  24943. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24944. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24945. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24946. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24947. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24948. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24949. * */
  24950. cullingStrategy: number;
  24951. /**
  24952. * @hidden Internal global position in the SPS.
  24953. */ private _globalPosition: Vector3;
  24954. /**
  24955. * Creates a Solid Particle object.
  24956. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24957. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24958. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24959. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24960. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24961. * @param shapeId (integer) is the model shape identifier in the SPS.
  24962. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24963. * @param sps defines the sps it is associated to
  24964. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24965. */
  24966. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24967. /**
  24968. * Legacy support, changed scale to scaling
  24969. */
  24970. /**
  24971. * Legacy support, changed scale to scaling
  24972. */
  24973. scale: Vector3;
  24974. /**
  24975. * Legacy support, changed quaternion to rotationQuaternion
  24976. */
  24977. /**
  24978. * Legacy support, changed quaternion to rotationQuaternion
  24979. */
  24980. quaternion: Nullable<Quaternion>;
  24981. /**
  24982. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24983. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24984. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24985. * @returns true if it intersects
  24986. */
  24987. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24988. /**
  24989. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24990. * A particle is in the frustum if its bounding box intersects the frustum
  24991. * @param frustumPlanes defines the frustum to test
  24992. * @returns true if the particle is in the frustum planes
  24993. */
  24994. isInFrustum(frustumPlanes: Plane[]): boolean;
  24995. /**
  24996. * get the rotation matrix of the particle
  24997. * @hidden
  24998. */
  24999. getRotationMatrix(m: Matrix): void;
  25000. }
  25001. /**
  25002. * Represents the shape of the model used by one particle of a solid particle system.
  25003. * SPS internal tool, don't use it manually.
  25004. */
  25005. export class ModelShape {
  25006. /**
  25007. * The shape id
  25008. * @hidden
  25009. */
  25010. shapeID: number;
  25011. /**
  25012. * flat array of model positions (internal use)
  25013. * @hidden
  25014. */ private _shape: Vector3[];
  25015. /**
  25016. * flat array of model UVs (internal use)
  25017. * @hidden
  25018. */ private _shapeUV: number[];
  25019. /**
  25020. * length of the shape in the model indices array (internal use)
  25021. * @hidden
  25022. */ private _indicesLength: number;
  25023. /**
  25024. * Custom position function (internal use)
  25025. * @hidden
  25026. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25027. /**
  25028. * Custom vertex function (internal use)
  25029. * @hidden
  25030. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25031. /**
  25032. * 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.
  25033. * SPS internal tool, don't use it manually.
  25034. * @hidden
  25035. */
  25036. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25037. }
  25038. /**
  25039. * Represents a Depth Sorted Particle in the solid particle system.
  25040. */
  25041. export class DepthSortedParticle {
  25042. /**
  25043. * Index of the particle in the "indices" array
  25044. */
  25045. ind: number;
  25046. /**
  25047. * Length of the particle shape in the "indices" array
  25048. */
  25049. indicesLength: number;
  25050. /**
  25051. * Squared distance from the particle to the camera
  25052. */
  25053. sqDistance: number;
  25054. }
  25055. }
  25056. declare module BABYLON {
  25057. /**
  25058. * @hidden
  25059. */
  25060. 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>>;
  25061. }
  25062. }
  25063. declare module BABYLON {
  25064. /** @hidden */ private class _FacetDataStorage {
  25065. facetPositions: Vector3[];
  25066. facetNormals: Vector3[];
  25067. facetPartitioning: number[][];
  25068. facetNb: number;
  25069. partitioningSubdivisions: number;
  25070. partitioningBBoxRatio: number;
  25071. facetDataEnabled: boolean;
  25072. facetParameters: any;
  25073. bbSize: Vector3;
  25074. subDiv: {
  25075. max: number;
  25076. X: number;
  25077. Y: number;
  25078. Z: number;
  25079. };
  25080. facetDepthSort: boolean;
  25081. facetDepthSortEnabled: boolean;
  25082. depthSortedIndices: IndicesArray;
  25083. depthSortedFacets: {
  25084. ind: number;
  25085. sqDistance: number;
  25086. }[];
  25087. facetDepthSortFunction: (f1: {
  25088. ind: number;
  25089. sqDistance: number;
  25090. }, f2: {
  25091. ind: number;
  25092. sqDistance: number;
  25093. }) => number;
  25094. facetDepthSortFrom: Vector3;
  25095. facetDepthSortOrigin: Vector3;
  25096. invertedMatrix: Matrix;
  25097. }
  25098. /**
  25099. * @hidden
  25100. **/ 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;
  25101. }
  25102. /**
  25103. * Class used to store all common mesh properties
  25104. */
  25105. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25106. /** No occlusion */
  25107. static OCCLUSION_TYPE_NONE: number;
  25108. /** Occlusion set to optimisitic */
  25109. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25110. /** Occlusion set to strict */
  25111. static OCCLUSION_TYPE_STRICT: number;
  25112. /** Use an accurante occlusion algorithm */
  25113. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25114. /** Use a conservative occlusion algorithm */
  25115. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25116. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25117. * Test order :
  25118. * Is the bounding sphere outside the frustum ?
  25119. * If not, are the bounding box vertices outside the frustum ?
  25120. * It not, then the cullable object is in the frustum.
  25121. */
  25122. static readonly CULLINGSTRATEGY_STANDARD: number;
  25123. /** Culling strategy : Bounding Sphere Only.
  25124. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25125. * It's also less accurate than the standard because some not visible objects can still be selected.
  25126. * Test : is the bounding sphere outside the frustum ?
  25127. * If not, then the cullable object is in the frustum.
  25128. */
  25129. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25130. /** Culling strategy : Optimistic Inclusion.
  25131. * This in an inclusion test first, then the standard exclusion test.
  25132. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25133. * 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.
  25134. * Anyway, it's as accurate as the standard strategy.
  25135. * Test :
  25136. * Is the cullable object bounding sphere center in the frustum ?
  25137. * If not, apply the default culling strategy.
  25138. */
  25139. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25140. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25141. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25142. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25143. * 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.
  25144. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25145. * Test :
  25146. * Is the cullable object bounding sphere center in the frustum ?
  25147. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25148. */
  25149. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25150. /**
  25151. * No billboard
  25152. */
  25153. static readonly BILLBOARDMODE_NONE: number;
  25154. /** Billboard on X axis */
  25155. static readonly BILLBOARDMODE_X: number;
  25156. /** Billboard on Y axis */
  25157. static readonly BILLBOARDMODE_Y: number;
  25158. /** Billboard on Z axis */
  25159. static readonly BILLBOARDMODE_Z: number;
  25160. /** Billboard on all axes */
  25161. static readonly BILLBOARDMODE_ALL: number;
  25162. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25163. /**
  25164. * The culling strategy to use to check whether the mesh must be rendered or not.
  25165. * This value can be changed at any time and will be used on the next render mesh selection.
  25166. * The possible values are :
  25167. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25168. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25169. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25170. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25171. * Please read each static variable documentation to get details about the culling process.
  25172. * */
  25173. cullingStrategy: number;
  25174. /**
  25175. * Gets the number of facets in the mesh
  25176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25177. */
  25178. readonly facetNb: number;
  25179. /**
  25180. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25182. */
  25183. partitioningSubdivisions: number;
  25184. /**
  25185. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25186. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25188. */
  25189. partitioningBBoxRatio: number;
  25190. /**
  25191. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25192. * Works only for updatable meshes.
  25193. * Doesn't work with multi-materials
  25194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25195. */
  25196. mustDepthSortFacets: boolean;
  25197. /**
  25198. * The location (Vector3) where the facet depth sort must be computed from.
  25199. * By default, the active camera position.
  25200. * Used only when facet depth sort is enabled
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25202. */
  25203. facetDepthSortFrom: Vector3;
  25204. /**
  25205. * gets a boolean indicating if facetData is enabled
  25206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25207. */
  25208. readonly isFacetDataEnabled: boolean;
  25209. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25210. /**
  25211. * An event triggered when this mesh collides with another one
  25212. */
  25213. onCollideObservable: Observable<AbstractMesh>;
  25214. /** Set a function to call when this mesh collides with another one */
  25215. onCollide: () => void;
  25216. /**
  25217. * An event triggered when the collision's position changes
  25218. */
  25219. onCollisionPositionChangeObservable: Observable<Vector3>;
  25220. /** Set a function to call when the collision's position changes */
  25221. onCollisionPositionChange: () => void;
  25222. /**
  25223. * An event triggered when material is changed
  25224. */
  25225. onMaterialChangedObservable: Observable<AbstractMesh>;
  25226. /**
  25227. * Gets or sets the orientation for POV movement & rotation
  25228. */
  25229. definedFacingForward: boolean;
  25230. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25231. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25232. /**
  25233. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25234. */
  25235. /**
  25236. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25237. */
  25238. visibility: number;
  25239. /** Gets or sets the alpha index used to sort transparent meshes
  25240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25241. */
  25242. alphaIndex: number;
  25243. /**
  25244. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25245. */
  25246. isVisible: boolean;
  25247. /**
  25248. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25249. */
  25250. isPickable: boolean;
  25251. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25252. showSubMeshesBoundingBox: boolean;
  25253. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25254. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25255. */
  25256. isBlocker: boolean;
  25257. /**
  25258. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25259. */
  25260. enablePointerMoveEvents: boolean;
  25261. /**
  25262. * Specifies the rendering group id for this mesh (0 by default)
  25263. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25264. */
  25265. renderingGroupId: number;
  25266. private _material;
  25267. /** Gets or sets current material */
  25268. material: Nullable<Material>;
  25269. /**
  25270. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25271. * @see http://doc.babylonjs.com/babylon101/shadows
  25272. */
  25273. receiveShadows: boolean;
  25274. /** Defines color to use when rendering outline */
  25275. outlineColor: Color3;
  25276. /** Define width to use when rendering outline */
  25277. outlineWidth: number;
  25278. /** Defines color to use when rendering overlay */
  25279. overlayColor: Color3;
  25280. /** Defines alpha to use when rendering overlay */
  25281. overlayAlpha: number;
  25282. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25283. hasVertexAlpha: boolean;
  25284. /** 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) */
  25285. useVertexColors: boolean;
  25286. /**
  25287. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25288. */
  25289. computeBonesUsingShaders: boolean;
  25290. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25291. numBoneInfluencers: number;
  25292. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25293. applyFog: boolean;
  25294. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25295. useOctreeForRenderingSelection: boolean;
  25296. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25297. useOctreeForPicking: boolean;
  25298. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25299. useOctreeForCollisions: boolean;
  25300. /**
  25301. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25302. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25303. */
  25304. layerMask: number;
  25305. /**
  25306. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25307. */
  25308. alwaysSelectAsActiveMesh: boolean;
  25309. /**
  25310. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25311. */
  25312. doNotSyncBoundingInfo: boolean;
  25313. /**
  25314. * Gets or sets the current action manager
  25315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25316. */
  25317. actionManager: Nullable<AbstractActionManager>;
  25318. private _meshCollisionData;
  25319. /**
  25320. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25322. */
  25323. ellipsoid: Vector3;
  25324. /**
  25325. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25327. */
  25328. ellipsoidOffset: Vector3;
  25329. /**
  25330. * Gets or sets a collision mask used to mask collisions (default is -1).
  25331. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25332. */
  25333. collisionMask: number;
  25334. /**
  25335. * Gets or sets the current collision group mask (-1 by default).
  25336. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25337. */
  25338. collisionGroup: number;
  25339. /**
  25340. * Defines edge width used when edgesRenderer is enabled
  25341. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25342. */
  25343. edgesWidth: number;
  25344. /**
  25345. * Defines edge color used when edgesRenderer is enabled
  25346. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25347. */
  25348. edgesColor: Color4;
  25349. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25350. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25351. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25352. /** @hidden */ private _renderId: number;
  25353. /**
  25354. * Gets or sets the list of subMeshes
  25355. * @see http://doc.babylonjs.com/how_to/multi_materials
  25356. */
  25357. subMeshes: SubMesh[];
  25358. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25359. /** @hidden */ private _unIndexed: boolean;
  25360. /** @hidden */ private _lightSources: Light[];
  25361. /** Gets the list of lights affecting that mesh */
  25362. readonly lightSources: Light[];
  25363. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25364. /** @hidden */ private _waitingData: {
  25365. lods: Nullable<any>;
  25366. actions: Nullable<any>;
  25367. freezeWorldMatrix: Nullable<boolean>;
  25368. };
  25369. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25370. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25371. /**
  25372. * Gets or sets a skeleton to apply skining transformations
  25373. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25374. */
  25375. skeleton: Nullable<Skeleton>;
  25376. /**
  25377. * An event triggered when the mesh is rebuilt.
  25378. */
  25379. onRebuildObservable: Observable<AbstractMesh>;
  25380. /**
  25381. * Creates a new AbstractMesh
  25382. * @param name defines the name of the mesh
  25383. * @param scene defines the hosting scene
  25384. */
  25385. constructor(name: string, scene?: Nullable<Scene>);
  25386. /**
  25387. * Returns the string "AbstractMesh"
  25388. * @returns "AbstractMesh"
  25389. */
  25390. getClassName(): string;
  25391. /**
  25392. * Gets a string representation of the current mesh
  25393. * @param fullDetails defines a boolean indicating if full details must be included
  25394. * @returns a string representation of the current mesh
  25395. */
  25396. toString(fullDetails?: boolean): string;
  25397. /**
  25398. * @hidden
  25399. */
  25400. protected _getEffectiveParent(): Nullable<Node>;
  25401. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25402. /** @hidden */ private _rebuild(): void;
  25403. /** @hidden */ private _resyncLightSources(): void;
  25404. /** @hidden */ private _resyncLighSource(light: Light): void;
  25405. /** @hidden */ private _unBindEffect(): void;
  25406. /** @hidden */ private _removeLightSource(light: Light): void;
  25407. private _markSubMeshesAsDirty;
  25408. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  25409. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25410. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25411. /**
  25412. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25413. */
  25414. scaling: Vector3;
  25415. /**
  25416. * Returns true if the mesh is blocked. Implemented by child classes
  25417. */
  25418. readonly isBlocked: boolean;
  25419. /**
  25420. * Returns the mesh itself by default. Implemented by child classes
  25421. * @param camera defines the camera to use to pick the right LOD level
  25422. * @returns the currentAbstractMesh
  25423. */
  25424. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25425. /**
  25426. * Returns 0 by default. Implemented by child classes
  25427. * @returns an integer
  25428. */
  25429. getTotalVertices(): number;
  25430. /**
  25431. * Returns a positive integer : the total number of indices in this mesh geometry.
  25432. * @returns the numner of indices or zero if the mesh has no geometry.
  25433. */
  25434. getTotalIndices(): number;
  25435. /**
  25436. * Returns null by default. Implemented by child classes
  25437. * @returns null
  25438. */
  25439. getIndices(): Nullable<IndicesArray>;
  25440. /**
  25441. * Returns the array of the requested vertex data kind. Implemented by child classes
  25442. * @param kind defines the vertex data kind to use
  25443. * @returns null
  25444. */
  25445. getVerticesData(kind: string): Nullable<FloatArray>;
  25446. /**
  25447. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25448. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25449. * Note that a new underlying VertexBuffer object is created each call.
  25450. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25451. * @param kind defines vertex data kind:
  25452. * * VertexBuffer.PositionKind
  25453. * * VertexBuffer.UVKind
  25454. * * VertexBuffer.UV2Kind
  25455. * * VertexBuffer.UV3Kind
  25456. * * VertexBuffer.UV4Kind
  25457. * * VertexBuffer.UV5Kind
  25458. * * VertexBuffer.UV6Kind
  25459. * * VertexBuffer.ColorKind
  25460. * * VertexBuffer.MatricesIndicesKind
  25461. * * VertexBuffer.MatricesIndicesExtraKind
  25462. * * VertexBuffer.MatricesWeightsKind
  25463. * * VertexBuffer.MatricesWeightsExtraKind
  25464. * @param data defines the data source
  25465. * @param updatable defines if the data must be flagged as updatable (or static)
  25466. * @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
  25467. * @returns the current mesh
  25468. */
  25469. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25470. /**
  25471. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25472. * If the mesh has no geometry, it is simply returned as it is.
  25473. * @param kind defines vertex data kind:
  25474. * * VertexBuffer.PositionKind
  25475. * * VertexBuffer.UVKind
  25476. * * VertexBuffer.UV2Kind
  25477. * * VertexBuffer.UV3Kind
  25478. * * VertexBuffer.UV4Kind
  25479. * * VertexBuffer.UV5Kind
  25480. * * VertexBuffer.UV6Kind
  25481. * * VertexBuffer.ColorKind
  25482. * * VertexBuffer.MatricesIndicesKind
  25483. * * VertexBuffer.MatricesIndicesExtraKind
  25484. * * VertexBuffer.MatricesWeightsKind
  25485. * * VertexBuffer.MatricesWeightsExtraKind
  25486. * @param data defines the data source
  25487. * @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
  25488. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25489. * @returns the current mesh
  25490. */
  25491. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25492. /**
  25493. * Sets the mesh indices,
  25494. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25495. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25496. * @param totalVertices Defines the total number of vertices
  25497. * @returns the current mesh
  25498. */
  25499. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25500. /**
  25501. * Gets a boolean indicating if specific vertex data is present
  25502. * @param kind defines the vertex data kind to use
  25503. * @returns true is data kind is present
  25504. */
  25505. isVerticesDataPresent(kind: string): boolean;
  25506. /**
  25507. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25508. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25509. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25510. * @returns a BoundingInfo
  25511. */
  25512. getBoundingInfo(): BoundingInfo;
  25513. /**
  25514. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25515. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25516. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25517. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25518. * @returns the current mesh
  25519. */
  25520. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25521. /**
  25522. * Overwrite the current bounding info
  25523. * @param boundingInfo defines the new bounding info
  25524. * @returns the current mesh
  25525. */
  25526. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25527. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25528. readonly useBones: boolean;
  25529. /** @hidden */ private _preActivate(): void;
  25530. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25531. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25532. /** @hidden */ private _postActivate(): void;
  25533. /** @hidden */ private _freeze(): void;
  25534. /** @hidden */ private _unFreeze(): void;
  25535. /**
  25536. * Gets the current world matrix
  25537. * @returns a Matrix
  25538. */
  25539. getWorldMatrix(): Matrix;
  25540. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25541. /**
  25542. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25543. */
  25544. readonly isAnInstance: boolean;
  25545. /**
  25546. * Perform relative position change from the point of view of behind the front of the mesh.
  25547. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25548. * Supports definition of mesh facing forward or backward
  25549. * @param amountRight defines the distance on the right axis
  25550. * @param amountUp defines the distance on the up axis
  25551. * @param amountForward defines the distance on the forward axis
  25552. * @returns the current mesh
  25553. */
  25554. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25555. /**
  25556. * Calculate relative position change from the point of view of behind the front of the mesh.
  25557. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25558. * Supports definition of mesh facing forward or backward
  25559. * @param amountRight defines the distance on the right axis
  25560. * @param amountUp defines the distance on the up axis
  25561. * @param amountForward defines the distance on the forward axis
  25562. * @returns the new displacement vector
  25563. */
  25564. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25565. /**
  25566. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25567. * Supports definition of mesh facing forward or backward
  25568. * @param flipBack defines the flip
  25569. * @param twirlClockwise defines the twirl
  25570. * @param tiltRight defines the tilt
  25571. * @returns the current mesh
  25572. */
  25573. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25574. /**
  25575. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25576. * Supports definition of mesh facing forward or backward.
  25577. * @param flipBack defines the flip
  25578. * @param twirlClockwise defines the twirl
  25579. * @param tiltRight defines the tilt
  25580. * @returns the new rotation vector
  25581. */
  25582. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25583. /**
  25584. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25585. * This means the mesh underlying bounding box and sphere are recomputed.
  25586. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25587. * @returns the current mesh
  25588. */
  25589. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25590. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25591. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25592. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25593. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25594. /** @hidden */
  25595. protected _afterComputeWorldMatrix(): void;
  25596. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25597. /**
  25598. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25599. * A mesh is in the frustum if its bounding box intersects the frustum
  25600. * @param frustumPlanes defines the frustum to test
  25601. * @returns true if the mesh is in the frustum planes
  25602. */
  25603. isInFrustum(frustumPlanes: Plane[]): boolean;
  25604. /**
  25605. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25606. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25607. * @param frustumPlanes defines the frustum to test
  25608. * @returns true if the mesh is completely in the frustum planes
  25609. */
  25610. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25611. /**
  25612. * True if the mesh intersects another mesh or a SolidParticle object
  25613. * @param mesh defines a target mesh or SolidParticle to test
  25614. * @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)
  25615. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25616. * @returns true if there is an intersection
  25617. */
  25618. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25619. /**
  25620. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25621. * @param point defines the point to test
  25622. * @returns true if there is an intersection
  25623. */
  25624. intersectsPoint(point: Vector3): boolean;
  25625. /**
  25626. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25627. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25628. */
  25629. checkCollisions: boolean;
  25630. /**
  25631. * Gets Collider object used to compute collisions (not physics)
  25632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25633. */
  25634. readonly collider: Nullable<Collider>;
  25635. /**
  25636. * Move the mesh using collision engine
  25637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25638. * @param displacement defines the requested displacement vector
  25639. * @returns the current mesh
  25640. */
  25641. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25642. private _onCollisionPositionChange;
  25643. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25644. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25645. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25646. /** @hidden */ private _generatePointsArray(): boolean;
  25647. /**
  25648. * Checks if the passed Ray intersects with the mesh
  25649. * @param ray defines the ray to use
  25650. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25651. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25652. * @returns the picking info
  25653. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25654. */
  25655. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25656. /**
  25657. * Clones the current mesh
  25658. * @param name defines the mesh name
  25659. * @param newParent defines the new mesh parent
  25660. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25661. * @returns the new mesh
  25662. */
  25663. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25664. /**
  25665. * Disposes all the submeshes of the current meshnp
  25666. * @returns the current mesh
  25667. */
  25668. releaseSubMeshes(): AbstractMesh;
  25669. /**
  25670. * Releases resources associated with this abstract mesh.
  25671. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25672. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25673. */
  25674. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25675. /**
  25676. * Adds the passed mesh as a child to the current mesh
  25677. * @param mesh defines the child mesh
  25678. * @returns the current mesh
  25679. */
  25680. addChild(mesh: AbstractMesh): AbstractMesh;
  25681. /**
  25682. * Removes the passed mesh from the current mesh children list
  25683. * @param mesh defines the child mesh
  25684. * @returns the current mesh
  25685. */
  25686. removeChild(mesh: AbstractMesh): AbstractMesh;
  25687. /** @hidden */
  25688. private _initFacetData;
  25689. /**
  25690. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25691. * This method can be called within the render loop.
  25692. * 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
  25693. * @returns the current mesh
  25694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25695. */
  25696. updateFacetData(): AbstractMesh;
  25697. /**
  25698. * Returns the facetLocalNormals array.
  25699. * The normals are expressed in the mesh local spac
  25700. * @returns an array of Vector3
  25701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25702. */
  25703. getFacetLocalNormals(): Vector3[];
  25704. /**
  25705. * Returns the facetLocalPositions array.
  25706. * The facet positions are expressed in the mesh local space
  25707. * @returns an array of Vector3
  25708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25709. */
  25710. getFacetLocalPositions(): Vector3[];
  25711. /**
  25712. * Returns the facetLocalPartioning array
  25713. * @returns an array of array of numbers
  25714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25715. */
  25716. getFacetLocalPartitioning(): number[][];
  25717. /**
  25718. * Returns the i-th facet position in the world system.
  25719. * This method allocates a new Vector3 per call
  25720. * @param i defines the facet index
  25721. * @returns a new Vector3
  25722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25723. */
  25724. getFacetPosition(i: number): Vector3;
  25725. /**
  25726. * Sets the reference Vector3 with the i-th facet position in the world system
  25727. * @param i defines the facet index
  25728. * @param ref defines the target vector
  25729. * @returns the current mesh
  25730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25731. */
  25732. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25733. /**
  25734. * Returns the i-th facet normal in the world system.
  25735. * This method allocates a new Vector3 per call
  25736. * @param i defines the facet index
  25737. * @returns a new Vector3
  25738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25739. */
  25740. getFacetNormal(i: number): Vector3;
  25741. /**
  25742. * Sets the reference Vector3 with the i-th facet normal in the world system
  25743. * @param i defines the facet index
  25744. * @param ref defines the target vector
  25745. * @returns the current mesh
  25746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25747. */
  25748. getFacetNormalToRef(i: number, ref: Vector3): this;
  25749. /**
  25750. * 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)
  25751. * @param x defines x coordinate
  25752. * @param y defines y coordinate
  25753. * @param z defines z coordinate
  25754. * @returns the array of facet indexes
  25755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25756. */
  25757. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25758. /**
  25759. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25760. * @param projected sets as the (x,y,z) world projection on the facet
  25761. * @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
  25762. * @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
  25763. * @param x defines x coordinate
  25764. * @param y defines y coordinate
  25765. * @param z defines z coordinate
  25766. * @returns the face index if found (or null instead)
  25767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25768. */
  25769. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25770. /**
  25771. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25772. * @param projected sets as the (x,y,z) local projection on the facet
  25773. * @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
  25774. * @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
  25775. * @param x defines x coordinate
  25776. * @param y defines y coordinate
  25777. * @param z defines z coordinate
  25778. * @returns the face index if found (or null instead)
  25779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25780. */
  25781. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25782. /**
  25783. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25784. * @returns the parameters
  25785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25786. */
  25787. getFacetDataParameters(): any;
  25788. /**
  25789. * Disables the feature FacetData and frees the related memory
  25790. * @returns the current mesh
  25791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25792. */
  25793. disableFacetData(): AbstractMesh;
  25794. /**
  25795. * Updates the AbstractMesh indices array
  25796. * @param indices defines the data source
  25797. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25798. * @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)
  25799. * @returns the current mesh
  25800. */
  25801. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25802. /**
  25803. * Creates new normals data for the mesh
  25804. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25805. * @returns the current mesh
  25806. */
  25807. createNormals(updatable: boolean): AbstractMesh;
  25808. /**
  25809. * Align the mesh with a normal
  25810. * @param normal defines the normal to use
  25811. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25812. * @returns the current mesh
  25813. */
  25814. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25815. /** @hidden */ private _checkOcclusionQuery(): boolean;
  25816. /**
  25817. * Disables the mesh edge rendering mode
  25818. * @returns the currentAbstractMesh
  25819. */
  25820. disableEdgesRendering(): AbstractMesh;
  25821. /**
  25822. * Enables the edge rendering mode on the mesh.
  25823. * This mode makes the mesh edges visible
  25824. * @param epsilon defines the maximal distance between two angles to detect a face
  25825. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25826. * @returns the currentAbstractMesh
  25827. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25828. */
  25829. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25830. }
  25831. }
  25832. declare module BABYLON {
  25833. /**
  25834. * Interface used to define ActionEvent
  25835. */
  25836. export interface IActionEvent {
  25837. /** The mesh or sprite that triggered the action */
  25838. source: any;
  25839. /** The X mouse cursor position at the time of the event */
  25840. pointerX: number;
  25841. /** The Y mouse cursor position at the time of the event */
  25842. pointerY: number;
  25843. /** The mesh that is currently pointed at (can be null) */
  25844. meshUnderPointer: Nullable<AbstractMesh>;
  25845. /** the original (browser) event that triggered the ActionEvent */
  25846. sourceEvent?: any;
  25847. /** additional data for the event */
  25848. additionalData?: any;
  25849. }
  25850. /**
  25851. * ActionEvent is the event being sent when an action is triggered.
  25852. */
  25853. export class ActionEvent implements IActionEvent {
  25854. /** The mesh or sprite that triggered the action */
  25855. source: any;
  25856. /** The X mouse cursor position at the time of the event */
  25857. pointerX: number;
  25858. /** The Y mouse cursor position at the time of the event */
  25859. pointerY: number;
  25860. /** The mesh that is currently pointed at (can be null) */
  25861. meshUnderPointer: Nullable<AbstractMesh>;
  25862. /** the original (browser) event that triggered the ActionEvent */
  25863. sourceEvent?: any;
  25864. /** additional data for the event */
  25865. additionalData?: any;
  25866. /**
  25867. * Creates a new ActionEvent
  25868. * @param source The mesh or sprite that triggered the action
  25869. * @param pointerX The X mouse cursor position at the time of the event
  25870. * @param pointerY The Y mouse cursor position at the time of the event
  25871. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25872. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25873. * @param additionalData additional data for the event
  25874. */
  25875. constructor(
  25876. /** The mesh or sprite that triggered the action */
  25877. source: any,
  25878. /** The X mouse cursor position at the time of the event */
  25879. pointerX: number,
  25880. /** The Y mouse cursor position at the time of the event */
  25881. pointerY: number,
  25882. /** The mesh that is currently pointed at (can be null) */
  25883. meshUnderPointer: Nullable<AbstractMesh>,
  25884. /** the original (browser) event that triggered the ActionEvent */
  25885. sourceEvent?: any,
  25886. /** additional data for the event */
  25887. additionalData?: any);
  25888. /**
  25889. * Helper function to auto-create an ActionEvent from a source mesh.
  25890. * @param source The source mesh that triggered the event
  25891. * @param evt The original (browser) event
  25892. * @param additionalData additional data for the event
  25893. * @returns the new ActionEvent
  25894. */
  25895. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25896. /**
  25897. * Helper function to auto-create an ActionEvent from a source sprite
  25898. * @param source The source sprite that triggered the event
  25899. * @param scene Scene associated with the sprite
  25900. * @param evt The original (browser) event
  25901. * @param additionalData additional data for the event
  25902. * @returns the new ActionEvent
  25903. */
  25904. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25905. /**
  25906. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25907. * @param scene the scene where the event occurred
  25908. * @param evt The original (browser) event
  25909. * @returns the new ActionEvent
  25910. */
  25911. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25912. /**
  25913. * Helper function to auto-create an ActionEvent from a primitive
  25914. * @param prim defines the target primitive
  25915. * @param pointerPos defines the pointer position
  25916. * @param evt The original (browser) event
  25917. * @param additionalData additional data for the event
  25918. * @returns the new ActionEvent
  25919. */
  25920. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25921. }
  25922. }
  25923. declare module BABYLON {
  25924. /**
  25925. * Abstract class used to decouple action Manager from scene and meshes.
  25926. * Do not instantiate.
  25927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25928. */
  25929. export abstract class AbstractActionManager implements IDisposable {
  25930. /** Gets the list of active triggers */
  25931. static Triggers: {
  25932. [key: string]: number;
  25933. };
  25934. /** Gets the cursor to use when hovering items */
  25935. hoverCursor: string;
  25936. /** Gets the list of actions */
  25937. actions: IAction[];
  25938. /**
  25939. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25940. */
  25941. isRecursive: boolean;
  25942. /**
  25943. * Releases all associated resources
  25944. */
  25945. abstract dispose(): void;
  25946. /**
  25947. * Does this action manager has pointer triggers
  25948. */
  25949. abstract readonly hasPointerTriggers: boolean;
  25950. /**
  25951. * Does this action manager has pick triggers
  25952. */
  25953. abstract readonly hasPickTriggers: boolean;
  25954. /**
  25955. * Process a specific trigger
  25956. * @param trigger defines the trigger to process
  25957. * @param evt defines the event details to be processed
  25958. */
  25959. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25960. /**
  25961. * Does this action manager handles actions of any of the given triggers
  25962. * @param triggers defines the triggers to be tested
  25963. * @return a boolean indicating whether one (or more) of the triggers is handled
  25964. */
  25965. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25966. /**
  25967. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25968. * speed.
  25969. * @param triggerA defines the trigger to be tested
  25970. * @param triggerB defines the trigger to be tested
  25971. * @return a boolean indicating whether one (or more) of the triggers is handled
  25972. */
  25973. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25974. /**
  25975. * Does this action manager handles actions of a given trigger
  25976. * @param trigger defines the trigger to be tested
  25977. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25978. * @return whether the trigger is handled
  25979. */
  25980. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25981. /**
  25982. * Serialize this manager to a JSON object
  25983. * @param name defines the property name to store this manager
  25984. * @returns a JSON representation of this manager
  25985. */
  25986. abstract serialize(name: string): any;
  25987. /**
  25988. * Registers an action to this action manager
  25989. * @param action defines the action to be registered
  25990. * @return the action amended (prepared) after registration
  25991. */
  25992. abstract registerAction(action: IAction): Nullable<IAction>;
  25993. /**
  25994. * Unregisters an action to this action manager
  25995. * @param action defines the action to be unregistered
  25996. * @return a boolean indicating whether the action has been unregistered
  25997. */
  25998. abstract unregisterAction(action: IAction): Boolean;
  25999. /**
  26000. * Does exist one action manager with at least one trigger
  26001. **/
  26002. static readonly HasTriggers: boolean;
  26003. /**
  26004. * Does exist one action manager with at least one pick trigger
  26005. **/
  26006. static readonly HasPickTriggers: boolean;
  26007. /**
  26008. * Does exist one action manager that handles actions of a given trigger
  26009. * @param trigger defines the trigger to be tested
  26010. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26011. **/
  26012. static HasSpecificTrigger(trigger: number): boolean;
  26013. }
  26014. }
  26015. declare module BABYLON {
  26016. /**
  26017. * Defines how a node can be built from a string name.
  26018. */
  26019. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26020. /**
  26021. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26022. */
  26023. export class Node implements IBehaviorAware<Node> {
  26024. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26025. private static _NodeConstructors;
  26026. /**
  26027. * Add a new node constructor
  26028. * @param type defines the type name of the node to construct
  26029. * @param constructorFunc defines the constructor function
  26030. */
  26031. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26032. /**
  26033. * Returns a node constructor based on type name
  26034. * @param type defines the type name
  26035. * @param name defines the new node name
  26036. * @param scene defines the hosting scene
  26037. * @param options defines optional options to transmit to constructors
  26038. * @returns the new constructor or null
  26039. */
  26040. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26041. /**
  26042. * Gets or sets the name of the node
  26043. */
  26044. name: string;
  26045. /**
  26046. * Gets or sets the id of the node
  26047. */
  26048. id: string;
  26049. /**
  26050. * Gets or sets the unique id of the node
  26051. */
  26052. uniqueId: number;
  26053. /**
  26054. * Gets or sets a string used to store user defined state for the node
  26055. */
  26056. state: string;
  26057. /**
  26058. * Gets or sets an object used to store user defined information for the node
  26059. */
  26060. metadata: any;
  26061. /**
  26062. * For internal use only. Please do not use.
  26063. */
  26064. reservedDataStore: any;
  26065. /**
  26066. * List of inspectable custom properties (used by the Inspector)
  26067. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26068. */
  26069. inspectableCustomProperties: IInspectable[];
  26070. /**
  26071. * Gets or sets a boolean used to define if the node must be serialized
  26072. */
  26073. doNotSerialize: boolean;
  26074. /** @hidden */ private _isDisposed: boolean;
  26075. /**
  26076. * Gets a list of Animations associated with the node
  26077. */
  26078. animations: Animation[];
  26079. protected _ranges: {
  26080. [name: string]: Nullable<AnimationRange>;
  26081. };
  26082. /**
  26083. * Callback raised when the node is ready to be used
  26084. */
  26085. onReady: Nullable<(node: Node) => void>;
  26086. private _isEnabled;
  26087. private _isParentEnabled;
  26088. private _isReady;
  26089. /** @hidden */ private _currentRenderId: number;
  26090. private _parentUpdateId;
  26091. /** @hidden */ private _childUpdateId: number;
  26092. /** @hidden */ private _waitingParentId: Nullable<string>;
  26093. /** @hidden */ private _scene: Scene;
  26094. /** @hidden */ private _cache: any;
  26095. private _parentNode;
  26096. private _children;
  26097. /** @hidden */ private _worldMatrix: Matrix;
  26098. /** @hidden */ private _worldMatrixDeterminant: number;
  26099. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26100. /** @hidden */
  26101. private _sceneRootNodesIndex;
  26102. /**
  26103. * Gets a boolean indicating if the node has been disposed
  26104. * @returns true if the node was disposed
  26105. */
  26106. isDisposed(): boolean;
  26107. /**
  26108. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26109. * @see https://doc.babylonjs.com/how_to/parenting
  26110. */
  26111. parent: Nullable<Node>;
  26112. private addToSceneRootNodes;
  26113. private removeFromSceneRootNodes;
  26114. private _animationPropertiesOverride;
  26115. /**
  26116. * Gets or sets the animation properties override
  26117. */
  26118. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26119. /**
  26120. * Gets a string idenfifying the name of the class
  26121. * @returns "Node" string
  26122. */
  26123. getClassName(): string;
  26124. /** @hidden */ protected readonly _isNode: boolean;
  26125. /**
  26126. * An event triggered when the mesh is disposed
  26127. */
  26128. onDisposeObservable: Observable<Node>;
  26129. private _onDisposeObserver;
  26130. /**
  26131. * Sets a callback that will be raised when the node will be disposed
  26132. */
  26133. onDispose: () => void;
  26134. /**
  26135. * Creates a new Node
  26136. * @param name the name and id to be given to this node
  26137. * @param scene the scene this node will be added to
  26138. * @param addToRootNodes the node will be added to scene.rootNodes
  26139. */
  26140. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26141. /**
  26142. * Gets the scene of the node
  26143. * @returns a scene
  26144. */
  26145. getScene(): Scene;
  26146. /**
  26147. * Gets the engine of the node
  26148. * @returns a Engine
  26149. */
  26150. getEngine(): Engine;
  26151. private _behaviors;
  26152. /**
  26153. * Attach a behavior to the node
  26154. * @see http://doc.babylonjs.com/features/behaviour
  26155. * @param behavior defines the behavior to attach
  26156. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26157. * @returns the current Node
  26158. */
  26159. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26160. /**
  26161. * Remove an attached behavior
  26162. * @see http://doc.babylonjs.com/features/behaviour
  26163. * @param behavior defines the behavior to attach
  26164. * @returns the current Node
  26165. */
  26166. removeBehavior(behavior: Behavior<Node>): Node;
  26167. /**
  26168. * Gets the list of attached behaviors
  26169. * @see http://doc.babylonjs.com/features/behaviour
  26170. */
  26171. readonly behaviors: Behavior<Node>[];
  26172. /**
  26173. * Gets an attached behavior by name
  26174. * @param name defines the name of the behavior to look for
  26175. * @see http://doc.babylonjs.com/features/behaviour
  26176. * @returns null if behavior was not found else the requested behavior
  26177. */
  26178. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26179. /**
  26180. * Returns the latest update of the World matrix
  26181. * @returns a Matrix
  26182. */
  26183. getWorldMatrix(): Matrix;
  26184. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26185. /**
  26186. * Returns directly the latest state of the mesh World matrix.
  26187. * A Matrix is returned.
  26188. */
  26189. readonly worldMatrixFromCache: Matrix;
  26190. /** @hidden */ private _initCache(): void;
  26191. /** @hidden */
  26192. updateCache(force?: boolean): void;
  26193. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26194. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26195. /** @hidden */ private _isSynchronized(): boolean;
  26196. /** @hidden */ private _markSyncedWithParent(): void;
  26197. /** @hidden */
  26198. isSynchronizedWithParent(): boolean;
  26199. /** @hidden */
  26200. isSynchronized(): boolean;
  26201. /**
  26202. * Is this node ready to be used/rendered
  26203. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26204. * @return true if the node is ready
  26205. */
  26206. isReady(completeCheck?: boolean): boolean;
  26207. /**
  26208. * Is this node enabled?
  26209. * 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
  26210. * @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
  26211. * @return whether this node (and its parent) is enabled
  26212. */
  26213. isEnabled(checkAncestors?: boolean): boolean;
  26214. /** @hidden */
  26215. protected _syncParentEnabledState(): void;
  26216. /**
  26217. * Set the enabled state of this node
  26218. * @param value defines the new enabled state
  26219. */
  26220. setEnabled(value: boolean): void;
  26221. /**
  26222. * Is this node a descendant of the given node?
  26223. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26224. * @param ancestor defines the parent node to inspect
  26225. * @returns a boolean indicating if this node is a descendant of the given node
  26226. */
  26227. isDescendantOf(ancestor: Node): boolean;
  26228. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26229. /**
  26230. * Will return all nodes that have this node as ascendant
  26231. * @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
  26232. * @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
  26233. * @return all children nodes of all types
  26234. */
  26235. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26236. /**
  26237. * Get all child-meshes of this node
  26238. * @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)
  26239. * @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
  26240. * @returns an array of AbstractMesh
  26241. */
  26242. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26243. /**
  26244. * Get all direct children of this node
  26245. * @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
  26246. * @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)
  26247. * @returns an array of Node
  26248. */
  26249. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26250. /** @hidden */ private _setReady(state: boolean): void;
  26251. /**
  26252. * Get an animation by name
  26253. * @param name defines the name of the animation to look for
  26254. * @returns null if not found else the requested animation
  26255. */
  26256. getAnimationByName(name: string): Nullable<Animation>;
  26257. /**
  26258. * Creates an animation range for this node
  26259. * @param name defines the name of the range
  26260. * @param from defines the starting key
  26261. * @param to defines the end key
  26262. */
  26263. createAnimationRange(name: string, from: number, to: number): void;
  26264. /**
  26265. * Delete a specific animation range
  26266. * @param name defines the name of the range to delete
  26267. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26268. */
  26269. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26270. /**
  26271. * Get an animation range by name
  26272. * @param name defines the name of the animation range to look for
  26273. * @returns null if not found else the requested animation range
  26274. */
  26275. getAnimationRange(name: string): Nullable<AnimationRange>;
  26276. /**
  26277. * Gets the list of all animation ranges defined on this node
  26278. * @returns an array
  26279. */
  26280. getAnimationRanges(): Nullable<AnimationRange>[];
  26281. /**
  26282. * Will start the animation sequence
  26283. * @param name defines the range frames for animation sequence
  26284. * @param loop defines if the animation should loop (false by default)
  26285. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26286. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26287. * @returns the object created for this animation. If range does not exist, it will return null
  26288. */
  26289. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26290. /**
  26291. * Serialize animation ranges into a JSON compatible object
  26292. * @returns serialization object
  26293. */
  26294. serializeAnimationRanges(): any;
  26295. /**
  26296. * Computes the world matrix of the node
  26297. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26298. * @returns the world matrix
  26299. */
  26300. computeWorldMatrix(force?: boolean): Matrix;
  26301. /**
  26302. * Releases resources associated with this node.
  26303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26305. */
  26306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26307. /**
  26308. * Parse animation range data from a serialization object and store them into a given node
  26309. * @param node defines where to store the animation ranges
  26310. * @param parsedNode defines the serialization object to read data from
  26311. * @param scene defines the hosting scene
  26312. */
  26313. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26314. /**
  26315. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26316. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26317. * @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
  26318. * @returns the new bounding vectors
  26319. */
  26320. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26321. min: Vector3;
  26322. max: Vector3;
  26323. };
  26324. }
  26325. }
  26326. declare module BABYLON {
  26327. /**
  26328. * @hidden
  26329. */
  26330. export class _IAnimationState {
  26331. key: number;
  26332. repeatCount: number;
  26333. workValue?: any;
  26334. loopMode?: number;
  26335. offsetValue?: any;
  26336. highLimitValue?: any;
  26337. }
  26338. /**
  26339. * Class used to store any kind of animation
  26340. */
  26341. export class Animation {
  26342. /**Name of the animation */
  26343. name: string;
  26344. /**Property to animate */
  26345. targetProperty: string;
  26346. /**The frames per second of the animation */
  26347. framePerSecond: number;
  26348. /**The data type of the animation */
  26349. dataType: number;
  26350. /**The loop mode of the animation */
  26351. loopMode?: number | undefined;
  26352. /**Specifies if blending should be enabled */
  26353. enableBlending?: boolean | undefined;
  26354. /**
  26355. * Use matrix interpolation instead of using direct key value when animating matrices
  26356. */
  26357. static AllowMatricesInterpolation: boolean;
  26358. /**
  26359. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26360. */
  26361. static AllowMatrixDecomposeForInterpolation: boolean;
  26362. /**
  26363. * Stores the key frames of the animation
  26364. */
  26365. private _keys;
  26366. /**
  26367. * Stores the easing function of the animation
  26368. */
  26369. private _easingFunction;
  26370. /**
  26371. * @hidden Internal use only
  26372. */ private _runtimeAnimations: RuntimeAnimation[];
  26373. /**
  26374. * The set of event that will be linked to this animation
  26375. */
  26376. private _events;
  26377. /**
  26378. * Stores an array of target property paths
  26379. */
  26380. targetPropertyPath: string[];
  26381. /**
  26382. * Stores the blending speed of the animation
  26383. */
  26384. blendingSpeed: number;
  26385. /**
  26386. * Stores the animation ranges for the animation
  26387. */
  26388. private _ranges;
  26389. /**
  26390. * @hidden Internal use
  26391. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26392. /**
  26393. * Sets up an animation
  26394. * @param property The property to animate
  26395. * @param animationType The animation type to apply
  26396. * @param framePerSecond The frames per second of the animation
  26397. * @param easingFunction The easing function used in the animation
  26398. * @returns The created animation
  26399. */
  26400. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26401. /**
  26402. * Create and start an animation on a node
  26403. * @param name defines the name of the global animation that will be run on all nodes
  26404. * @param node defines the root node where the animation will take place
  26405. * @param targetProperty defines property to animate
  26406. * @param framePerSecond defines the number of frame per second yo use
  26407. * @param totalFrame defines the number of frames in total
  26408. * @param from defines the initial value
  26409. * @param to defines the final value
  26410. * @param loopMode defines which loop mode you want to use (off by default)
  26411. * @param easingFunction defines the easing function to use (linear by default)
  26412. * @param onAnimationEnd defines the callback to call when animation end
  26413. * @returns the animatable created for this animation
  26414. */
  26415. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26416. /**
  26417. * Create and start an animation on a node and its descendants
  26418. * @param name defines the name of the global animation that will be run on all nodes
  26419. * @param node defines the root node where the animation will take place
  26420. * @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
  26421. * @param targetProperty defines property to animate
  26422. * @param framePerSecond defines the number of frame per second to use
  26423. * @param totalFrame defines the number of frames in total
  26424. * @param from defines the initial value
  26425. * @param to defines the final value
  26426. * @param loopMode defines which loop mode you want to use (off by default)
  26427. * @param easingFunction defines the easing function to use (linear by default)
  26428. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26429. * @returns the list of animatables created for all nodes
  26430. * @example https://www.babylonjs-playground.com/#MH0VLI
  26431. */
  26432. 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[]>;
  26433. /**
  26434. * Creates a new animation, merges it with the existing animations and starts it
  26435. * @param name Name of the animation
  26436. * @param node Node which contains the scene that begins the animations
  26437. * @param targetProperty Specifies which property to animate
  26438. * @param framePerSecond The frames per second of the animation
  26439. * @param totalFrame The total number of frames
  26440. * @param from The frame at the beginning of the animation
  26441. * @param to The frame at the end of the animation
  26442. * @param loopMode Specifies the loop mode of the animation
  26443. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26444. * @param onAnimationEnd Callback to run once the animation is complete
  26445. * @returns Nullable animation
  26446. */
  26447. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26448. /**
  26449. * Transition property of an host to the target Value
  26450. * @param property The property to transition
  26451. * @param targetValue The target Value of the property
  26452. * @param host The object where the property to animate belongs
  26453. * @param scene Scene used to run the animation
  26454. * @param frameRate Framerate (in frame/s) to use
  26455. * @param transition The transition type we want to use
  26456. * @param duration The duration of the animation, in milliseconds
  26457. * @param onAnimationEnd Callback trigger at the end of the animation
  26458. * @returns Nullable animation
  26459. */
  26460. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26461. /**
  26462. * Return the array of runtime animations currently using this animation
  26463. */
  26464. readonly runtimeAnimations: RuntimeAnimation[];
  26465. /**
  26466. * Specifies if any of the runtime animations are currently running
  26467. */
  26468. readonly hasRunningRuntimeAnimations: boolean;
  26469. /**
  26470. * Initializes the animation
  26471. * @param name Name of the animation
  26472. * @param targetProperty Property to animate
  26473. * @param framePerSecond The frames per second of the animation
  26474. * @param dataType The data type of the animation
  26475. * @param loopMode The loop mode of the animation
  26476. * @param enableBlending Specifies if blending should be enabled
  26477. */
  26478. constructor(
  26479. /**Name of the animation */
  26480. name: string,
  26481. /**Property to animate */
  26482. targetProperty: string,
  26483. /**The frames per second of the animation */
  26484. framePerSecond: number,
  26485. /**The data type of the animation */
  26486. dataType: number,
  26487. /**The loop mode of the animation */
  26488. loopMode?: number | undefined,
  26489. /**Specifies if blending should be enabled */
  26490. enableBlending?: boolean | undefined);
  26491. /**
  26492. * Converts the animation to a string
  26493. * @param fullDetails support for multiple levels of logging within scene loading
  26494. * @returns String form of the animation
  26495. */
  26496. toString(fullDetails?: boolean): string;
  26497. /**
  26498. * Add an event to this animation
  26499. * @param event Event to add
  26500. */
  26501. addEvent(event: AnimationEvent): void;
  26502. /**
  26503. * Remove all events found at the given frame
  26504. * @param frame The frame to remove events from
  26505. */
  26506. removeEvents(frame: number): void;
  26507. /**
  26508. * Retrieves all the events from the animation
  26509. * @returns Events from the animation
  26510. */
  26511. getEvents(): AnimationEvent[];
  26512. /**
  26513. * Creates an animation range
  26514. * @param name Name of the animation range
  26515. * @param from Starting frame of the animation range
  26516. * @param to Ending frame of the animation
  26517. */
  26518. createRange(name: string, from: number, to: number): void;
  26519. /**
  26520. * Deletes an animation range by name
  26521. * @param name Name of the animation range to delete
  26522. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26523. */
  26524. deleteRange(name: string, deleteFrames?: boolean): void;
  26525. /**
  26526. * Gets the animation range by name, or null if not defined
  26527. * @param name Name of the animation range
  26528. * @returns Nullable animation range
  26529. */
  26530. getRange(name: string): Nullable<AnimationRange>;
  26531. /**
  26532. * Gets the key frames from the animation
  26533. * @returns The key frames of the animation
  26534. */
  26535. getKeys(): Array<IAnimationKey>;
  26536. /**
  26537. * Gets the highest frame rate of the animation
  26538. * @returns Highest frame rate of the animation
  26539. */
  26540. getHighestFrame(): number;
  26541. /**
  26542. * Gets the easing function of the animation
  26543. * @returns Easing function of the animation
  26544. */
  26545. getEasingFunction(): IEasingFunction;
  26546. /**
  26547. * Sets the easing function of the animation
  26548. * @param easingFunction A custom mathematical formula for animation
  26549. */
  26550. setEasingFunction(easingFunction: EasingFunction): void;
  26551. /**
  26552. * Interpolates a scalar linearly
  26553. * @param startValue Start value of the animation curve
  26554. * @param endValue End value of the animation curve
  26555. * @param gradient Scalar amount to interpolate
  26556. * @returns Interpolated scalar value
  26557. */
  26558. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26559. /**
  26560. * Interpolates a scalar cubically
  26561. * @param startValue Start value of the animation curve
  26562. * @param outTangent End tangent of the animation
  26563. * @param endValue End value of the animation curve
  26564. * @param inTangent Start tangent of the animation curve
  26565. * @param gradient Scalar amount to interpolate
  26566. * @returns Interpolated scalar value
  26567. */
  26568. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26569. /**
  26570. * Interpolates a quaternion using a spherical linear interpolation
  26571. * @param startValue Start value of the animation curve
  26572. * @param endValue End value of the animation curve
  26573. * @param gradient Scalar amount to interpolate
  26574. * @returns Interpolated quaternion value
  26575. */
  26576. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26577. /**
  26578. * Interpolates a quaternion cubically
  26579. * @param startValue Start value of the animation curve
  26580. * @param outTangent End tangent of the animation curve
  26581. * @param endValue End value of the animation curve
  26582. * @param inTangent Start tangent of the animation curve
  26583. * @param gradient Scalar amount to interpolate
  26584. * @returns Interpolated quaternion value
  26585. */
  26586. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26587. /**
  26588. * Interpolates a Vector3 linearl
  26589. * @param startValue Start value of the animation curve
  26590. * @param endValue End value of the animation curve
  26591. * @param gradient Scalar amount to interpolate
  26592. * @returns Interpolated scalar value
  26593. */
  26594. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26595. /**
  26596. * Interpolates a Vector3 cubically
  26597. * @param startValue Start value of the animation curve
  26598. * @param outTangent End tangent of the animation
  26599. * @param endValue End value of the animation curve
  26600. * @param inTangent Start tangent of the animation curve
  26601. * @param gradient Scalar amount to interpolate
  26602. * @returns InterpolatedVector3 value
  26603. */
  26604. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26605. /**
  26606. * Interpolates a Vector2 linearly
  26607. * @param startValue Start value of the animation curve
  26608. * @param endValue End value of the animation curve
  26609. * @param gradient Scalar amount to interpolate
  26610. * @returns Interpolated Vector2 value
  26611. */
  26612. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26613. /**
  26614. * Interpolates a Vector2 cubically
  26615. * @param startValue Start value of the animation curve
  26616. * @param outTangent End tangent of the animation
  26617. * @param endValue End value of the animation curve
  26618. * @param inTangent Start tangent of the animation curve
  26619. * @param gradient Scalar amount to interpolate
  26620. * @returns Interpolated Vector2 value
  26621. */
  26622. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26623. /**
  26624. * Interpolates a size linearly
  26625. * @param startValue Start value of the animation curve
  26626. * @param endValue End value of the animation curve
  26627. * @param gradient Scalar amount to interpolate
  26628. * @returns Interpolated Size value
  26629. */
  26630. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26631. /**
  26632. * Interpolates a Color3 linearly
  26633. * @param startValue Start value of the animation curve
  26634. * @param endValue End value of the animation curve
  26635. * @param gradient Scalar amount to interpolate
  26636. * @returns Interpolated Color3 value
  26637. */
  26638. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26639. /**
  26640. * @hidden Internal use only
  26641. */ private _getKeyValue(value: any): any;
  26642. /**
  26643. * @hidden Internal use only
  26644. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26645. /**
  26646. * Defines the function to use to interpolate matrices
  26647. * @param startValue defines the start matrix
  26648. * @param endValue defines the end matrix
  26649. * @param gradient defines the gradient between both matrices
  26650. * @param result defines an optional target matrix where to store the interpolation
  26651. * @returns the interpolated matrix
  26652. */
  26653. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26654. /**
  26655. * Makes a copy of the animation
  26656. * @returns Cloned animation
  26657. */
  26658. clone(): Animation;
  26659. /**
  26660. * Sets the key frames of the animation
  26661. * @param values The animation key frames to set
  26662. */
  26663. setKeys(values: Array<IAnimationKey>): void;
  26664. /**
  26665. * Serializes the animation to an object
  26666. * @returns Serialized object
  26667. */
  26668. serialize(): any;
  26669. /**
  26670. * Float animation type
  26671. */
  26672. private static _ANIMATIONTYPE_FLOAT;
  26673. /**
  26674. * Vector3 animation type
  26675. */
  26676. private static _ANIMATIONTYPE_VECTOR3;
  26677. /**
  26678. * Quaternion animation type
  26679. */
  26680. private static _ANIMATIONTYPE_QUATERNION;
  26681. /**
  26682. * Matrix animation type
  26683. */
  26684. private static _ANIMATIONTYPE_MATRIX;
  26685. /**
  26686. * Color3 animation type
  26687. */
  26688. private static _ANIMATIONTYPE_COLOR3;
  26689. /**
  26690. * Vector2 animation type
  26691. */
  26692. private static _ANIMATIONTYPE_VECTOR2;
  26693. /**
  26694. * Size animation type
  26695. */
  26696. private static _ANIMATIONTYPE_SIZE;
  26697. /**
  26698. * Relative Loop Mode
  26699. */
  26700. private static _ANIMATIONLOOPMODE_RELATIVE;
  26701. /**
  26702. * Cycle Loop Mode
  26703. */
  26704. private static _ANIMATIONLOOPMODE_CYCLE;
  26705. /**
  26706. * Constant Loop Mode
  26707. */
  26708. private static _ANIMATIONLOOPMODE_CONSTANT;
  26709. /**
  26710. * Get the float animation type
  26711. */
  26712. static readonly ANIMATIONTYPE_FLOAT: number;
  26713. /**
  26714. * Get the Vector3 animation type
  26715. */
  26716. static readonly ANIMATIONTYPE_VECTOR3: number;
  26717. /**
  26718. * Get the Vector2 animation type
  26719. */
  26720. static readonly ANIMATIONTYPE_VECTOR2: number;
  26721. /**
  26722. * Get the Size animation type
  26723. */
  26724. static readonly ANIMATIONTYPE_SIZE: number;
  26725. /**
  26726. * Get the Quaternion animation type
  26727. */
  26728. static readonly ANIMATIONTYPE_QUATERNION: number;
  26729. /**
  26730. * Get the Matrix animation type
  26731. */
  26732. static readonly ANIMATIONTYPE_MATRIX: number;
  26733. /**
  26734. * Get the Color3 animation type
  26735. */
  26736. static readonly ANIMATIONTYPE_COLOR3: number;
  26737. /**
  26738. * Get the Relative Loop Mode
  26739. */
  26740. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26741. /**
  26742. * Get the Cycle Loop Mode
  26743. */
  26744. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26745. /**
  26746. * Get the Constant Loop Mode
  26747. */
  26748. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26749. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26750. /**
  26751. * Parses an animation object and creates an animation
  26752. * @param parsedAnimation Parsed animation object
  26753. * @returns Animation object
  26754. */
  26755. static Parse(parsedAnimation: any): Animation;
  26756. /**
  26757. * Appends the serialized animations from the source animations
  26758. * @param source Source containing the animations
  26759. * @param destination Target to store the animations
  26760. */
  26761. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26762. }
  26763. }
  26764. declare module BABYLON {
  26765. /**
  26766. * Interface containing an array of animations
  26767. */
  26768. export interface IAnimatable {
  26769. /**
  26770. * Array of animations
  26771. */
  26772. animations: Nullable<Array<Animation>>;
  26773. }
  26774. }
  26775. declare module BABYLON {
  26776. /**
  26777. * This represents all the required information to add a fresnel effect on a material:
  26778. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26779. */
  26780. export class FresnelParameters {
  26781. private _isEnabled;
  26782. /**
  26783. * Define if the fresnel effect is enable or not.
  26784. */
  26785. isEnabled: boolean;
  26786. /**
  26787. * Define the color used on edges (grazing angle)
  26788. */
  26789. leftColor: Color3;
  26790. /**
  26791. * Define the color used on center
  26792. */
  26793. rightColor: Color3;
  26794. /**
  26795. * Define bias applied to computed fresnel term
  26796. */
  26797. bias: number;
  26798. /**
  26799. * Defined the power exponent applied to fresnel term
  26800. */
  26801. power: number;
  26802. /**
  26803. * Clones the current fresnel and its valuues
  26804. * @returns a clone fresnel configuration
  26805. */
  26806. clone(): FresnelParameters;
  26807. /**
  26808. * Serializes the current fresnel parameters to a JSON representation.
  26809. * @return the JSON serialization
  26810. */
  26811. serialize(): any;
  26812. /**
  26813. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26814. * @param parsedFresnelParameters Define the JSON representation
  26815. * @returns the parsed parameters
  26816. */
  26817. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26818. }
  26819. }
  26820. declare module BABYLON {
  26821. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26822. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26823. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26824. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26825. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26826. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26827. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26828. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26829. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26830. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26831. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26832. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26833. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26834. /**
  26835. * Decorator used to define property that can be serialized as reference to a camera
  26836. * @param sourceName defines the name of the property to decorate
  26837. */
  26838. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26839. /**
  26840. * Class used to help serialization objects
  26841. */
  26842. export class SerializationHelper {
  26843. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  26844. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  26845. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  26846. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  26847. /**
  26848. * Appends the serialized animations from the source animations
  26849. * @param source Source containing the animations
  26850. * @param destination Target to store the animations
  26851. */
  26852. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26853. /**
  26854. * Static function used to serialized a specific entity
  26855. * @param entity defines the entity to serialize
  26856. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  26857. * @returns a JSON compatible object representing the serialization of the entity
  26858. */
  26859. static Serialize<T>(entity: T, serializationObject?: any): any;
  26860. /**
  26861. * Creates a new entity from a serialization data object
  26862. * @param creationFunction defines a function used to instanciated the new entity
  26863. * @param source defines the source serialization data
  26864. * @param scene defines the hosting scene
  26865. * @param rootUrl defines the root url for resources
  26866. * @returns a new entity
  26867. */
  26868. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26869. /**
  26870. * Clones an object
  26871. * @param creationFunction defines the function used to instanciate the new object
  26872. * @param source defines the source object
  26873. * @returns the cloned object
  26874. */
  26875. static Clone<T>(creationFunction: () => T, source: T): T;
  26876. /**
  26877. * Instanciates a new object based on a source one (some data will be shared between both object)
  26878. * @param creationFunction defines the function used to instanciate the new object
  26879. * @param source defines the source object
  26880. * @returns the new object
  26881. */
  26882. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26883. }
  26884. }
  26885. declare module BABYLON {
  26886. /**
  26887. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26888. */
  26889. export interface CubeMapInfo {
  26890. /**
  26891. * The pixel array for the front face.
  26892. * This is stored in format, left to right, up to down format.
  26893. */
  26894. front: Nullable<ArrayBufferView>;
  26895. /**
  26896. * The pixel array for the back face.
  26897. * This is stored in format, left to right, up to down format.
  26898. */
  26899. back: Nullable<ArrayBufferView>;
  26900. /**
  26901. * The pixel array for the left face.
  26902. * This is stored in format, left to right, up to down format.
  26903. */
  26904. left: Nullable<ArrayBufferView>;
  26905. /**
  26906. * The pixel array for the right face.
  26907. * This is stored in format, left to right, up to down format.
  26908. */
  26909. right: Nullable<ArrayBufferView>;
  26910. /**
  26911. * The pixel array for the up face.
  26912. * This is stored in format, left to right, up to down format.
  26913. */
  26914. up: Nullable<ArrayBufferView>;
  26915. /**
  26916. * The pixel array for the down face.
  26917. * This is stored in format, left to right, up to down format.
  26918. */
  26919. down: Nullable<ArrayBufferView>;
  26920. /**
  26921. * The size of the cubemap stored.
  26922. *
  26923. * Each faces will be size * size pixels.
  26924. */
  26925. size: number;
  26926. /**
  26927. * The format of the texture.
  26928. *
  26929. * RGBA, RGB.
  26930. */
  26931. format: number;
  26932. /**
  26933. * The type of the texture data.
  26934. *
  26935. * UNSIGNED_INT, FLOAT.
  26936. */
  26937. type: number;
  26938. /**
  26939. * Specifies whether the texture is in gamma space.
  26940. */
  26941. gammaSpace: boolean;
  26942. }
  26943. /**
  26944. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26945. */
  26946. export class PanoramaToCubeMapTools {
  26947. private static FACE_FRONT;
  26948. private static FACE_BACK;
  26949. private static FACE_RIGHT;
  26950. private static FACE_LEFT;
  26951. private static FACE_DOWN;
  26952. private static FACE_UP;
  26953. /**
  26954. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26955. *
  26956. * @param float32Array The source data.
  26957. * @param inputWidth The width of the input panorama.
  26958. * @param inputHeight The height of the input panorama.
  26959. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26960. * @return The cubemap data
  26961. */
  26962. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26963. private static CreateCubemapTexture;
  26964. private static CalcProjectionSpherical;
  26965. }
  26966. }
  26967. declare module BABYLON {
  26968. /**
  26969. * Helper class dealing with the extraction of spherical polynomial dataArray
  26970. * from a cube map.
  26971. */
  26972. export class CubeMapToSphericalPolynomialTools {
  26973. private static FileFaces;
  26974. /**
  26975. * Converts a texture to the according Spherical Polynomial data.
  26976. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26977. *
  26978. * @param texture The texture to extract the information from.
  26979. * @return The Spherical Polynomial data.
  26980. */
  26981. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26982. /**
  26983. * Converts a cubemap to the according Spherical Polynomial data.
  26984. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26985. *
  26986. * @param cubeInfo The Cube map to extract the information from.
  26987. * @return The Spherical Polynomial data.
  26988. */
  26989. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26990. }
  26991. }
  26992. declare module BABYLON {
  26993. /**
  26994. * Class used to manipulate GUIDs
  26995. */
  26996. export class GUID {
  26997. /**
  26998. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26999. * Be aware Math.random() could cause collisions, but:
  27000. * "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"
  27001. * @returns a pseudo random id
  27002. */
  27003. static RandomId(): string;
  27004. }
  27005. }
  27006. declare module BABYLON {
  27007. /**
  27008. * Base class of all the textures in babylon.
  27009. * It groups all the common properties the materials, post process, lights... might need
  27010. * in order to make a correct use of the texture.
  27011. */
  27012. export class BaseTexture implements IAnimatable {
  27013. /**
  27014. * Default anisotropic filtering level for the application.
  27015. * It is set to 4 as a good tradeoff between perf and quality.
  27016. */
  27017. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27018. /**
  27019. * Gets or sets the unique id of the texture
  27020. */
  27021. uniqueId: number;
  27022. /**
  27023. * Define the name of the texture.
  27024. */
  27025. name: string;
  27026. /**
  27027. * Gets or sets an object used to store user defined information.
  27028. */
  27029. metadata: any;
  27030. /**
  27031. * For internal use only. Please do not use.
  27032. */
  27033. reservedDataStore: any;
  27034. private _hasAlpha;
  27035. /**
  27036. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27037. */
  27038. hasAlpha: boolean;
  27039. /**
  27040. * Defines if the alpha value should be determined via the rgb values.
  27041. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27042. */
  27043. getAlphaFromRGB: boolean;
  27044. /**
  27045. * Intensity or strength of the texture.
  27046. * It is commonly used by materials to fine tune the intensity of the texture
  27047. */
  27048. level: number;
  27049. /**
  27050. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27051. * This is part of the texture as textures usually maps to one uv set.
  27052. */
  27053. coordinatesIndex: number;
  27054. private _coordinatesMode;
  27055. /**
  27056. * How a texture is mapped.
  27057. *
  27058. * | Value | Type | Description |
  27059. * | ----- | ----------------------------------- | ----------- |
  27060. * | 0 | EXPLICIT_MODE | |
  27061. * | 1 | SPHERICAL_MODE | |
  27062. * | 2 | PLANAR_MODE | |
  27063. * | 3 | CUBIC_MODE | |
  27064. * | 4 | PROJECTION_MODE | |
  27065. * | 5 | SKYBOX_MODE | |
  27066. * | 6 | INVCUBIC_MODE | |
  27067. * | 7 | EQUIRECTANGULAR_MODE | |
  27068. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27069. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27070. */
  27071. coordinatesMode: number;
  27072. /**
  27073. * | Value | Type | Description |
  27074. * | ----- | ------------------ | ----------- |
  27075. * | 0 | CLAMP_ADDRESSMODE | |
  27076. * | 1 | WRAP_ADDRESSMODE | |
  27077. * | 2 | MIRROR_ADDRESSMODE | |
  27078. */
  27079. wrapU: number;
  27080. /**
  27081. * | Value | Type | Description |
  27082. * | ----- | ------------------ | ----------- |
  27083. * | 0 | CLAMP_ADDRESSMODE | |
  27084. * | 1 | WRAP_ADDRESSMODE | |
  27085. * | 2 | MIRROR_ADDRESSMODE | |
  27086. */
  27087. wrapV: number;
  27088. /**
  27089. * | Value | Type | Description |
  27090. * | ----- | ------------------ | ----------- |
  27091. * | 0 | CLAMP_ADDRESSMODE | |
  27092. * | 1 | WRAP_ADDRESSMODE | |
  27093. * | 2 | MIRROR_ADDRESSMODE | |
  27094. */
  27095. wrapR: number;
  27096. /**
  27097. * With compliant hardware and browser (supporting anisotropic filtering)
  27098. * this defines the level of anisotropic filtering in the texture.
  27099. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27100. */
  27101. anisotropicFilteringLevel: number;
  27102. /**
  27103. * Define if the texture is a cube texture or if false a 2d texture.
  27104. */
  27105. isCube: boolean;
  27106. /**
  27107. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27108. */
  27109. is3D: boolean;
  27110. /**
  27111. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27112. * HDR texture are usually stored in linear space.
  27113. * This only impacts the PBR and Background materials
  27114. */
  27115. gammaSpace: boolean;
  27116. /**
  27117. * Gets whether or not the texture contains RGBD data.
  27118. */
  27119. readonly isRGBD: boolean;
  27120. /**
  27121. * Is Z inverted in the texture (useful in a cube texture).
  27122. */
  27123. invertZ: boolean;
  27124. /**
  27125. * Are mip maps generated for this texture or not.
  27126. */
  27127. readonly noMipmap: boolean;
  27128. /**
  27129. * @hidden
  27130. */
  27131. lodLevelInAlpha: boolean;
  27132. /**
  27133. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27134. */
  27135. lodGenerationOffset: number;
  27136. /**
  27137. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27138. */
  27139. lodGenerationScale: number;
  27140. /**
  27141. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27142. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27143. * average roughness values.
  27144. */
  27145. linearSpecularLOD: boolean;
  27146. /**
  27147. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27148. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27149. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27150. */
  27151. irradianceTexture: Nullable<BaseTexture>;
  27152. /**
  27153. * Define if the texture is a render target.
  27154. */
  27155. isRenderTarget: boolean;
  27156. /**
  27157. * Define the unique id of the texture in the scene.
  27158. */
  27159. readonly uid: string;
  27160. /**
  27161. * Return a string representation of the texture.
  27162. * @returns the texture as a string
  27163. */
  27164. toString(): string;
  27165. /**
  27166. * Get the class name of the texture.
  27167. * @returns "BaseTexture"
  27168. */
  27169. getClassName(): string;
  27170. /**
  27171. * Define the list of animation attached to the texture.
  27172. */
  27173. animations: Animation[];
  27174. /**
  27175. * An event triggered when the texture is disposed.
  27176. */
  27177. onDisposeObservable: Observable<BaseTexture>;
  27178. private _onDisposeObserver;
  27179. /**
  27180. * Callback triggered when the texture has been disposed.
  27181. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27182. */
  27183. onDispose: () => void;
  27184. /**
  27185. * Define the current state of the loading sequence when in delayed load mode.
  27186. */
  27187. delayLoadState: number;
  27188. private _scene;
  27189. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27190. private _uid;
  27191. /**
  27192. * Define if the texture is preventinga material to render or not.
  27193. * If not and the texture is not ready, the engine will use a default black texture instead.
  27194. */
  27195. readonly isBlocking: boolean;
  27196. /**
  27197. * Instantiates a new BaseTexture.
  27198. * Base class of all the textures in babylon.
  27199. * It groups all the common properties the materials, post process, lights... might need
  27200. * in order to make a correct use of the texture.
  27201. * @param scene Define the scene the texture blongs to
  27202. */
  27203. constructor(scene: Nullable<Scene>);
  27204. /**
  27205. * Get the scene the texture belongs to.
  27206. * @returns the scene or null if undefined
  27207. */
  27208. getScene(): Nullable<Scene>;
  27209. /**
  27210. * Get the texture transform matrix used to offset tile the texture for istance.
  27211. * @returns the transformation matrix
  27212. */
  27213. getTextureMatrix(): Matrix;
  27214. /**
  27215. * Get the texture reflection matrix used to rotate/transform the reflection.
  27216. * @returns the reflection matrix
  27217. */
  27218. getReflectionTextureMatrix(): Matrix;
  27219. /**
  27220. * Get the underlying lower level texture from Babylon.
  27221. * @returns the insternal texture
  27222. */
  27223. getInternalTexture(): Nullable<InternalTexture>;
  27224. /**
  27225. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27226. * @returns true if ready or not blocking
  27227. */
  27228. isReadyOrNotBlocking(): boolean;
  27229. /**
  27230. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27231. * @returns true if fully ready
  27232. */
  27233. isReady(): boolean;
  27234. private _cachedSize;
  27235. /**
  27236. * Get the size of the texture.
  27237. * @returns the texture size.
  27238. */
  27239. getSize(): ISize;
  27240. /**
  27241. * Get the base size of the texture.
  27242. * It can be different from the size if the texture has been resized for POT for instance
  27243. * @returns the base size
  27244. */
  27245. getBaseSize(): ISize;
  27246. /**
  27247. * Update the sampling mode of the texture.
  27248. * Default is Trilinear mode.
  27249. *
  27250. * | Value | Type | Description |
  27251. * | ----- | ------------------ | ----------- |
  27252. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27253. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27254. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27255. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27256. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27257. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27258. * | 7 | NEAREST_LINEAR | |
  27259. * | 8 | NEAREST_NEAREST | |
  27260. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27261. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27262. * | 11 | LINEAR_LINEAR | |
  27263. * | 12 | LINEAR_NEAREST | |
  27264. *
  27265. * > _mag_: magnification filter (close to the viewer)
  27266. * > _min_: minification filter (far from the viewer)
  27267. * > _mip_: filter used between mip map levels
  27268. *@param samplingMode Define the new sampling mode of the texture
  27269. */
  27270. updateSamplingMode(samplingMode: number): void;
  27271. /**
  27272. * Scales the texture if is `canRescale()`
  27273. * @param ratio the resize factor we want to use to rescale
  27274. */
  27275. scale(ratio: number): void;
  27276. /**
  27277. * Get if the texture can rescale.
  27278. */
  27279. readonly canRescale: boolean;
  27280. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27281. /** @hidden */ private _rebuild(): void;
  27282. /**
  27283. * Triggers the load sequence in delayed load mode.
  27284. */
  27285. delayLoad(): void;
  27286. /**
  27287. * Clones the texture.
  27288. * @returns the cloned texture
  27289. */
  27290. clone(): Nullable<BaseTexture>;
  27291. /**
  27292. * Get the texture underlying type (INT, FLOAT...)
  27293. */
  27294. readonly textureType: number;
  27295. /**
  27296. * Get the texture underlying format (RGB, RGBA...)
  27297. */
  27298. readonly textureFormat: number;
  27299. /**
  27300. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27301. * This will returns an RGBA array buffer containing either in values (0-255) or
  27302. * float values (0-1) depending of the underlying buffer type.
  27303. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27304. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27305. * @param buffer defines a user defined buffer to fill with data (can be null)
  27306. * @returns The Array buffer containing the pixels data.
  27307. */
  27308. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27309. /**
  27310. * Release and destroy the underlying lower level texture aka internalTexture.
  27311. */
  27312. releaseInternalTexture(): void;
  27313. /**
  27314. * Get the polynomial representation of the texture data.
  27315. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27316. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27317. */
  27318. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27319. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27320. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27321. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27322. /**
  27323. * Dispose the texture and release its associated resources.
  27324. */
  27325. dispose(): void;
  27326. /**
  27327. * Serialize the texture into a JSON representation that can be parsed later on.
  27328. * @returns the JSON representation of the texture
  27329. */
  27330. serialize(): any;
  27331. /**
  27332. * Helper function to be called back once a list of texture contains only ready textures.
  27333. * @param textures Define the list of textures to wait for
  27334. * @param callback Define the callback triggered once the entire list will be ready
  27335. */
  27336. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27337. }
  27338. }
  27339. declare module BABYLON {
  27340. /**
  27341. * Class used to store data associated with WebGL texture data for the engine
  27342. * This class should not be used directly
  27343. */
  27344. export class InternalTexture {
  27345. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27346. /**
  27347. * The source of the texture data is unknown
  27348. */
  27349. static DATASOURCE_UNKNOWN: number;
  27350. /**
  27351. * Texture data comes from an URL
  27352. */
  27353. static DATASOURCE_URL: number;
  27354. /**
  27355. * Texture data is only used for temporary storage
  27356. */
  27357. static DATASOURCE_TEMP: number;
  27358. /**
  27359. * Texture data comes from raw data (ArrayBuffer)
  27360. */
  27361. static DATASOURCE_RAW: number;
  27362. /**
  27363. * Texture content is dynamic (video or dynamic texture)
  27364. */
  27365. static DATASOURCE_DYNAMIC: number;
  27366. /**
  27367. * Texture content is generated by rendering to it
  27368. */
  27369. static DATASOURCE_RENDERTARGET: number;
  27370. /**
  27371. * Texture content is part of a multi render target process
  27372. */
  27373. static DATASOURCE_MULTIRENDERTARGET: number;
  27374. /**
  27375. * Texture data comes from a cube data file
  27376. */
  27377. static DATASOURCE_CUBE: number;
  27378. /**
  27379. * Texture data comes from a raw cube data
  27380. */
  27381. static DATASOURCE_CUBERAW: number;
  27382. /**
  27383. * Texture data come from a prefiltered cube data file
  27384. */
  27385. static DATASOURCE_CUBEPREFILTERED: number;
  27386. /**
  27387. * Texture content is raw 3D data
  27388. */
  27389. static DATASOURCE_RAW3D: number;
  27390. /**
  27391. * Texture content is a depth texture
  27392. */
  27393. static DATASOURCE_DEPTHTEXTURE: number;
  27394. /**
  27395. * Texture data comes from a raw cube data encoded with RGBD
  27396. */
  27397. static DATASOURCE_CUBERAW_RGBD: number;
  27398. /**
  27399. * Defines if the texture is ready
  27400. */
  27401. isReady: boolean;
  27402. /**
  27403. * Defines if the texture is a cube texture
  27404. */
  27405. isCube: boolean;
  27406. /**
  27407. * Defines if the texture contains 3D data
  27408. */
  27409. is3D: boolean;
  27410. /**
  27411. * Defines if the texture contains multiview data
  27412. */
  27413. isMultiview: boolean;
  27414. /**
  27415. * Gets the URL used to load this texture
  27416. */
  27417. url: string;
  27418. /**
  27419. * Gets the sampling mode of the texture
  27420. */
  27421. samplingMode: number;
  27422. /**
  27423. * Gets a boolean indicating if the texture needs mipmaps generation
  27424. */
  27425. generateMipMaps: boolean;
  27426. /**
  27427. * Gets the number of samples used by the texture (WebGL2+ only)
  27428. */
  27429. samples: number;
  27430. /**
  27431. * Gets the type of the texture (int, float...)
  27432. */
  27433. type: number;
  27434. /**
  27435. * Gets the format of the texture (RGB, RGBA...)
  27436. */
  27437. format: number;
  27438. /**
  27439. * Observable called when the texture is loaded
  27440. */
  27441. onLoadedObservable: Observable<InternalTexture>;
  27442. /**
  27443. * Gets the width of the texture
  27444. */
  27445. width: number;
  27446. /**
  27447. * Gets the height of the texture
  27448. */
  27449. height: number;
  27450. /**
  27451. * Gets the depth of the texture
  27452. */
  27453. depth: number;
  27454. /**
  27455. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27456. */
  27457. baseWidth: number;
  27458. /**
  27459. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27460. */
  27461. baseHeight: number;
  27462. /**
  27463. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27464. */
  27465. baseDepth: number;
  27466. /**
  27467. * Gets a boolean indicating if the texture is inverted on Y axis
  27468. */
  27469. invertY: boolean;
  27470. /** @hidden */ private _invertVScale: boolean;
  27471. /** @hidden */ private _associatedChannel: number;
  27472. /** @hidden */ private _dataSource: number;
  27473. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27474. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27475. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27476. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27477. /** @hidden */ private _size: number;
  27478. /** @hidden */ private _extension: string;
  27479. /** @hidden */ private _files: Nullable<string[]>;
  27480. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27481. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27482. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27483. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27484. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27485. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27486. /** @hidden */ private _attachments: Nullable<number[]>;
  27487. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27488. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27489. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27490. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27491. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27492. /** @hidden */ private _isDisabled: boolean;
  27493. /** @hidden */ private _compression: Nullable<string>;
  27494. /** @hidden */ private _generateStencilBuffer: boolean;
  27495. /** @hidden */ private _generateDepthBuffer: boolean;
  27496. /** @hidden */ private _comparisonFunction: number;
  27497. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27498. /** @hidden */ private _lodGenerationScale: number;
  27499. /** @hidden */ private _lodGenerationOffset: number;
  27500. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27501. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27502. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27503. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27504. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27505. /** @hidden */ private _isRGBD: boolean;
  27506. /** @hidden */ private _linearSpecularLOD: boolean;
  27507. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27508. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27509. /** @hidden */ private _references: number;
  27510. private _engine;
  27511. /**
  27512. * Gets the Engine the texture belongs to.
  27513. * @returns The babylon engine
  27514. */
  27515. getEngine(): Engine;
  27516. /**
  27517. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27518. */
  27519. readonly dataSource: number;
  27520. /**
  27521. * Creates a new InternalTexture
  27522. * @param engine defines the engine to use
  27523. * @param dataSource defines the type of data that will be used
  27524. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27525. */
  27526. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27527. /**
  27528. * Increments the number of references (ie. the number of Texture that point to it)
  27529. */
  27530. incrementReferences(): void;
  27531. /**
  27532. * Change the size of the texture (not the size of the content)
  27533. * @param width defines the new width
  27534. * @param height defines the new height
  27535. * @param depth defines the new depth (1 by default)
  27536. */
  27537. updateSize(width: int, height: int, depth?: int): void;
  27538. /** @hidden */ private _rebuild(): void;
  27539. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27540. /**
  27541. * Dispose the current allocated resources
  27542. */
  27543. dispose(): void;
  27544. }
  27545. }
  27546. declare module BABYLON {
  27547. /**
  27548. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27549. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27550. */
  27551. export class EffectFallbacks {
  27552. private _defines;
  27553. private _currentRank;
  27554. private _maxRank;
  27555. private _mesh;
  27556. /**
  27557. * Removes the fallback from the bound mesh.
  27558. */
  27559. unBindMesh(): void;
  27560. /**
  27561. * Adds a fallback on the specified property.
  27562. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27563. * @param define The name of the define in the shader
  27564. */
  27565. addFallback(rank: number, define: string): void;
  27566. /**
  27567. * Sets the mesh to use CPU skinning when needing to fallback.
  27568. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27569. * @param mesh The mesh to use the fallbacks.
  27570. */
  27571. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27572. /**
  27573. * Checks to see if more fallbacks are still availible.
  27574. */
  27575. readonly isMoreFallbacks: boolean;
  27576. /**
  27577. * Removes the defines that should be removed when falling back.
  27578. * @param currentDefines defines the current define statements for the shader.
  27579. * @param effect defines the current effect we try to compile
  27580. * @returns The resulting defines with defines of the current rank removed.
  27581. */
  27582. reduce(currentDefines: string, effect: Effect): string;
  27583. }
  27584. /**
  27585. * Options to be used when creating an effect.
  27586. */
  27587. export class EffectCreationOptions {
  27588. /**
  27589. * Atrributes that will be used in the shader.
  27590. */
  27591. attributes: string[];
  27592. /**
  27593. * Uniform varible names that will be set in the shader.
  27594. */
  27595. uniformsNames: string[];
  27596. /**
  27597. * Uniform buffer varible names that will be set in the shader.
  27598. */
  27599. uniformBuffersNames: string[];
  27600. /**
  27601. * Sampler texture variable names that will be set in the shader.
  27602. */
  27603. samplers: string[];
  27604. /**
  27605. * Define statements that will be set in the shader.
  27606. */
  27607. defines: any;
  27608. /**
  27609. * Possible fallbacks for this effect to improve performance when needed.
  27610. */
  27611. fallbacks: Nullable<EffectFallbacks>;
  27612. /**
  27613. * Callback that will be called when the shader is compiled.
  27614. */
  27615. onCompiled: Nullable<(effect: Effect) => void>;
  27616. /**
  27617. * Callback that will be called if an error occurs during shader compilation.
  27618. */
  27619. onError: Nullable<(effect: Effect, errors: string) => void>;
  27620. /**
  27621. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27622. */
  27623. indexParameters: any;
  27624. /**
  27625. * Max number of lights that can be used in the shader.
  27626. */
  27627. maxSimultaneousLights: number;
  27628. /**
  27629. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27630. */
  27631. transformFeedbackVaryings: Nullable<string[]>;
  27632. }
  27633. /**
  27634. * Effect containing vertex and fragment shader that can be executed on an object.
  27635. */
  27636. export class Effect implements IDisposable {
  27637. /**
  27638. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27639. */
  27640. static ShadersRepository: string;
  27641. /**
  27642. * Name of the effect.
  27643. */
  27644. name: any;
  27645. /**
  27646. * String container all the define statements that should be set on the shader.
  27647. */
  27648. defines: string;
  27649. /**
  27650. * Callback that will be called when the shader is compiled.
  27651. */
  27652. onCompiled: Nullable<(effect: Effect) => void>;
  27653. /**
  27654. * Callback that will be called if an error occurs during shader compilation.
  27655. */
  27656. onError: Nullable<(effect: Effect, errors: string) => void>;
  27657. /**
  27658. * Callback that will be called when effect is bound.
  27659. */
  27660. onBind: Nullable<(effect: Effect) => void>;
  27661. /**
  27662. * Unique ID of the effect.
  27663. */
  27664. uniqueId: number;
  27665. /**
  27666. * Observable that will be called when the shader is compiled.
  27667. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27668. */
  27669. onCompileObservable: Observable<Effect>;
  27670. /**
  27671. * Observable that will be called if an error occurs during shader compilation.
  27672. */
  27673. onErrorObservable: Observable<Effect>;
  27674. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27675. /**
  27676. * Observable that will be called when effect is bound.
  27677. */
  27678. readonly onBindObservable: Observable<Effect>;
  27679. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27680. private static _uniqueIdSeed;
  27681. private _engine;
  27682. private _uniformBuffersNames;
  27683. private _uniformsNames;
  27684. private _samplerList;
  27685. private _samplers;
  27686. private _isReady;
  27687. private _compilationError;
  27688. private _attributesNames;
  27689. private _attributes;
  27690. private _uniforms;
  27691. /**
  27692. * Key for the effect.
  27693. * @hidden
  27694. */ private _key: string;
  27695. private _indexParameters;
  27696. private _fallbacks;
  27697. private _vertexSourceCode;
  27698. private _fragmentSourceCode;
  27699. private _vertexSourceCodeOverride;
  27700. private _fragmentSourceCodeOverride;
  27701. private _transformFeedbackVaryings;
  27702. /**
  27703. * Compiled shader to webGL program.
  27704. * @hidden
  27705. */ private _pipelineContext: Nullable<IPipelineContext>;
  27706. private _valueCache;
  27707. private static _baseCache;
  27708. /**
  27709. * Instantiates an effect.
  27710. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27711. * @param baseName Name of the effect.
  27712. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27713. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27714. * @param samplers List of sampler variables that will be passed to the shader.
  27715. * @param engine Engine to be used to render the effect
  27716. * @param defines Define statements to be added to the shader.
  27717. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27718. * @param onCompiled Callback that will be called when the shader is compiled.
  27719. * @param onError Callback that will be called if an error occurs during shader compilation.
  27720. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27721. */
  27722. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27723. private _useFinalCode;
  27724. /**
  27725. * Unique key for this effect
  27726. */
  27727. readonly key: string;
  27728. /**
  27729. * If the effect has been compiled and prepared.
  27730. * @returns if the effect is compiled and prepared.
  27731. */
  27732. isReady(): boolean;
  27733. /**
  27734. * The engine the effect was initialized with.
  27735. * @returns the engine.
  27736. */
  27737. getEngine(): Engine;
  27738. /**
  27739. * The pipeline context for this effect
  27740. * @returns the associated pipeline context
  27741. */
  27742. getPipelineContext(): Nullable<IPipelineContext>;
  27743. /**
  27744. * The set of names of attribute variables for the shader.
  27745. * @returns An array of attribute names.
  27746. */
  27747. getAttributesNames(): string[];
  27748. /**
  27749. * Returns the attribute at the given index.
  27750. * @param index The index of the attribute.
  27751. * @returns The location of the attribute.
  27752. */
  27753. getAttributeLocation(index: number): number;
  27754. /**
  27755. * Returns the attribute based on the name of the variable.
  27756. * @param name of the attribute to look up.
  27757. * @returns the attribute location.
  27758. */
  27759. getAttributeLocationByName(name: string): number;
  27760. /**
  27761. * The number of attributes.
  27762. * @returns the numnber of attributes.
  27763. */
  27764. getAttributesCount(): number;
  27765. /**
  27766. * Gets the index of a uniform variable.
  27767. * @param uniformName of the uniform to look up.
  27768. * @returns the index.
  27769. */
  27770. getUniformIndex(uniformName: string): number;
  27771. /**
  27772. * Returns the attribute based on the name of the variable.
  27773. * @param uniformName of the uniform to look up.
  27774. * @returns the location of the uniform.
  27775. */
  27776. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27777. /**
  27778. * Returns an array of sampler variable names
  27779. * @returns The array of sampler variable neames.
  27780. */
  27781. getSamplers(): string[];
  27782. /**
  27783. * The error from the last compilation.
  27784. * @returns the error string.
  27785. */
  27786. getCompilationError(): string;
  27787. /**
  27788. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27789. * @param func The callback to be used.
  27790. */
  27791. executeWhenCompiled(func: (effect: Effect) => void): void;
  27792. private _checkIsReady;
  27793. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27794. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27795. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27796. /**
  27797. * Recompiles the webGL program
  27798. * @param vertexSourceCode The source code for the vertex shader.
  27799. * @param fragmentSourceCode The source code for the fragment shader.
  27800. * @param onCompiled Callback called when completed.
  27801. * @param onError Callback called on error.
  27802. * @hidden
  27803. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27804. /**
  27805. * Prepares the effect
  27806. * @hidden
  27807. */ private _prepareEffect(): void;
  27808. /**
  27809. * Checks if the effect is supported. (Must be called after compilation)
  27810. */
  27811. readonly isSupported: boolean;
  27812. /**
  27813. * Binds a texture to the engine to be used as output of the shader.
  27814. * @param channel Name of the output variable.
  27815. * @param texture Texture to bind.
  27816. * @hidden
  27817. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27818. /**
  27819. * Sets a texture on the engine to be used in the shader.
  27820. * @param channel Name of the sampler variable.
  27821. * @param texture Texture to set.
  27822. */
  27823. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27824. /**
  27825. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27826. * @param channel Name of the sampler variable.
  27827. * @param texture Texture to set.
  27828. */
  27829. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27830. /**
  27831. * Sets an array of textures on the engine to be used in the shader.
  27832. * @param channel Name of the variable.
  27833. * @param textures Textures to set.
  27834. */
  27835. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27836. /**
  27837. * 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)
  27838. * @param channel Name of the sampler variable.
  27839. * @param postProcess Post process to get the input texture from.
  27840. */
  27841. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27842. /**
  27843. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27844. * 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)
  27845. * @param channel Name of the sampler variable.
  27846. * @param postProcess Post process to get the output texture from.
  27847. */
  27848. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27849. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27850. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27851. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27852. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27853. /**
  27854. * Binds a buffer to a uniform.
  27855. * @param buffer Buffer to bind.
  27856. * @param name Name of the uniform variable to bind to.
  27857. */
  27858. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27859. /**
  27860. * Binds block to a uniform.
  27861. * @param blockName Name of the block to bind.
  27862. * @param index Index to bind.
  27863. */
  27864. bindUniformBlock(blockName: string, index: number): void;
  27865. /**
  27866. * Sets an interger value on a uniform variable.
  27867. * @param uniformName Name of the variable.
  27868. * @param value Value to be set.
  27869. * @returns this effect.
  27870. */
  27871. setInt(uniformName: string, value: number): Effect;
  27872. /**
  27873. * Sets an int array on a uniform variable.
  27874. * @param uniformName Name of the variable.
  27875. * @param array array to be set.
  27876. * @returns this effect.
  27877. */
  27878. setIntArray(uniformName: string, array: Int32Array): Effect;
  27879. /**
  27880. * 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)
  27881. * @param uniformName Name of the variable.
  27882. * @param array array to be set.
  27883. * @returns this effect.
  27884. */
  27885. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27886. /**
  27887. * 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)
  27888. * @param uniformName Name of the variable.
  27889. * @param array array to be set.
  27890. * @returns this effect.
  27891. */
  27892. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27893. /**
  27894. * 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)
  27895. * @param uniformName Name of the variable.
  27896. * @param array array to be set.
  27897. * @returns this effect.
  27898. */
  27899. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27900. /**
  27901. * Sets an float array on a uniform variable.
  27902. * @param uniformName Name of the variable.
  27903. * @param array array to be set.
  27904. * @returns this effect.
  27905. */
  27906. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27907. /**
  27908. * 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)
  27909. * @param uniformName Name of the variable.
  27910. * @param array array to be set.
  27911. * @returns this effect.
  27912. */
  27913. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27914. /**
  27915. * 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)
  27916. * @param uniformName Name of the variable.
  27917. * @param array array to be set.
  27918. * @returns this effect.
  27919. */
  27920. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27921. /**
  27922. * 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)
  27923. * @param uniformName Name of the variable.
  27924. * @param array array to be set.
  27925. * @returns this effect.
  27926. */
  27927. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27928. /**
  27929. * Sets an array on a uniform variable.
  27930. * @param uniformName Name of the variable.
  27931. * @param array array to be set.
  27932. * @returns this effect.
  27933. */
  27934. setArray(uniformName: string, array: number[]): Effect;
  27935. /**
  27936. * 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)
  27937. * @param uniformName Name of the variable.
  27938. * @param array array to be set.
  27939. * @returns this effect.
  27940. */
  27941. setArray2(uniformName: string, array: number[]): Effect;
  27942. /**
  27943. * 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)
  27944. * @param uniformName Name of the variable.
  27945. * @param array array to be set.
  27946. * @returns this effect.
  27947. */
  27948. setArray3(uniformName: string, array: number[]): Effect;
  27949. /**
  27950. * 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)
  27951. * @param uniformName Name of the variable.
  27952. * @param array array to be set.
  27953. * @returns this effect.
  27954. */
  27955. setArray4(uniformName: string, array: number[]): Effect;
  27956. /**
  27957. * Sets matrices on a uniform variable.
  27958. * @param uniformName Name of the variable.
  27959. * @param matrices matrices to be set.
  27960. * @returns this effect.
  27961. */
  27962. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  27963. /**
  27964. * Sets matrix on a uniform variable.
  27965. * @param uniformName Name of the variable.
  27966. * @param matrix matrix to be set.
  27967. * @returns this effect.
  27968. */
  27969. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  27970. /**
  27971. * 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)
  27972. * @param uniformName Name of the variable.
  27973. * @param matrix matrix to be set.
  27974. * @returns this effect.
  27975. */
  27976. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  27977. /**
  27978. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  27979. * @param uniformName Name of the variable.
  27980. * @param matrix matrix to be set.
  27981. * @returns this effect.
  27982. */
  27983. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  27984. /**
  27985. * Sets a float on a uniform variable.
  27986. * @param uniformName Name of the variable.
  27987. * @param value value to be set.
  27988. * @returns this effect.
  27989. */
  27990. setFloat(uniformName: string, value: number): Effect;
  27991. /**
  27992. * Sets a boolean on a uniform variable.
  27993. * @param uniformName Name of the variable.
  27994. * @param bool value to be set.
  27995. * @returns this effect.
  27996. */
  27997. setBool(uniformName: string, bool: boolean): Effect;
  27998. /**
  27999. * Sets a Vector2 on a uniform variable.
  28000. * @param uniformName Name of the variable.
  28001. * @param vector2 vector2 to be set.
  28002. * @returns this effect.
  28003. */
  28004. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28005. /**
  28006. * Sets a float2 on a uniform variable.
  28007. * @param uniformName Name of the variable.
  28008. * @param x First float in float2.
  28009. * @param y Second float in float2.
  28010. * @returns this effect.
  28011. */
  28012. setFloat2(uniformName: string, x: number, y: number): Effect;
  28013. /**
  28014. * Sets a Vector3 on a uniform variable.
  28015. * @param uniformName Name of the variable.
  28016. * @param vector3 Value to be set.
  28017. * @returns this effect.
  28018. */
  28019. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28020. /**
  28021. * Sets a float3 on a uniform variable.
  28022. * @param uniformName Name of the variable.
  28023. * @param x First float in float3.
  28024. * @param y Second float in float3.
  28025. * @param z Third float in float3.
  28026. * @returns this effect.
  28027. */
  28028. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28029. /**
  28030. * Sets a Vector4 on a uniform variable.
  28031. * @param uniformName Name of the variable.
  28032. * @param vector4 Value to be set.
  28033. * @returns this effect.
  28034. */
  28035. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28036. /**
  28037. * Sets a float4 on a uniform variable.
  28038. * @param uniformName Name of the variable.
  28039. * @param x First float in float4.
  28040. * @param y Second float in float4.
  28041. * @param z Third float in float4.
  28042. * @param w Fourth float in float4.
  28043. * @returns this effect.
  28044. */
  28045. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28046. /**
  28047. * Sets a Color3 on a uniform variable.
  28048. * @param uniformName Name of the variable.
  28049. * @param color3 Value to be set.
  28050. * @returns this effect.
  28051. */
  28052. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28053. /**
  28054. * Sets a Color4 on a uniform variable.
  28055. * @param uniformName Name of the variable.
  28056. * @param color3 Value to be set.
  28057. * @param alpha Alpha value to be set.
  28058. * @returns this effect.
  28059. */
  28060. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28061. /**
  28062. * Sets a Color4 on a uniform variable
  28063. * @param uniformName defines the name of the variable
  28064. * @param color4 defines the value to be set
  28065. * @returns this effect.
  28066. */
  28067. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28068. /** Release all associated resources */
  28069. dispose(): void;
  28070. /**
  28071. * This function will add a new shader to the shader store
  28072. * @param name the name of the shader
  28073. * @param pixelShader optional pixel shader content
  28074. * @param vertexShader optional vertex shader content
  28075. */
  28076. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28077. /**
  28078. * Store of each shader (The can be looked up using effect.key)
  28079. */
  28080. static ShadersStore: {
  28081. [key: string]: string;
  28082. };
  28083. /**
  28084. * Store of each included file for a shader (The can be looked up using effect.key)
  28085. */
  28086. static IncludesShadersStore: {
  28087. [key: string]: string;
  28088. };
  28089. /**
  28090. * Resets the cache of effects.
  28091. */
  28092. static ResetCache(): void;
  28093. }
  28094. }
  28095. declare module BABYLON {
  28096. /**
  28097. * Uniform buffer objects.
  28098. *
  28099. * Handles blocks of uniform on the GPU.
  28100. *
  28101. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28102. *
  28103. * For more information, please refer to :
  28104. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28105. */
  28106. export class UniformBuffer {
  28107. private _engine;
  28108. private _buffer;
  28109. private _data;
  28110. private _bufferData;
  28111. private _dynamic?;
  28112. private _uniformLocations;
  28113. private _uniformSizes;
  28114. private _uniformLocationPointer;
  28115. private _needSync;
  28116. private _noUBO;
  28117. private _currentEffect;
  28118. private static _MAX_UNIFORM_SIZE;
  28119. private static _tempBuffer;
  28120. /**
  28121. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28122. * This is dynamic to allow compat with webgl 1 and 2.
  28123. * You will need to pass the name of the uniform as well as the value.
  28124. */
  28125. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28126. /**
  28127. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28128. * This is dynamic to allow compat with webgl 1 and 2.
  28129. * You will need to pass the name of the uniform as well as the value.
  28130. */
  28131. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28132. /**
  28133. * Lambda to Update a single float in a uniform buffer.
  28134. * This is dynamic to allow compat with webgl 1 and 2.
  28135. * You will need to pass the name of the uniform as well as the value.
  28136. */
  28137. updateFloat: (name: string, x: number) => void;
  28138. /**
  28139. * Lambda to Update a vec2 of float in a uniform buffer.
  28140. * This is dynamic to allow compat with webgl 1 and 2.
  28141. * You will need to pass the name of the uniform as well as the value.
  28142. */
  28143. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28144. /**
  28145. * Lambda to Update a vec3 of float in a uniform buffer.
  28146. * This is dynamic to allow compat with webgl 1 and 2.
  28147. * You will need to pass the name of the uniform as well as the value.
  28148. */
  28149. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28150. /**
  28151. * Lambda to Update a vec4 of float in a uniform buffer.
  28152. * This is dynamic to allow compat with webgl 1 and 2.
  28153. * You will need to pass the name of the uniform as well as the value.
  28154. */
  28155. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28156. /**
  28157. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28158. * This is dynamic to allow compat with webgl 1 and 2.
  28159. * You will need to pass the name of the uniform as well as the value.
  28160. */
  28161. updateMatrix: (name: string, mat: Matrix) => void;
  28162. /**
  28163. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28164. * This is dynamic to allow compat with webgl 1 and 2.
  28165. * You will need to pass the name of the uniform as well as the value.
  28166. */
  28167. updateVector3: (name: string, vector: Vector3) => void;
  28168. /**
  28169. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28170. * This is dynamic to allow compat with webgl 1 and 2.
  28171. * You will need to pass the name of the uniform as well as the value.
  28172. */
  28173. updateVector4: (name: string, vector: Vector4) => void;
  28174. /**
  28175. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28176. * This is dynamic to allow compat with webgl 1 and 2.
  28177. * You will need to pass the name of the uniform as well as the value.
  28178. */
  28179. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28180. /**
  28181. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28182. * This is dynamic to allow compat with webgl 1 and 2.
  28183. * You will need to pass the name of the uniform as well as the value.
  28184. */
  28185. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28186. /**
  28187. * Instantiates a new Uniform buffer objects.
  28188. *
  28189. * Handles blocks of uniform on the GPU.
  28190. *
  28191. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28192. *
  28193. * For more information, please refer to :
  28194. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28195. * @param engine Define the engine the buffer is associated with
  28196. * @param data Define the data contained in the buffer
  28197. * @param dynamic Define if the buffer is updatable
  28198. */
  28199. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28200. /**
  28201. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28202. * or just falling back on setUniformXXX calls.
  28203. */
  28204. readonly useUbo: boolean;
  28205. /**
  28206. * Indicates if the WebGL underlying uniform buffer is in sync
  28207. * with the javascript cache data.
  28208. */
  28209. readonly isSync: boolean;
  28210. /**
  28211. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28212. * Also, a dynamic UniformBuffer will disable cache verification and always
  28213. * update the underlying WebGL uniform buffer to the GPU.
  28214. * @returns if Dynamic, otherwise false
  28215. */
  28216. isDynamic(): boolean;
  28217. /**
  28218. * The data cache on JS side.
  28219. * @returns the underlying data as a float array
  28220. */
  28221. getData(): Float32Array;
  28222. /**
  28223. * The underlying WebGL Uniform buffer.
  28224. * @returns the webgl buffer
  28225. */
  28226. getBuffer(): Nullable<DataBuffer>;
  28227. /**
  28228. * std140 layout specifies how to align data within an UBO structure.
  28229. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28230. * for specs.
  28231. */
  28232. private _fillAlignment;
  28233. /**
  28234. * Adds an uniform in the buffer.
  28235. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28236. * for the layout to be correct !
  28237. * @param name Name of the uniform, as used in the uniform block in the shader.
  28238. * @param size Data size, or data directly.
  28239. */
  28240. addUniform(name: string, size: number | number[]): void;
  28241. /**
  28242. * Adds a Matrix 4x4 to the uniform buffer.
  28243. * @param name Name of the uniform, as used in the uniform block in the shader.
  28244. * @param mat A 4x4 matrix.
  28245. */
  28246. addMatrix(name: string, mat: Matrix): void;
  28247. /**
  28248. * Adds a vec2 to the uniform buffer.
  28249. * @param name Name of the uniform, as used in the uniform block in the shader.
  28250. * @param x Define the x component value of the vec2
  28251. * @param y Define the y component value of the vec2
  28252. */
  28253. addFloat2(name: string, x: number, y: number): void;
  28254. /**
  28255. * Adds a vec3 to the uniform buffer.
  28256. * @param name Name of the uniform, as used in the uniform block in the shader.
  28257. * @param x Define the x component value of the vec3
  28258. * @param y Define the y component value of the vec3
  28259. * @param z Define the z component value of the vec3
  28260. */
  28261. addFloat3(name: string, x: number, y: number, z: number): void;
  28262. /**
  28263. * Adds a vec3 to the uniform buffer.
  28264. * @param name Name of the uniform, as used in the uniform block in the shader.
  28265. * @param color Define the vec3 from a Color
  28266. */
  28267. addColor3(name: string, color: Color3): void;
  28268. /**
  28269. * Adds a vec4 to the uniform buffer.
  28270. * @param name Name of the uniform, as used in the uniform block in the shader.
  28271. * @param color Define the rgb components from a Color
  28272. * @param alpha Define the a component of the vec4
  28273. */
  28274. addColor4(name: string, color: Color3, alpha: number): void;
  28275. /**
  28276. * Adds a vec3 to the uniform buffer.
  28277. * @param name Name of the uniform, as used in the uniform block in the shader.
  28278. * @param vector Define the vec3 components from a Vector
  28279. */
  28280. addVector3(name: string, vector: Vector3): void;
  28281. /**
  28282. * Adds a Matrix 3x3 to the uniform buffer.
  28283. * @param name Name of the uniform, as used in the uniform block in the shader.
  28284. */
  28285. addMatrix3x3(name: string): void;
  28286. /**
  28287. * Adds a Matrix 2x2 to the uniform buffer.
  28288. * @param name Name of the uniform, as used in the uniform block in the shader.
  28289. */
  28290. addMatrix2x2(name: string): void;
  28291. /**
  28292. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28293. */
  28294. create(): void;
  28295. /** @hidden */ private _rebuild(): void;
  28296. /**
  28297. * Updates the WebGL Uniform Buffer on the GPU.
  28298. * If the `dynamic` flag is set to true, no cache comparison is done.
  28299. * Otherwise, the buffer will be updated only if the cache differs.
  28300. */
  28301. update(): void;
  28302. /**
  28303. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28304. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28305. * @param data Define the flattened data
  28306. * @param size Define the size of the data.
  28307. */
  28308. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28309. private _updateMatrix3x3ForUniform;
  28310. private _updateMatrix3x3ForEffect;
  28311. private _updateMatrix2x2ForEffect;
  28312. private _updateMatrix2x2ForUniform;
  28313. private _updateFloatForEffect;
  28314. private _updateFloatForUniform;
  28315. private _updateFloat2ForEffect;
  28316. private _updateFloat2ForUniform;
  28317. private _updateFloat3ForEffect;
  28318. private _updateFloat3ForUniform;
  28319. private _updateFloat4ForEffect;
  28320. private _updateFloat4ForUniform;
  28321. private _updateMatrixForEffect;
  28322. private _updateMatrixForUniform;
  28323. private _updateVector3ForEffect;
  28324. private _updateVector3ForUniform;
  28325. private _updateVector4ForEffect;
  28326. private _updateVector4ForUniform;
  28327. private _updateColor3ForEffect;
  28328. private _updateColor3ForUniform;
  28329. private _updateColor4ForEffect;
  28330. private _updateColor4ForUniform;
  28331. /**
  28332. * Sets a sampler uniform on the effect.
  28333. * @param name Define the name of the sampler.
  28334. * @param texture Define the texture to set in the sampler
  28335. */
  28336. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28337. /**
  28338. * Directly updates the value of the uniform in the cache AND on the GPU.
  28339. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28340. * @param data Define the flattened data
  28341. */
  28342. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28343. /**
  28344. * Binds this uniform buffer to an effect.
  28345. * @param effect Define the effect to bind the buffer to
  28346. * @param name Name of the uniform block in the shader.
  28347. */
  28348. bindToEffect(effect: Effect, name: string): void;
  28349. /**
  28350. * Disposes the uniform buffer.
  28351. */
  28352. dispose(): void;
  28353. }
  28354. }
  28355. declare module BABYLON {
  28356. /**
  28357. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28359. */
  28360. export class Analyser {
  28361. /**
  28362. * Gets or sets the smoothing
  28363. * @ignorenaming
  28364. */
  28365. SMOOTHING: number;
  28366. /**
  28367. * Gets or sets the FFT table size
  28368. * @ignorenaming
  28369. */
  28370. FFT_SIZE: number;
  28371. /**
  28372. * Gets or sets the bar graph amplitude
  28373. * @ignorenaming
  28374. */
  28375. BARGRAPHAMPLITUDE: number;
  28376. /**
  28377. * Gets or sets the position of the debug canvas
  28378. * @ignorenaming
  28379. */
  28380. DEBUGCANVASPOS: {
  28381. x: number;
  28382. y: number;
  28383. };
  28384. /**
  28385. * Gets or sets the debug canvas size
  28386. * @ignorenaming
  28387. */
  28388. DEBUGCANVASSIZE: {
  28389. width: number;
  28390. height: number;
  28391. };
  28392. private _byteFreqs;
  28393. private _byteTime;
  28394. private _floatFreqs;
  28395. private _webAudioAnalyser;
  28396. private _debugCanvas;
  28397. private _debugCanvasContext;
  28398. private _scene;
  28399. private _registerFunc;
  28400. private _audioEngine;
  28401. /**
  28402. * Creates a new analyser
  28403. * @param scene defines hosting scene
  28404. */
  28405. constructor(scene: Scene);
  28406. /**
  28407. * Get the number of data values you will have to play with for the visualization
  28408. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28409. * @returns a number
  28410. */
  28411. getFrequencyBinCount(): number;
  28412. /**
  28413. * Gets the current frequency data as a byte array
  28414. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28415. * @returns a Uint8Array
  28416. */
  28417. getByteFrequencyData(): Uint8Array;
  28418. /**
  28419. * Gets the current waveform as a byte array
  28420. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28421. * @returns a Uint8Array
  28422. */
  28423. getByteTimeDomainData(): Uint8Array;
  28424. /**
  28425. * Gets the current frequency data as a float array
  28426. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28427. * @returns a Float32Array
  28428. */
  28429. getFloatFrequencyData(): Float32Array;
  28430. /**
  28431. * Renders the debug canvas
  28432. */
  28433. drawDebugCanvas(): void;
  28434. /**
  28435. * Stops rendering the debug canvas and removes it
  28436. */
  28437. stopDebugCanvas(): void;
  28438. /**
  28439. * Connects two audio nodes
  28440. * @param inputAudioNode defines first node to connect
  28441. * @param outputAudioNode defines second node to connect
  28442. */
  28443. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28444. /**
  28445. * Releases all associated resources
  28446. */
  28447. dispose(): void;
  28448. }
  28449. }
  28450. declare module BABYLON {
  28451. /**
  28452. * This represents an audio engine and it is responsible
  28453. * to play, synchronize and analyse sounds throughout the application.
  28454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28455. */
  28456. export interface IAudioEngine extends IDisposable {
  28457. /**
  28458. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28459. */
  28460. readonly canUseWebAudio: boolean;
  28461. /**
  28462. * Gets the current AudioContext if available.
  28463. */
  28464. readonly audioContext: Nullable<AudioContext>;
  28465. /**
  28466. * The master gain node defines the global audio volume of your audio engine.
  28467. */
  28468. readonly masterGain: GainNode;
  28469. /**
  28470. * Gets whether or not mp3 are supported by your browser.
  28471. */
  28472. readonly isMP3supported: boolean;
  28473. /**
  28474. * Gets whether or not ogg are supported by your browser.
  28475. */
  28476. readonly isOGGsupported: boolean;
  28477. /**
  28478. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28479. * @ignoreNaming
  28480. */
  28481. WarnedWebAudioUnsupported: boolean;
  28482. /**
  28483. * Defines if the audio engine relies on a custom unlocked button.
  28484. * In this case, the embedded button will not be displayed.
  28485. */
  28486. useCustomUnlockedButton: boolean;
  28487. /**
  28488. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28489. */
  28490. readonly unlocked: boolean;
  28491. /**
  28492. * Event raised when audio has been unlocked on the browser.
  28493. */
  28494. onAudioUnlockedObservable: Observable<AudioEngine>;
  28495. /**
  28496. * Event raised when audio has been locked on the browser.
  28497. */
  28498. onAudioLockedObservable: Observable<AudioEngine>;
  28499. /**
  28500. * Flags the audio engine in Locked state.
  28501. * This happens due to new browser policies preventing audio to autoplay.
  28502. */
  28503. lock(): void;
  28504. /**
  28505. * Unlocks the audio engine once a user action has been done on the dom.
  28506. * This is helpful to resume play once browser policies have been satisfied.
  28507. */
  28508. unlock(): void;
  28509. }
  28510. /**
  28511. * This represents the default audio engine used in babylon.
  28512. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28514. */
  28515. export class AudioEngine implements IAudioEngine {
  28516. private _audioContext;
  28517. private _audioContextInitialized;
  28518. private _muteButton;
  28519. private _hostElement;
  28520. /**
  28521. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28522. */
  28523. canUseWebAudio: boolean;
  28524. /**
  28525. * The master gain node defines the global audio volume of your audio engine.
  28526. */
  28527. masterGain: GainNode;
  28528. /**
  28529. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28530. * @ignoreNaming
  28531. */
  28532. WarnedWebAudioUnsupported: boolean;
  28533. /**
  28534. * Gets whether or not mp3 are supported by your browser.
  28535. */
  28536. isMP3supported: boolean;
  28537. /**
  28538. * Gets whether or not ogg are supported by your browser.
  28539. */
  28540. isOGGsupported: boolean;
  28541. /**
  28542. * Gets whether audio has been unlocked on the device.
  28543. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28544. * a user interaction has happened.
  28545. */
  28546. unlocked: boolean;
  28547. /**
  28548. * Defines if the audio engine relies on a custom unlocked button.
  28549. * In this case, the embedded button will not be displayed.
  28550. */
  28551. useCustomUnlockedButton: boolean;
  28552. /**
  28553. * Event raised when audio has been unlocked on the browser.
  28554. */
  28555. onAudioUnlockedObservable: Observable<AudioEngine>;
  28556. /**
  28557. * Event raised when audio has been locked on the browser.
  28558. */
  28559. onAudioLockedObservable: Observable<AudioEngine>;
  28560. /**
  28561. * Gets the current AudioContext if available.
  28562. */
  28563. readonly audioContext: Nullable<AudioContext>;
  28564. private _connectedAnalyser;
  28565. /**
  28566. * Instantiates a new audio engine.
  28567. *
  28568. * There should be only one per page as some browsers restrict the number
  28569. * of audio contexts you can create.
  28570. * @param hostElement defines the host element where to display the mute icon if necessary
  28571. */
  28572. constructor(hostElement?: Nullable<HTMLElement>);
  28573. /**
  28574. * Flags the audio engine in Locked state.
  28575. * This happens due to new browser policies preventing audio to autoplay.
  28576. */
  28577. lock(): void;
  28578. /**
  28579. * Unlocks the audio engine once a user action has been done on the dom.
  28580. * This is helpful to resume play once browser policies have been satisfied.
  28581. */
  28582. unlock(): void;
  28583. private _resumeAudioContext;
  28584. private _initializeAudioContext;
  28585. private _tryToRun;
  28586. private _triggerRunningState;
  28587. private _triggerSuspendedState;
  28588. private _displayMuteButton;
  28589. private _moveButtonToTopLeft;
  28590. private _onResize;
  28591. private _hideMuteButton;
  28592. /**
  28593. * Destroy and release the resources associated with the audio ccontext.
  28594. */
  28595. dispose(): void;
  28596. /**
  28597. * Gets the global volume sets on the master gain.
  28598. * @returns the global volume if set or -1 otherwise
  28599. */
  28600. getGlobalVolume(): number;
  28601. /**
  28602. * Sets the global volume of your experience (sets on the master gain).
  28603. * @param newVolume Defines the new global volume of the application
  28604. */
  28605. setGlobalVolume(newVolume: number): void;
  28606. /**
  28607. * Connect the audio engine to an audio analyser allowing some amazing
  28608. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28610. * @param analyser The analyser to connect to the engine
  28611. */
  28612. connectToAnalyser(analyser: Analyser): void;
  28613. }
  28614. }
  28615. declare module BABYLON {
  28616. /**
  28617. * Interface used to present a loading screen while loading a scene
  28618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28619. */
  28620. export interface ILoadingScreen {
  28621. /**
  28622. * Function called to display the loading screen
  28623. */
  28624. displayLoadingUI: () => void;
  28625. /**
  28626. * Function called to hide the loading screen
  28627. */
  28628. hideLoadingUI: () => void;
  28629. /**
  28630. * Gets or sets the color to use for the background
  28631. */
  28632. loadingUIBackgroundColor: string;
  28633. /**
  28634. * Gets or sets the text to display while loading
  28635. */
  28636. loadingUIText: string;
  28637. }
  28638. /**
  28639. * Class used for the default loading screen
  28640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28641. */
  28642. export class DefaultLoadingScreen implements ILoadingScreen {
  28643. private _renderingCanvas;
  28644. private _loadingText;
  28645. private _loadingDivBackgroundColor;
  28646. private _loadingDiv;
  28647. private _loadingTextDiv;
  28648. /** Gets or sets the logo url to use for the default loading screen */
  28649. static DefaultLogoUrl: string;
  28650. /** Gets or sets the spinner url to use for the default loading screen */
  28651. static DefaultSpinnerUrl: string;
  28652. /**
  28653. * Creates a new default loading screen
  28654. * @param _renderingCanvas defines the canvas used to render the scene
  28655. * @param _loadingText defines the default text to display
  28656. * @param _loadingDivBackgroundColor defines the default background color
  28657. */
  28658. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28659. /**
  28660. * Function called to display the loading screen
  28661. */
  28662. displayLoadingUI(): void;
  28663. /**
  28664. * Function called to hide the loading screen
  28665. */
  28666. hideLoadingUI(): void;
  28667. /**
  28668. * Gets or sets the text to display while loading
  28669. */
  28670. loadingUIText: string;
  28671. /**
  28672. * Gets or sets the color to use for the background
  28673. */
  28674. loadingUIBackgroundColor: string;
  28675. private _resizeLoadingUI;
  28676. }
  28677. }
  28678. declare module BABYLON {
  28679. /** @hidden */
  28680. export class WebGLPipelineContext implements IPipelineContext {
  28681. engine: Engine;
  28682. program: Nullable<WebGLProgram>;
  28683. context?: WebGLRenderingContext;
  28684. vertexShader?: WebGLShader;
  28685. fragmentShader?: WebGLShader;
  28686. isParallelCompiled: boolean;
  28687. onCompiled?: () => void;
  28688. transformFeedback?: WebGLTransformFeedback | null;
  28689. readonly isAsync: boolean;
  28690. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28691. }
  28692. }
  28693. declare module BABYLON {
  28694. /** @hidden */
  28695. export class WebGLDataBuffer extends DataBuffer {
  28696. private _buffer;
  28697. constructor(resource: WebGLBuffer);
  28698. readonly underlyingResource: any;
  28699. }
  28700. }
  28701. declare module BABYLON {
  28702. /** @hidden */
  28703. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28704. attributeProcessor(attribute: string): string;
  28705. varyingProcessor(varying: string, isFragment: boolean): string;
  28706. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28707. }
  28708. }
  28709. declare module BABYLON {
  28710. /**
  28711. * This class is used to track a performance counter which is number based.
  28712. * The user has access to many properties which give statistics of different nature.
  28713. *
  28714. * The implementer can track two kinds of Performance Counter: time and count.
  28715. * 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.
  28716. * 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.
  28717. */
  28718. export class PerfCounter {
  28719. /**
  28720. * Gets or sets a global boolean to turn on and off all the counters
  28721. */
  28722. static Enabled: boolean;
  28723. /**
  28724. * Returns the smallest value ever
  28725. */
  28726. readonly min: number;
  28727. /**
  28728. * Returns the biggest value ever
  28729. */
  28730. readonly max: number;
  28731. /**
  28732. * Returns the average value since the performance counter is running
  28733. */
  28734. readonly average: number;
  28735. /**
  28736. * Returns the average value of the last second the counter was monitored
  28737. */
  28738. readonly lastSecAverage: number;
  28739. /**
  28740. * Returns the current value
  28741. */
  28742. readonly current: number;
  28743. /**
  28744. * Gets the accumulated total
  28745. */
  28746. readonly total: number;
  28747. /**
  28748. * Gets the total value count
  28749. */
  28750. readonly count: number;
  28751. /**
  28752. * Creates a new counter
  28753. */
  28754. constructor();
  28755. /**
  28756. * Call this method to start monitoring a new frame.
  28757. * 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.
  28758. */
  28759. fetchNewFrame(): void;
  28760. /**
  28761. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28762. * @param newCount the count value to add to the monitored count
  28763. * @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.
  28764. */
  28765. addCount(newCount: number, fetchResult: boolean): void;
  28766. /**
  28767. * Start monitoring this performance counter
  28768. */
  28769. beginMonitoring(): void;
  28770. /**
  28771. * Compute the time lapsed since the previous beginMonitoring() call.
  28772. * @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
  28773. */
  28774. endMonitoring(newFrame?: boolean): void;
  28775. private _fetchResult;
  28776. private _startMonitoringTime;
  28777. private _min;
  28778. private _max;
  28779. private _average;
  28780. private _current;
  28781. private _totalValueCount;
  28782. private _totalAccumulated;
  28783. private _lastSecAverage;
  28784. private _lastSecAccumulated;
  28785. private _lastSecTime;
  28786. private _lastSecValueCount;
  28787. }
  28788. }
  28789. declare module BABYLON {
  28790. /**
  28791. * Interface for any object that can request an animation frame
  28792. */
  28793. export interface ICustomAnimationFrameRequester {
  28794. /**
  28795. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  28796. */
  28797. renderFunction?: Function;
  28798. /**
  28799. * Called to request the next frame to render to
  28800. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  28801. */
  28802. requestAnimationFrame: Function;
  28803. /**
  28804. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  28805. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  28806. */
  28807. requestID?: number;
  28808. }
  28809. }
  28810. declare module BABYLON {
  28811. /**
  28812. * Settings for finer control over video usage
  28813. */
  28814. export interface VideoTextureSettings {
  28815. /**
  28816. * Applies `autoplay` to video, if specified
  28817. */
  28818. autoPlay?: boolean;
  28819. /**
  28820. * Applies `loop` to video, if specified
  28821. */
  28822. loop?: boolean;
  28823. /**
  28824. * Automatically updates internal texture from video at every frame in the render loop
  28825. */
  28826. autoUpdateTexture: boolean;
  28827. /**
  28828. * Image src displayed during the video loading or until the user interacts with the video.
  28829. */
  28830. poster?: string;
  28831. }
  28832. /**
  28833. * If you want to display a video in your scene, this is the special texture for that.
  28834. * This special texture works similar to other textures, with the exception of a few parameters.
  28835. * @see https://doc.babylonjs.com/how_to/video_texture
  28836. */
  28837. export class VideoTexture extends Texture {
  28838. /**
  28839. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28840. */
  28841. readonly autoUpdateTexture: boolean;
  28842. /**
  28843. * The video instance used by the texture internally
  28844. */
  28845. readonly video: HTMLVideoElement;
  28846. private _onUserActionRequestedObservable;
  28847. /**
  28848. * Event triggerd when a dom action is required by the user to play the video.
  28849. * This happens due to recent changes in browser policies preventing video to auto start.
  28850. */
  28851. readonly onUserActionRequestedObservable: Observable<Texture>;
  28852. private _generateMipMaps;
  28853. private _engine;
  28854. private _stillImageCaptured;
  28855. private _displayingPosterTexture;
  28856. private _settings;
  28857. private _createInternalTextureOnEvent;
  28858. /**
  28859. * Creates a video texture.
  28860. * If you want to display a video in your scene, this is the special texture for that.
  28861. * This special texture works similar to other textures, with the exception of a few parameters.
  28862. * @see https://doc.babylonjs.com/how_to/video_texture
  28863. * @param name optional name, will detect from video source, if not defined
  28864. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28865. * @param scene is obviously the current scene.
  28866. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28867. * @param invertY is false by default but can be used to invert video on Y axis
  28868. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28869. * @param settings allows finer control over video usage
  28870. */
  28871. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28872. private _getName;
  28873. private _getVideo;
  28874. private _createInternalTexture;
  28875. private reset;
  28876. /**
  28877. * @hidden Internal method to initiate `update`.
  28878. */ private _rebuild(): void;
  28879. /**
  28880. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28881. */
  28882. update(): void;
  28883. /**
  28884. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28885. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28886. */
  28887. updateTexture(isVisible: boolean): void;
  28888. protected _updateInternalTexture: () => void;
  28889. /**
  28890. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28891. * @param url New url.
  28892. */
  28893. updateURL(url: string): void;
  28894. /**
  28895. * Dispose the texture and release its associated resources.
  28896. */
  28897. dispose(): void;
  28898. /**
  28899. * Creates a video texture straight from a stream.
  28900. * @param scene Define the scene the texture should be created in
  28901. * @param stream Define the stream the texture should be created from
  28902. * @returns The created video texture as a promise
  28903. */
  28904. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28905. /**
  28906. * Creates a video texture straight from your WebCam video feed.
  28907. * @param scene Define the scene the texture should be created in
  28908. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28909. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28910. * @returns The created video texture as a promise
  28911. */
  28912. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28913. minWidth: number;
  28914. maxWidth: number;
  28915. minHeight: number;
  28916. maxHeight: number;
  28917. deviceId: string;
  28918. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28919. /**
  28920. * Creates a video texture straight from your WebCam video feed.
  28921. * @param scene Define the scene the texture should be created in
  28922. * @param onReady Define a callback to triggered once the texture will be ready
  28923. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28924. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28925. */
  28926. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28927. minWidth: number;
  28928. maxWidth: number;
  28929. minHeight: number;
  28930. maxHeight: number;
  28931. deviceId: string;
  28932. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28933. }
  28934. }
  28935. declare module BABYLON {
  28936. /**
  28937. * Defines the interface used by objects containing a viewport (like a camera)
  28938. */
  28939. interface IViewportOwnerLike {
  28940. /**
  28941. * Gets or sets the viewport
  28942. */
  28943. viewport: IViewportLike;
  28944. }
  28945. /**
  28946. * Interface for attribute information associated with buffer instanciation
  28947. */
  28948. export class InstancingAttributeInfo {
  28949. /**
  28950. * Index/offset of the attribute in the vertex shader
  28951. */
  28952. index: number;
  28953. /**
  28954. * size of the attribute, 1, 2, 3 or 4
  28955. */
  28956. attributeSize: number;
  28957. /**
  28958. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28959. * default is FLOAT
  28960. */
  28961. attribyteType: number;
  28962. /**
  28963. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28964. */
  28965. normalized: boolean;
  28966. /**
  28967. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28968. */
  28969. offset: number;
  28970. /**
  28971. * Name of the GLSL attribute, for debugging purpose only
  28972. */
  28973. attributeName: string;
  28974. }
  28975. /**
  28976. * Define options used to create a depth texture
  28977. */
  28978. export class DepthTextureCreationOptions {
  28979. /** Specifies whether or not a stencil should be allocated in the texture */
  28980. generateStencil?: boolean;
  28981. /** Specifies whether or not bilinear filtering is enable on the texture */
  28982. bilinearFiltering?: boolean;
  28983. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28984. comparisonFunction?: number;
  28985. /** Specifies if the created texture is a cube texture */
  28986. isCube?: boolean;
  28987. }
  28988. /**
  28989. * Class used to describe the capabilities of the engine relatively to the current browser
  28990. */
  28991. export class EngineCapabilities {
  28992. /** Maximum textures units per fragment shader */
  28993. maxTexturesImageUnits: number;
  28994. /** Maximum texture units per vertex shader */
  28995. maxVertexTextureImageUnits: number;
  28996. /** Maximum textures units in the entire pipeline */
  28997. maxCombinedTexturesImageUnits: number;
  28998. /** Maximum texture size */
  28999. maxTextureSize: number;
  29000. /** Maximum cube texture size */
  29001. maxCubemapTextureSize: number;
  29002. /** Maximum render texture size */
  29003. maxRenderTextureSize: number;
  29004. /** Maximum number of vertex attributes */
  29005. maxVertexAttribs: number;
  29006. /** Maximum number of varyings */
  29007. maxVaryingVectors: number;
  29008. /** Maximum number of uniforms per vertex shader */
  29009. maxVertexUniformVectors: number;
  29010. /** Maximum number of uniforms per fragment shader */
  29011. maxFragmentUniformVectors: number;
  29012. /** Defines if standard derivates (dx/dy) are supported */
  29013. standardDerivatives: boolean;
  29014. /** Defines if s3tc texture compression is supported */
  29015. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29016. /** Defines if pvrtc texture compression is supported */
  29017. pvrtc: any;
  29018. /** Defines if etc1 texture compression is supported */
  29019. etc1: any;
  29020. /** Defines if etc2 texture compression is supported */
  29021. etc2: any;
  29022. /** Defines if astc texture compression is supported */
  29023. astc: any;
  29024. /** Defines if float textures are supported */
  29025. textureFloat: boolean;
  29026. /** Defines if vertex array objects are supported */
  29027. vertexArrayObject: boolean;
  29028. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29029. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29030. /** Gets the maximum level of anisotropy supported */
  29031. maxAnisotropy: number;
  29032. /** Defines if instancing is supported */
  29033. instancedArrays: boolean;
  29034. /** Defines if 32 bits indices are supported */
  29035. uintIndices: boolean;
  29036. /** Defines if high precision shaders are supported */
  29037. highPrecisionShaderSupported: boolean;
  29038. /** Defines if depth reading in the fragment shader is supported */
  29039. fragmentDepthSupported: boolean;
  29040. /** Defines if float texture linear filtering is supported*/
  29041. textureFloatLinearFiltering: boolean;
  29042. /** Defines if rendering to float textures is supported */
  29043. textureFloatRender: boolean;
  29044. /** Defines if half float textures are supported*/
  29045. textureHalfFloat: boolean;
  29046. /** Defines if half float texture linear filtering is supported*/
  29047. textureHalfFloatLinearFiltering: boolean;
  29048. /** Defines if rendering to half float textures is supported */
  29049. textureHalfFloatRender: boolean;
  29050. /** Defines if textureLOD shader command is supported */
  29051. textureLOD: boolean;
  29052. /** Defines if draw buffers extension is supported */
  29053. drawBuffersExtension: boolean;
  29054. /** Defines if depth textures are supported */
  29055. depthTextureExtension: boolean;
  29056. /** Defines if float color buffer are supported */
  29057. colorBufferFloat: boolean;
  29058. /** Gets disjoint timer query extension (null if not supported) */
  29059. timerQuery: EXT_disjoint_timer_query;
  29060. /** Defines if timestamp can be used with timer query */
  29061. canUseTimestampForTimerQuery: boolean;
  29062. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29063. multiview: any;
  29064. /** Function used to let the system compiles shaders in background */
  29065. parallelShaderCompile: {
  29066. COMPLETION_STATUS_KHR: number;
  29067. };
  29068. }
  29069. /** Interface defining initialization parameters for Engine class */
  29070. export interface EngineOptions extends WebGLContextAttributes {
  29071. /**
  29072. * Defines if the engine should no exceed a specified device ratio
  29073. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29074. */
  29075. limitDeviceRatio?: number;
  29076. /**
  29077. * Defines if webvr should be enabled automatically
  29078. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29079. */
  29080. autoEnableWebVR?: boolean;
  29081. /**
  29082. * Defines if webgl2 should be turned off even if supported
  29083. * @see http://doc.babylonjs.com/features/webgl2
  29084. */
  29085. disableWebGL2Support?: boolean;
  29086. /**
  29087. * Defines if webaudio should be initialized as well
  29088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29089. */
  29090. audioEngine?: boolean;
  29091. /**
  29092. * Defines if animations should run using a deterministic lock step
  29093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29094. */
  29095. deterministicLockstep?: boolean;
  29096. /** Defines the maximum steps to use with deterministic lock step mode */
  29097. lockstepMaxSteps?: number;
  29098. /**
  29099. * Defines that engine should ignore context lost events
  29100. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29101. */
  29102. doNotHandleContextLost?: boolean;
  29103. /**
  29104. * Defines that engine should ignore modifying touch action attribute and style
  29105. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29106. */
  29107. doNotHandleTouchAction?: boolean;
  29108. /**
  29109. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29110. */
  29111. useHighPrecisionFloats?: boolean;
  29112. }
  29113. /**
  29114. * Defines the interface used by display changed events
  29115. */
  29116. export interface IDisplayChangedEventArgs {
  29117. /** Gets the vrDisplay object (if any) */
  29118. vrDisplay: Nullable<any>;
  29119. /** Gets a boolean indicating if webVR is supported */
  29120. vrSupported: boolean;
  29121. }
  29122. /**
  29123. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29124. */
  29125. export class Engine {
  29126. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29127. static ExceptionList: ({
  29128. key: string;
  29129. capture: string;
  29130. captureConstraint: number;
  29131. targets: string[];
  29132. } | {
  29133. key: string;
  29134. capture: null;
  29135. captureConstraint: null;
  29136. targets: string[];
  29137. })[];
  29138. /** Gets the list of created engines */
  29139. static readonly Instances: Engine[];
  29140. /**
  29141. * Gets the latest created engine
  29142. */
  29143. static readonly LastCreatedEngine: Nullable<Engine>;
  29144. /**
  29145. * Gets the latest created scene
  29146. */
  29147. static readonly LastCreatedScene: Nullable<Scene>;
  29148. /**
  29149. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29150. * @param flag defines which part of the materials must be marked as dirty
  29151. * @param predicate defines a predicate used to filter which materials should be affected
  29152. */
  29153. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29154. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29155. /** Defines that alpha blending is disabled */
  29156. static readonly ALPHA_DISABLE: number;
  29157. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29158. static readonly ALPHA_ADD: number;
  29159. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29160. static readonly ALPHA_COMBINE: number;
  29161. /** Defines that alpha blending to DEST - SRC * DEST */
  29162. static readonly ALPHA_SUBTRACT: number;
  29163. /** Defines that alpha blending to SRC * DEST */
  29164. static readonly ALPHA_MULTIPLY: number;
  29165. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29166. static readonly ALPHA_MAXIMIZED: number;
  29167. /** Defines that alpha blending to SRC + DEST */
  29168. static readonly ALPHA_ONEONE: number;
  29169. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29170. static readonly ALPHA_PREMULTIPLIED: number;
  29171. /**
  29172. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29173. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29174. */
  29175. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29176. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29177. static readonly ALPHA_INTERPOLATE: number;
  29178. /**
  29179. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29180. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29181. */
  29182. static readonly ALPHA_SCREENMODE: number;
  29183. /** Defines that the ressource is not delayed*/
  29184. static readonly DELAYLOADSTATE_NONE: number;
  29185. /** Defines that the ressource was successfully delay loaded */
  29186. static readonly DELAYLOADSTATE_LOADED: number;
  29187. /** Defines that the ressource is currently delay loading */
  29188. static readonly DELAYLOADSTATE_LOADING: number;
  29189. /** Defines that the ressource is delayed and has not started loading */
  29190. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29191. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29192. static readonly NEVER: number;
  29193. /** 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 */
  29194. static readonly ALWAYS: number;
  29195. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29196. static readonly LESS: number;
  29197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29198. static readonly EQUAL: number;
  29199. /** 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 */
  29200. static readonly LEQUAL: number;
  29201. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29202. static readonly GREATER: number;
  29203. /** 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 */
  29204. static readonly GEQUAL: number;
  29205. /** 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 */
  29206. static readonly NOTEQUAL: number;
  29207. /** Passed to stencilOperation to specify that stencil value must be kept */
  29208. static readonly KEEP: number;
  29209. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29210. static readonly REPLACE: number;
  29211. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29212. static readonly INCR: number;
  29213. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29214. static readonly DECR: number;
  29215. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29216. static readonly INVERT: number;
  29217. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29218. static readonly INCR_WRAP: number;
  29219. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29220. static readonly DECR_WRAP: number;
  29221. /** Texture is not repeating outside of 0..1 UVs */
  29222. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29223. /** Texture is repeating outside of 0..1 UVs */
  29224. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29225. /** Texture is repeating and mirrored */
  29226. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29227. /** ALPHA */
  29228. static readonly TEXTUREFORMAT_ALPHA: number;
  29229. /** LUMINANCE */
  29230. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29231. /** LUMINANCE_ALPHA */
  29232. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29233. /** RGB */
  29234. static readonly TEXTUREFORMAT_RGB: number;
  29235. /** RGBA */
  29236. static readonly TEXTUREFORMAT_RGBA: number;
  29237. /** RED */
  29238. static readonly TEXTUREFORMAT_RED: number;
  29239. /** RED (2nd reference) */
  29240. static readonly TEXTUREFORMAT_R: number;
  29241. /** RG */
  29242. static readonly TEXTUREFORMAT_RG: number;
  29243. /** RED_INTEGER */
  29244. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29245. /** RED_INTEGER (2nd reference) */
  29246. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29247. /** RG_INTEGER */
  29248. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29249. /** RGB_INTEGER */
  29250. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29251. /** RGBA_INTEGER */
  29252. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29253. /** UNSIGNED_BYTE */
  29254. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29255. /** UNSIGNED_BYTE (2nd reference) */
  29256. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29257. /** FLOAT */
  29258. static readonly TEXTURETYPE_FLOAT: number;
  29259. /** HALF_FLOAT */
  29260. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29261. /** BYTE */
  29262. static readonly TEXTURETYPE_BYTE: number;
  29263. /** SHORT */
  29264. static readonly TEXTURETYPE_SHORT: number;
  29265. /** UNSIGNED_SHORT */
  29266. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29267. /** INT */
  29268. static readonly TEXTURETYPE_INT: number;
  29269. /** UNSIGNED_INT */
  29270. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29271. /** UNSIGNED_SHORT_4_4_4_4 */
  29272. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29273. /** UNSIGNED_SHORT_5_5_5_1 */
  29274. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29275. /** UNSIGNED_SHORT_5_6_5 */
  29276. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29277. /** UNSIGNED_INT_2_10_10_10_REV */
  29278. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29279. /** UNSIGNED_INT_24_8 */
  29280. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29281. /** UNSIGNED_INT_10F_11F_11F_REV */
  29282. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29283. /** UNSIGNED_INT_5_9_9_9_REV */
  29284. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29285. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29286. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29287. /** nearest is mag = nearest and min = nearest and mip = linear */
  29288. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29289. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29290. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29291. /** Trilinear is mag = linear and min = linear and mip = linear */
  29292. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29293. /** nearest is mag = nearest and min = nearest and mip = linear */
  29294. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29295. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29296. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29297. /** Trilinear is mag = linear and min = linear and mip = linear */
  29298. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29299. /** mag = nearest and min = nearest and mip = nearest */
  29300. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29301. /** mag = nearest and min = linear and mip = nearest */
  29302. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29303. /** mag = nearest and min = linear and mip = linear */
  29304. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29305. /** mag = nearest and min = linear and mip = none */
  29306. static readonly TEXTURE_NEAREST_LINEAR: number;
  29307. /** mag = nearest and min = nearest and mip = none */
  29308. static readonly TEXTURE_NEAREST_NEAREST: number;
  29309. /** mag = linear and min = nearest and mip = nearest */
  29310. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29311. /** mag = linear and min = nearest and mip = linear */
  29312. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29313. /** mag = linear and min = linear and mip = none */
  29314. static readonly TEXTURE_LINEAR_LINEAR: number;
  29315. /** mag = linear and min = nearest and mip = none */
  29316. static readonly TEXTURE_LINEAR_NEAREST: number;
  29317. /** Explicit coordinates mode */
  29318. static readonly TEXTURE_EXPLICIT_MODE: number;
  29319. /** Spherical coordinates mode */
  29320. static readonly TEXTURE_SPHERICAL_MODE: number;
  29321. /** Planar coordinates mode */
  29322. static readonly TEXTURE_PLANAR_MODE: number;
  29323. /** Cubic coordinates mode */
  29324. static readonly TEXTURE_CUBIC_MODE: number;
  29325. /** Projection coordinates mode */
  29326. static readonly TEXTURE_PROJECTION_MODE: number;
  29327. /** Skybox coordinates mode */
  29328. static readonly TEXTURE_SKYBOX_MODE: number;
  29329. /** Inverse Cubic coordinates mode */
  29330. static readonly TEXTURE_INVCUBIC_MODE: number;
  29331. /** Equirectangular coordinates mode */
  29332. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29333. /** Equirectangular Fixed coordinates mode */
  29334. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29335. /** Equirectangular Fixed Mirrored coordinates mode */
  29336. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29337. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29338. static readonly SCALEMODE_FLOOR: number;
  29339. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29340. static readonly SCALEMODE_NEAREST: number;
  29341. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29342. static readonly SCALEMODE_CEILING: number;
  29343. /**
  29344. * Returns the current npm package of the sdk
  29345. */
  29346. static readonly NpmPackage: string;
  29347. /**
  29348. * Returns the current version of the framework
  29349. */
  29350. static readonly Version: string;
  29351. /**
  29352. * Returns a string describing the current engine
  29353. */
  29354. readonly description: string;
  29355. /**
  29356. * Gets or sets the epsilon value used by collision engine
  29357. */
  29358. static CollisionsEpsilon: number;
  29359. /**
  29360. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29361. */
  29362. static ShadersRepository: string;
  29363. /**
  29364. * Method called to create the default loading screen.
  29365. * This can be overriden in your own app.
  29366. * @param canvas The rendering canvas element
  29367. * @returns The loading screen
  29368. */
  29369. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29370. /**
  29371. * Method called to create the default rescale post process on each engine.
  29372. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29373. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  29374. /**
  29375. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29376. */
  29377. forcePOTTextures: boolean;
  29378. /**
  29379. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29380. */
  29381. isFullscreen: boolean;
  29382. /**
  29383. * Gets a boolean indicating if the pointer is currently locked
  29384. */
  29385. isPointerLock: boolean;
  29386. /**
  29387. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29388. */
  29389. cullBackFaces: boolean;
  29390. /**
  29391. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29392. */
  29393. renderEvenInBackground: boolean;
  29394. /**
  29395. * Gets or sets a boolean indicating that cache can be kept between frames
  29396. */
  29397. preventCacheWipeBetweenFrames: boolean;
  29398. /**
  29399. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29400. **/
  29401. enableOfflineSupport: boolean;
  29402. /**
  29403. * 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)
  29404. **/
  29405. disableManifestCheck: boolean;
  29406. /**
  29407. * Gets the list of created scenes
  29408. */
  29409. scenes: Scene[];
  29410. /**
  29411. * Event raised when a new scene is created
  29412. */
  29413. onNewSceneAddedObservable: Observable<Scene>;
  29414. /**
  29415. * Gets the list of created postprocesses
  29416. */
  29417. postProcesses: PostProcess[];
  29418. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29419. validateShaderPrograms: boolean;
  29420. /**
  29421. * Observable event triggered each time the rendering canvas is resized
  29422. */
  29423. onResizeObservable: Observable<Engine>;
  29424. /**
  29425. * Observable event triggered each time the canvas loses focus
  29426. */
  29427. onCanvasBlurObservable: Observable<Engine>;
  29428. /**
  29429. * Observable event triggered each time the canvas gains focus
  29430. */
  29431. onCanvasFocusObservable: Observable<Engine>;
  29432. /**
  29433. * Observable event triggered each time the canvas receives pointerout event
  29434. */
  29435. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29436. /**
  29437. * Observable event triggered before each texture is initialized
  29438. */
  29439. onBeforeTextureInitObservable: Observable<Texture>;
  29440. /**
  29441. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29442. */
  29443. disableUniformBuffers: boolean;
  29444. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29445. /**
  29446. * Gets a boolean indicating that the engine supports uniform buffers
  29447. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29448. */
  29449. readonly supportsUniformBuffers: boolean;
  29450. /**
  29451. * Observable raised when the engine begins a new frame
  29452. */
  29453. onBeginFrameObservable: Observable<Engine>;
  29454. /**
  29455. * If set, will be used to request the next animation frame for the render loop
  29456. */
  29457. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29458. /**
  29459. * Observable raised when the engine ends the current frame
  29460. */
  29461. onEndFrameObservable: Observable<Engine>;
  29462. /**
  29463. * Observable raised when the engine is about to compile a shader
  29464. */
  29465. onBeforeShaderCompilationObservable: Observable<Engine>;
  29466. /**
  29467. * Observable raised when the engine has jsut compiled a shader
  29468. */
  29469. onAfterShaderCompilationObservable: Observable<Engine>;
  29470. /** @hidden */ private _gl: WebGLRenderingContext;
  29471. private _renderingCanvas;
  29472. private _windowIsBackground;
  29473. private _webGLVersion;
  29474. protected _highPrecisionShadersAllowed: boolean;
  29475. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  29476. /**
  29477. * Gets a boolean indicating that only power of 2 textures are supported
  29478. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29479. */
  29480. readonly needPOTTextures: boolean;
  29481. /** @hidden */ private _badOS: boolean;
  29482. /** @hidden */ private _badDesktopOS: boolean;
  29483. /**
  29484. * Gets the audio engine
  29485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29486. * @ignorenaming
  29487. */
  29488. static audioEngine: IAudioEngine;
  29489. /**
  29490. * Default AudioEngine factory responsible of creating the Audio Engine.
  29491. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29492. */
  29493. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29494. /**
  29495. * Default offline support factory responsible of creating a tool used to store data locally.
  29496. * By default, this will create a Database object if the workload has been embedded.
  29497. */
  29498. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29499. private _onFocus;
  29500. private _onBlur;
  29501. private _onCanvasPointerOut;
  29502. private _onCanvasBlur;
  29503. private _onCanvasFocus;
  29504. private _onFullscreenChange;
  29505. private _onPointerLockChange;
  29506. private _hardwareScalingLevel;
  29507. /** @hidden */ private _caps: EngineCapabilities;
  29508. private _pointerLockRequested;
  29509. private _isStencilEnable;
  29510. private _colorWrite;
  29511. private _loadingScreen;
  29512. /** @hidden */ private _drawCalls: PerfCounter;
  29513. private _glVersion;
  29514. private _glRenderer;
  29515. private _glVendor;
  29516. private _videoTextureSupported;
  29517. private _renderingQueueLaunched;
  29518. private _activeRenderLoops;
  29519. private _deterministicLockstep;
  29520. private _lockstepMaxSteps;
  29521. /**
  29522. * Observable signaled when a context lost event is raised
  29523. */
  29524. onContextLostObservable: Observable<Engine>;
  29525. /**
  29526. * Observable signaled when a context restored event is raised
  29527. */
  29528. onContextRestoredObservable: Observable<Engine>;
  29529. private _onContextLost;
  29530. private _onContextRestored;
  29531. private _contextWasLost;
  29532. /** @hidden */ private _doNotHandleContextLost: boolean;
  29533. /**
  29534. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29536. */
  29537. doNotHandleContextLost: boolean;
  29538. private _performanceMonitor;
  29539. private _fps;
  29540. private _deltaTime;
  29541. /**
  29542. * Turn this value on if you want to pause FPS computation when in background
  29543. */
  29544. disablePerformanceMonitorInBackground: boolean;
  29545. /**
  29546. * Gets the performance monitor attached to this engine
  29547. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29548. */
  29549. readonly performanceMonitor: PerformanceMonitor;
  29550. /**
  29551. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29552. */
  29553. disableVertexArrayObjects: boolean;
  29554. /** @hidden */
  29555. protected _depthCullingState: _DepthCullingState;
  29556. /** @hidden */
  29557. protected _stencilState: _StencilState;
  29558. /** @hidden */
  29559. protected _alphaState: _AlphaState;
  29560. /** @hidden */
  29561. protected _alphaMode: number;
  29562. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  29563. /** @hidden */
  29564. protected _activeChannel: number;
  29565. private _currentTextureChannel;
  29566. /** @hidden */
  29567. protected _boundTexturesCache: {
  29568. [key: string]: Nullable<InternalTexture>;
  29569. };
  29570. /** @hidden */
  29571. protected _currentEffect: Nullable<Effect>;
  29572. /** @hidden */
  29573. protected _currentProgram: Nullable<WebGLProgram>;
  29574. private _compiledEffects;
  29575. private _vertexAttribArraysEnabled;
  29576. /** @hidden */
  29577. protected _cachedViewport: Nullable<IViewportLike>;
  29578. private _cachedVertexArrayObject;
  29579. /** @hidden */
  29580. protected _cachedVertexBuffers: any;
  29581. /** @hidden */
  29582. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29583. /** @hidden */
  29584. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29585. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  29586. private _uintIndicesCurrentlySet;
  29587. private _currentBoundBuffer;
  29588. /** @hidden */
  29589. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29590. private _currentBufferPointers;
  29591. private _currentInstanceLocations;
  29592. private _currentInstanceBuffers;
  29593. private _textureUnits;
  29594. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29595. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29596. private _rescalePostProcess;
  29597. private _dummyFramebuffer;
  29598. private _externalData;
  29599. /** @hidden */ private _bindedRenderFunction: any;
  29600. private _vaoRecordInProgress;
  29601. private _mustWipeVertexAttributes;
  29602. private _emptyTexture;
  29603. private _emptyCubeTexture;
  29604. private _emptyTexture3D;
  29605. /** @hidden */ private _frameHandler: number;
  29606. private _nextFreeTextureSlots;
  29607. private _maxSimultaneousTextures;
  29608. private _activeRequests;
  29609. private _texturesSupported;
  29610. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  29611. /**
  29612. * Gets the list of texture formats supported
  29613. */
  29614. readonly texturesSupported: Array<string>;
  29615. /**
  29616. * Gets the list of texture formats in use
  29617. */
  29618. readonly textureFormatInUse: Nullable<string>;
  29619. /**
  29620. * Gets the current viewport
  29621. */
  29622. readonly currentViewport: Nullable<IViewportLike>;
  29623. /**
  29624. * Gets the default empty texture
  29625. */
  29626. readonly emptyTexture: InternalTexture;
  29627. /**
  29628. * Gets the default empty 3D texture
  29629. */
  29630. readonly emptyTexture3D: InternalTexture;
  29631. /**
  29632. * Gets the default empty cube texture
  29633. */
  29634. readonly emptyCubeTexture: InternalTexture;
  29635. /**
  29636. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29637. */
  29638. readonly premultipliedAlpha: boolean;
  29639. /**
  29640. * Creates a new engine
  29641. * @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
  29642. * @param antialias defines enable antialiasing (default: false)
  29643. * @param options defines further options to be sent to the getContext() function
  29644. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29645. */
  29646. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29647. /**
  29648. * Initializes a webVR display and starts listening to display change events
  29649. * The onVRDisplayChangedObservable will be notified upon these changes
  29650. * @returns The onVRDisplayChangedObservable
  29651. */
  29652. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29653. /** @hidden */ private _prepareVRComponent(): void;
  29654. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  29655. /** @hidden */ private _submitVRFrame(): void;
  29656. /**
  29657. * Call this function to leave webVR mode
  29658. * Will do nothing if webVR is not supported or if there is no webVR device
  29659. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29660. */
  29661. disableVR(): void;
  29662. /**
  29663. * Gets a boolean indicating that the system is in VR mode and is presenting
  29664. * @returns true if VR mode is engaged
  29665. */
  29666. isVRPresenting(): boolean;
  29667. /** @hidden */ private _requestVRFrame(): void;
  29668. private _disableTouchAction;
  29669. private _rebuildInternalTextures;
  29670. private _rebuildEffects;
  29671. /**
  29672. * Gets a boolean indicating if all created effects are ready
  29673. * @returns true if all effects are ready
  29674. */
  29675. areAllEffectsReady(): boolean;
  29676. private _rebuildBuffers;
  29677. private _initGLContext;
  29678. /**
  29679. * Gets version of the current webGL context
  29680. */
  29681. readonly webGLVersion: number;
  29682. /**
  29683. * Gets a string idenfifying the name of the class
  29684. * @returns "Engine" string
  29685. */
  29686. getClassName(): string;
  29687. /**
  29688. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29689. */
  29690. readonly isStencilEnable: boolean;
  29691. /** @hidden */ private _prepareWorkingCanvas(): void;
  29692. /**
  29693. * Reset the texture cache to empty state
  29694. */
  29695. resetTextureCache(): void;
  29696. /**
  29697. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29698. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29699. * @returns true if engine is in deterministic lock step mode
  29700. */
  29701. isDeterministicLockStep(): boolean;
  29702. /**
  29703. * Gets the max steps when engine is running in deterministic lock step
  29704. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29705. * @returns the max steps
  29706. */
  29707. getLockstepMaxSteps(): number;
  29708. /**
  29709. * Gets an object containing information about the current webGL context
  29710. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29711. */
  29712. getGlInfo(): {
  29713. vendor: string;
  29714. renderer: string;
  29715. version: string;
  29716. };
  29717. /**
  29718. * Gets current aspect ratio
  29719. * @param viewportOwner defines the camera to use to get the aspect ratio
  29720. * @param useScreen defines if screen size must be used (or the current render target if any)
  29721. * @returns a number defining the aspect ratio
  29722. */
  29723. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29724. /**
  29725. * Gets current screen aspect ratio
  29726. * @returns a number defining the aspect ratio
  29727. */
  29728. getScreenAspectRatio(): number;
  29729. /**
  29730. * Gets the current render width
  29731. * @param useScreen defines if screen size must be used (or the current render target if any)
  29732. * @returns a number defining the current render width
  29733. */
  29734. getRenderWidth(useScreen?: boolean): number;
  29735. /**
  29736. * Gets the current render height
  29737. * @param useScreen defines if screen size must be used (or the current render target if any)
  29738. * @returns a number defining the current render height
  29739. */
  29740. getRenderHeight(useScreen?: boolean): number;
  29741. /**
  29742. * Gets the HTML canvas attached with the current webGL context
  29743. * @returns a HTML canvas
  29744. */
  29745. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29746. /**
  29747. * Gets host window
  29748. * @returns the host window object
  29749. */
  29750. getHostWindow(): Window;
  29751. /**
  29752. * Gets host document
  29753. * @returns the host document object
  29754. */
  29755. getHostDocument(): Document;
  29756. /**
  29757. * Gets the client rect of the HTML canvas attached with the current webGL context
  29758. * @returns a client rectanglee
  29759. */
  29760. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29761. /**
  29762. * Defines the hardware scaling level.
  29763. * By default the hardware scaling level is computed from the window device ratio.
  29764. * 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.
  29765. * @param level defines the level to use
  29766. */
  29767. setHardwareScalingLevel(level: number): void;
  29768. /**
  29769. * Gets the current hardware scaling level.
  29770. * By default the hardware scaling level is computed from the window device ratio.
  29771. * 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.
  29772. * @returns a number indicating the current hardware scaling level
  29773. */
  29774. getHardwareScalingLevel(): number;
  29775. /**
  29776. * Gets the list of loaded textures
  29777. * @returns an array containing all loaded textures
  29778. */
  29779. getLoadedTexturesCache(): InternalTexture[];
  29780. /**
  29781. * Gets the object containing all engine capabilities
  29782. * @returns the EngineCapabilities object
  29783. */
  29784. getCaps(): EngineCapabilities;
  29785. /**
  29786. * Gets the current depth function
  29787. * @returns a number defining the depth function
  29788. */
  29789. getDepthFunction(): Nullable<number>;
  29790. /**
  29791. * Sets the current depth function
  29792. * @param depthFunc defines the function to use
  29793. */
  29794. setDepthFunction(depthFunc: number): void;
  29795. /**
  29796. * Sets the current depth function to GREATER
  29797. */
  29798. setDepthFunctionToGreater(): void;
  29799. /**
  29800. * Sets the current depth function to GEQUAL
  29801. */
  29802. setDepthFunctionToGreaterOrEqual(): void;
  29803. /**
  29804. * Sets the current depth function to LESS
  29805. */
  29806. setDepthFunctionToLess(): void;
  29807. private _cachedStencilBuffer;
  29808. private _cachedStencilFunction;
  29809. private _cachedStencilMask;
  29810. private _cachedStencilOperationPass;
  29811. private _cachedStencilOperationFail;
  29812. private _cachedStencilOperationDepthFail;
  29813. private _cachedStencilReference;
  29814. /**
  29815. * Caches the the state of the stencil buffer
  29816. */
  29817. cacheStencilState(): void;
  29818. /**
  29819. * Restores the state of the stencil buffer
  29820. */
  29821. restoreStencilState(): void;
  29822. /**
  29823. * Sets the current depth function to LEQUAL
  29824. */
  29825. setDepthFunctionToLessOrEqual(): void;
  29826. /**
  29827. * Gets a boolean indicating if stencil buffer is enabled
  29828. * @returns the current stencil buffer state
  29829. */
  29830. getStencilBuffer(): boolean;
  29831. /**
  29832. * Enable or disable the stencil buffer
  29833. * @param enable defines if the stencil buffer must be enabled or disabled
  29834. */
  29835. setStencilBuffer(enable: boolean): void;
  29836. /**
  29837. * Gets the current stencil mask
  29838. * @returns a number defining the new stencil mask to use
  29839. */
  29840. getStencilMask(): number;
  29841. /**
  29842. * Sets the current stencil mask
  29843. * @param mask defines the new stencil mask to use
  29844. */
  29845. setStencilMask(mask: number): void;
  29846. /**
  29847. * Gets the current stencil function
  29848. * @returns a number defining the stencil function to use
  29849. */
  29850. getStencilFunction(): number;
  29851. /**
  29852. * Gets the current stencil reference value
  29853. * @returns a number defining the stencil reference value to use
  29854. */
  29855. getStencilFunctionReference(): number;
  29856. /**
  29857. * Gets the current stencil mask
  29858. * @returns a number defining the stencil mask to use
  29859. */
  29860. getStencilFunctionMask(): number;
  29861. /**
  29862. * Sets the current stencil function
  29863. * @param stencilFunc defines the new stencil function to use
  29864. */
  29865. setStencilFunction(stencilFunc: number): void;
  29866. /**
  29867. * Sets the current stencil reference
  29868. * @param reference defines the new stencil reference to use
  29869. */
  29870. setStencilFunctionReference(reference: number): void;
  29871. /**
  29872. * Sets the current stencil mask
  29873. * @param mask defines the new stencil mask to use
  29874. */
  29875. setStencilFunctionMask(mask: number): void;
  29876. /**
  29877. * Gets the current stencil operation when stencil fails
  29878. * @returns a number defining stencil operation to use when stencil fails
  29879. */
  29880. getStencilOperationFail(): number;
  29881. /**
  29882. * Gets the current stencil operation when depth fails
  29883. * @returns a number defining stencil operation to use when depth fails
  29884. */
  29885. getStencilOperationDepthFail(): number;
  29886. /**
  29887. * Gets the current stencil operation when stencil passes
  29888. * @returns a number defining stencil operation to use when stencil passes
  29889. */
  29890. getStencilOperationPass(): number;
  29891. /**
  29892. * Sets the stencil operation to use when stencil fails
  29893. * @param operation defines the stencil operation to use when stencil fails
  29894. */
  29895. setStencilOperationFail(operation: number): void;
  29896. /**
  29897. * Sets the stencil operation to use when depth fails
  29898. * @param operation defines the stencil operation to use when depth fails
  29899. */
  29900. setStencilOperationDepthFail(operation: number): void;
  29901. /**
  29902. * Sets the stencil operation to use when stencil passes
  29903. * @param operation defines the stencil operation to use when stencil passes
  29904. */
  29905. setStencilOperationPass(operation: number): void;
  29906. /**
  29907. * Sets a boolean indicating if the dithering state is enabled or disabled
  29908. * @param value defines the dithering state
  29909. */
  29910. setDitheringState(value: boolean): void;
  29911. /**
  29912. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29913. * @param value defines the rasterizer state
  29914. */
  29915. setRasterizerState(value: boolean): void;
  29916. /**
  29917. * stop executing a render loop function and remove it from the execution array
  29918. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29919. */
  29920. stopRenderLoop(renderFunction?: () => void): void;
  29921. /** @hidden */ private _renderLoop(): void;
  29922. /**
  29923. * Register and execute a render loop. The engine can have more than one render function
  29924. * @param renderFunction defines the function to continuously execute
  29925. */
  29926. runRenderLoop(renderFunction: () => void): void;
  29927. /**
  29928. * Toggle full screen mode
  29929. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29930. */
  29931. switchFullscreen(requestPointerLock: boolean): void;
  29932. /**
  29933. * Enters full screen mode
  29934. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29935. */
  29936. enterFullscreen(requestPointerLock: boolean): void;
  29937. /**
  29938. * Exits full screen mode
  29939. */
  29940. exitFullscreen(): void;
  29941. /**
  29942. * Enters Pointerlock mode
  29943. */
  29944. enterPointerlock(): void;
  29945. /**
  29946. * Exits Pointerlock mode
  29947. */
  29948. exitPointerlock(): void;
  29949. /**
  29950. * Clear the current render buffer or the current render target (if any is set up)
  29951. * @param color defines the color to use
  29952. * @param backBuffer defines if the back buffer must be cleared
  29953. * @param depth defines if the depth buffer must be cleared
  29954. * @param stencil defines if the stencil buffer must be cleared
  29955. */
  29956. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29957. /**
  29958. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29959. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29960. * @param y defines the y-coordinate of the corner of the clear rectangle
  29961. * @param width defines the width of the clear rectangle
  29962. * @param height defines the height of the clear rectangle
  29963. * @param clearColor defines the clear color
  29964. */
  29965. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  29966. /**
  29967. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29968. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29969. * @param y defines the y-coordinate of the corner of the clear rectangle
  29970. * @param width defines the width of the clear rectangle
  29971. * @param height defines the height of the clear rectangle
  29972. */
  29973. enableScissor(x: number, y: number, width: number, height: number): void;
  29974. /**
  29975. * Disable previously set scissor test rectangle
  29976. */
  29977. disableScissor(): void;
  29978. private _viewportCached;
  29979. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  29980. /**
  29981. * Set the WebGL's viewport
  29982. * @param viewport defines the viewport element to be used
  29983. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29984. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29985. */
  29986. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29987. /**
  29988. * Directly set the WebGL Viewport
  29989. * @param x defines the x coordinate of the viewport (in screen space)
  29990. * @param y defines the y coordinate of the viewport (in screen space)
  29991. * @param width defines the width of the viewport (in screen space)
  29992. * @param height defines the height of the viewport (in screen space)
  29993. * @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
  29994. */
  29995. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  29996. /**
  29997. * Begin a new frame
  29998. */
  29999. beginFrame(): void;
  30000. /**
  30001. * Enf the current frame
  30002. */
  30003. endFrame(): void;
  30004. /**
  30005. * Resize the view according to the canvas' size
  30006. */
  30007. resize(): void;
  30008. /**
  30009. * Force a specific size of the canvas
  30010. * @param width defines the new canvas' width
  30011. * @param height defines the new canvas' height
  30012. */
  30013. setSize(width: number, height: number): void;
  30014. /**
  30015. * Binds the frame buffer to the specified texture.
  30016. * @param texture The texture to render to or null for the default canvas
  30017. * @param faceIndex The face of the texture to render to in case of cube texture
  30018. * @param requiredWidth The width of the target to render to
  30019. * @param requiredHeight The height of the target to render to
  30020. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30021. * @param depthStencilTexture The depth stencil texture to use to render
  30022. * @param lodLevel defines le lod level to bind to the frame buffer
  30023. */
  30024. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30025. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30026. /**
  30027. * Unbind the current render target texture from the webGL context
  30028. * @param texture defines the render target texture to unbind
  30029. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30030. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30031. */
  30032. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30033. /**
  30034. * Force the mipmap generation for the given render target texture
  30035. * @param texture defines the render target texture to use
  30036. */
  30037. generateMipMapsForCubemap(texture: InternalTexture): void;
  30038. /**
  30039. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30040. */
  30041. flushFramebuffer(): void;
  30042. /**
  30043. * Unbind the current render target and bind the default framebuffer
  30044. */
  30045. restoreDefaultFramebuffer(): void;
  30046. /**
  30047. * Create an uniform buffer
  30048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30049. * @param elements defines the content of the uniform buffer
  30050. * @returns the webGL uniform buffer
  30051. */
  30052. createUniformBuffer(elements: FloatArray): DataBuffer;
  30053. /**
  30054. * Create a dynamic uniform buffer
  30055. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30056. * @param elements defines the content of the uniform buffer
  30057. * @returns the webGL uniform buffer
  30058. */
  30059. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30060. /**
  30061. * Update an existing uniform buffer
  30062. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30063. * @param uniformBuffer defines the target uniform buffer
  30064. * @param elements defines the content to update
  30065. * @param offset defines the offset in the uniform buffer where update should start
  30066. * @param count defines the size of the data to update
  30067. */
  30068. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30069. private _resetVertexBufferBinding;
  30070. /**
  30071. * Creates a vertex buffer
  30072. * @param data the data for the vertex buffer
  30073. * @returns the new WebGL static buffer
  30074. */
  30075. createVertexBuffer(data: DataArray): DataBuffer;
  30076. /**
  30077. * Creates a dynamic vertex buffer
  30078. * @param data the data for the dynamic vertex buffer
  30079. * @returns the new WebGL dynamic buffer
  30080. */
  30081. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30082. /**
  30083. * Update a dynamic index buffer
  30084. * @param indexBuffer defines the target index buffer
  30085. * @param indices defines the data to update
  30086. * @param offset defines the offset in the target index buffer where update should start
  30087. */
  30088. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30089. /**
  30090. * Updates a dynamic vertex buffer.
  30091. * @param vertexBuffer the vertex buffer to update
  30092. * @param data the data used to update the vertex buffer
  30093. * @param byteOffset the byte offset of the data
  30094. * @param byteLength the byte length of the data
  30095. */
  30096. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30097. private _resetIndexBufferBinding;
  30098. /**
  30099. * Creates a new index buffer
  30100. * @param indices defines the content of the index buffer
  30101. * @param updatable defines if the index buffer must be updatable
  30102. * @returns a new webGL buffer
  30103. */
  30104. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30105. /**
  30106. * Bind a webGL buffer to the webGL context
  30107. * @param buffer defines the buffer to bind
  30108. */
  30109. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30110. /**
  30111. * Bind an uniform buffer to the current webGL context
  30112. * @param buffer defines the buffer to bind
  30113. */
  30114. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30115. /**
  30116. * Bind a buffer to the current webGL context at a given location
  30117. * @param buffer defines the buffer to bind
  30118. * @param location defines the index where to bind the buffer
  30119. */
  30120. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30121. /**
  30122. * Bind a specific block at a given index in a specific shader program
  30123. * @param pipelineContext defines the pipeline context to use
  30124. * @param blockName defines the block name
  30125. * @param index defines the index where to bind the block
  30126. */
  30127. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30128. private bindIndexBuffer;
  30129. private bindBuffer;
  30130. /**
  30131. * update the bound buffer with the given data
  30132. * @param data defines the data to update
  30133. */
  30134. updateArrayBuffer(data: Float32Array): void;
  30135. private _vertexAttribPointer;
  30136. private _bindIndexBufferWithCache;
  30137. private _bindVertexBuffersAttributes;
  30138. /**
  30139. * Records a vertex array object
  30140. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30141. * @param vertexBuffers defines the list of vertex buffers to store
  30142. * @param indexBuffer defines the index buffer to store
  30143. * @param effect defines the effect to store
  30144. * @returns the new vertex array object
  30145. */
  30146. recordVertexArrayObject(vertexBuffers: {
  30147. [key: string]: VertexBuffer;
  30148. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30149. /**
  30150. * Bind a specific vertex array object
  30151. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30152. * @param vertexArrayObject defines the vertex array object to bind
  30153. * @param indexBuffer defines the index buffer to bind
  30154. */
  30155. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30156. /**
  30157. * Bind webGl buffers directly to the webGL context
  30158. * @param vertexBuffer defines the vertex buffer to bind
  30159. * @param indexBuffer defines the index buffer to bind
  30160. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30161. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30162. * @param effect defines the effect associated with the vertex buffer
  30163. */
  30164. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30165. private _unbindVertexArrayObject;
  30166. /**
  30167. * Bind a list of vertex buffers to the webGL context
  30168. * @param vertexBuffers defines the list of vertex buffers to bind
  30169. * @param indexBuffer defines the index buffer to bind
  30170. * @param effect defines the effect associated with the vertex buffers
  30171. */
  30172. bindBuffers(vertexBuffers: {
  30173. [key: string]: Nullable<VertexBuffer>;
  30174. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30175. /**
  30176. * Unbind all instance attributes
  30177. */
  30178. unbindInstanceAttributes(): void;
  30179. /**
  30180. * Release and free the memory of a vertex array object
  30181. * @param vao defines the vertex array object to delete
  30182. */
  30183. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30184. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30185. /**
  30186. * Creates a webGL buffer to use with instanciation
  30187. * @param capacity defines the size of the buffer
  30188. * @returns the webGL buffer
  30189. */
  30190. createInstancesBuffer(capacity: number): DataBuffer;
  30191. /**
  30192. * Delete a webGL buffer used with instanciation
  30193. * @param buffer defines the webGL buffer to delete
  30194. */
  30195. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30196. /**
  30197. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30198. * @param instancesBuffer defines the webGL buffer to update and bind
  30199. * @param data defines the data to store in the buffer
  30200. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30201. */
  30202. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30203. /**
  30204. * Apply all cached states (depth, culling, stencil and alpha)
  30205. */
  30206. applyStates(): void;
  30207. /**
  30208. * Send a draw order
  30209. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30210. * @param indexStart defines the starting index
  30211. * @param indexCount defines the number of index to draw
  30212. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30213. */
  30214. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30215. /**
  30216. * Draw a list of points
  30217. * @param verticesStart defines the index of first vertex to draw
  30218. * @param verticesCount defines the count of vertices to draw
  30219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30220. */
  30221. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30222. /**
  30223. * Draw a list of unindexed primitives
  30224. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30225. * @param verticesStart defines the index of first vertex to draw
  30226. * @param verticesCount defines the count of vertices to draw
  30227. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30228. */
  30229. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30230. /**
  30231. * Draw a list of indexed primitives
  30232. * @param fillMode defines the primitive to use
  30233. * @param indexStart defines the starting index
  30234. * @param indexCount defines the number of index to draw
  30235. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30236. */
  30237. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30238. /**
  30239. * Draw a list of unindexed primitives
  30240. * @param fillMode defines the primitive to use
  30241. * @param verticesStart defines the index of first vertex to draw
  30242. * @param verticesCount defines the count of vertices to draw
  30243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30244. */
  30245. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30246. private _drawMode;
  30247. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30248. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30249. /**
  30250. * Create a new effect (used to store vertex/fragment shaders)
  30251. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30252. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30253. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30254. * @param samplers defines an array of string used to represent textures
  30255. * @param defines defines the string containing the defines to use to compile the shaders
  30256. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30257. * @param onCompiled defines a function to call when the effect creation is successful
  30258. * @param onError defines a function to call when the effect creation has failed
  30259. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30260. * @returns the new Effect
  30261. */
  30262. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30263. private _compileShader;
  30264. private _compileRawShader;
  30265. /**
  30266. * Directly creates a webGL program
  30267. * @param pipelineContext defines the pipeline context to attach to
  30268. * @param vertexCode defines the vertex shader code to use
  30269. * @param fragmentCode defines the fragment shader code to use
  30270. * @param context defines the webGL context to use (if not set, the current one will be used)
  30271. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30272. * @returns the new webGL program
  30273. */
  30274. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30275. /**
  30276. * Creates a webGL program
  30277. * @param pipelineContext defines the pipeline context to attach to
  30278. * @param vertexCode defines the vertex shader code to use
  30279. * @param fragmentCode defines the fragment shader code to use
  30280. * @param defines defines the string containing the defines to use to compile the shaders
  30281. * @param context defines the webGL context to use (if not set, the current one will be used)
  30282. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30283. * @returns the new webGL program
  30284. */
  30285. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30286. /**
  30287. * Creates a new pipeline context
  30288. * @returns the new pipeline
  30289. */
  30290. createPipelineContext(): WebGLPipelineContext;
  30291. private _createShaderProgram;
  30292. private _finalizePipelineContext;
  30293. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30294. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30295. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30296. /**
  30297. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30298. * @param pipelineContext defines the pipeline context to use
  30299. * @param uniformsNames defines the list of uniform names
  30300. * @returns an array of webGL uniform locations
  30301. */
  30302. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30303. /**
  30304. * Gets the lsit of active attributes for a given webGL program
  30305. * @param pipelineContext defines the pipeline context to use
  30306. * @param attributesNames defines the list of attribute names to get
  30307. * @returns an array of indices indicating the offset of each attribute
  30308. */
  30309. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30310. /**
  30311. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30312. * @param effect defines the effect to activate
  30313. */
  30314. enableEffect(effect: Nullable<Effect>): void;
  30315. /**
  30316. * Set the value of an uniform to an array of int32
  30317. * @param uniform defines the webGL uniform location where to store the value
  30318. * @param array defines the array of int32 to store
  30319. */
  30320. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30321. /**
  30322. * Set the value of an uniform to an array of int32 (stored as vec2)
  30323. * @param uniform defines the webGL uniform location where to store the value
  30324. * @param array defines the array of int32 to store
  30325. */
  30326. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30327. /**
  30328. * Set the value of an uniform to an array of int32 (stored as vec3)
  30329. * @param uniform defines the webGL uniform location where to store the value
  30330. * @param array defines the array of int32 to store
  30331. */
  30332. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30333. /**
  30334. * Set the value of an uniform to an array of int32 (stored as vec4)
  30335. * @param uniform defines the webGL uniform location where to store the value
  30336. * @param array defines the array of int32 to store
  30337. */
  30338. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30339. /**
  30340. * Set the value of an uniform to an array of float32
  30341. * @param uniform defines the webGL uniform location where to store the value
  30342. * @param array defines the array of float32 to store
  30343. */
  30344. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30345. /**
  30346. * Set the value of an uniform to an array of float32 (stored as vec2)
  30347. * @param uniform defines the webGL uniform location where to store the value
  30348. * @param array defines the array of float32 to store
  30349. */
  30350. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30351. /**
  30352. * Set the value of an uniform to an array of float32 (stored as vec3)
  30353. * @param uniform defines the webGL uniform location where to store the value
  30354. * @param array defines the array of float32 to store
  30355. */
  30356. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30357. /**
  30358. * Set the value of an uniform to an array of float32 (stored as vec4)
  30359. * @param uniform defines the webGL uniform location where to store the value
  30360. * @param array defines the array of float32 to store
  30361. */
  30362. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30363. /**
  30364. * Set the value of an uniform to an array of number
  30365. * @param uniform defines the webGL uniform location where to store the value
  30366. * @param array defines the array of number to store
  30367. */
  30368. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30369. /**
  30370. * Set the value of an uniform to an array of number (stored as vec2)
  30371. * @param uniform defines the webGL uniform location where to store the value
  30372. * @param array defines the array of number to store
  30373. */
  30374. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30375. /**
  30376. * Set the value of an uniform to an array of number (stored as vec3)
  30377. * @param uniform defines the webGL uniform location where to store the value
  30378. * @param array defines the array of number to store
  30379. */
  30380. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30381. /**
  30382. * Set the value of an uniform to an array of number (stored as vec4)
  30383. * @param uniform defines the webGL uniform location where to store the value
  30384. * @param array defines the array of number to store
  30385. */
  30386. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30387. /**
  30388. * Set the value of an uniform to an array of float32 (stored as matrices)
  30389. * @param uniform defines the webGL uniform location where to store the value
  30390. * @param matrices defines the array of float32 to store
  30391. */
  30392. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30393. /**
  30394. * Set the value of an uniform to a matrix (3x3)
  30395. * @param uniform defines the webGL uniform location where to store the value
  30396. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30397. */
  30398. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30399. /**
  30400. * Set the value of an uniform to a matrix (2x2)
  30401. * @param uniform defines the webGL uniform location where to store the value
  30402. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30403. */
  30404. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30405. /**
  30406. * Set the value of an uniform to a number (int)
  30407. * @param uniform defines the webGL uniform location where to store the value
  30408. * @param value defines the int number to store
  30409. */
  30410. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30411. /**
  30412. * Set the value of an uniform to a number (float)
  30413. * @param uniform defines the webGL uniform location where to store the value
  30414. * @param value defines the float number to store
  30415. */
  30416. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30417. /**
  30418. * Set the value of an uniform to a vec2
  30419. * @param uniform defines the webGL uniform location where to store the value
  30420. * @param x defines the 1st component of the value
  30421. * @param y defines the 2nd component of the value
  30422. */
  30423. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30424. /**
  30425. * Set the value of an uniform to a vec3
  30426. * @param uniform defines the webGL uniform location where to store the value
  30427. * @param x defines the 1st component of the value
  30428. * @param y defines the 2nd component of the value
  30429. * @param z defines the 3rd component of the value
  30430. */
  30431. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30432. /**
  30433. * Set the value of an uniform to a boolean
  30434. * @param uniform defines the webGL uniform location where to store the value
  30435. * @param bool defines the boolean to store
  30436. */
  30437. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30438. /**
  30439. * Set the value of an uniform to a vec4
  30440. * @param uniform defines the webGL uniform location where to store the value
  30441. * @param x defines the 1st component of the value
  30442. * @param y defines the 2nd component of the value
  30443. * @param z defines the 3rd component of the value
  30444. * @param w defines the 4th component of the value
  30445. */
  30446. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30447. /**
  30448. * Sets a Color4 on a uniform variable
  30449. * @param uniform defines the uniform location
  30450. * @param color4 defines the value to be set
  30451. */
  30452. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30453. /**
  30454. * Set various states to the webGL context
  30455. * @param culling defines backface culling state
  30456. * @param zOffset defines the value to apply to zOffset (0 by default)
  30457. * @param force defines if states must be applied even if cache is up to date
  30458. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30459. */
  30460. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30461. /**
  30462. * Set the z offset to apply to current rendering
  30463. * @param value defines the offset to apply
  30464. */
  30465. setZOffset(value: number): void;
  30466. /**
  30467. * Gets the current value of the zOffset
  30468. * @returns the current zOffset state
  30469. */
  30470. getZOffset(): number;
  30471. /**
  30472. * Enable or disable depth buffering
  30473. * @param enable defines the state to set
  30474. */
  30475. setDepthBuffer(enable: boolean): void;
  30476. /**
  30477. * Gets a boolean indicating if depth writing is enabled
  30478. * @returns the current depth writing state
  30479. */
  30480. getDepthWrite(): boolean;
  30481. /**
  30482. * Enable or disable depth writing
  30483. * @param enable defines the state to set
  30484. */
  30485. setDepthWrite(enable: boolean): void;
  30486. /**
  30487. * Enable or disable color writing
  30488. * @param enable defines the state to set
  30489. */
  30490. setColorWrite(enable: boolean): void;
  30491. /**
  30492. * Gets a boolean indicating if color writing is enabled
  30493. * @returns the current color writing state
  30494. */
  30495. getColorWrite(): boolean;
  30496. /**
  30497. * Sets alpha constants used by some alpha blending modes
  30498. * @param r defines the red component
  30499. * @param g defines the green component
  30500. * @param b defines the blue component
  30501. * @param a defines the alpha component
  30502. */
  30503. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30504. /**
  30505. * Sets the current alpha mode
  30506. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30507. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30508. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30509. */
  30510. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30511. /**
  30512. * Gets the current alpha mode
  30513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30514. * @returns the current alpha mode
  30515. */
  30516. getAlphaMode(): number;
  30517. /**
  30518. * Clears the list of texture accessible through engine.
  30519. * This can help preventing texture load conflict due to name collision.
  30520. */
  30521. clearInternalTexturesCache(): void;
  30522. /**
  30523. * Force the entire cache to be cleared
  30524. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30525. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30526. */
  30527. wipeCaches(bruteForce?: boolean): void;
  30528. /**
  30529. * Set the compressed texture format to use, based on the formats you have, and the formats
  30530. * supported by the hardware / browser.
  30531. *
  30532. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30533. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30534. * to API arguments needed to compressed textures. This puts the burden on the container
  30535. * generator to house the arcane code for determining these for current & future formats.
  30536. *
  30537. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30538. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30539. *
  30540. * Note: The result of this call is not taken into account when a texture is base64.
  30541. *
  30542. * @param formatsAvailable defines the list of those format families you have created
  30543. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30544. *
  30545. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30546. * @returns The extension selected.
  30547. */
  30548. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30549. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30550. min: number;
  30551. mag: number;
  30552. };
  30553. /** @hidden */ private _createTexture(): WebGLTexture;
  30554. /**
  30555. * Usually called from Texture.ts.
  30556. * Passed information to create a WebGLTexture
  30557. * @param urlArg defines a value which contains one of the following:
  30558. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30559. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30560. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30561. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30562. * @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)
  30563. * @param scene needed for loading to the correct scene
  30564. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30565. * @param onLoad optional callback to be called upon successful completion
  30566. * @param onError optional callback to be called upon failure
  30567. * @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
  30568. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30569. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30570. * @param forcedExtension defines the extension to use to pick the right loader
  30571. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30572. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30573. */
  30574. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30575. /**
  30576. * @hidden
  30577. * Rescales a texture
  30578. * @param source input texutre
  30579. * @param destination destination texture
  30580. * @param scene scene to use to render the resize
  30581. * @param internalFormat format to use when resizing
  30582. * @param onComplete callback to be called when resize has completed
  30583. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  30584. private _unpackFlipYCached;
  30585. /**
  30586. * In case you are sharing the context with other applications, it might
  30587. * be interested to not cache the unpack flip y state to ensure a consistent
  30588. * value would be set.
  30589. */
  30590. enableUnpackFlipYCached: boolean;
  30591. /** @hidden */ private _unpackFlipY(value: boolean): void;
  30592. /** @hidden */ private _getUnpackAlignement(): number;
  30593. /**
  30594. * Creates a dynamic texture
  30595. * @param width defines the width of the texture
  30596. * @param height defines the height of the texture
  30597. * @param generateMipMaps defines if the engine should generate the mip levels
  30598. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30599. * @returns the dynamic texture inside an InternalTexture
  30600. */
  30601. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30602. /**
  30603. * Update the sampling mode of a given texture
  30604. * @param samplingMode defines the required sampling mode
  30605. * @param texture defines the texture to update
  30606. */
  30607. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30608. /**
  30609. * Update the content of a dynamic texture
  30610. * @param texture defines the texture to update
  30611. * @param canvas defines the canvas containing the source
  30612. * @param invertY defines if data must be stored with Y axis inverted
  30613. * @param premulAlpha defines if alpha is stored as premultiplied
  30614. * @param format defines the format of the data
  30615. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30616. */
  30617. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30618. /**
  30619. * Update a video texture
  30620. * @param texture defines the texture to update
  30621. * @param video defines the video element to use
  30622. * @param invertY defines if data must be stored with Y axis inverted
  30623. */
  30624. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30625. /**
  30626. * Updates a depth texture Comparison Mode and Function.
  30627. * If the comparison Function is equal to 0, the mode will be set to none.
  30628. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30629. * @param texture The texture to set the comparison function for
  30630. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30631. */
  30632. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30633. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30634. width: number;
  30635. height: number;
  30636. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30637. /**
  30638. * Creates a depth stencil texture.
  30639. * This is only available in WebGL 2 or with the depth texture extension available.
  30640. * @param size The size of face edge in the texture.
  30641. * @param options The options defining the texture.
  30642. * @returns The texture
  30643. */
  30644. createDepthStencilTexture(size: number | {
  30645. width: number;
  30646. height: number;
  30647. }, options: DepthTextureCreationOptions): InternalTexture;
  30648. /**
  30649. * Creates a depth stencil texture.
  30650. * This is only available in WebGL 2 or with the depth texture extension available.
  30651. * @param size The size of face edge in the texture.
  30652. * @param options The options defining the texture.
  30653. * @returns The texture
  30654. */
  30655. private _createDepthStencilTexture;
  30656. /**
  30657. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30658. * @param renderTarget The render target to set the frame buffer for
  30659. */
  30660. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30661. /**
  30662. * Creates a new render target texture
  30663. * @param size defines the size of the texture
  30664. * @param options defines the options used to create the texture
  30665. * @returns a new render target texture stored in an InternalTexture
  30666. */
  30667. createRenderTargetTexture(size: number | {
  30668. width: number;
  30669. height: number;
  30670. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30671. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30672. /**
  30673. * Updates the sample count of a render target texture
  30674. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30675. * @param texture defines the texture to update
  30676. * @param samples defines the sample count to set
  30677. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30678. */
  30679. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30680. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30681. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30682. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30683. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30684. /**
  30685. * @hidden
  30686. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  30687. private _prepareWebGLTextureContinuation;
  30688. private _prepareWebGLTexture;
  30689. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30690. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  30691. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  30692. private setProgram;
  30693. private _boundUniforms;
  30694. /**
  30695. * Binds an effect to the webGL context
  30696. * @param effect defines the effect to bind
  30697. */
  30698. bindSamplers(effect: Effect): void;
  30699. private _activateCurrentTexture;
  30700. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30701. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30702. /**
  30703. * Sets a texture to the webGL context from a postprocess
  30704. * @param channel defines the channel to use
  30705. * @param postProcess defines the source postprocess
  30706. */
  30707. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30708. /**
  30709. * Binds the output of the passed in post process to the texture channel specified
  30710. * @param channel The channel the texture should be bound to
  30711. * @param postProcess The post process which's output should be bound
  30712. */
  30713. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30714. /**
  30715. * Unbind all textures from the webGL context
  30716. */
  30717. unbindAllTextures(): void;
  30718. /**
  30719. * Sets a texture to the according uniform.
  30720. * @param channel The texture channel
  30721. * @param uniform The uniform to set
  30722. * @param texture The texture to apply
  30723. */
  30724. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30725. /**
  30726. * Sets a depth stencil texture from a render target to the according uniform.
  30727. * @param channel The texture channel
  30728. * @param uniform The uniform to set
  30729. * @param texture The render target texture containing the depth stencil texture to apply
  30730. */
  30731. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30732. private _bindSamplerUniformToChannel;
  30733. private _getTextureWrapMode;
  30734. private _setTexture;
  30735. /**
  30736. * Sets an array of texture to the webGL context
  30737. * @param channel defines the channel where the texture array must be set
  30738. * @param uniform defines the associated uniform location
  30739. * @param textures defines the array of textures to bind
  30740. */
  30741. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30742. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30743. private _setTextureParameterFloat;
  30744. private _setTextureParameterInteger;
  30745. /**
  30746. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30747. * @param x defines the x coordinate of the rectangle where pixels must be read
  30748. * @param y defines the y coordinate of the rectangle where pixels must be read
  30749. * @param width defines the width of the rectangle where pixels must be read
  30750. * @param height defines the height of the rectangle where pixels must be read
  30751. * @returns a Uint8Array containing RGBA colors
  30752. */
  30753. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30754. /**
  30755. * Add an externaly attached data from its key.
  30756. * This method call will fail and return false, if such key already exists.
  30757. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  30758. * @param key the unique key that identifies the data
  30759. * @param data the data object to associate to the key for this Engine instance
  30760. * @return true if no such key were already present and the data was added successfully, false otherwise
  30761. */
  30762. addExternalData<T>(key: string, data: T): boolean;
  30763. /**
  30764. * Get an externaly attached data from its key
  30765. * @param key the unique key that identifies the data
  30766. * @return the associated data, if present (can be null), or undefined if not present
  30767. */
  30768. getExternalData<T>(key: string): T;
  30769. /**
  30770. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30771. * @param key the unique key that identifies the data
  30772. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30773. * @return the associated data, can be null if the factory returned null.
  30774. */
  30775. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30776. /**
  30777. * Remove an externaly attached data from the Engine instance
  30778. * @param key the unique key that identifies the data
  30779. * @return true if the data was successfully removed, false if it doesn't exist
  30780. */
  30781. removeExternalData(key: string): boolean;
  30782. /**
  30783. * Unbind all vertex attributes from the webGL context
  30784. */
  30785. unbindAllAttributes(): void;
  30786. /**
  30787. * 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
  30788. */
  30789. releaseEffects(): void;
  30790. /**
  30791. * Dispose and release all associated resources
  30792. */
  30793. dispose(): void;
  30794. /**
  30795. * Display the loading screen
  30796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30797. */
  30798. displayLoadingUI(): void;
  30799. /**
  30800. * Hide the loading screen
  30801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30802. */
  30803. hideLoadingUI(): void;
  30804. /**
  30805. * Gets the current loading screen object
  30806. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30807. */
  30808. /**
  30809. * Sets the current loading screen object
  30810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30811. */
  30812. loadingScreen: ILoadingScreen;
  30813. /**
  30814. * Sets the current loading screen text
  30815. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30816. */
  30817. loadingUIText: string;
  30818. /**
  30819. * Sets the current loading screen background color
  30820. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30821. */
  30822. loadingUIBackgroundColor: string;
  30823. /**
  30824. * Attach a new callback raised when context lost event is fired
  30825. * @param callback defines the callback to call
  30826. */
  30827. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30828. /**
  30829. * Attach a new callback raised when context restored event is fired
  30830. * @param callback defines the callback to call
  30831. */
  30832. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30833. /**
  30834. * Gets the source code of the vertex shader associated with a specific webGL program
  30835. * @param program defines the program to use
  30836. * @returns a string containing the source code of the vertex shader associated with the program
  30837. */
  30838. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30839. /**
  30840. * Gets the source code of the fragment shader associated with a specific webGL program
  30841. * @param program defines the program to use
  30842. * @returns a string containing the source code of the fragment shader associated with the program
  30843. */
  30844. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30845. /**
  30846. * Get the current error code of the webGL context
  30847. * @returns the error code
  30848. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30849. */
  30850. getError(): number;
  30851. /**
  30852. * Gets the current framerate
  30853. * @returns a number representing the framerate
  30854. */
  30855. getFps(): number;
  30856. /**
  30857. * Gets the time spent between current and previous frame
  30858. * @returns a number representing the delta time in ms
  30859. */
  30860. getDeltaTime(): number;
  30861. private _measureFps;
  30862. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30863. private _canRenderToFloatFramebuffer;
  30864. private _canRenderToHalfFloatFramebuffer;
  30865. private _canRenderToFramebuffer;
  30866. /** @hidden */ private _getWebGLTextureType(type: number): number;
  30867. /** @hidden */ private _getInternalFormat(format: number): number;
  30868. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30869. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  30870. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30871. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30872. /**
  30873. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30874. * @returns true if the engine can be created
  30875. * @ignorenaming
  30876. */
  30877. static isSupported(): boolean;
  30878. /**
  30879. * Find the next highest power of two.
  30880. * @param x Number to start search from.
  30881. * @return Next highest power of two.
  30882. */
  30883. static CeilingPOT(x: number): number;
  30884. /**
  30885. * Find the next lowest power of two.
  30886. * @param x Number to start search from.
  30887. * @return Next lowest power of two.
  30888. */
  30889. static FloorPOT(x: number): number;
  30890. /**
  30891. * Find the nearest power of two.
  30892. * @param x Number to start search from.
  30893. * @return Next nearest power of two.
  30894. */
  30895. static NearestPOT(x: number): number;
  30896. /**
  30897. * Get the closest exponent of two
  30898. * @param value defines the value to approximate
  30899. * @param max defines the maximum value to return
  30900. * @param mode defines how to define the closest value
  30901. * @returns closest exponent of two of the given value
  30902. */
  30903. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30904. /**
  30905. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30906. * @param func - the function to be called
  30907. * @param requester - the object that will request the next frame. Falls back to window.
  30908. * @returns frame number
  30909. */
  30910. static QueueNewFrame(func: () => void, requester?: any): number;
  30911. /**
  30912. * Ask the browser to promote the current element to pointerlock mode
  30913. * @param element defines the DOM element to promote
  30914. */ private static _RequestPointerlock(element: HTMLElement): void;
  30915. /**
  30916. * Asks the browser to exit pointerlock mode
  30917. */ private static _ExitPointerlock(): void;
  30918. /**
  30919. * Ask the browser to promote the current element to fullscreen rendering mode
  30920. * @param element defines the DOM element to promote
  30921. */ private static _RequestFullscreen(element: HTMLElement): void;
  30922. /**
  30923. * Asks the browser to exit fullscreen mode
  30924. */ private static _ExitFullscreen(): void;
  30925. }
  30926. }
  30927. declare module BABYLON {
  30928. /**
  30929. * The engine store class is responsible to hold all the instances of Engine and Scene created
  30930. * during the life time of the application.
  30931. */
  30932. export class EngineStore {
  30933. /** Gets the list of created engines */
  30934. static Instances: Engine[];
  30935. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  30936. /**
  30937. * Gets the latest created engine
  30938. */
  30939. static readonly LastCreatedEngine: Nullable<Engine>;
  30940. /**
  30941. * Gets the latest created scene
  30942. */
  30943. static readonly LastCreatedScene: Nullable<Scene>;
  30944. /**
  30945. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30946. * @ignorenaming
  30947. */
  30948. static UseFallbackTexture: boolean;
  30949. /**
  30950. * Texture content used if a texture cannot loaded
  30951. * @ignorenaming
  30952. */
  30953. static FallbackTexture: string;
  30954. }
  30955. }
  30956. declare module BABYLON {
  30957. /**
  30958. * Helper class that provides a small promise polyfill
  30959. */
  30960. export class PromisePolyfill {
  30961. /**
  30962. * Static function used to check if the polyfill is required
  30963. * If this is the case then the function will inject the polyfill to window.Promise
  30964. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30965. */
  30966. static Apply(force?: boolean): void;
  30967. }
  30968. }
  30969. declare module BABYLON {
  30970. /**
  30971. * Interface for screenshot methods with describe argument called `size` as object with options
  30972. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  30973. */
  30974. export interface IScreenshotSize {
  30975. /**
  30976. * number in pixels for canvas height
  30977. */
  30978. height?: number;
  30979. /**
  30980. * multiplier allowing render at a higher or lower resolution
  30981. * If value is defined then height and width will be ignored and taken from camera
  30982. */
  30983. precision?: number;
  30984. /**
  30985. * number in pixels for canvas width
  30986. */
  30987. width?: number;
  30988. }
  30989. }
  30990. declare module BABYLON {
  30991. interface IColor4Like {
  30992. r: float;
  30993. g: float;
  30994. b: float;
  30995. a: float;
  30996. }
  30997. /**
  30998. * Class containing a set of static utilities functions
  30999. */
  31000. export class Tools {
  31001. /**
  31002. * Gets or sets the base URL to use to load assets
  31003. */
  31004. static BaseUrl: string;
  31005. /**
  31006. * Enable/Disable Custom HTTP Request Headers globally.
  31007. * default = false
  31008. * @see CustomRequestHeaders
  31009. */
  31010. static UseCustomRequestHeaders: boolean;
  31011. /**
  31012. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31013. * i.e. when loading files, where the server/service expects an Authorization header
  31014. */
  31015. static CustomRequestHeaders: {
  31016. [key: string]: string;
  31017. };
  31018. /**
  31019. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31020. */
  31021. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31022. /**
  31023. * Default behaviour for cors in the application.
  31024. * It can be a string if the expected behavior is identical in the entire app.
  31025. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31026. */
  31027. static CorsBehavior: string | ((url: string | string[]) => string);
  31028. /**
  31029. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31030. * @ignorenaming
  31031. */
  31032. static UseFallbackTexture: boolean;
  31033. /**
  31034. * Use this object to register external classes like custom textures or material
  31035. * to allow the laoders to instantiate them
  31036. */
  31037. static RegisteredExternalClasses: {
  31038. [key: string]: Object;
  31039. };
  31040. /**
  31041. * Texture content used if a texture cannot loaded
  31042. * @ignorenaming
  31043. */
  31044. static fallbackTexture: string;
  31045. /**
  31046. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31047. * @param u defines the coordinate on X axis
  31048. * @param v defines the coordinate on Y axis
  31049. * @param width defines the width of the source data
  31050. * @param height defines the height of the source data
  31051. * @param pixels defines the source byte array
  31052. * @param color defines the output color
  31053. */
  31054. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31055. /**
  31056. * Interpolates between a and b via alpha
  31057. * @param a The lower value (returned when alpha = 0)
  31058. * @param b The upper value (returned when alpha = 1)
  31059. * @param alpha The interpolation-factor
  31060. * @return The mixed value
  31061. */
  31062. static Mix(a: number, b: number, alpha: number): number;
  31063. /**
  31064. * Tries to instantiate a new object from a given class name
  31065. * @param className defines the class name to instantiate
  31066. * @returns the new object or null if the system was not able to do the instantiation
  31067. */
  31068. static Instantiate(className: string): any;
  31069. /**
  31070. * Provides a slice function that will work even on IE
  31071. * @param data defines the array to slice
  31072. * @param start defines the start of the data (optional)
  31073. * @param end defines the end of the data (optional)
  31074. * @returns the new sliced array
  31075. */
  31076. static Slice<T>(data: T, start?: number, end?: number): T;
  31077. /**
  31078. * Polyfill for setImmediate
  31079. * @param action defines the action to execute after the current execution block
  31080. */
  31081. static SetImmediate(action: () => void): void;
  31082. /**
  31083. * Function indicating if a number is an exponent of 2
  31084. * @param value defines the value to test
  31085. * @returns true if the value is an exponent of 2
  31086. */
  31087. static IsExponentOfTwo(value: number): boolean;
  31088. private static _tmpFloatArray;
  31089. /**
  31090. * Returns the nearest 32-bit single precision float representation of a Number
  31091. * @param value A Number. If the parameter is of a different type, it will get converted
  31092. * to a number or to NaN if it cannot be converted
  31093. * @returns number
  31094. */
  31095. static FloatRound(value: number): number;
  31096. /**
  31097. * Extracts the filename from a path
  31098. * @param path defines the path to use
  31099. * @returns the filename
  31100. */
  31101. static GetFilename(path: string): string;
  31102. /**
  31103. * Extracts the "folder" part of a path (everything before the filename).
  31104. * @param uri The URI to extract the info from
  31105. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31106. * @returns The "folder" part of the path
  31107. */
  31108. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31109. /**
  31110. * Extracts text content from a DOM element hierarchy
  31111. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31112. */
  31113. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31114. /**
  31115. * Convert an angle in radians to degrees
  31116. * @param angle defines the angle to convert
  31117. * @returns the angle in degrees
  31118. */
  31119. static ToDegrees(angle: number): number;
  31120. /**
  31121. * Convert an angle in degrees to radians
  31122. * @param angle defines the angle to convert
  31123. * @returns the angle in radians
  31124. */
  31125. static ToRadians(angle: number): number;
  31126. /**
  31127. * Encode a buffer to a base64 string
  31128. * @param buffer defines the buffer to encode
  31129. * @returns the encoded string
  31130. */
  31131. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31132. /**
  31133. * Returns an array if obj is not an array
  31134. * @param obj defines the object to evaluate as an array
  31135. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31136. * @returns either obj directly if obj is an array or a new array containing obj
  31137. */
  31138. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31139. /**
  31140. * Gets the pointer prefix to use
  31141. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31142. */
  31143. static GetPointerPrefix(): string;
  31144. /**
  31145. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31146. * @param url define the url we are trying
  31147. * @param element define the dom element where to configure the cors policy
  31148. */
  31149. static SetCorsBehavior(url: string | string[], element: {
  31150. crossOrigin: string | null;
  31151. }): void;
  31152. /**
  31153. * Removes unwanted characters from an url
  31154. * @param url defines the url to clean
  31155. * @returns the cleaned url
  31156. */
  31157. static CleanUrl(url: string): string;
  31158. /**
  31159. * Gets or sets a function used to pre-process url before using them to load assets
  31160. */
  31161. static PreprocessUrl: (url: string) => string;
  31162. /**
  31163. * Loads an image as an HTMLImageElement.
  31164. * @param input url string, ArrayBuffer, or Blob to load
  31165. * @param onLoad callback called when the image successfully loads
  31166. * @param onError callback called when the image fails to load
  31167. * @param offlineProvider offline provider for caching
  31168. * @returns the HTMLImageElement of the loaded image
  31169. */
  31170. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31171. /**
  31172. * Loads a file
  31173. * @param url url string, ArrayBuffer, or Blob to load
  31174. * @param onSuccess callback called when the file successfully loads
  31175. * @param onProgress callback called while file is loading (if the server supports this mode)
  31176. * @param offlineProvider defines the offline provider for caching
  31177. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31178. * @param onError callback called when the file fails to load
  31179. * @returns a file request object
  31180. */
  31181. 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;
  31182. /**
  31183. * Loads a file from a url
  31184. * @param url the file url to load
  31185. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31186. */
  31187. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31188. /**
  31189. * Load a script (identified by an url). When the url returns, the
  31190. * content of this file is added into a new script element, attached to the DOM (body element)
  31191. * @param scriptUrl defines the url of the script to laod
  31192. * @param onSuccess defines the callback called when the script is loaded
  31193. * @param onError defines the callback to call if an error occurs
  31194. * @param scriptId defines the id of the script element
  31195. */
  31196. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31197. /**
  31198. * Load an asynchronous script (identified by an url). When the url returns, the
  31199. * content of this file is added into a new script element, attached to the DOM (body element)
  31200. * @param scriptUrl defines the url of the script to laod
  31201. * @param scriptId defines the id of the script element
  31202. * @returns a promise request object
  31203. */
  31204. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31205. /**
  31206. * Loads a file from a blob
  31207. * @param fileToLoad defines the blob to use
  31208. * @param callback defines the callback to call when data is loaded
  31209. * @param progressCallback defines the callback to call during loading process
  31210. * @returns a file request object
  31211. */
  31212. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31213. /**
  31214. * Loads a file
  31215. * @param fileToLoad defines the file to load
  31216. * @param callback defines the callback to call when data is loaded
  31217. * @param progressCallBack defines the callback to call during loading process
  31218. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31219. * @returns a file request object
  31220. */
  31221. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31222. /**
  31223. * Creates a data url from a given string content
  31224. * @param content defines the content to convert
  31225. * @returns the new data url link
  31226. */
  31227. static FileAsURL(content: string): string;
  31228. /**
  31229. * Format the given number to a specific decimal format
  31230. * @param value defines the number to format
  31231. * @param decimals defines the number of decimals to use
  31232. * @returns the formatted string
  31233. */
  31234. static Format(value: number, decimals?: number): string;
  31235. /**
  31236. * Tries to copy an object by duplicating every property
  31237. * @param source defines the source object
  31238. * @param destination defines the target object
  31239. * @param doNotCopyList defines a list of properties to avoid
  31240. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31241. */
  31242. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31243. /**
  31244. * Gets a boolean indicating if the given object has no own property
  31245. * @param obj defines the object to test
  31246. * @returns true if object has no own property
  31247. */
  31248. static IsEmpty(obj: any): boolean;
  31249. /**
  31250. * Function used to register events at window level
  31251. * @param windowElement defines the Window object to use
  31252. * @param events defines the events to register
  31253. */
  31254. static RegisterTopRootEvents(windowElement: Window, events: {
  31255. name: string;
  31256. handler: Nullable<(e: FocusEvent) => any>;
  31257. }[]): void;
  31258. /**
  31259. * Function used to unregister events from window level
  31260. * @param windowElement defines the Window object to use
  31261. * @param events defines the events to unregister
  31262. */
  31263. static UnregisterTopRootEvents(windowElement: Window, events: {
  31264. name: string;
  31265. handler: Nullable<(e: FocusEvent) => any>;
  31266. }[]): void;
  31267. /**
  31268. * @ignore
  31269. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31270. /**
  31271. * Dumps the current bound framebuffer
  31272. * @param width defines the rendering width
  31273. * @param height defines the rendering height
  31274. * @param engine defines the hosting engine
  31275. * @param successCallback defines the callback triggered once the data are available
  31276. * @param mimeType defines the mime type of the result
  31277. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31278. */
  31279. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31280. /**
  31281. * Converts the canvas data to blob.
  31282. * This acts as a polyfill for browsers not supporting the to blob function.
  31283. * @param canvas Defines the canvas to extract the data from
  31284. * @param successCallback Defines the callback triggered once the data are available
  31285. * @param mimeType Defines the mime type of the result
  31286. */
  31287. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31288. /**
  31289. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31290. * @param successCallback defines the callback triggered once the data are available
  31291. * @param mimeType defines the mime type of the result
  31292. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31293. */
  31294. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31295. /**
  31296. * Downloads a blob in the browser
  31297. * @param blob defines the blob to download
  31298. * @param fileName defines the name of the downloaded file
  31299. */
  31300. static Download(blob: Blob, fileName: string): void;
  31301. /**
  31302. * Captures a screenshot of the current rendering
  31303. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31304. * @param engine defines the rendering engine
  31305. * @param camera defines the source camera
  31306. * @param size This parameter can be set to a single number or to an object with the
  31307. * following (optional) properties: precision, width, height. If a single number is passed,
  31308. * it will be used for both width and height. If an object is passed, the screenshot size
  31309. * will be derived from the parameters. The precision property is a multiplier allowing
  31310. * rendering at a higher or lower resolution
  31311. * @param successCallback defines the callback receives a single parameter which contains the
  31312. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31313. * src parameter of an <img> to display it
  31314. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31315. * Check your browser for supported MIME types
  31316. */
  31317. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31318. /**
  31319. * Captures a screenshot of the current rendering
  31320. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31321. * @param engine defines the rendering engine
  31322. * @param camera defines the source camera
  31323. * @param size This parameter can be set to a single number or to an object with the
  31324. * following (optional) properties: precision, width, height. If a single number is passed,
  31325. * it will be used for both width and height. If an object is passed, the screenshot size
  31326. * will be derived from the parameters. The precision property is a multiplier allowing
  31327. * rendering at a higher or lower resolution
  31328. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31329. * Check your browser for supported MIME types
  31330. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31331. * to the src parameter of an <img> to display it
  31332. */
  31333. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31334. /**
  31335. * Generates an image screenshot from the specified camera.
  31336. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31337. * @param engine The engine to use for rendering
  31338. * @param camera The camera to use for rendering
  31339. * @param size This parameter can be set to a single number or to an object with the
  31340. * following (optional) properties: precision, width, height. If a single number is passed,
  31341. * it will be used for both width and height. If an object is passed, the screenshot size
  31342. * will be derived from the parameters. The precision property is a multiplier allowing
  31343. * rendering at a higher or lower resolution
  31344. * @param successCallback The callback receives a single parameter which contains the
  31345. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31346. * src parameter of an <img> to display it
  31347. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31348. * Check your browser for supported MIME types
  31349. * @param samples Texture samples (default: 1)
  31350. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31351. * @param fileName A name for for the downloaded file.
  31352. */
  31353. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31354. /**
  31355. * Generates an image screenshot from the specified camera.
  31356. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31357. * @param engine The engine to use for rendering
  31358. * @param camera The camera to use for rendering
  31359. * @param size This parameter can be set to a single number or to an object with the
  31360. * following (optional) properties: precision, width, height. If a single number is passed,
  31361. * it will be used for both width and height. If an object is passed, the screenshot size
  31362. * will be derived from the parameters. The precision property is a multiplier allowing
  31363. * rendering at a higher or lower resolution
  31364. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31365. * Check your browser for supported MIME types
  31366. * @param samples Texture samples (default: 1)
  31367. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31368. * @param fileName A name for for the downloaded file.
  31369. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31370. * to the src parameter of an <img> to display it
  31371. */
  31372. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31373. /**
  31374. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31375. * Be aware Math.random() could cause collisions, but:
  31376. * "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"
  31377. * @returns a pseudo random id
  31378. */
  31379. static RandomId(): string;
  31380. /**
  31381. * Test if the given uri is a base64 string
  31382. * @param uri The uri to test
  31383. * @return True if the uri is a base64 string or false otherwise
  31384. */
  31385. static IsBase64(uri: string): boolean;
  31386. /**
  31387. * Decode the given base64 uri.
  31388. * @param uri The uri to decode
  31389. * @return The decoded base64 data.
  31390. */
  31391. static DecodeBase64(uri: string): ArrayBuffer;
  31392. /**
  31393. * Gets the absolute url.
  31394. * @param url the input url
  31395. * @return the absolute url
  31396. */
  31397. static GetAbsoluteUrl(url: string): string;
  31398. /**
  31399. * No log
  31400. */
  31401. static readonly NoneLogLevel: number;
  31402. /**
  31403. * Only message logs
  31404. */
  31405. static readonly MessageLogLevel: number;
  31406. /**
  31407. * Only warning logs
  31408. */
  31409. static readonly WarningLogLevel: number;
  31410. /**
  31411. * Only error logs
  31412. */
  31413. static readonly ErrorLogLevel: number;
  31414. /**
  31415. * All logs
  31416. */
  31417. static readonly AllLogLevel: number;
  31418. /**
  31419. * Gets a value indicating the number of loading errors
  31420. * @ignorenaming
  31421. */
  31422. static readonly errorsCount: number;
  31423. /**
  31424. * Callback called when a new log is added
  31425. */
  31426. static OnNewCacheEntry: (entry: string) => void;
  31427. /**
  31428. * Log a message to the console
  31429. * @param message defines the message to log
  31430. */
  31431. static Log(message: string): void;
  31432. /**
  31433. * Write a warning message to the console
  31434. * @param message defines the message to log
  31435. */
  31436. static Warn(message: string): void;
  31437. /**
  31438. * Write an error message to the console
  31439. * @param message defines the message to log
  31440. */
  31441. static Error(message: string): void;
  31442. /**
  31443. * Gets current log cache (list of logs)
  31444. */
  31445. static readonly LogCache: string;
  31446. /**
  31447. * Clears the log cache
  31448. */
  31449. static ClearLogCache(): void;
  31450. /**
  31451. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31452. */
  31453. static LogLevels: number;
  31454. /**
  31455. * Checks if the window object exists
  31456. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31457. */
  31458. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31459. /**
  31460. * No performance log
  31461. */
  31462. static readonly PerformanceNoneLogLevel: number;
  31463. /**
  31464. * Use user marks to log performance
  31465. */
  31466. static readonly PerformanceUserMarkLogLevel: number;
  31467. /**
  31468. * Log performance to the console
  31469. */
  31470. static readonly PerformanceConsoleLogLevel: number;
  31471. private static _performance;
  31472. /**
  31473. * Sets the current performance log level
  31474. */
  31475. static PerformanceLogLevel: number;
  31476. private static _StartPerformanceCounterDisabled;
  31477. private static _EndPerformanceCounterDisabled;
  31478. private static _StartUserMark;
  31479. private static _EndUserMark;
  31480. private static _StartPerformanceConsole;
  31481. private static _EndPerformanceConsole;
  31482. /**
  31483. * Starts a performance counter
  31484. */
  31485. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31486. /**
  31487. * Ends a specific performance coutner
  31488. */
  31489. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31490. /**
  31491. * Gets either window.performance.now() if supported or Date.now() else
  31492. */
  31493. static readonly Now: number;
  31494. /**
  31495. * This method will return the name of the class used to create the instance of the given object.
  31496. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31497. * @param object the object to get the class name from
  31498. * @param isType defines if the object is actually a type
  31499. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31500. */
  31501. static GetClassName(object: any, isType?: boolean): string;
  31502. /**
  31503. * Gets the first element of an array satisfying a given predicate
  31504. * @param array defines the array to browse
  31505. * @param predicate defines the predicate to use
  31506. * @returns null if not found or the element
  31507. */
  31508. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31509. /**
  31510. * This method will return the name of the full name of the class, including its owning module (if any).
  31511. * 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).
  31512. * @param object the object to get the class name from
  31513. * @param isType defines if the object is actually a type
  31514. * @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.
  31515. * @ignorenaming
  31516. */
  31517. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31518. /**
  31519. * Returns a promise that resolves after the given amount of time.
  31520. * @param delay Number of milliseconds to delay
  31521. * @returns Promise that resolves after the given amount of time
  31522. */
  31523. static DelayAsync(delay: number): Promise<void>;
  31524. }
  31525. /**
  31526. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31527. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31528. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31529. * @param name The name of the class, case should be preserved
  31530. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31531. */
  31532. export function className(name: string, module?: string): (target: Object) => void;
  31533. /**
  31534. * An implementation of a loop for asynchronous functions.
  31535. */
  31536. export class AsyncLoop {
  31537. /**
  31538. * Defines the number of iterations for the loop
  31539. */
  31540. iterations: number;
  31541. /**
  31542. * Defines the current index of the loop.
  31543. */
  31544. index: number;
  31545. private _done;
  31546. private _fn;
  31547. private _successCallback;
  31548. /**
  31549. * Constructor.
  31550. * @param iterations the number of iterations.
  31551. * @param func the function to run each iteration
  31552. * @param successCallback the callback that will be called upon succesful execution
  31553. * @param offset starting offset.
  31554. */
  31555. constructor(
  31556. /**
  31557. * Defines the number of iterations for the loop
  31558. */
  31559. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31560. /**
  31561. * Execute the next iteration. Must be called after the last iteration was finished.
  31562. */
  31563. executeNext(): void;
  31564. /**
  31565. * Break the loop and run the success callback.
  31566. */
  31567. breakLoop(): void;
  31568. /**
  31569. * Create and run an async loop.
  31570. * @param iterations the number of iterations.
  31571. * @param fn the function to run each iteration
  31572. * @param successCallback the callback that will be called upon succesful execution
  31573. * @param offset starting offset.
  31574. * @returns the created async loop object
  31575. */
  31576. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31577. /**
  31578. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31579. * @param iterations total number of iterations
  31580. * @param syncedIterations number of synchronous iterations in each async iteration.
  31581. * @param fn the function to call each iteration.
  31582. * @param callback a success call back that will be called when iterating stops.
  31583. * @param breakFunction a break condition (optional)
  31584. * @param timeout timeout settings for the setTimeout function. default - 0.
  31585. * @returns the created async loop object
  31586. */
  31587. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31588. }
  31589. }
  31590. declare module BABYLON {
  31591. /** @hidden */
  31592. export interface ICollisionCoordinator {
  31593. createCollider(): Collider;
  31594. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31595. init(scene: Scene): void;
  31596. }
  31597. /** @hidden */
  31598. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31599. private _scene;
  31600. private _scaledPosition;
  31601. private _scaledVelocity;
  31602. private _finalPosition;
  31603. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31604. createCollider(): Collider;
  31605. init(scene: Scene): void;
  31606. private _collideWithWorld;
  31607. }
  31608. }
  31609. declare module BABYLON {
  31610. /**
  31611. * Class used to manage all inputs for the scene.
  31612. */
  31613. export class InputManager {
  31614. /** The distance in pixel that you have to move to prevent some events */
  31615. static DragMovementThreshold: number;
  31616. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31617. static LongPressDelay: number;
  31618. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31619. static DoubleClickDelay: number;
  31620. /** If you need to check double click without raising a single click at first click, enable this flag */
  31621. static ExclusiveDoubleClickMode: boolean;
  31622. private _wheelEventName;
  31623. private _onPointerMove;
  31624. private _onPointerDown;
  31625. private _onPointerUp;
  31626. private _initClickEvent;
  31627. private _initActionManager;
  31628. private _delayedSimpleClick;
  31629. private _delayedSimpleClickTimeout;
  31630. private _previousDelayedSimpleClickTimeout;
  31631. private _meshPickProceed;
  31632. private _previousButtonPressed;
  31633. private _currentPickResult;
  31634. private _previousPickResult;
  31635. private _totalPointersPressed;
  31636. private _doubleClickOccured;
  31637. private _pointerOverMesh;
  31638. private _pickedDownMesh;
  31639. private _pickedUpMesh;
  31640. private _pointerX;
  31641. private _pointerY;
  31642. private _unTranslatedPointerX;
  31643. private _unTranslatedPointerY;
  31644. private _startingPointerPosition;
  31645. private _previousStartingPointerPosition;
  31646. private _startingPointerTime;
  31647. private _previousStartingPointerTime;
  31648. private _pointerCaptures;
  31649. private _onKeyDown;
  31650. private _onKeyUp;
  31651. private _onCanvasFocusObserver;
  31652. private _onCanvasBlurObserver;
  31653. private _scene;
  31654. /**
  31655. * Creates a new InputManager
  31656. * @param scene defines the hosting scene
  31657. */
  31658. constructor(scene: Scene);
  31659. /**
  31660. * Gets the mesh that is currently under the pointer
  31661. */
  31662. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31663. /**
  31664. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31665. */
  31666. readonly unTranslatedPointer: Vector2;
  31667. /**
  31668. * Gets or sets the current on-screen X position of the pointer
  31669. */
  31670. pointerX: number;
  31671. /**
  31672. * Gets or sets the current on-screen Y position of the pointer
  31673. */
  31674. pointerY: number;
  31675. private _updatePointerPosition;
  31676. private _processPointerMove;
  31677. private _setRayOnPointerInfo;
  31678. private _checkPrePointerObservable;
  31679. /**
  31680. * Use this method to simulate a pointer move on a mesh
  31681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31684. */
  31685. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31686. /**
  31687. * Use this method to simulate a pointer down on a mesh
  31688. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31689. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31690. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31691. */
  31692. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31693. private _processPointerDown;
  31694. /** @hidden */ private _isPointerSwiping(): boolean;
  31695. /**
  31696. * Use this method to simulate a pointer up on a mesh
  31697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31700. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31701. */
  31702. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31703. private _processPointerUp;
  31704. /**
  31705. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31706. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31707. * @returns true if the pointer was captured
  31708. */
  31709. isPointerCaptured(pointerId?: number): boolean;
  31710. /**
  31711. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31712. * @param attachUp defines if you want to attach events to pointerup
  31713. * @param attachDown defines if you want to attach events to pointerdown
  31714. * @param attachMove defines if you want to attach events to pointermove
  31715. */
  31716. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31717. /**
  31718. * Detaches all event handlers
  31719. */
  31720. detachControl(): void;
  31721. /**
  31722. * Force the value of meshUnderPointer
  31723. * @param mesh defines the mesh to use
  31724. */
  31725. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31726. /**
  31727. * Gets the mesh under the pointer
  31728. * @returns a Mesh or null if no mesh is under the pointer
  31729. */
  31730. getPointerOverMesh(): Nullable<AbstractMesh>;
  31731. }
  31732. }
  31733. declare module BABYLON {
  31734. /**
  31735. * Helper class used to generate session unique ID
  31736. */
  31737. export class UniqueIdGenerator {
  31738. private static _UniqueIdCounter;
  31739. /**
  31740. * Gets an unique (relatively to the current scene) Id
  31741. */
  31742. static readonly UniqueId: number;
  31743. }
  31744. }
  31745. declare module BABYLON {
  31746. /**
  31747. * This class defines the direct association between an animation and a target
  31748. */
  31749. export class TargetedAnimation {
  31750. /**
  31751. * Animation to perform
  31752. */
  31753. animation: Animation;
  31754. /**
  31755. * Target to animate
  31756. */
  31757. target: any;
  31758. /**
  31759. * Serialize the object
  31760. * @returns the JSON object representing the current entity
  31761. */
  31762. serialize(): any;
  31763. }
  31764. /**
  31765. * Use this class to create coordinated animations on multiple targets
  31766. */
  31767. export class AnimationGroup implements IDisposable {
  31768. /** The name of the animation group */
  31769. name: string;
  31770. private _scene;
  31771. private _targetedAnimations;
  31772. private _animatables;
  31773. private _from;
  31774. private _to;
  31775. private _isStarted;
  31776. private _isPaused;
  31777. private _speedRatio;
  31778. private _loopAnimation;
  31779. /**
  31780. * Gets or sets the unique id of the node
  31781. */
  31782. uniqueId: number;
  31783. /**
  31784. * This observable will notify when one animation have ended
  31785. */
  31786. onAnimationEndObservable: Observable<TargetedAnimation>;
  31787. /**
  31788. * Observer raised when one animation loops
  31789. */
  31790. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31791. /**
  31792. * This observable will notify when all animations have ended.
  31793. */
  31794. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31795. /**
  31796. * This observable will notify when all animations have paused.
  31797. */
  31798. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31799. /**
  31800. * This observable will notify when all animations are playing.
  31801. */
  31802. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31803. /**
  31804. * Gets the first frame
  31805. */
  31806. readonly from: number;
  31807. /**
  31808. * Gets the last frame
  31809. */
  31810. readonly to: number;
  31811. /**
  31812. * Define if the animations are started
  31813. */
  31814. readonly isStarted: boolean;
  31815. /**
  31816. * Gets a value indicating that the current group is playing
  31817. */
  31818. readonly isPlaying: boolean;
  31819. /**
  31820. * Gets or sets the speed ratio to use for all animations
  31821. */
  31822. /**
  31823. * Gets or sets the speed ratio to use for all animations
  31824. */
  31825. speedRatio: number;
  31826. /**
  31827. * Gets or sets if all animations should loop or not
  31828. */
  31829. loopAnimation: boolean;
  31830. /**
  31831. * Gets the targeted animations for this animation group
  31832. */
  31833. readonly targetedAnimations: Array<TargetedAnimation>;
  31834. /**
  31835. * returning the list of animatables controlled by this animation group.
  31836. */
  31837. readonly animatables: Array<Animatable>;
  31838. /**
  31839. * Instantiates a new Animation Group.
  31840. * This helps managing several animations at once.
  31841. * @see http://doc.babylonjs.com/how_to/group
  31842. * @param name Defines the name of the group
  31843. * @param scene Defines the scene the group belongs to
  31844. */
  31845. constructor(
  31846. /** The name of the animation group */
  31847. name: string, scene?: Nullable<Scene>);
  31848. /**
  31849. * Add an animation (with its target) in the group
  31850. * @param animation defines the animation we want to add
  31851. * @param target defines the target of the animation
  31852. * @returns the TargetedAnimation object
  31853. */
  31854. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31855. /**
  31856. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31857. * It can add constant keys at begin or end
  31858. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31859. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31860. * @returns the animation group
  31861. */
  31862. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31863. /**
  31864. * Start all animations on given targets
  31865. * @param loop defines if animations must loop
  31866. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31867. * @param from defines the from key (optional)
  31868. * @param to defines the to key (optional)
  31869. * @returns the current animation group
  31870. */
  31871. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31872. /**
  31873. * Pause all animations
  31874. * @returns the animation group
  31875. */
  31876. pause(): AnimationGroup;
  31877. /**
  31878. * Play all animations to initial state
  31879. * This function will start() the animations if they were not started or will restart() them if they were paused
  31880. * @param loop defines if animations must loop
  31881. * @returns the animation group
  31882. */
  31883. play(loop?: boolean): AnimationGroup;
  31884. /**
  31885. * Reset all animations to initial state
  31886. * @returns the animation group
  31887. */
  31888. reset(): AnimationGroup;
  31889. /**
  31890. * Restart animations from key 0
  31891. * @returns the animation group
  31892. */
  31893. restart(): AnimationGroup;
  31894. /**
  31895. * Stop all animations
  31896. * @returns the animation group
  31897. */
  31898. stop(): AnimationGroup;
  31899. /**
  31900. * Set animation weight for all animatables
  31901. * @param weight defines the weight to use
  31902. * @return the animationGroup
  31903. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31904. */
  31905. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31906. /**
  31907. * Synchronize and normalize all animatables with a source animatable
  31908. * @param root defines the root animatable to synchronize with
  31909. * @return the animationGroup
  31910. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31911. */
  31912. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31913. /**
  31914. * Goes to a specific frame in this animation group
  31915. * @param frame the frame number to go to
  31916. * @return the animationGroup
  31917. */
  31918. goToFrame(frame: number): AnimationGroup;
  31919. /**
  31920. * Dispose all associated resources
  31921. */
  31922. dispose(): void;
  31923. private _checkAnimationGroupEnded;
  31924. /**
  31925. * Clone the current animation group and returns a copy
  31926. * @param newName defines the name of the new group
  31927. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31928. * @returns the new aniamtion group
  31929. */
  31930. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31931. /**
  31932. * Serializes the animationGroup to an object
  31933. * @returns Serialized object
  31934. */
  31935. serialize(): any;
  31936. /**
  31937. * Returns a new AnimationGroup object parsed from the source provided.
  31938. * @param parsedAnimationGroup defines the source
  31939. * @param scene defines the scene that will receive the animationGroup
  31940. * @returns a new AnimationGroup
  31941. */
  31942. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31943. /**
  31944. * Returns the string "AnimationGroup"
  31945. * @returns "AnimationGroup"
  31946. */
  31947. getClassName(): string;
  31948. /**
  31949. * Creates a detailled string about the object
  31950. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31951. * @returns a string representing the object
  31952. */
  31953. toString(fullDetails?: boolean): string;
  31954. }
  31955. }
  31956. declare module BABYLON {
  31957. /**
  31958. * Define an interface for all classes that will hold resources
  31959. */
  31960. export interface IDisposable {
  31961. /**
  31962. * Releases all held resources
  31963. */
  31964. dispose(): void;
  31965. }
  31966. /** Interface defining initialization parameters for Scene class */
  31967. export interface SceneOptions {
  31968. /**
  31969. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31970. * It will improve performance when the number of geometries becomes important.
  31971. */
  31972. useGeometryUniqueIdsMap?: boolean;
  31973. /**
  31974. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31975. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31976. */
  31977. useMaterialMeshMap?: boolean;
  31978. /**
  31979. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31980. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31981. */
  31982. useClonedMeshhMap?: boolean;
  31983. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31984. virtual?: boolean;
  31985. }
  31986. /**
  31987. * Represents a scene to be rendered by the engine.
  31988. * @see http://doc.babylonjs.com/features/scene
  31989. */
  31990. export class Scene extends AbstractScene implements IAnimatable {
  31991. /** The fog is deactivated */
  31992. static readonly FOGMODE_NONE: number;
  31993. /** The fog density is following an exponential function */
  31994. static readonly FOGMODE_EXP: number;
  31995. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31996. static readonly FOGMODE_EXP2: number;
  31997. /** The fog density is following a linear function. */
  31998. static readonly FOGMODE_LINEAR: number;
  31999. /**
  32000. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32002. */
  32003. static MinDeltaTime: number;
  32004. /**
  32005. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32007. */
  32008. static MaxDeltaTime: number;
  32009. /**
  32010. * Factory used to create the default material.
  32011. * @param name The name of the material to create
  32012. * @param scene The scene to create the material for
  32013. * @returns The default material
  32014. */
  32015. static DefaultMaterialFactory(scene: Scene): Material;
  32016. /**
  32017. * Factory used to create the a collision coordinator.
  32018. * @returns The collision coordinator
  32019. */
  32020. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32021. /** @hidden */ private _inputManager: InputManager;
  32022. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32023. cameraToUseForPointers: Nullable<Camera>;
  32024. /** @hidden */ protected readonly _isScene: boolean;
  32025. /**
  32026. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32027. */
  32028. autoClear: boolean;
  32029. /**
  32030. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32031. */
  32032. autoClearDepthAndStencil: boolean;
  32033. /**
  32034. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32035. */
  32036. clearColor: Color4;
  32037. /**
  32038. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32039. */
  32040. ambientColor: Color3;
  32041. /**
  32042. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32043. * It should only be one of the following (if not the default embedded one):
  32044. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32045. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32046. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32047. * The material properties need to be setup according to the type of texture in use.
  32048. */
  32049. environmentBRDFTexture: BaseTexture;
  32050. /** @hidden */
  32051. protected _environmentTexture: Nullable<BaseTexture>;
  32052. /**
  32053. * Texture used in all pbr material as the reflection texture.
  32054. * As in the majority of the scene they are the same (exception for multi room and so on),
  32055. * this is easier to reference from here than from all the materials.
  32056. */
  32057. /**
  32058. * Texture used in all pbr material as the reflection texture.
  32059. * As in the majority of the scene they are the same (exception for multi room and so on),
  32060. * this is easier to set here than in all the materials.
  32061. */
  32062. environmentTexture: Nullable<BaseTexture>;
  32063. /** @hidden */
  32064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32065. /**
  32066. * Default image processing configuration used either in the rendering
  32067. * Forward main pass or through the imageProcessingPostProcess if present.
  32068. * As in the majority of the scene they are the same (exception for multi camera),
  32069. * this is easier to reference from here than from all the materials and post process.
  32070. *
  32071. * No setter as we it is a shared configuration, you can set the values instead.
  32072. */
  32073. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32074. private _forceWireframe;
  32075. /**
  32076. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32077. */
  32078. forceWireframe: boolean;
  32079. private _forcePointsCloud;
  32080. /**
  32081. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32082. */
  32083. forcePointsCloud: boolean;
  32084. /**
  32085. * Gets or sets the active clipplane 1
  32086. */
  32087. clipPlane: Nullable<Plane>;
  32088. /**
  32089. * Gets or sets the active clipplane 2
  32090. */
  32091. clipPlane2: Nullable<Plane>;
  32092. /**
  32093. * Gets or sets the active clipplane 3
  32094. */
  32095. clipPlane3: Nullable<Plane>;
  32096. /**
  32097. * Gets or sets the active clipplane 4
  32098. */
  32099. clipPlane4: Nullable<Plane>;
  32100. /**
  32101. * Gets or sets a boolean indicating if animations are enabled
  32102. */
  32103. animationsEnabled: boolean;
  32104. private _animationPropertiesOverride;
  32105. /**
  32106. * Gets or sets the animation properties override
  32107. */
  32108. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32109. /**
  32110. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32111. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32112. */
  32113. useConstantAnimationDeltaTime: boolean;
  32114. /**
  32115. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32116. * Please note that it requires to run a ray cast through the scene on every frame
  32117. */
  32118. constantlyUpdateMeshUnderPointer: boolean;
  32119. /**
  32120. * Defines the HTML cursor to use when hovering over interactive elements
  32121. */
  32122. hoverCursor: string;
  32123. /**
  32124. * Defines the HTML default cursor to use (empty by default)
  32125. */
  32126. defaultCursor: string;
  32127. /**
  32128. * This is used to call preventDefault() on pointer down
  32129. * in order to block unwanted artifacts like system double clicks
  32130. */
  32131. preventDefaultOnPointerDown: boolean;
  32132. /**
  32133. * This is used to call preventDefault() on pointer up
  32134. * in order to block unwanted artifacts like system double clicks
  32135. */
  32136. preventDefaultOnPointerUp: boolean;
  32137. /**
  32138. * Gets or sets user defined metadata
  32139. */
  32140. metadata: any;
  32141. /**
  32142. * For internal use only. Please do not use.
  32143. */
  32144. reservedDataStore: any;
  32145. /**
  32146. * Gets the name of the plugin used to load this scene (null by default)
  32147. */
  32148. loadingPluginName: string;
  32149. /**
  32150. * Use this array to add regular expressions used to disable offline support for specific urls
  32151. */
  32152. disableOfflineSupportExceptionRules: RegExp[];
  32153. /**
  32154. * An event triggered when the scene is disposed.
  32155. */
  32156. onDisposeObservable: Observable<Scene>;
  32157. private _onDisposeObserver;
  32158. /** Sets a function to be executed when this scene is disposed. */
  32159. onDispose: () => void;
  32160. /**
  32161. * An event triggered before rendering the scene (right after animations and physics)
  32162. */
  32163. onBeforeRenderObservable: Observable<Scene>;
  32164. private _onBeforeRenderObserver;
  32165. /** Sets a function to be executed before rendering this scene */
  32166. beforeRender: Nullable<() => void>;
  32167. /**
  32168. * An event triggered after rendering the scene
  32169. */
  32170. onAfterRenderObservable: Observable<Scene>;
  32171. /**
  32172. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32173. */
  32174. onAfterRenderCameraObservable: Observable<Camera>;
  32175. private _onAfterRenderObserver;
  32176. /** Sets a function to be executed after rendering this scene */
  32177. afterRender: Nullable<() => void>;
  32178. /**
  32179. * An event triggered before animating the scene
  32180. */
  32181. onBeforeAnimationsObservable: Observable<Scene>;
  32182. /**
  32183. * An event triggered after animations processing
  32184. */
  32185. onAfterAnimationsObservable: Observable<Scene>;
  32186. /**
  32187. * An event triggered before draw calls are ready to be sent
  32188. */
  32189. onBeforeDrawPhaseObservable: Observable<Scene>;
  32190. /**
  32191. * An event triggered after draw calls have been sent
  32192. */
  32193. onAfterDrawPhaseObservable: Observable<Scene>;
  32194. /**
  32195. * An event triggered when the scene is ready
  32196. */
  32197. onReadyObservable: Observable<Scene>;
  32198. /**
  32199. * An event triggered before rendering a camera
  32200. */
  32201. onBeforeCameraRenderObservable: Observable<Camera>;
  32202. private _onBeforeCameraRenderObserver;
  32203. /** Sets a function to be executed before rendering a camera*/
  32204. beforeCameraRender: () => void;
  32205. /**
  32206. * An event triggered after rendering a camera
  32207. */
  32208. onAfterCameraRenderObservable: Observable<Camera>;
  32209. private _onAfterCameraRenderObserver;
  32210. /** Sets a function to be executed after rendering a camera*/
  32211. afterCameraRender: () => void;
  32212. /**
  32213. * An event triggered when active meshes evaluation is about to start
  32214. */
  32215. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32216. /**
  32217. * An event triggered when active meshes evaluation is done
  32218. */
  32219. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32220. /**
  32221. * An event triggered when particles rendering is about to start
  32222. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32223. */
  32224. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32225. /**
  32226. * An event triggered when particles rendering is done
  32227. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32228. */
  32229. onAfterParticlesRenderingObservable: Observable<Scene>;
  32230. /**
  32231. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32232. */
  32233. onDataLoadedObservable: Observable<Scene>;
  32234. /**
  32235. * An event triggered when a camera is created
  32236. */
  32237. onNewCameraAddedObservable: Observable<Camera>;
  32238. /**
  32239. * An event triggered when a camera is removed
  32240. */
  32241. onCameraRemovedObservable: Observable<Camera>;
  32242. /**
  32243. * An event triggered when a light is created
  32244. */
  32245. onNewLightAddedObservable: Observable<Light>;
  32246. /**
  32247. * An event triggered when a light is removed
  32248. */
  32249. onLightRemovedObservable: Observable<Light>;
  32250. /**
  32251. * An event triggered when a geometry is created
  32252. */
  32253. onNewGeometryAddedObservable: Observable<Geometry>;
  32254. /**
  32255. * An event triggered when a geometry is removed
  32256. */
  32257. onGeometryRemovedObservable: Observable<Geometry>;
  32258. /**
  32259. * An event triggered when a transform node is created
  32260. */
  32261. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32262. /**
  32263. * An event triggered when a transform node is removed
  32264. */
  32265. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32266. /**
  32267. * An event triggered when a mesh is created
  32268. */
  32269. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32270. /**
  32271. * An event triggered when a mesh is removed
  32272. */
  32273. onMeshRemovedObservable: Observable<AbstractMesh>;
  32274. /**
  32275. * An event triggered when a skeleton is created
  32276. */
  32277. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32278. /**
  32279. * An event triggered when a skeleton is removed
  32280. */
  32281. onSkeletonRemovedObservable: Observable<Skeleton>;
  32282. /**
  32283. * An event triggered when a material is created
  32284. */
  32285. onNewMaterialAddedObservable: Observable<Material>;
  32286. /**
  32287. * An event triggered when a material is removed
  32288. */
  32289. onMaterialRemovedObservable: Observable<Material>;
  32290. /**
  32291. * An event triggered when a texture is created
  32292. */
  32293. onNewTextureAddedObservable: Observable<BaseTexture>;
  32294. /**
  32295. * An event triggered when a texture is removed
  32296. */
  32297. onTextureRemovedObservable: Observable<BaseTexture>;
  32298. /**
  32299. * An event triggered when render targets are about to be rendered
  32300. * Can happen multiple times per frame.
  32301. */
  32302. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32303. /**
  32304. * An event triggered when render targets were rendered.
  32305. * Can happen multiple times per frame.
  32306. */
  32307. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32308. /**
  32309. * An event triggered before calculating deterministic simulation step
  32310. */
  32311. onBeforeStepObservable: Observable<Scene>;
  32312. /**
  32313. * An event triggered after calculating deterministic simulation step
  32314. */
  32315. onAfterStepObservable: Observable<Scene>;
  32316. /**
  32317. * An event triggered when the activeCamera property is updated
  32318. */
  32319. onActiveCameraChanged: Observable<Scene>;
  32320. /**
  32321. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32322. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32323. * 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)
  32324. */
  32325. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32326. /**
  32327. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32328. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32329. * 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)
  32330. */
  32331. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32332. /**
  32333. * This Observable will when a mesh has been imported into the scene.
  32334. */
  32335. onMeshImportedObservable: Observable<AbstractMesh>;
  32336. /**
  32337. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32338. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32339. */
  32340. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32341. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32342. /**
  32343. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32344. */
  32345. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32346. /**
  32347. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32348. */
  32349. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32350. /**
  32351. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32352. */
  32353. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32354. /** Callback called when a pointer move is detected */
  32355. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32356. /** Callback called when a pointer down is detected */
  32357. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32358. /** Callback called when a pointer up is detected */
  32359. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32360. /** Callback called when a pointer pick is detected */
  32361. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32362. /**
  32363. * 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).
  32364. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32365. */
  32366. onPrePointerObservable: Observable<PointerInfoPre>;
  32367. /**
  32368. * Observable event triggered each time an input event is received from the rendering canvas
  32369. */
  32370. onPointerObservable: Observable<PointerInfo>;
  32371. /**
  32372. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32373. */
  32374. readonly unTranslatedPointer: Vector2;
  32375. /**
  32376. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32377. */
  32378. static DragMovementThreshold: number;
  32379. /**
  32380. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32381. */
  32382. static LongPressDelay: number;
  32383. /**
  32384. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32385. */
  32386. static DoubleClickDelay: number;
  32387. /** If you need to check double click without raising a single click at first click, enable this flag */
  32388. static ExclusiveDoubleClickMode: boolean;
  32389. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32390. /**
  32391. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32392. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32393. */
  32394. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32395. /**
  32396. * Observable event triggered each time an keyboard event is received from the hosting window
  32397. */
  32398. onKeyboardObservable: Observable<KeyboardInfo>;
  32399. private _useRightHandedSystem;
  32400. /**
  32401. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32402. */
  32403. useRightHandedSystem: boolean;
  32404. private _timeAccumulator;
  32405. private _currentStepId;
  32406. private _currentInternalStep;
  32407. /**
  32408. * Sets the step Id used by deterministic lock step
  32409. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32410. * @param newStepId defines the step Id
  32411. */
  32412. setStepId(newStepId: number): void;
  32413. /**
  32414. * Gets the step Id used by deterministic lock step
  32415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32416. * @returns the step Id
  32417. */
  32418. getStepId(): number;
  32419. /**
  32420. * Gets the internal step used by deterministic lock step
  32421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32422. * @returns the internal step
  32423. */
  32424. getInternalStep(): number;
  32425. private _fogEnabled;
  32426. /**
  32427. * Gets or sets a boolean indicating if fog is enabled on this scene
  32428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32429. * (Default is true)
  32430. */
  32431. fogEnabled: boolean;
  32432. private _fogMode;
  32433. /**
  32434. * Gets or sets the fog mode to use
  32435. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32436. * | mode | value |
  32437. * | --- | --- |
  32438. * | FOGMODE_NONE | 0 |
  32439. * | FOGMODE_EXP | 1 |
  32440. * | FOGMODE_EXP2 | 2 |
  32441. * | FOGMODE_LINEAR | 3 |
  32442. */
  32443. fogMode: number;
  32444. /**
  32445. * Gets or sets the fog color to use
  32446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32447. * (Default is Color3(0.2, 0.2, 0.3))
  32448. */
  32449. fogColor: Color3;
  32450. /**
  32451. * Gets or sets the fog density to use
  32452. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32453. * (Default is 0.1)
  32454. */
  32455. fogDensity: number;
  32456. /**
  32457. * Gets or sets the fog start distance to use
  32458. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32459. * (Default is 0)
  32460. */
  32461. fogStart: number;
  32462. /**
  32463. * Gets or sets the fog end distance to use
  32464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32465. * (Default is 1000)
  32466. */
  32467. fogEnd: number;
  32468. private _shadowsEnabled;
  32469. /**
  32470. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32471. */
  32472. shadowsEnabled: boolean;
  32473. private _lightsEnabled;
  32474. /**
  32475. * Gets or sets a boolean indicating if lights are enabled on this scene
  32476. */
  32477. lightsEnabled: boolean;
  32478. /** All of the active cameras added to this scene. */
  32479. activeCameras: Camera[];
  32480. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32481. /** Gets or sets the current active camera */
  32482. activeCamera: Nullable<Camera>;
  32483. private _defaultMaterial;
  32484. /** The default material used on meshes when no material is affected */
  32485. /** The default material used on meshes when no material is affected */
  32486. defaultMaterial: Material;
  32487. private _texturesEnabled;
  32488. /**
  32489. * Gets or sets a boolean indicating if textures are enabled on this scene
  32490. */
  32491. texturesEnabled: boolean;
  32492. /**
  32493. * Gets or sets a boolean indicating if particles are enabled on this scene
  32494. */
  32495. particlesEnabled: boolean;
  32496. /**
  32497. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32498. */
  32499. spritesEnabled: boolean;
  32500. private _skeletonsEnabled;
  32501. /**
  32502. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32503. */
  32504. skeletonsEnabled: boolean;
  32505. /**
  32506. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32507. */
  32508. lensFlaresEnabled: boolean;
  32509. /**
  32510. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32512. */
  32513. collisionsEnabled: boolean;
  32514. private _collisionCoordinator;
  32515. /** @hidden */
  32516. readonly collisionCoordinator: ICollisionCoordinator;
  32517. /**
  32518. * Defines the gravity applied to this scene (used only for collisions)
  32519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32520. */
  32521. gravity: Vector3;
  32522. /**
  32523. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32524. */
  32525. postProcessesEnabled: boolean;
  32526. /**
  32527. * The list of postprocesses added to the scene
  32528. */
  32529. postProcesses: PostProcess[];
  32530. /**
  32531. * Gets the current postprocess manager
  32532. */
  32533. postProcessManager: PostProcessManager;
  32534. /**
  32535. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32536. */
  32537. renderTargetsEnabled: boolean;
  32538. /**
  32539. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32540. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32541. */
  32542. dumpNextRenderTargets: boolean;
  32543. /**
  32544. * The list of user defined render targets added to the scene
  32545. */
  32546. customRenderTargets: RenderTargetTexture[];
  32547. /**
  32548. * Defines if texture loading must be delayed
  32549. * If true, textures will only be loaded when they need to be rendered
  32550. */
  32551. useDelayedTextureLoading: boolean;
  32552. /**
  32553. * Gets the list of meshes imported to the scene through SceneLoader
  32554. */
  32555. importedMeshesFiles: String[];
  32556. /**
  32557. * Gets or sets a boolean indicating if probes are enabled on this scene
  32558. */
  32559. probesEnabled: boolean;
  32560. /**
  32561. * Gets or sets the current offline provider to use to store scene data
  32562. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32563. */
  32564. offlineProvider: IOfflineProvider;
  32565. /**
  32566. * Gets or sets the action manager associated with the scene
  32567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32568. */
  32569. actionManager: AbstractActionManager;
  32570. private _meshesForIntersections;
  32571. /**
  32572. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32573. */
  32574. proceduralTexturesEnabled: boolean;
  32575. private _engine;
  32576. private _totalVertices;
  32577. /** @hidden */ private _activeIndices: PerfCounter;
  32578. /** @hidden */ private _activeParticles: PerfCounter;
  32579. /** @hidden */ private _activeBones: PerfCounter;
  32580. private _animationRatio;
  32581. /** @hidden */ private _animationTimeLast: number;
  32582. /** @hidden */ private _animationTime: number;
  32583. /**
  32584. * Gets or sets a general scale for animation speed
  32585. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32586. */
  32587. animationTimeScale: number;
  32588. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32589. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32590. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32591. private _renderId;
  32592. private _frameId;
  32593. private _executeWhenReadyTimeoutId;
  32594. private _intermediateRendering;
  32595. private _viewUpdateFlag;
  32596. private _projectionUpdateFlag;
  32597. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32598. private _activeRequests;
  32599. /** @hidden */ private _pendingData: any[];
  32600. private _isDisposed;
  32601. /**
  32602. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32603. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32604. */
  32605. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32606. private _activeMeshes;
  32607. private _processedMaterials;
  32608. private _renderTargets;
  32609. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32610. private _activeSkeletons;
  32611. private _softwareSkinnedMeshes;
  32612. private _renderingManager;
  32613. /** @hidden */ private _activeAnimatables: Animatable[];
  32614. private _transformMatrix;
  32615. private _sceneUbo;
  32616. /** @hidden */ private _viewMatrix: Matrix;
  32617. private _projectionMatrix;
  32618. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32619. /** @hidden */ private _frustumPlanes: Plane[];
  32620. /**
  32621. * Gets the list of frustum planes (built from the active camera)
  32622. */
  32623. readonly frustumPlanes: Plane[];
  32624. /**
  32625. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32626. * This is useful if there are more lights that the maximum simulteanous authorized
  32627. */
  32628. requireLightSorting: boolean;
  32629. /** @hidden */
  32630. readonly useMaterialMeshMap: boolean;
  32631. /** @hidden */
  32632. readonly useClonedMeshhMap: boolean;
  32633. private _externalData;
  32634. private _uid;
  32635. /**
  32636. * @hidden
  32637. * Backing store of defined scene components.
  32638. */ private _components: ISceneComponent[];
  32639. /**
  32640. * @hidden
  32641. * Backing store of defined scene components.
  32642. */ private _serializableComponents: ISceneSerializableComponent[];
  32643. /**
  32644. * List of components to register on the next registration step.
  32645. */
  32646. private _transientComponents;
  32647. /**
  32648. * Registers the transient components if needed.
  32649. */
  32650. private _registerTransientComponents;
  32651. /**
  32652. * @hidden
  32653. * Add a component to the scene.
  32654. * Note that the ccomponent could be registered on th next frame if this is called after
  32655. * the register component stage.
  32656. * @param component Defines the component to add to the scene
  32657. */ private _addComponent(component: ISceneComponent): void;
  32658. /**
  32659. * @hidden
  32660. * Gets a component from the scene.
  32661. * @param name defines the name of the component to retrieve
  32662. * @returns the component or null if not present
  32663. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32664. /**
  32665. * @hidden
  32666. * Defines the actions happening before camera updates.
  32667. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32668. /**
  32669. * @hidden
  32670. * Defines the actions happening before clear the canvas.
  32671. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32672. /**
  32673. * @hidden
  32674. * Defines the actions when collecting render targets for the frame.
  32675. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32676. /**
  32677. * @hidden
  32678. * Defines the actions happening for one camera in the frame.
  32679. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32680. /**
  32681. * @hidden
  32682. * Defines the actions happening during the per mesh ready checks.
  32683. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32684. /**
  32685. * @hidden
  32686. * Defines the actions happening before evaluate active mesh checks.
  32687. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32688. /**
  32689. * @hidden
  32690. * Defines the actions happening during the evaluate sub mesh checks.
  32691. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32692. /**
  32693. * @hidden
  32694. * Defines the actions happening during the active mesh stage.
  32695. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32696. /**
  32697. * @hidden
  32698. * Defines the actions happening during the per camera render target step.
  32699. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32700. /**
  32701. * @hidden
  32702. * Defines the actions happening just before the active camera is drawing.
  32703. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32704. /**
  32705. * @hidden
  32706. * Defines the actions happening just before a render target is drawing.
  32707. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32708. /**
  32709. * @hidden
  32710. * Defines the actions happening just before a rendering group is drawing.
  32711. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32712. /**
  32713. * @hidden
  32714. * Defines the actions happening just before a mesh is drawing.
  32715. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32716. /**
  32717. * @hidden
  32718. * Defines the actions happening just after a mesh has been drawn.
  32719. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32720. /**
  32721. * @hidden
  32722. * Defines the actions happening just after a rendering group has been drawn.
  32723. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32724. /**
  32725. * @hidden
  32726. * Defines the actions happening just after the active camera has been drawn.
  32727. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32728. /**
  32729. * @hidden
  32730. * Defines the actions happening just after a render target has been drawn.
  32731. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32732. /**
  32733. * @hidden
  32734. * Defines the actions happening just after rendering all cameras and computing intersections.
  32735. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32736. /**
  32737. * @hidden
  32738. * Defines the actions happening when a pointer move event happens.
  32739. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32740. /**
  32741. * @hidden
  32742. * Defines the actions happening when a pointer down event happens.
  32743. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32744. /**
  32745. * @hidden
  32746. * Defines the actions happening when a pointer up event happens.
  32747. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32748. /**
  32749. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32750. */
  32751. private geometriesByUniqueId;
  32752. /**
  32753. * Creates a new Scene
  32754. * @param engine defines the engine to use to render this scene
  32755. * @param options defines the scene options
  32756. */
  32757. constructor(engine: Engine, options?: SceneOptions);
  32758. /**
  32759. * Gets a string idenfifying the name of the class
  32760. * @returns "Scene" string
  32761. */
  32762. getClassName(): string;
  32763. private _defaultMeshCandidates;
  32764. /**
  32765. * @hidden
  32766. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32767. private _defaultSubMeshCandidates;
  32768. /**
  32769. * @hidden
  32770. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32771. /**
  32772. * Sets the default candidate providers for the scene.
  32773. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32774. * and getCollidingSubMeshCandidates to their default function
  32775. */
  32776. setDefaultCandidateProviders(): void;
  32777. /**
  32778. * Gets the mesh that is currently under the pointer
  32779. */
  32780. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32781. /**
  32782. * Gets or sets the current on-screen X position of the pointer
  32783. */
  32784. pointerX: number;
  32785. /**
  32786. * Gets or sets the current on-screen Y position of the pointer
  32787. */
  32788. pointerY: number;
  32789. /**
  32790. * Gets the cached material (ie. the latest rendered one)
  32791. * @returns the cached material
  32792. */
  32793. getCachedMaterial(): Nullable<Material>;
  32794. /**
  32795. * Gets the cached effect (ie. the latest rendered one)
  32796. * @returns the cached effect
  32797. */
  32798. getCachedEffect(): Nullable<Effect>;
  32799. /**
  32800. * Gets the cached visibility state (ie. the latest rendered one)
  32801. * @returns the cached visibility state
  32802. */
  32803. getCachedVisibility(): Nullable<number>;
  32804. /**
  32805. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32806. * @param material defines the current material
  32807. * @param effect defines the current effect
  32808. * @param visibility defines the current visibility state
  32809. * @returns true if one parameter is not cached
  32810. */
  32811. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32812. /**
  32813. * Gets the engine associated with the scene
  32814. * @returns an Engine
  32815. */
  32816. getEngine(): Engine;
  32817. /**
  32818. * Gets the total number of vertices rendered per frame
  32819. * @returns the total number of vertices rendered per frame
  32820. */
  32821. getTotalVertices(): number;
  32822. /**
  32823. * Gets the performance counter for total vertices
  32824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32825. */
  32826. readonly totalVerticesPerfCounter: PerfCounter;
  32827. /**
  32828. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32829. * @returns the total number of active indices rendered per frame
  32830. */
  32831. getActiveIndices(): number;
  32832. /**
  32833. * Gets the performance counter for active indices
  32834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32835. */
  32836. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32837. /**
  32838. * Gets the total number of active particles rendered per frame
  32839. * @returns the total number of active particles rendered per frame
  32840. */
  32841. getActiveParticles(): number;
  32842. /**
  32843. * Gets the performance counter for active particles
  32844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32845. */
  32846. readonly activeParticlesPerfCounter: PerfCounter;
  32847. /**
  32848. * Gets the total number of active bones rendered per frame
  32849. * @returns the total number of active bones rendered per frame
  32850. */
  32851. getActiveBones(): number;
  32852. /**
  32853. * Gets the performance counter for active bones
  32854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32855. */
  32856. readonly activeBonesPerfCounter: PerfCounter;
  32857. /**
  32858. * Gets the array of active meshes
  32859. * @returns an array of AbstractMesh
  32860. */
  32861. getActiveMeshes(): SmartArray<AbstractMesh>;
  32862. /**
  32863. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32864. * @returns a number
  32865. */
  32866. getAnimationRatio(): number;
  32867. /**
  32868. * Gets an unique Id for the current render phase
  32869. * @returns a number
  32870. */
  32871. getRenderId(): number;
  32872. /**
  32873. * Gets an unique Id for the current frame
  32874. * @returns a number
  32875. */
  32876. getFrameId(): number;
  32877. /** Call this function if you want to manually increment the render Id*/
  32878. incrementRenderId(): void;
  32879. private _createUbo;
  32880. /**
  32881. * Use this method to simulate a pointer move on a mesh
  32882. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32883. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32884. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32885. * @returns the current scene
  32886. */
  32887. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32888. /**
  32889. * Use this method to simulate a pointer down on a mesh
  32890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32893. * @returns the current scene
  32894. */
  32895. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32896. /**
  32897. * Use this method to simulate a pointer up on a mesh
  32898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32901. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32902. * @returns the current scene
  32903. */
  32904. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32905. /**
  32906. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32907. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32908. * @returns true if the pointer was captured
  32909. */
  32910. isPointerCaptured(pointerId?: number): boolean;
  32911. /**
  32912. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32913. * @param attachUp defines if you want to attach events to pointerup
  32914. * @param attachDown defines if you want to attach events to pointerdown
  32915. * @param attachMove defines if you want to attach events to pointermove
  32916. */
  32917. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32918. /** Detaches all event handlers*/
  32919. detachControl(): void;
  32920. /**
  32921. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32922. * Delay loaded resources are not taking in account
  32923. * @return true if all required resources are ready
  32924. */
  32925. isReady(): boolean;
  32926. /** Resets all cached information relative to material (including effect and visibility) */
  32927. resetCachedMaterial(): void;
  32928. /**
  32929. * Registers a function to be called before every frame render
  32930. * @param func defines the function to register
  32931. */
  32932. registerBeforeRender(func: () => void): void;
  32933. /**
  32934. * Unregisters a function called before every frame render
  32935. * @param func defines the function to unregister
  32936. */
  32937. unregisterBeforeRender(func: () => void): void;
  32938. /**
  32939. * Registers a function to be called after every frame render
  32940. * @param func defines the function to register
  32941. */
  32942. registerAfterRender(func: () => void): void;
  32943. /**
  32944. * Unregisters a function called after every frame render
  32945. * @param func defines the function to unregister
  32946. */
  32947. unregisterAfterRender(func: () => void): void;
  32948. private _executeOnceBeforeRender;
  32949. /**
  32950. * The provided function will run before render once and will be disposed afterwards.
  32951. * A timeout delay can be provided so that the function will be executed in N ms.
  32952. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32953. * @param func The function to be executed.
  32954. * @param timeout optional delay in ms
  32955. */
  32956. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32957. /** @hidden */ private _addPendingData(data: any): void;
  32958. /** @hidden */ private _removePendingData(data: any): void;
  32959. /**
  32960. * Returns the number of items waiting to be loaded
  32961. * @returns the number of items waiting to be loaded
  32962. */
  32963. getWaitingItemsCount(): number;
  32964. /**
  32965. * Returns a boolean indicating if the scene is still loading data
  32966. */
  32967. readonly isLoading: boolean;
  32968. /**
  32969. * Registers a function to be executed when the scene is ready
  32970. * @param {Function} func - the function to be executed
  32971. */
  32972. executeWhenReady(func: () => void): void;
  32973. /**
  32974. * Returns a promise that resolves when the scene is ready
  32975. * @returns A promise that resolves when the scene is ready
  32976. */
  32977. whenReadyAsync(): Promise<void>;
  32978. /** @hidden */ private _checkIsReady(): void;
  32979. /**
  32980. * Gets all animatable attached to the scene
  32981. */
  32982. readonly animatables: Animatable[];
  32983. /**
  32984. * Resets the last animation time frame.
  32985. * Useful to override when animations start running when loading a scene for the first time.
  32986. */
  32987. resetLastAnimationTimeFrame(): void;
  32988. /**
  32989. * Gets the current view matrix
  32990. * @returns a Matrix
  32991. */
  32992. getViewMatrix(): Matrix;
  32993. /**
  32994. * Gets the current projection matrix
  32995. * @returns a Matrix
  32996. */
  32997. getProjectionMatrix(): Matrix;
  32998. /**
  32999. * Gets the current transform matrix
  33000. * @returns a Matrix made of View * Projection
  33001. */
  33002. getTransformMatrix(): Matrix;
  33003. /**
  33004. * Sets the current transform matrix
  33005. * @param viewL defines the View matrix to use
  33006. * @param projectionL defines the Projection matrix to use
  33007. * @param viewR defines the right View matrix to use (if provided)
  33008. * @param projectionR defines the right Projection matrix to use (if provided)
  33009. */
  33010. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33011. /**
  33012. * Gets the uniform buffer used to store scene data
  33013. * @returns a UniformBuffer
  33014. */
  33015. getSceneUniformBuffer(): UniformBuffer;
  33016. /**
  33017. * Gets an unique (relatively to the current scene) Id
  33018. * @returns an unique number for the scene
  33019. */
  33020. getUniqueId(): number;
  33021. /**
  33022. * Add a mesh to the list of scene's meshes
  33023. * @param newMesh defines the mesh to add
  33024. * @param recursive if all child meshes should also be added to the scene
  33025. */
  33026. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33027. /**
  33028. * Remove a mesh for the list of scene's meshes
  33029. * @param toRemove defines the mesh to remove
  33030. * @param recursive if all child meshes should also be removed from the scene
  33031. * @returns the index where the mesh was in the mesh list
  33032. */
  33033. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33034. /**
  33035. * Add a transform node to the list of scene's transform nodes
  33036. * @param newTransformNode defines the transform node to add
  33037. */
  33038. addTransformNode(newTransformNode: TransformNode): void;
  33039. /**
  33040. * Remove a transform node for the list of scene's transform nodes
  33041. * @param toRemove defines the transform node to remove
  33042. * @returns the index where the transform node was in the transform node list
  33043. */
  33044. removeTransformNode(toRemove: TransformNode): number;
  33045. /**
  33046. * Remove a skeleton for the list of scene's skeletons
  33047. * @param toRemove defines the skeleton to remove
  33048. * @returns the index where the skeleton was in the skeleton list
  33049. */
  33050. removeSkeleton(toRemove: Skeleton): number;
  33051. /**
  33052. * Remove a morph target for the list of scene's morph targets
  33053. * @param toRemove defines the morph target to remove
  33054. * @returns the index where the morph target was in the morph target list
  33055. */
  33056. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33057. /**
  33058. * Remove a light for the list of scene's lights
  33059. * @param toRemove defines the light to remove
  33060. * @returns the index where the light was in the light list
  33061. */
  33062. removeLight(toRemove: Light): number;
  33063. /**
  33064. * Remove a camera for the list of scene's cameras
  33065. * @param toRemove defines the camera to remove
  33066. * @returns the index where the camera was in the camera list
  33067. */
  33068. removeCamera(toRemove: Camera): number;
  33069. /**
  33070. * Remove a particle system for the list of scene's particle systems
  33071. * @param toRemove defines the particle system to remove
  33072. * @returns the index where the particle system was in the particle system list
  33073. */
  33074. removeParticleSystem(toRemove: IParticleSystem): number;
  33075. /**
  33076. * Remove a animation for the list of scene's animations
  33077. * @param toRemove defines the animation to remove
  33078. * @returns the index where the animation was in the animation list
  33079. */
  33080. removeAnimation(toRemove: Animation): number;
  33081. /**
  33082. * Will stop the animation of the given target
  33083. * @param target - the target
  33084. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33085. * @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)
  33086. */
  33087. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33088. /**
  33089. * Removes the given animation group from this scene.
  33090. * @param toRemove The animation group to remove
  33091. * @returns The index of the removed animation group
  33092. */
  33093. removeAnimationGroup(toRemove: AnimationGroup): number;
  33094. /**
  33095. * Removes the given multi-material from this scene.
  33096. * @param toRemove The multi-material to remove
  33097. * @returns The index of the removed multi-material
  33098. */
  33099. removeMultiMaterial(toRemove: MultiMaterial): number;
  33100. /**
  33101. * Removes the given material from this scene.
  33102. * @param toRemove The material to remove
  33103. * @returns The index of the removed material
  33104. */
  33105. removeMaterial(toRemove: Material): number;
  33106. /**
  33107. * Removes the given action manager from this scene.
  33108. * @param toRemove The action manager to remove
  33109. * @returns The index of the removed action manager
  33110. */
  33111. removeActionManager(toRemove: AbstractActionManager): number;
  33112. /**
  33113. * Removes the given texture from this scene.
  33114. * @param toRemove The texture to remove
  33115. * @returns The index of the removed texture
  33116. */
  33117. removeTexture(toRemove: BaseTexture): number;
  33118. /**
  33119. * Adds the given light to this scene
  33120. * @param newLight The light to add
  33121. */
  33122. addLight(newLight: Light): void;
  33123. /**
  33124. * Sorts the list list based on light priorities
  33125. */
  33126. sortLightsByPriority(): void;
  33127. /**
  33128. * Adds the given camera to this scene
  33129. * @param newCamera The camera to add
  33130. */
  33131. addCamera(newCamera: Camera): void;
  33132. /**
  33133. * Adds the given skeleton to this scene
  33134. * @param newSkeleton The skeleton to add
  33135. */
  33136. addSkeleton(newSkeleton: Skeleton): void;
  33137. /**
  33138. * Adds the given particle system to this scene
  33139. * @param newParticleSystem The particle system to add
  33140. */
  33141. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33142. /**
  33143. * Adds the given animation to this scene
  33144. * @param newAnimation The animation to add
  33145. */
  33146. addAnimation(newAnimation: Animation): void;
  33147. /**
  33148. * Adds the given animation group to this scene.
  33149. * @param newAnimationGroup The animation group to add
  33150. */
  33151. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33152. /**
  33153. * Adds the given multi-material to this scene
  33154. * @param newMultiMaterial The multi-material to add
  33155. */
  33156. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33157. /**
  33158. * Adds the given material to this scene
  33159. * @param newMaterial The material to add
  33160. */
  33161. addMaterial(newMaterial: Material): void;
  33162. /**
  33163. * Adds the given morph target to this scene
  33164. * @param newMorphTargetManager The morph target to add
  33165. */
  33166. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33167. /**
  33168. * Adds the given geometry to this scene
  33169. * @param newGeometry The geometry to add
  33170. */
  33171. addGeometry(newGeometry: Geometry): void;
  33172. /**
  33173. * Adds the given action manager to this scene
  33174. * @param newActionManager The action manager to add
  33175. */
  33176. addActionManager(newActionManager: AbstractActionManager): void;
  33177. /**
  33178. * Adds the given texture to this scene.
  33179. * @param newTexture The texture to add
  33180. */
  33181. addTexture(newTexture: BaseTexture): void;
  33182. /**
  33183. * Switch active camera
  33184. * @param newCamera defines the new active camera
  33185. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33186. */
  33187. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33188. /**
  33189. * sets the active camera of the scene using its ID
  33190. * @param id defines the camera's ID
  33191. * @return the new active camera or null if none found.
  33192. */
  33193. setActiveCameraByID(id: string): Nullable<Camera>;
  33194. /**
  33195. * sets the active camera of the scene using its name
  33196. * @param name defines the camera's name
  33197. * @returns the new active camera or null if none found.
  33198. */
  33199. setActiveCameraByName(name: string): Nullable<Camera>;
  33200. /**
  33201. * get an animation group using its name
  33202. * @param name defines the material's name
  33203. * @return the animation group or null if none found.
  33204. */
  33205. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33206. /**
  33207. * Get a material using its unique id
  33208. * @param uniqueId defines the material's unique id
  33209. * @return the material or null if none found.
  33210. */
  33211. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33212. /**
  33213. * get a material using its id
  33214. * @param id defines the material's ID
  33215. * @return the material or null if none found.
  33216. */
  33217. getMaterialByID(id: string): Nullable<Material>;
  33218. /**
  33219. * Gets a the last added material using a given id
  33220. * @param id defines the material's ID
  33221. * @return the last material with the given id or null if none found.
  33222. */
  33223. getLastMaterialByID(id: string): Nullable<Material>;
  33224. /**
  33225. * Gets a material using its name
  33226. * @param name defines the material's name
  33227. * @return the material or null if none found.
  33228. */
  33229. getMaterialByName(name: string): Nullable<Material>;
  33230. /**
  33231. * Get a texture using its unique id
  33232. * @param uniqueId defines the texture's unique id
  33233. * @return the texture or null if none found.
  33234. */
  33235. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33236. /**
  33237. * Gets a camera using its id
  33238. * @param id defines the id to look for
  33239. * @returns the camera or null if not found
  33240. */
  33241. getCameraByID(id: string): Nullable<Camera>;
  33242. /**
  33243. * Gets a camera using its unique id
  33244. * @param uniqueId defines the unique id to look for
  33245. * @returns the camera or null if not found
  33246. */
  33247. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33248. /**
  33249. * Gets a camera using its name
  33250. * @param name defines the camera's name
  33251. * @return the camera or null if none found.
  33252. */
  33253. getCameraByName(name: string): Nullable<Camera>;
  33254. /**
  33255. * Gets a bone using its id
  33256. * @param id defines the bone's id
  33257. * @return the bone or null if not found
  33258. */
  33259. getBoneByID(id: string): Nullable<Bone>;
  33260. /**
  33261. * Gets a bone using its id
  33262. * @param name defines the bone's name
  33263. * @return the bone or null if not found
  33264. */
  33265. getBoneByName(name: string): Nullable<Bone>;
  33266. /**
  33267. * Gets a light node using its name
  33268. * @param name defines the the light's name
  33269. * @return the light or null if none found.
  33270. */
  33271. getLightByName(name: string): Nullable<Light>;
  33272. /**
  33273. * Gets a light node using its id
  33274. * @param id defines the light's id
  33275. * @return the light or null if none found.
  33276. */
  33277. getLightByID(id: string): Nullable<Light>;
  33278. /**
  33279. * Gets a light node using its scene-generated unique ID
  33280. * @param uniqueId defines the light's unique id
  33281. * @return the light or null if none found.
  33282. */
  33283. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33284. /**
  33285. * Gets a particle system by id
  33286. * @param id defines the particle system id
  33287. * @return the corresponding system or null if none found
  33288. */
  33289. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33290. /**
  33291. * Gets a geometry using its ID
  33292. * @param id defines the geometry's id
  33293. * @return the geometry or null if none found.
  33294. */
  33295. getGeometryByID(id: string): Nullable<Geometry>;
  33296. private _getGeometryByUniqueID;
  33297. /**
  33298. * Add a new geometry to this scene
  33299. * @param geometry defines the geometry to be added to the scene.
  33300. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33301. * @return a boolean defining if the geometry was added or not
  33302. */
  33303. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33304. /**
  33305. * Removes an existing geometry
  33306. * @param geometry defines the geometry to be removed from the scene
  33307. * @return a boolean defining if the geometry was removed or not
  33308. */
  33309. removeGeometry(geometry: Geometry): boolean;
  33310. /**
  33311. * Gets the list of geometries attached to the scene
  33312. * @returns an array of Geometry
  33313. */
  33314. getGeometries(): Geometry[];
  33315. /**
  33316. * Gets the first added mesh found of a given ID
  33317. * @param id defines the id to search for
  33318. * @return the mesh found or null if not found at all
  33319. */
  33320. getMeshByID(id: string): Nullable<AbstractMesh>;
  33321. /**
  33322. * Gets a list of meshes using their id
  33323. * @param id defines the id to search for
  33324. * @returns a list of meshes
  33325. */
  33326. getMeshesByID(id: string): Array<AbstractMesh>;
  33327. /**
  33328. * Gets the first added transform node found of a given ID
  33329. * @param id defines the id to search for
  33330. * @return the found transform node or null if not found at all.
  33331. */
  33332. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33333. /**
  33334. * Gets a transform node with its auto-generated unique id
  33335. * @param uniqueId efines the unique id to search for
  33336. * @return the found transform node or null if not found at all.
  33337. */
  33338. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33339. /**
  33340. * Gets a list of transform nodes using their id
  33341. * @param id defines the id to search for
  33342. * @returns a list of transform nodes
  33343. */
  33344. getTransformNodesByID(id: string): Array<TransformNode>;
  33345. /**
  33346. * Gets a mesh with its auto-generated unique id
  33347. * @param uniqueId defines the unique id to search for
  33348. * @return the found mesh or null if not found at all.
  33349. */
  33350. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33351. /**
  33352. * Gets a the last added mesh using a given id
  33353. * @param id defines the id to search for
  33354. * @return the found mesh or null if not found at all.
  33355. */
  33356. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33357. /**
  33358. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33359. * @param id defines the id to search for
  33360. * @return the found node or null if not found at all
  33361. */
  33362. getLastEntryByID(id: string): Nullable<Node>;
  33363. /**
  33364. * Gets a node (Mesh, Camera, Light) using a given id
  33365. * @param id defines the id to search for
  33366. * @return the found node or null if not found at all
  33367. */
  33368. getNodeByID(id: string): Nullable<Node>;
  33369. /**
  33370. * Gets a node (Mesh, Camera, Light) using a given name
  33371. * @param name defines the name to search for
  33372. * @return the found node or null if not found at all.
  33373. */
  33374. getNodeByName(name: string): Nullable<Node>;
  33375. /**
  33376. * Gets a mesh using a given name
  33377. * @param name defines the name to search for
  33378. * @return the found mesh or null if not found at all.
  33379. */
  33380. getMeshByName(name: string): Nullable<AbstractMesh>;
  33381. /**
  33382. * Gets a transform node using a given name
  33383. * @param name defines the name to search for
  33384. * @return the found transform node or null if not found at all.
  33385. */
  33386. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33387. /**
  33388. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33389. * @param id defines the id to search for
  33390. * @return the found skeleton or null if not found at all.
  33391. */
  33392. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33393. /**
  33394. * Gets a skeleton using a given auto generated unique id
  33395. * @param uniqueId defines the unique id to search for
  33396. * @return the found skeleton or null if not found at all.
  33397. */
  33398. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33399. /**
  33400. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33401. * @param id defines the id to search for
  33402. * @return the found skeleton or null if not found at all.
  33403. */
  33404. getSkeletonById(id: string): Nullable<Skeleton>;
  33405. /**
  33406. * Gets a skeleton using a given name
  33407. * @param name defines the name to search for
  33408. * @return the found skeleton or null if not found at all.
  33409. */
  33410. getSkeletonByName(name: string): Nullable<Skeleton>;
  33411. /**
  33412. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33413. * @param id defines the id to search for
  33414. * @return the found morph target manager or null if not found at all.
  33415. */
  33416. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33417. /**
  33418. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33419. * @param id defines the id to search for
  33420. * @return the found morph target or null if not found at all.
  33421. */
  33422. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33423. /**
  33424. * Gets a boolean indicating if the given mesh is active
  33425. * @param mesh defines the mesh to look for
  33426. * @returns true if the mesh is in the active list
  33427. */
  33428. isActiveMesh(mesh: AbstractMesh): boolean;
  33429. /**
  33430. * Return a unique id as a string which can serve as an identifier for the scene
  33431. */
  33432. readonly uid: string;
  33433. /**
  33434. * Add an externaly attached data from its key.
  33435. * This method call will fail and return false, if such key already exists.
  33436. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33437. * @param key the unique key that identifies the data
  33438. * @param data the data object to associate to the key for this Engine instance
  33439. * @return true if no such key were already present and the data was added successfully, false otherwise
  33440. */
  33441. addExternalData<T>(key: string, data: T): boolean;
  33442. /**
  33443. * Get an externaly attached data from its key
  33444. * @param key the unique key that identifies the data
  33445. * @return the associated data, if present (can be null), or undefined if not present
  33446. */
  33447. getExternalData<T>(key: string): Nullable<T>;
  33448. /**
  33449. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33450. * @param key the unique key that identifies the data
  33451. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33452. * @return the associated data, can be null if the factory returned null.
  33453. */
  33454. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33455. /**
  33456. * Remove an externaly attached data from the Engine instance
  33457. * @param key the unique key that identifies the data
  33458. * @return true if the data was successfully removed, false if it doesn't exist
  33459. */
  33460. removeExternalData(key: string): boolean;
  33461. private _evaluateSubMesh;
  33462. /**
  33463. * Clear the processed materials smart array preventing retention point in material dispose.
  33464. */
  33465. freeProcessedMaterials(): void;
  33466. private _preventFreeActiveMeshesAndRenderingGroups;
  33467. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33468. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33469. * when disposing several meshes in a row or a hierarchy of meshes.
  33470. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33471. */
  33472. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33473. /**
  33474. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33475. */
  33476. freeActiveMeshes(): void;
  33477. /**
  33478. * Clear the info related to rendering groups preventing retention points during dispose.
  33479. */
  33480. freeRenderingGroups(): void;
  33481. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33482. /**
  33483. * Lambda returning the list of potentially active meshes.
  33484. */
  33485. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33486. /**
  33487. * Lambda returning the list of potentially active sub meshes.
  33488. */
  33489. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33490. /**
  33491. * Lambda returning the list of potentially intersecting sub meshes.
  33492. */
  33493. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33494. /**
  33495. * Lambda returning the list of potentially colliding sub meshes.
  33496. */
  33497. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33498. private _activeMeshesFrozen;
  33499. /**
  33500. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33501. * @returns the current scene
  33502. */
  33503. freezeActiveMeshes(): Scene;
  33504. /**
  33505. * Use this function to restart evaluating active meshes on every frame
  33506. * @returns the current scene
  33507. */
  33508. unfreezeActiveMeshes(): Scene;
  33509. private _evaluateActiveMeshes;
  33510. private _activeMesh;
  33511. /**
  33512. * Update the transform matrix to update from the current active camera
  33513. * @param force defines a boolean used to force the update even if cache is up to date
  33514. */
  33515. updateTransformMatrix(force?: boolean): void;
  33516. private _bindFrameBuffer;
  33517. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33518. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33519. private _processSubCameras;
  33520. private _checkIntersections;
  33521. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33522. /**
  33523. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33524. */
  33525. getDeterministicFrameTime: () => number;
  33526. /** @hidden */ private _animate(): void;
  33527. /** Execute all animations (for a frame) */
  33528. animate(): void;
  33529. /**
  33530. * Render the scene
  33531. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33532. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33533. */
  33534. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33535. /**
  33536. * Freeze all materials
  33537. * A frozen material will not be updatable but should be faster to render
  33538. */
  33539. freezeMaterials(): void;
  33540. /**
  33541. * Unfreeze all materials
  33542. * A frozen material will not be updatable but should be faster to render
  33543. */
  33544. unfreezeMaterials(): void;
  33545. /**
  33546. * Releases all held ressources
  33547. */
  33548. dispose(): void;
  33549. /**
  33550. * Gets if the scene is already disposed
  33551. */
  33552. readonly isDisposed: boolean;
  33553. /**
  33554. * Call this function to reduce memory footprint of the scene.
  33555. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33556. */
  33557. clearCachedVertexData(): void;
  33558. /**
  33559. * This function will remove the local cached buffer data from texture.
  33560. * It will save memory but will prevent the texture from being rebuilt
  33561. */
  33562. cleanCachedTextureBuffer(): void;
  33563. /**
  33564. * Get the world extend vectors with an optional filter
  33565. *
  33566. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33567. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33568. */
  33569. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33570. min: Vector3;
  33571. max: Vector3;
  33572. };
  33573. /**
  33574. * Creates a ray that can be used to pick in the scene
  33575. * @param x defines the x coordinate of the origin (on-screen)
  33576. * @param y defines the y coordinate of the origin (on-screen)
  33577. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33578. * @param camera defines the camera to use for the picking
  33579. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33580. * @returns a Ray
  33581. */
  33582. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33583. /**
  33584. * Creates a ray that can be used to pick in the scene
  33585. * @param x defines the x coordinate of the origin (on-screen)
  33586. * @param y defines the y coordinate of the origin (on-screen)
  33587. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33588. * @param result defines the ray where to store the picking ray
  33589. * @param camera defines the camera to use for the picking
  33590. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33591. * @returns the current scene
  33592. */
  33593. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33594. /**
  33595. * Creates a ray that can be used to pick in the scene
  33596. * @param x defines the x coordinate of the origin (on-screen)
  33597. * @param y defines the y coordinate of the origin (on-screen)
  33598. * @param camera defines the camera to use for the picking
  33599. * @returns a Ray
  33600. */
  33601. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33602. /**
  33603. * Creates a ray that can be used to pick in the scene
  33604. * @param x defines the x coordinate of the origin (on-screen)
  33605. * @param y defines the y coordinate of the origin (on-screen)
  33606. * @param result defines the ray where to store the picking ray
  33607. * @param camera defines the camera to use for the picking
  33608. * @returns the current scene
  33609. */
  33610. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33611. /** Launch a ray to try to pick a mesh in the scene
  33612. * @param x position on screen
  33613. * @param y position on screen
  33614. * @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
  33615. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33616. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33618. * @returns a PickingInfo
  33619. */
  33620. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33621. /** Use the given ray to pick a mesh in the scene
  33622. * @param ray The ray to use to pick meshes
  33623. * @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
  33624. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33625. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33626. * @returns a PickingInfo
  33627. */
  33628. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33629. /**
  33630. * Launch a ray to try to pick a mesh in the scene
  33631. * @param x X position on screen
  33632. * @param y Y position on screen
  33633. * @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
  33634. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33636. * @returns an array of PickingInfo
  33637. */
  33638. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33639. /**
  33640. * Launch a ray to try to pick a mesh in the scene
  33641. * @param ray Ray to use
  33642. * @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
  33643. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33644. * @returns an array of PickingInfo
  33645. */
  33646. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33647. /**
  33648. * Force the value of meshUnderPointer
  33649. * @param mesh defines the mesh to use
  33650. */
  33651. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33652. /**
  33653. * Gets the mesh under the pointer
  33654. * @returns a Mesh or null if no mesh is under the pointer
  33655. */
  33656. getPointerOverMesh(): Nullable<AbstractMesh>;
  33657. /** @hidden */ private _rebuildGeometries(): void;
  33658. /** @hidden */ private _rebuildTextures(): void;
  33659. private _getByTags;
  33660. /**
  33661. * Get a list of meshes by tags
  33662. * @param tagsQuery defines the tags query to use
  33663. * @param forEach defines a predicate used to filter results
  33664. * @returns an array of Mesh
  33665. */
  33666. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33667. /**
  33668. * Get a list of cameras by tags
  33669. * @param tagsQuery defines the tags query to use
  33670. * @param forEach defines a predicate used to filter results
  33671. * @returns an array of Camera
  33672. */
  33673. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33674. /**
  33675. * Get a list of lights by tags
  33676. * @param tagsQuery defines the tags query to use
  33677. * @param forEach defines a predicate used to filter results
  33678. * @returns an array of Light
  33679. */
  33680. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33681. /**
  33682. * Get a list of materials by tags
  33683. * @param tagsQuery defines the tags query to use
  33684. * @param forEach defines a predicate used to filter results
  33685. * @returns an array of Material
  33686. */
  33687. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33688. /**
  33689. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33690. * This allowed control for front to back rendering or reversly depending of the special needs.
  33691. *
  33692. * @param renderingGroupId The rendering group id corresponding to its index
  33693. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33694. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33695. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33696. */
  33697. 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;
  33698. /**
  33699. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33700. *
  33701. * @param renderingGroupId The rendering group id corresponding to its index
  33702. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33703. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33704. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33705. */
  33706. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33707. /**
  33708. * Gets the current auto clear configuration for one rendering group of the rendering
  33709. * manager.
  33710. * @param index the rendering group index to get the information for
  33711. * @returns The auto clear setup for the requested rendering group
  33712. */
  33713. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33714. private _blockMaterialDirtyMechanism;
  33715. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33716. blockMaterialDirtyMechanism: boolean;
  33717. /**
  33718. * Will flag all materials as dirty to trigger new shader compilation
  33719. * @param flag defines the flag used to specify which material part must be marked as dirty
  33720. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33721. */
  33722. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33723. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33724. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33725. }
  33726. }
  33727. declare module BABYLON {
  33728. /**
  33729. * Set of assets to keep when moving a scene into an asset container.
  33730. */
  33731. export class KeepAssets extends AbstractScene {
  33732. }
  33733. /**
  33734. * Container with a set of assets that can be added or removed from a scene.
  33735. */
  33736. export class AssetContainer extends AbstractScene {
  33737. /**
  33738. * The scene the AssetContainer belongs to.
  33739. */
  33740. scene: Scene;
  33741. /**
  33742. * Instantiates an AssetContainer.
  33743. * @param scene The scene the AssetContainer belongs to.
  33744. */
  33745. constructor(scene: Scene);
  33746. /**
  33747. * Adds all the assets from the container to the scene.
  33748. */
  33749. addAllToScene(): void;
  33750. /**
  33751. * Removes all the assets in the container from the scene
  33752. */
  33753. removeAllFromScene(): void;
  33754. /**
  33755. * Disposes all the assets in the container
  33756. */
  33757. dispose(): void;
  33758. private _moveAssets;
  33759. /**
  33760. * Removes all the assets contained in the scene and adds them to the container.
  33761. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33762. */
  33763. moveAllFromScene(keepAssets?: KeepAssets): void;
  33764. /**
  33765. * 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.
  33766. * @returns the root mesh
  33767. */
  33768. createRootMesh(): Mesh;
  33769. }
  33770. }
  33771. declare module BABYLON {
  33772. /**
  33773. * Defines how the parser contract is defined.
  33774. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33775. */
  33776. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33777. /**
  33778. * Defines how the individual parser contract is defined.
  33779. * These parser can parse an individual asset
  33780. */
  33781. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33782. /**
  33783. * Base class of the scene acting as a container for the different elements composing a scene.
  33784. * This class is dynamically extended by the different components of the scene increasing
  33785. * flexibility and reducing coupling
  33786. */
  33787. export abstract class AbstractScene {
  33788. /**
  33789. * Stores the list of available parsers in the application.
  33790. */
  33791. private static _BabylonFileParsers;
  33792. /**
  33793. * Stores the list of available individual parsers in the application.
  33794. */
  33795. private static _IndividualBabylonFileParsers;
  33796. /**
  33797. * Adds a parser in the list of available ones
  33798. * @param name Defines the name of the parser
  33799. * @param parser Defines the parser to add
  33800. */
  33801. static AddParser(name: string, parser: BabylonFileParser): void;
  33802. /**
  33803. * Gets a general parser from the list of avaialble ones
  33804. * @param name Defines the name of the parser
  33805. * @returns the requested parser or null
  33806. */
  33807. static GetParser(name: string): Nullable<BabylonFileParser>;
  33808. /**
  33809. * Adds n individual parser in the list of available ones
  33810. * @param name Defines the name of the parser
  33811. * @param parser Defines the parser to add
  33812. */
  33813. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33814. /**
  33815. * Gets an individual parser from the list of avaialble ones
  33816. * @param name Defines the name of the parser
  33817. * @returns the requested parser or null
  33818. */
  33819. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33820. /**
  33821. * Parser json data and populate both a scene and its associated container object
  33822. * @param jsonData Defines the data to parse
  33823. * @param scene Defines the scene to parse the data for
  33824. * @param container Defines the container attached to the parsing sequence
  33825. * @param rootUrl Defines the root url of the data
  33826. */
  33827. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33828. /**
  33829. * Gets the list of root nodes (ie. nodes with no parent)
  33830. */
  33831. rootNodes: Node[];
  33832. /** All of the cameras added to this scene
  33833. * @see http://doc.babylonjs.com/babylon101/cameras
  33834. */
  33835. cameras: Camera[];
  33836. /**
  33837. * All of the lights added to this scene
  33838. * @see http://doc.babylonjs.com/babylon101/lights
  33839. */
  33840. lights: Light[];
  33841. /**
  33842. * All of the (abstract) meshes added to this scene
  33843. */
  33844. meshes: AbstractMesh[];
  33845. /**
  33846. * The list of skeletons added to the scene
  33847. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33848. */
  33849. skeletons: Skeleton[];
  33850. /**
  33851. * All of the particle systems added to this scene
  33852. * @see http://doc.babylonjs.com/babylon101/particles
  33853. */
  33854. particleSystems: IParticleSystem[];
  33855. /**
  33856. * Gets a list of Animations associated with the scene
  33857. */
  33858. animations: Animation[];
  33859. /**
  33860. * All of the animation groups added to this scene
  33861. * @see http://doc.babylonjs.com/how_to/group
  33862. */
  33863. animationGroups: AnimationGroup[];
  33864. /**
  33865. * All of the multi-materials added to this scene
  33866. * @see http://doc.babylonjs.com/how_to/multi_materials
  33867. */
  33868. multiMaterials: MultiMaterial[];
  33869. /**
  33870. * All of the materials added to this scene
  33871. * In the context of a Scene, it is not supposed to be modified manually.
  33872. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33873. * Note also that the order of the Material wihin the array is not significant and might change.
  33874. * @see http://doc.babylonjs.com/babylon101/materials
  33875. */
  33876. materials: Material[];
  33877. /**
  33878. * The list of morph target managers added to the scene
  33879. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33880. */
  33881. morphTargetManagers: MorphTargetManager[];
  33882. /**
  33883. * The list of geometries used in the scene.
  33884. */
  33885. geometries: Geometry[];
  33886. /**
  33887. * All of the tranform nodes added to this scene
  33888. * In the context of a Scene, it is not supposed to be modified manually.
  33889. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33890. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33891. * @see http://doc.babylonjs.com/how_to/transformnode
  33892. */
  33893. transformNodes: TransformNode[];
  33894. /**
  33895. * ActionManagers available on the scene.
  33896. */
  33897. actionManagers: AbstractActionManager[];
  33898. /**
  33899. * Textures to keep.
  33900. */
  33901. textures: BaseTexture[];
  33902. /**
  33903. * Environment texture for the scene
  33904. */
  33905. environmentTexture: Nullable<BaseTexture>;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Interface used to define options for Sound class
  33911. */
  33912. export interface ISoundOptions {
  33913. /**
  33914. * Does the sound autoplay once loaded.
  33915. */
  33916. autoplay?: boolean;
  33917. /**
  33918. * Does the sound loop after it finishes playing once.
  33919. */
  33920. loop?: boolean;
  33921. /**
  33922. * Sound's volume
  33923. */
  33924. volume?: number;
  33925. /**
  33926. * Is it a spatial sound?
  33927. */
  33928. spatialSound?: boolean;
  33929. /**
  33930. * Maximum distance to hear that sound
  33931. */
  33932. maxDistance?: number;
  33933. /**
  33934. * Uses user defined attenuation function
  33935. */
  33936. useCustomAttenuation?: boolean;
  33937. /**
  33938. * Define the roll off factor of spatial sounds.
  33939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33940. */
  33941. rolloffFactor?: number;
  33942. /**
  33943. * Define the reference distance the sound should be heard perfectly.
  33944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33945. */
  33946. refDistance?: number;
  33947. /**
  33948. * Define the distance attenuation model the sound will follow.
  33949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33950. */
  33951. distanceModel?: string;
  33952. /**
  33953. * Defines the playback speed (1 by default)
  33954. */
  33955. playbackRate?: number;
  33956. /**
  33957. * Defines if the sound is from a streaming source
  33958. */
  33959. streaming?: boolean;
  33960. /**
  33961. * Defines an optional length (in seconds) inside the sound file
  33962. */
  33963. length?: number;
  33964. /**
  33965. * Defines an optional offset (in seconds) inside the sound file
  33966. */
  33967. offset?: number;
  33968. /**
  33969. * If true, URLs will not be required to state the audio file codec to use.
  33970. */
  33971. skipCodecCheck?: boolean;
  33972. }
  33973. /**
  33974. * Defines a sound that can be played in the application.
  33975. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33977. */
  33978. export class Sound {
  33979. /**
  33980. * The name of the sound in the scene.
  33981. */
  33982. name: string;
  33983. /**
  33984. * Does the sound autoplay once loaded.
  33985. */
  33986. autoplay: boolean;
  33987. /**
  33988. * Does the sound loop after it finishes playing once.
  33989. */
  33990. loop: boolean;
  33991. /**
  33992. * Does the sound use a custom attenuation curve to simulate the falloff
  33993. * happening when the source gets further away from the camera.
  33994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33995. */
  33996. useCustomAttenuation: boolean;
  33997. /**
  33998. * The sound track id this sound belongs to.
  33999. */
  34000. soundTrackId: number;
  34001. /**
  34002. * Is this sound currently played.
  34003. */
  34004. isPlaying: boolean;
  34005. /**
  34006. * Is this sound currently paused.
  34007. */
  34008. isPaused: boolean;
  34009. /**
  34010. * Does this sound enables spatial sound.
  34011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34012. */
  34013. spatialSound: boolean;
  34014. /**
  34015. * Define the reference distance the sound should be heard perfectly.
  34016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34017. */
  34018. refDistance: number;
  34019. /**
  34020. * Define the roll off factor of spatial sounds.
  34021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34022. */
  34023. rolloffFactor: number;
  34024. /**
  34025. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34027. */
  34028. maxDistance: number;
  34029. /**
  34030. * Define the distance attenuation model the sound will follow.
  34031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34032. */
  34033. distanceModel: string;
  34034. /**
  34035. * @hidden
  34036. * Back Compat
  34037. **/
  34038. onended: () => any;
  34039. /**
  34040. * Observable event when the current playing sound finishes.
  34041. */
  34042. onEndedObservable: Observable<Sound>;
  34043. private _panningModel;
  34044. private _playbackRate;
  34045. private _streaming;
  34046. private _startTime;
  34047. private _startOffset;
  34048. private _position;
  34049. /** @hidden */ private _positionInEmitterSpace: boolean;
  34050. private _localDirection;
  34051. private _volume;
  34052. private _isReadyToPlay;
  34053. private _isDirectional;
  34054. private _readyToPlayCallback;
  34055. private _audioBuffer;
  34056. private _soundSource;
  34057. private _streamingSource;
  34058. private _soundPanner;
  34059. private _soundGain;
  34060. private _inputAudioNode;
  34061. private _outputAudioNode;
  34062. private _coneInnerAngle;
  34063. private _coneOuterAngle;
  34064. private _coneOuterGain;
  34065. private _scene;
  34066. private _connectedTransformNode;
  34067. private _customAttenuationFunction;
  34068. private _registerFunc;
  34069. private _isOutputConnected;
  34070. private _htmlAudioElement;
  34071. private _urlType;
  34072. private _length?;
  34073. private _offset?;
  34074. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34075. /**
  34076. * Create a sound and attach it to a scene
  34077. * @param name Name of your sound
  34078. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34079. * @param scene defines the scene the sound belongs to
  34080. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34081. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34082. */
  34083. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34084. /**
  34085. * Release the sound and its associated resources
  34086. */
  34087. dispose(): void;
  34088. /**
  34089. * Gets if the sounds is ready to be played or not.
  34090. * @returns true if ready, otherwise false
  34091. */
  34092. isReady(): boolean;
  34093. private _soundLoaded;
  34094. /**
  34095. * Sets the data of the sound from an audiobuffer
  34096. * @param audioBuffer The audioBuffer containing the data
  34097. */
  34098. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34099. /**
  34100. * Updates the current sounds options such as maxdistance, loop...
  34101. * @param options A JSON object containing values named as the object properties
  34102. */
  34103. updateOptions(options: ISoundOptions): void;
  34104. private _createSpatialParameters;
  34105. private _updateSpatialParameters;
  34106. /**
  34107. * Switch the panning model to HRTF:
  34108. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34110. */
  34111. switchPanningModelToHRTF(): void;
  34112. /**
  34113. * Switch the panning model to Equal Power:
  34114. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34116. */
  34117. switchPanningModelToEqualPower(): void;
  34118. private _switchPanningModel;
  34119. /**
  34120. * Connect this sound to a sound track audio node like gain...
  34121. * @param soundTrackAudioNode the sound track audio node to connect to
  34122. */
  34123. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34124. /**
  34125. * Transform this sound into a directional source
  34126. * @param coneInnerAngle Size of the inner cone in degree
  34127. * @param coneOuterAngle Size of the outer cone in degree
  34128. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34129. */
  34130. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34131. /**
  34132. * Gets or sets the inner angle for the directional cone.
  34133. */
  34134. /**
  34135. * Gets or sets the inner angle for the directional cone.
  34136. */
  34137. directionalConeInnerAngle: number;
  34138. /**
  34139. * Gets or sets the outer angle for the directional cone.
  34140. */
  34141. /**
  34142. * Gets or sets the outer angle for the directional cone.
  34143. */
  34144. directionalConeOuterAngle: number;
  34145. /**
  34146. * Sets the position of the emitter if spatial sound is enabled
  34147. * @param newPosition Defines the new posisiton
  34148. */
  34149. setPosition(newPosition: Vector3): void;
  34150. /**
  34151. * Sets the local direction of the emitter if spatial sound is enabled
  34152. * @param newLocalDirection Defines the new local direction
  34153. */
  34154. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34155. private _updateDirection;
  34156. /** @hidden */
  34157. updateDistanceFromListener(): void;
  34158. /**
  34159. * Sets a new custom attenuation function for the sound.
  34160. * @param callback Defines the function used for the attenuation
  34161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34162. */
  34163. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34164. /**
  34165. * Play the sound
  34166. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34167. * @param offset (optional) Start the sound at a specific time in seconds
  34168. * @param length (optional) Sound duration (in seconds)
  34169. */
  34170. play(time?: number, offset?: number, length?: number): void;
  34171. private _onended;
  34172. /**
  34173. * Stop the sound
  34174. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34175. */
  34176. stop(time?: number): void;
  34177. /**
  34178. * Put the sound in pause
  34179. */
  34180. pause(): void;
  34181. /**
  34182. * Sets a dedicated volume for this sounds
  34183. * @param newVolume Define the new volume of the sound
  34184. * @param time Define time for gradual change to new volume
  34185. */
  34186. setVolume(newVolume: number, time?: number): void;
  34187. /**
  34188. * Set the sound play back rate
  34189. * @param newPlaybackRate Define the playback rate the sound should be played at
  34190. */
  34191. setPlaybackRate(newPlaybackRate: number): void;
  34192. /**
  34193. * Gets the volume of the sound.
  34194. * @returns the volume of the sound
  34195. */
  34196. getVolume(): number;
  34197. /**
  34198. * Attach the sound to a dedicated mesh
  34199. * @param transformNode The transform node to connect the sound with
  34200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34201. */
  34202. attachToMesh(transformNode: TransformNode): void;
  34203. /**
  34204. * Detach the sound from the previously attached mesh
  34205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34206. */
  34207. detachFromMesh(): void;
  34208. private _onRegisterAfterWorldMatrixUpdate;
  34209. /**
  34210. * Clone the current sound in the scene.
  34211. * @returns the new sound clone
  34212. */
  34213. clone(): Nullable<Sound>;
  34214. /**
  34215. * Gets the current underlying audio buffer containing the data
  34216. * @returns the audio buffer
  34217. */
  34218. getAudioBuffer(): Nullable<AudioBuffer>;
  34219. /**
  34220. * Serializes the Sound in a JSON representation
  34221. * @returns the JSON representation of the sound
  34222. */
  34223. serialize(): any;
  34224. /**
  34225. * Parse a JSON representation of a sound to innstantiate in a given scene
  34226. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34227. * @param scene Define the scene the new parsed sound should be created in
  34228. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34229. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34230. * @returns the newly parsed sound
  34231. */
  34232. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34233. }
  34234. }
  34235. declare module BABYLON {
  34236. /**
  34237. * This defines an action helpful to play a defined sound on a triggered action.
  34238. */
  34239. export class PlaySoundAction extends Action {
  34240. private _sound;
  34241. /**
  34242. * Instantiate the action
  34243. * @param triggerOptions defines the trigger options
  34244. * @param sound defines the sound to play
  34245. * @param condition defines the trigger related conditions
  34246. */
  34247. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34248. /** @hidden */ private _prepare(): void;
  34249. /**
  34250. * Execute the action and play the sound.
  34251. */
  34252. execute(): void;
  34253. /**
  34254. * Serializes the actions and its related information.
  34255. * @param parent defines the object to serialize in
  34256. * @returns the serialized object
  34257. */
  34258. serialize(parent: any): any;
  34259. }
  34260. /**
  34261. * This defines an action helpful to stop a defined sound on a triggered action.
  34262. */
  34263. export class StopSoundAction extends Action {
  34264. private _sound;
  34265. /**
  34266. * Instantiate the action
  34267. * @param triggerOptions defines the trigger options
  34268. * @param sound defines the sound to stop
  34269. * @param condition defines the trigger related conditions
  34270. */
  34271. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34272. /** @hidden */ private _prepare(): void;
  34273. /**
  34274. * Execute the action and stop the sound.
  34275. */
  34276. execute(): void;
  34277. /**
  34278. * Serializes the actions and its related information.
  34279. * @param parent defines the object to serialize in
  34280. * @returns the serialized object
  34281. */
  34282. serialize(parent: any): any;
  34283. }
  34284. }
  34285. declare module BABYLON {
  34286. /**
  34287. * This defines an action responsible to change the value of a property
  34288. * by interpolating between its current value and the newly set one once triggered.
  34289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34290. */
  34291. export class InterpolateValueAction extends Action {
  34292. /**
  34293. * Defines the path of the property where the value should be interpolated
  34294. */
  34295. propertyPath: string;
  34296. /**
  34297. * Defines the target value at the end of the interpolation.
  34298. */
  34299. value: any;
  34300. /**
  34301. * Defines the time it will take for the property to interpolate to the value.
  34302. */
  34303. duration: number;
  34304. /**
  34305. * Defines if the other scene animations should be stopped when the action has been triggered
  34306. */
  34307. stopOtherAnimations?: boolean;
  34308. /**
  34309. * Defines a callback raised once the interpolation animation has been done.
  34310. */
  34311. onInterpolationDone?: () => void;
  34312. /**
  34313. * Observable triggered once the interpolation animation has been done.
  34314. */
  34315. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34316. private _target;
  34317. private _effectiveTarget;
  34318. private _property;
  34319. /**
  34320. * Instantiate the action
  34321. * @param triggerOptions defines the trigger options
  34322. * @param target defines the object containing the value to interpolate
  34323. * @param propertyPath defines the path to the property in the target object
  34324. * @param value defines the target value at the end of the interpolation
  34325. * @param duration deines the time it will take for the property to interpolate to the value.
  34326. * @param condition defines the trigger related conditions
  34327. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34328. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34329. */
  34330. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34331. /** @hidden */ private _prepare(): void;
  34332. /**
  34333. * Execute the action starts the value interpolation.
  34334. */
  34335. execute(): void;
  34336. /**
  34337. * Serializes the actions and its related information.
  34338. * @param parent defines the object to serialize in
  34339. * @returns the serialized object
  34340. */
  34341. serialize(parent: any): any;
  34342. }
  34343. }
  34344. declare module BABYLON {
  34345. /**
  34346. * Options allowed during the creation of a sound track.
  34347. */
  34348. export interface ISoundTrackOptions {
  34349. /**
  34350. * The volume the sound track should take during creation
  34351. */
  34352. volume?: number;
  34353. /**
  34354. * Define if the sound track is the main sound track of the scene
  34355. */
  34356. mainTrack?: boolean;
  34357. }
  34358. /**
  34359. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34360. * It will be also used in a future release to apply effects on a specific track.
  34361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34362. */
  34363. export class SoundTrack {
  34364. /**
  34365. * The unique identifier of the sound track in the scene.
  34366. */
  34367. id: number;
  34368. /**
  34369. * The list of sounds included in the sound track.
  34370. */
  34371. soundCollection: Array<Sound>;
  34372. private _outputAudioNode;
  34373. private _scene;
  34374. private _isMainTrack;
  34375. private _connectedAnalyser;
  34376. private _options;
  34377. private _isInitialized;
  34378. /**
  34379. * Creates a new sound track.
  34380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34381. * @param scene Define the scene the sound track belongs to
  34382. * @param options
  34383. */
  34384. constructor(scene: Scene, options?: ISoundTrackOptions);
  34385. private _initializeSoundTrackAudioGraph;
  34386. /**
  34387. * Release the sound track and its associated resources
  34388. */
  34389. dispose(): void;
  34390. /**
  34391. * Adds a sound to this sound track
  34392. * @param sound define the cound to add
  34393. * @ignoreNaming
  34394. */
  34395. AddSound(sound: Sound): void;
  34396. /**
  34397. * Removes a sound to this sound track
  34398. * @param sound define the cound to remove
  34399. * @ignoreNaming
  34400. */
  34401. RemoveSound(sound: Sound): void;
  34402. /**
  34403. * Set a global volume for the full sound track.
  34404. * @param newVolume Define the new volume of the sound track
  34405. */
  34406. setVolume(newVolume: number): void;
  34407. /**
  34408. * Switch the panning model to HRTF:
  34409. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34411. */
  34412. switchPanningModelToHRTF(): void;
  34413. /**
  34414. * Switch the panning model to Equal Power:
  34415. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34417. */
  34418. switchPanningModelToEqualPower(): void;
  34419. /**
  34420. * Connect the sound track to an audio analyser allowing some amazing
  34421. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34423. * @param analyser The analyser to connect to the engine
  34424. */
  34425. connectToAnalyser(analyser: Analyser): void;
  34426. }
  34427. }
  34428. declare module BABYLON {
  34429. interface AbstractScene {
  34430. /**
  34431. * The list of sounds used in the scene.
  34432. */
  34433. sounds: Nullable<Array<Sound>>;
  34434. }
  34435. interface Scene {
  34436. /**
  34437. * @hidden
  34438. * Backing field
  34439. */ private _mainSoundTrack: SoundTrack;
  34440. /**
  34441. * The main sound track played by the scene.
  34442. * It cotains your primary collection of sounds.
  34443. */
  34444. mainSoundTrack: SoundTrack;
  34445. /**
  34446. * The list of sound tracks added to the scene
  34447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34448. */
  34449. soundTracks: Nullable<Array<SoundTrack>>;
  34450. /**
  34451. * Gets a sound using a given name
  34452. * @param name defines the name to search for
  34453. * @return the found sound or null if not found at all.
  34454. */
  34455. getSoundByName(name: string): Nullable<Sound>;
  34456. /**
  34457. * Gets or sets if audio support is enabled
  34458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34459. */
  34460. audioEnabled: boolean;
  34461. /**
  34462. * Gets or sets if audio will be output to headphones
  34463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34464. */
  34465. headphone: boolean;
  34466. }
  34467. /**
  34468. * Defines the sound scene component responsible to manage any sounds
  34469. * in a given scene.
  34470. */
  34471. export class AudioSceneComponent implements ISceneSerializableComponent {
  34472. /**
  34473. * The component name helpfull to identify the component in the list of scene components.
  34474. */
  34475. readonly name: string;
  34476. /**
  34477. * The scene the component belongs to.
  34478. */
  34479. scene: Scene;
  34480. private _audioEnabled;
  34481. /**
  34482. * Gets whether audio is enabled or not.
  34483. * Please use related enable/disable method to switch state.
  34484. */
  34485. readonly audioEnabled: boolean;
  34486. private _headphone;
  34487. /**
  34488. * Gets whether audio is outputing to headphone or not.
  34489. * Please use the according Switch methods to change output.
  34490. */
  34491. readonly headphone: boolean;
  34492. /**
  34493. * Creates a new instance of the component for the given scene
  34494. * @param scene Defines the scene to register the component in
  34495. */
  34496. constructor(scene: Scene);
  34497. /**
  34498. * Registers the component in a given scene
  34499. */
  34500. register(): void;
  34501. /**
  34502. * Rebuilds the elements related to this component in case of
  34503. * context lost for instance.
  34504. */
  34505. rebuild(): void;
  34506. /**
  34507. * Serializes the component data to the specified json object
  34508. * @param serializationObject The object to serialize to
  34509. */
  34510. serialize(serializationObject: any): void;
  34511. /**
  34512. * Adds all the elements from the container to the scene
  34513. * @param container the container holding the elements
  34514. */
  34515. addFromContainer(container: AbstractScene): void;
  34516. /**
  34517. * Removes all the elements in the container from the scene
  34518. * @param container contains the elements to remove
  34519. * @param dispose if the removed element should be disposed (default: false)
  34520. */
  34521. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34522. /**
  34523. * Disposes the component and the associated ressources.
  34524. */
  34525. dispose(): void;
  34526. /**
  34527. * Disables audio in the associated scene.
  34528. */
  34529. disableAudio(): void;
  34530. /**
  34531. * Enables audio in the associated scene.
  34532. */
  34533. enableAudio(): void;
  34534. /**
  34535. * Switch audio to headphone output.
  34536. */
  34537. switchAudioModeForHeadphones(): void;
  34538. /**
  34539. * Switch audio to normal speakers.
  34540. */
  34541. switchAudioModeForNormalSpeakers(): void;
  34542. private _afterRender;
  34543. }
  34544. }
  34545. declare module BABYLON {
  34546. /**
  34547. * Wraps one or more Sound objects and selects one with random weight for playback.
  34548. */
  34549. export class WeightedSound {
  34550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34551. loop: boolean;
  34552. private _coneInnerAngle;
  34553. private _coneOuterAngle;
  34554. private _volume;
  34555. /** A Sound is currently playing. */
  34556. isPlaying: boolean;
  34557. /** A Sound is currently paused. */
  34558. isPaused: boolean;
  34559. private _sounds;
  34560. private _weights;
  34561. private _currentIndex?;
  34562. /**
  34563. * Creates a new WeightedSound from the list of sounds given.
  34564. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34565. * @param sounds Array of Sounds that will be selected from.
  34566. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34567. */
  34568. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34569. /**
  34570. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34571. */
  34572. /**
  34573. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34574. */
  34575. directionalConeInnerAngle: number;
  34576. /**
  34577. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34578. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34579. */
  34580. /**
  34581. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34582. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34583. */
  34584. directionalConeOuterAngle: number;
  34585. /**
  34586. * Playback volume.
  34587. */
  34588. /**
  34589. * Playback volume.
  34590. */
  34591. volume: number;
  34592. private _onended;
  34593. /**
  34594. * Suspend playback
  34595. */
  34596. pause(): void;
  34597. /**
  34598. * Stop playback
  34599. */
  34600. stop(): void;
  34601. /**
  34602. * Start playback.
  34603. * @param startOffset Position the clip head at a specific time in seconds.
  34604. */
  34605. play(startOffset?: number): void;
  34606. }
  34607. }
  34608. declare module BABYLON {
  34609. /**
  34610. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34611. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34612. */
  34613. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34614. /**
  34615. * Gets the name of the behavior.
  34616. */
  34617. readonly name: string;
  34618. /**
  34619. * The easing function used by animations
  34620. */
  34621. static EasingFunction: BackEase;
  34622. /**
  34623. * The easing mode used by animations
  34624. */
  34625. static EasingMode: number;
  34626. /**
  34627. * The duration of the animation, in milliseconds
  34628. */
  34629. transitionDuration: number;
  34630. /**
  34631. * Length of the distance animated by the transition when lower radius is reached
  34632. */
  34633. lowerRadiusTransitionRange: number;
  34634. /**
  34635. * Length of the distance animated by the transition when upper radius is reached
  34636. */
  34637. upperRadiusTransitionRange: number;
  34638. private _autoTransitionRange;
  34639. /**
  34640. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34641. */
  34642. /**
  34643. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34644. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34645. */
  34646. autoTransitionRange: boolean;
  34647. private _attachedCamera;
  34648. private _onAfterCheckInputsObserver;
  34649. private _onMeshTargetChangedObserver;
  34650. /**
  34651. * Initializes the behavior.
  34652. */
  34653. init(): void;
  34654. /**
  34655. * Attaches the behavior to its arc rotate camera.
  34656. * @param camera Defines the camera to attach the behavior to
  34657. */
  34658. attach(camera: ArcRotateCamera): void;
  34659. /**
  34660. * Detaches the behavior from its current arc rotate camera.
  34661. */
  34662. detach(): void;
  34663. private _radiusIsAnimating;
  34664. private _radiusBounceTransition;
  34665. private _animatables;
  34666. private _cachedWheelPrecision;
  34667. /**
  34668. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34669. * @param radiusLimit The limit to check against.
  34670. * @return Bool to indicate if at limit.
  34671. */
  34672. private _isRadiusAtLimit;
  34673. /**
  34674. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34675. * @param radiusDelta The delta by which to animate to. Can be negative.
  34676. */
  34677. private _applyBoundRadiusAnimation;
  34678. /**
  34679. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34680. */
  34681. protected _clearAnimationLocks(): void;
  34682. /**
  34683. * Stops and removes all animations that have been applied to the camera
  34684. */
  34685. stopAllAnimations(): void;
  34686. }
  34687. }
  34688. declare module BABYLON {
  34689. /**
  34690. * 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.
  34691. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34692. */
  34693. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34694. /**
  34695. * Gets the name of the behavior.
  34696. */
  34697. readonly name: string;
  34698. private _mode;
  34699. private _radiusScale;
  34700. private _positionScale;
  34701. private _defaultElevation;
  34702. private _elevationReturnTime;
  34703. private _elevationReturnWaitTime;
  34704. private _zoomStopsAnimation;
  34705. private _framingTime;
  34706. /**
  34707. * The easing function used by animations
  34708. */
  34709. static EasingFunction: ExponentialEase;
  34710. /**
  34711. * The easing mode used by animations
  34712. */
  34713. static EasingMode: number;
  34714. /**
  34715. * Sets the current mode used by the behavior
  34716. */
  34717. /**
  34718. * Gets current mode used by the behavior.
  34719. */
  34720. mode: number;
  34721. /**
  34722. * Sets the scale applied to the radius (1 by default)
  34723. */
  34724. /**
  34725. * Gets the scale applied to the radius
  34726. */
  34727. radiusScale: number;
  34728. /**
  34729. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34730. */
  34731. /**
  34732. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34733. */
  34734. positionScale: number;
  34735. /**
  34736. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34737. * behaviour is triggered, in radians.
  34738. */
  34739. /**
  34740. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34741. * behaviour is triggered, in radians.
  34742. */
  34743. defaultElevation: number;
  34744. /**
  34745. * Sets the time (in milliseconds) taken to return to the default beta position.
  34746. * Negative value indicates camera should not return to default.
  34747. */
  34748. /**
  34749. * Gets the time (in milliseconds) taken to return to the default beta position.
  34750. * Negative value indicates camera should not return to default.
  34751. */
  34752. elevationReturnTime: number;
  34753. /**
  34754. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34755. */
  34756. /**
  34757. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34758. */
  34759. elevationReturnWaitTime: number;
  34760. /**
  34761. * Sets the flag that indicates if user zooming should stop animation.
  34762. */
  34763. /**
  34764. * Gets the flag that indicates if user zooming should stop animation.
  34765. */
  34766. zoomStopsAnimation: boolean;
  34767. /**
  34768. * Sets the transition time when framing the mesh, in milliseconds
  34769. */
  34770. /**
  34771. * Gets the transition time when framing the mesh, in milliseconds
  34772. */
  34773. framingTime: number;
  34774. /**
  34775. * Define if the behavior should automatically change the configured
  34776. * camera limits and sensibilities.
  34777. */
  34778. autoCorrectCameraLimitsAndSensibility: boolean;
  34779. private _onPrePointerObservableObserver;
  34780. private _onAfterCheckInputsObserver;
  34781. private _onMeshTargetChangedObserver;
  34782. private _attachedCamera;
  34783. private _isPointerDown;
  34784. private _lastInteractionTime;
  34785. /**
  34786. * Initializes the behavior.
  34787. */
  34788. init(): void;
  34789. /**
  34790. * Attaches the behavior to its arc rotate camera.
  34791. * @param camera Defines the camera to attach the behavior to
  34792. */
  34793. attach(camera: ArcRotateCamera): void;
  34794. /**
  34795. * Detaches the behavior from its current arc rotate camera.
  34796. */
  34797. detach(): void;
  34798. private _animatables;
  34799. private _betaIsAnimating;
  34800. private _betaTransition;
  34801. private _radiusTransition;
  34802. private _vectorTransition;
  34803. /**
  34804. * Targets the given mesh and updates zoom level accordingly.
  34805. * @param mesh The mesh to target.
  34806. * @param radius Optional. If a cached radius position already exists, overrides default.
  34807. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34808. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34809. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34810. */
  34811. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34812. /**
  34813. * Targets the given mesh with its children and updates zoom level accordingly.
  34814. * @param mesh The mesh to target.
  34815. * @param radius Optional. If a cached radius position already exists, overrides default.
  34816. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34817. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34818. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34819. */
  34820. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34821. /**
  34822. * Targets the given meshes with their children and updates zoom level accordingly.
  34823. * @param meshes The mesh to target.
  34824. * @param radius Optional. If a cached radius position already exists, overrides default.
  34825. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34826. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34827. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34828. */
  34829. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34830. /**
  34831. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34832. * @param minimumWorld Determines the smaller position of the bounding box extend
  34833. * @param maximumWorld Determines the bigger position of the bounding box extend
  34834. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34835. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34836. */
  34837. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34838. /**
  34839. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34840. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34841. * frustum width.
  34842. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34843. * to fully enclose the mesh in the viewing frustum.
  34844. */
  34845. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34846. /**
  34847. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34848. * is automatically returned to its default position (expected to be above ground plane).
  34849. */
  34850. private _maintainCameraAboveGround;
  34851. /**
  34852. * Returns the frustum slope based on the canvas ratio and camera FOV
  34853. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34854. */
  34855. private _getFrustumSlope;
  34856. /**
  34857. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34858. */
  34859. private _clearAnimationLocks;
  34860. /**
  34861. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34862. */
  34863. private _applyUserInteraction;
  34864. /**
  34865. * Stops and removes all animations that have been applied to the camera
  34866. */
  34867. stopAllAnimations(): void;
  34868. /**
  34869. * Gets a value indicating if the user is moving the camera
  34870. */
  34871. readonly isUserIsMoving: boolean;
  34872. /**
  34873. * The camera can move all the way towards the mesh.
  34874. */
  34875. static IgnoreBoundsSizeMode: number;
  34876. /**
  34877. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34878. */
  34879. static FitFrustumSidesMode: number;
  34880. }
  34881. }
  34882. declare module BABYLON {
  34883. /**
  34884. * Base class for Camera Pointer Inputs.
  34885. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34886. * for example usage.
  34887. */
  34888. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34889. /**
  34890. * Defines the camera the input is attached to.
  34891. */
  34892. abstract camera: Camera;
  34893. /**
  34894. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34895. */
  34896. protected _altKey: boolean;
  34897. protected _ctrlKey: boolean;
  34898. protected _metaKey: boolean;
  34899. protected _shiftKey: boolean;
  34900. /**
  34901. * Which mouse buttons were pressed at time of last mouse event.
  34902. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34903. */
  34904. protected _buttonsPressed: number;
  34905. /**
  34906. * Defines the buttons associated with the input to handle camera move.
  34907. */
  34908. buttons: number[];
  34909. /**
  34910. * Attach the input controls to a specific dom element to get the input from.
  34911. * @param element Defines the element the controls should be listened from
  34912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34913. */
  34914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34915. /**
  34916. * Detach the current controls from the specified dom element.
  34917. * @param element Defines the element to stop listening the inputs from
  34918. */
  34919. detachControl(element: Nullable<HTMLElement>): void;
  34920. /**
  34921. * Gets the class name of the current input.
  34922. * @returns the class name
  34923. */
  34924. getClassName(): string;
  34925. /**
  34926. * Get the friendly name associated with the input class.
  34927. * @returns the input friendly name
  34928. */
  34929. getSimpleName(): string;
  34930. /**
  34931. * Called on pointer POINTERDOUBLETAP event.
  34932. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34933. */
  34934. protected onDoubleTap(type: string): void;
  34935. /**
  34936. * Called on pointer POINTERMOVE event if only a single touch is active.
  34937. * Override this method to provide functionality.
  34938. */
  34939. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34940. /**
  34941. * Called on pointer POINTERMOVE event if multiple touches are active.
  34942. * Override this method to provide functionality.
  34943. */
  34944. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34945. /**
  34946. * Called on JS contextmenu event.
  34947. * Override this method to provide functionality.
  34948. */
  34949. protected onContextMenu(evt: PointerEvent): void;
  34950. /**
  34951. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34952. * press.
  34953. * Override this method to provide functionality.
  34954. */
  34955. protected onButtonDown(evt: PointerEvent): void;
  34956. /**
  34957. * Called each time a new POINTERUP event occurs. Ie, for each button
  34958. * release.
  34959. * Override this method to provide functionality.
  34960. */
  34961. protected onButtonUp(evt: PointerEvent): void;
  34962. /**
  34963. * Called when window becomes inactive.
  34964. * Override this method to provide functionality.
  34965. */
  34966. protected onLostFocus(): void;
  34967. private _pointerInput;
  34968. private _observer;
  34969. private _onLostFocus;
  34970. private pointA;
  34971. private pointB;
  34972. }
  34973. }
  34974. declare module BABYLON {
  34975. /**
  34976. * Manage the pointers inputs to control an arc rotate camera.
  34977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34978. */
  34979. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34980. /**
  34981. * Defines the camera the input is attached to.
  34982. */
  34983. camera: ArcRotateCamera;
  34984. /**
  34985. * Gets the class name of the current input.
  34986. * @returns the class name
  34987. */
  34988. getClassName(): string;
  34989. /**
  34990. * Defines the buttons associated with the input to handle camera move.
  34991. */
  34992. buttons: number[];
  34993. /**
  34994. * Defines the pointer angular sensibility along the X axis or how fast is
  34995. * the camera rotating.
  34996. */
  34997. angularSensibilityX: number;
  34998. /**
  34999. * Defines the pointer angular sensibility along the Y axis or how fast is
  35000. * the camera rotating.
  35001. */
  35002. angularSensibilityY: number;
  35003. /**
  35004. * Defines the pointer pinch precision or how fast is the camera zooming.
  35005. */
  35006. pinchPrecision: number;
  35007. /**
  35008. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35009. * from 0.
  35010. * It defines the percentage of current camera.radius to use as delta when
  35011. * pinch zoom is used.
  35012. */
  35013. pinchDeltaPercentage: number;
  35014. /**
  35015. * Defines the pointer panning sensibility or how fast is the camera moving.
  35016. */
  35017. panningSensibility: number;
  35018. /**
  35019. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35020. */
  35021. multiTouchPanning: boolean;
  35022. /**
  35023. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35024. * zoom (pinch) through multitouch.
  35025. */
  35026. multiTouchPanAndZoom: boolean;
  35027. /**
  35028. * Revers pinch action direction.
  35029. */
  35030. pinchInwards: boolean;
  35031. private _isPanClick;
  35032. private _twoFingerActivityCount;
  35033. private _isPinching;
  35034. /**
  35035. * Called on pointer POINTERMOVE event if only a single touch is active.
  35036. */
  35037. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35038. /**
  35039. * Called on pointer POINTERDOUBLETAP event.
  35040. */
  35041. protected onDoubleTap(type: string): void;
  35042. /**
  35043. * Called on pointer POINTERMOVE event if multiple touches are active.
  35044. */
  35045. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35046. /**
  35047. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35048. * press.
  35049. */
  35050. protected onButtonDown(evt: PointerEvent): void;
  35051. /**
  35052. * Called each time a new POINTERUP event occurs. Ie, for each button
  35053. * release.
  35054. */
  35055. protected onButtonUp(evt: PointerEvent): void;
  35056. /**
  35057. * Called when window becomes inactive.
  35058. */
  35059. protected onLostFocus(): void;
  35060. }
  35061. }
  35062. declare module BABYLON {
  35063. /**
  35064. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35066. */
  35067. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35068. /**
  35069. * Defines the camera the input is attached to.
  35070. */
  35071. camera: ArcRotateCamera;
  35072. /**
  35073. * Defines the list of key codes associated with the up action (increase alpha)
  35074. */
  35075. keysUp: number[];
  35076. /**
  35077. * Defines the list of key codes associated with the down action (decrease alpha)
  35078. */
  35079. keysDown: number[];
  35080. /**
  35081. * Defines the list of key codes associated with the left action (increase beta)
  35082. */
  35083. keysLeft: number[];
  35084. /**
  35085. * Defines the list of key codes associated with the right action (decrease beta)
  35086. */
  35087. keysRight: number[];
  35088. /**
  35089. * Defines the list of key codes associated with the reset action.
  35090. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35091. */
  35092. keysReset: number[];
  35093. /**
  35094. * Defines the panning sensibility of the inputs.
  35095. * (How fast is the camera paning)
  35096. */
  35097. panningSensibility: number;
  35098. /**
  35099. * Defines the zooming sensibility of the inputs.
  35100. * (How fast is the camera zooming)
  35101. */
  35102. zoomingSensibility: number;
  35103. /**
  35104. * Defines wether maintaining the alt key down switch the movement mode from
  35105. * orientation to zoom.
  35106. */
  35107. useAltToZoom: boolean;
  35108. /**
  35109. * Rotation speed of the camera
  35110. */
  35111. angularSpeed: number;
  35112. private _keys;
  35113. private _ctrlPressed;
  35114. private _altPressed;
  35115. private _onCanvasBlurObserver;
  35116. private _onKeyboardObserver;
  35117. private _engine;
  35118. private _scene;
  35119. /**
  35120. * Attach the input controls to a specific dom element to get the input from.
  35121. * @param element Defines the element the controls should be listened from
  35122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35123. */
  35124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35125. /**
  35126. * Detach the current controls from the specified dom element.
  35127. * @param element Defines the element to stop listening the inputs from
  35128. */
  35129. detachControl(element: Nullable<HTMLElement>): void;
  35130. /**
  35131. * Update the current camera state depending on the inputs that have been used this frame.
  35132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35133. */
  35134. checkInputs(): void;
  35135. /**
  35136. * Gets the class name of the current intput.
  35137. * @returns the class name
  35138. */
  35139. getClassName(): string;
  35140. /**
  35141. * Get the friendly name associated with the input class.
  35142. * @returns the input friendly name
  35143. */
  35144. getSimpleName(): string;
  35145. }
  35146. }
  35147. declare module BABYLON {
  35148. /**
  35149. * Manage the mouse wheel inputs to control an arc rotate camera.
  35150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35151. */
  35152. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35153. /**
  35154. * Defines the camera the input is attached to.
  35155. */
  35156. camera: ArcRotateCamera;
  35157. /**
  35158. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35159. */
  35160. wheelPrecision: number;
  35161. /**
  35162. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35163. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35164. */
  35165. wheelDeltaPercentage: number;
  35166. private _wheel;
  35167. private _observer;
  35168. private computeDeltaFromMouseWheelLegacyEvent;
  35169. /**
  35170. * Attach the input controls to a specific dom element to get the input from.
  35171. * @param element Defines the element the controls should be listened from
  35172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35173. */
  35174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35175. /**
  35176. * Detach the current controls from the specified dom element.
  35177. * @param element Defines the element to stop listening the inputs from
  35178. */
  35179. detachControl(element: Nullable<HTMLElement>): void;
  35180. /**
  35181. * Gets the class name of the current intput.
  35182. * @returns the class name
  35183. */
  35184. getClassName(): string;
  35185. /**
  35186. * Get the friendly name associated with the input class.
  35187. * @returns the input friendly name
  35188. */
  35189. getSimpleName(): string;
  35190. }
  35191. }
  35192. declare module BABYLON {
  35193. /**
  35194. * Default Inputs manager for the ArcRotateCamera.
  35195. * It groups all the default supported inputs for ease of use.
  35196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35197. */
  35198. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35199. /**
  35200. * Instantiates a new ArcRotateCameraInputsManager.
  35201. * @param camera Defines the camera the inputs belong to
  35202. */
  35203. constructor(camera: ArcRotateCamera);
  35204. /**
  35205. * Add mouse wheel input support to the input manager.
  35206. * @returns the current input manager
  35207. */
  35208. addMouseWheel(): ArcRotateCameraInputsManager;
  35209. /**
  35210. * Add pointers input support to the input manager.
  35211. * @returns the current input manager
  35212. */
  35213. addPointers(): ArcRotateCameraInputsManager;
  35214. /**
  35215. * Add keyboard input support to the input manager.
  35216. * @returns the current input manager
  35217. */
  35218. addKeyboard(): ArcRotateCameraInputsManager;
  35219. }
  35220. }
  35221. declare module BABYLON {
  35222. /**
  35223. * This represents an orbital type of camera.
  35224. *
  35225. * 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.
  35226. * 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.
  35227. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35228. */
  35229. export class ArcRotateCamera extends TargetCamera {
  35230. /**
  35231. * Defines the rotation angle of the camera along the longitudinal axis.
  35232. */
  35233. alpha: number;
  35234. /**
  35235. * Defines the rotation angle of the camera along the latitudinal axis.
  35236. */
  35237. beta: number;
  35238. /**
  35239. * Defines the radius of the camera from it s target point.
  35240. */
  35241. radius: number;
  35242. protected _target: Vector3;
  35243. protected _targetHost: Nullable<AbstractMesh>;
  35244. /**
  35245. * Defines the target point of the camera.
  35246. * The camera looks towards it form the radius distance.
  35247. */
  35248. target: Vector3;
  35249. /**
  35250. * Define the current local position of the camera in the scene
  35251. */
  35252. position: Vector3;
  35253. protected _upVector: Vector3;
  35254. protected _upToYMatrix: Matrix;
  35255. protected _YToUpMatrix: Matrix;
  35256. /**
  35257. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35258. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35259. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35260. */
  35261. upVector: Vector3;
  35262. /**
  35263. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35264. */
  35265. setMatUp(): void;
  35266. /**
  35267. * Current inertia value on the longitudinal axis.
  35268. * The bigger this number the longer it will take for the camera to stop.
  35269. */
  35270. inertialAlphaOffset: number;
  35271. /**
  35272. * Current inertia value on the latitudinal axis.
  35273. * The bigger this number the longer it will take for the camera to stop.
  35274. */
  35275. inertialBetaOffset: number;
  35276. /**
  35277. * Current inertia value on the radius axis.
  35278. * The bigger this number the longer it will take for the camera to stop.
  35279. */
  35280. inertialRadiusOffset: number;
  35281. /**
  35282. * Minimum allowed angle on the longitudinal axis.
  35283. * This can help limiting how the Camera is able to move in the scene.
  35284. */
  35285. lowerAlphaLimit: Nullable<number>;
  35286. /**
  35287. * Maximum allowed angle on the longitudinal axis.
  35288. * This can help limiting how the Camera is able to move in the scene.
  35289. */
  35290. upperAlphaLimit: Nullable<number>;
  35291. /**
  35292. * Minimum allowed angle on the latitudinal axis.
  35293. * This can help limiting how the Camera is able to move in the scene.
  35294. */
  35295. lowerBetaLimit: number;
  35296. /**
  35297. * Maximum allowed angle on the latitudinal axis.
  35298. * This can help limiting how the Camera is able to move in the scene.
  35299. */
  35300. upperBetaLimit: number;
  35301. /**
  35302. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35303. * This can help limiting how the Camera is able to move in the scene.
  35304. */
  35305. lowerRadiusLimit: Nullable<number>;
  35306. /**
  35307. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35308. * This can help limiting how the Camera is able to move in the scene.
  35309. */
  35310. upperRadiusLimit: Nullable<number>;
  35311. /**
  35312. * Defines the current inertia value used during panning of the camera along the X axis.
  35313. */
  35314. inertialPanningX: number;
  35315. /**
  35316. * Defines the current inertia value used during panning of the camera along the Y axis.
  35317. */
  35318. inertialPanningY: number;
  35319. /**
  35320. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35321. * Basically if your fingers moves away from more than this distance you will be considered
  35322. * in pinch mode.
  35323. */
  35324. pinchToPanMaxDistance: number;
  35325. /**
  35326. * Defines the maximum distance the camera can pan.
  35327. * This could help keeping the cammera always in your scene.
  35328. */
  35329. panningDistanceLimit: Nullable<number>;
  35330. /**
  35331. * Defines the target of the camera before paning.
  35332. */
  35333. panningOriginTarget: Vector3;
  35334. /**
  35335. * Defines the value of the inertia used during panning.
  35336. * 0 would mean stop inertia and one would mean no decelleration at all.
  35337. */
  35338. panningInertia: number;
  35339. /**
  35340. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35341. */
  35342. angularSensibilityX: number;
  35343. /**
  35344. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35345. */
  35346. angularSensibilityY: number;
  35347. /**
  35348. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35349. */
  35350. pinchPrecision: number;
  35351. /**
  35352. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35353. * It will be used instead of pinchDeltaPrecision if different from 0.
  35354. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35355. */
  35356. pinchDeltaPercentage: number;
  35357. /**
  35358. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35359. */
  35360. panningSensibility: number;
  35361. /**
  35362. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35363. */
  35364. keysUp: number[];
  35365. /**
  35366. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35367. */
  35368. keysDown: number[];
  35369. /**
  35370. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35371. */
  35372. keysLeft: number[];
  35373. /**
  35374. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35375. */
  35376. keysRight: number[];
  35377. /**
  35378. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35379. */
  35380. wheelPrecision: number;
  35381. /**
  35382. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35383. * It will be used instead of pinchDeltaPrecision if different from 0.
  35384. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35385. */
  35386. wheelDeltaPercentage: number;
  35387. /**
  35388. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35389. */
  35390. zoomOnFactor: number;
  35391. /**
  35392. * Defines a screen offset for the camera position.
  35393. */
  35394. targetScreenOffset: Vector2;
  35395. /**
  35396. * Allows the camera to be completely reversed.
  35397. * If false the camera can not arrive upside down.
  35398. */
  35399. allowUpsideDown: boolean;
  35400. /**
  35401. * Define if double tap/click is used to restore the previously saved state of the camera.
  35402. */
  35403. useInputToRestoreState: boolean;
  35404. /** @hidden */ private _viewMatrix: Matrix;
  35405. /** @hidden */ private _useCtrlForPanning: boolean;
  35406. /** @hidden */ private _panningMouseButton: number;
  35407. /**
  35408. * Defines the input associated to the camera.
  35409. */
  35410. inputs: ArcRotateCameraInputsManager;
  35411. /** @hidden */ private _reset: () => void;
  35412. /**
  35413. * Defines the allowed panning axis.
  35414. */
  35415. panningAxis: Vector3;
  35416. protected _localDirection: Vector3;
  35417. protected _transformedDirection: Vector3;
  35418. private _bouncingBehavior;
  35419. /**
  35420. * Gets the bouncing behavior of the camera if it has been enabled.
  35421. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35422. */
  35423. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35424. /**
  35425. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35427. */
  35428. useBouncingBehavior: boolean;
  35429. private _framingBehavior;
  35430. /**
  35431. * Gets the framing behavior of the camera if it has been enabled.
  35432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35433. */
  35434. readonly framingBehavior: Nullable<FramingBehavior>;
  35435. /**
  35436. * Defines if the framing behavior of the camera is enabled on the camera.
  35437. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35438. */
  35439. useFramingBehavior: boolean;
  35440. private _autoRotationBehavior;
  35441. /**
  35442. * Gets the auto rotation behavior of the camera if it has been enabled.
  35443. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35444. */
  35445. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35446. /**
  35447. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35449. */
  35450. useAutoRotationBehavior: boolean;
  35451. /**
  35452. * Observable triggered when the mesh target has been changed on the camera.
  35453. */
  35454. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35455. /**
  35456. * Event raised when the camera is colliding with a mesh.
  35457. */
  35458. onCollide: (collidedMesh: AbstractMesh) => void;
  35459. /**
  35460. * Defines whether the camera should check collision with the objects oh the scene.
  35461. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35462. */
  35463. checkCollisions: boolean;
  35464. /**
  35465. * Defines the collision radius of the camera.
  35466. * This simulates a sphere around the camera.
  35467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35468. */
  35469. collisionRadius: Vector3;
  35470. protected _collider: Collider;
  35471. protected _previousPosition: Vector3;
  35472. protected _collisionVelocity: Vector3;
  35473. protected _newPosition: Vector3;
  35474. protected _previousAlpha: number;
  35475. protected _previousBeta: number;
  35476. protected _previousRadius: number;
  35477. protected _collisionTriggered: boolean;
  35478. protected _targetBoundingCenter: Nullable<Vector3>;
  35479. private _computationVector;
  35480. /**
  35481. * Instantiates a new ArcRotateCamera in a given scene
  35482. * @param name Defines the name of the camera
  35483. * @param alpha Defines the camera rotation along the logitudinal axis
  35484. * @param beta Defines the camera rotation along the latitudinal axis
  35485. * @param radius Defines the camera distance from its target
  35486. * @param target Defines the camera target
  35487. * @param scene Defines the scene the camera belongs to
  35488. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35489. */
  35490. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35491. /** @hidden */ private _initCache(): void;
  35492. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35493. protected _getTargetPosition(): Vector3;
  35494. private _storedAlpha;
  35495. private _storedBeta;
  35496. private _storedRadius;
  35497. private _storedTarget;
  35498. /**
  35499. * Stores the current state of the camera (alpha, beta, radius and target)
  35500. * @returns the camera itself
  35501. */
  35502. storeState(): Camera;
  35503. /**
  35504. * @hidden
  35505. * Restored camera state. You must call storeState() first
  35506. */ private _restoreStateValues(): boolean;
  35507. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35508. /**
  35509. * Attached controls to the current camera.
  35510. * @param element Defines the element the controls should be listened from
  35511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35512. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35513. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35514. */
  35515. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35516. /**
  35517. * Detach the current controls from the camera.
  35518. * The camera will stop reacting to inputs.
  35519. * @param element Defines the element to stop listening the inputs from
  35520. */
  35521. detachControl(element: HTMLElement): void;
  35522. /** @hidden */ private _checkInputs(): void;
  35523. protected _checkLimits(): void;
  35524. /**
  35525. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35526. */
  35527. rebuildAnglesAndRadius(): void;
  35528. /**
  35529. * Use a position to define the current camera related information like aplha, beta and radius
  35530. * @param position Defines the position to set the camera at
  35531. */
  35532. setPosition(position: Vector3): void;
  35533. /**
  35534. * Defines the target the camera should look at.
  35535. * This will automatically adapt alpha beta and radius to fit within the new target.
  35536. * @param target Defines the new target as a Vector or a mesh
  35537. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35538. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35539. */
  35540. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35541. /** @hidden */ private _getViewMatrix(): Matrix;
  35542. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35543. /**
  35544. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35545. * @param meshes Defines the mesh to zoom on
  35546. * @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)
  35547. */
  35548. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35549. /**
  35550. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35551. * The target will be changed but the radius
  35552. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35553. * @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)
  35554. */
  35555. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35556. min: Vector3;
  35557. max: Vector3;
  35558. distance: number;
  35559. }, doNotUpdateMaxZ?: boolean): void;
  35560. /**
  35561. * @override
  35562. * Override Camera.createRigCamera
  35563. */
  35564. createRigCamera(name: string, cameraIndex: number): Camera;
  35565. /**
  35566. * @hidden
  35567. * @override
  35568. * Override Camera._updateRigCameras
  35569. */ private _updateRigCameras(): void;
  35570. /**
  35571. * Destroy the camera and release the current resources hold by it.
  35572. */
  35573. dispose(): void;
  35574. /**
  35575. * Gets the current object class name.
  35576. * @return the class name
  35577. */
  35578. getClassName(): string;
  35579. }
  35580. }
  35581. declare module BABYLON {
  35582. /**
  35583. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35585. */
  35586. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35587. /**
  35588. * Gets the name of the behavior.
  35589. */
  35590. readonly name: string;
  35591. private _zoomStopsAnimation;
  35592. private _idleRotationSpeed;
  35593. private _idleRotationWaitTime;
  35594. private _idleRotationSpinupTime;
  35595. /**
  35596. * Sets the flag that indicates if user zooming should stop animation.
  35597. */
  35598. /**
  35599. * Gets the flag that indicates if user zooming should stop animation.
  35600. */
  35601. zoomStopsAnimation: boolean;
  35602. /**
  35603. * Sets the default speed at which the camera rotates around the model.
  35604. */
  35605. /**
  35606. * Gets the default speed at which the camera rotates around the model.
  35607. */
  35608. idleRotationSpeed: number;
  35609. /**
  35610. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35611. */
  35612. /**
  35613. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35614. */
  35615. idleRotationWaitTime: number;
  35616. /**
  35617. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35618. */
  35619. /**
  35620. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35621. */
  35622. idleRotationSpinupTime: number;
  35623. /**
  35624. * Gets a value indicating if the camera is currently rotating because of this behavior
  35625. */
  35626. readonly rotationInProgress: boolean;
  35627. private _onPrePointerObservableObserver;
  35628. private _onAfterCheckInputsObserver;
  35629. private _attachedCamera;
  35630. private _isPointerDown;
  35631. private _lastFrameTime;
  35632. private _lastInteractionTime;
  35633. private _cameraRotationSpeed;
  35634. /**
  35635. * Initializes the behavior.
  35636. */
  35637. init(): void;
  35638. /**
  35639. * Attaches the behavior to its arc rotate camera.
  35640. * @param camera Defines the camera to attach the behavior to
  35641. */
  35642. attach(camera: ArcRotateCamera): void;
  35643. /**
  35644. * Detaches the behavior from its current arc rotate camera.
  35645. */
  35646. detach(): void;
  35647. /**
  35648. * Returns true if user is scrolling.
  35649. * @return true if user is scrolling.
  35650. */
  35651. private _userIsZooming;
  35652. private _lastFrameRadius;
  35653. private _shouldAnimationStopForInteraction;
  35654. /**
  35655. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35656. */
  35657. private _applyUserInteraction;
  35658. private _userIsMoving;
  35659. }
  35660. }
  35661. declare module BABYLON {
  35662. /**
  35663. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35664. */
  35665. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35666. private ui;
  35667. /**
  35668. * The name of the behavior
  35669. */
  35670. name: string;
  35671. /**
  35672. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35673. */
  35674. distanceAwayFromFace: number;
  35675. /**
  35676. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35677. */
  35678. distanceAwayFromBottomOfFace: number;
  35679. private _faceVectors;
  35680. private _target;
  35681. private _scene;
  35682. private _onRenderObserver;
  35683. private _tmpMatrix;
  35684. private _tmpVector;
  35685. /**
  35686. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35687. * @param ui The transform node that should be attched to the mesh
  35688. */
  35689. constructor(ui: TransformNode);
  35690. /**
  35691. * Initializes the behavior
  35692. */
  35693. init(): void;
  35694. private _closestFace;
  35695. private _zeroVector;
  35696. private _lookAtTmpMatrix;
  35697. private _lookAtToRef;
  35698. /**
  35699. * Attaches the AttachToBoxBehavior to the passed in mesh
  35700. * @param target The mesh that the specified node will be attached to
  35701. */
  35702. attach(target: Mesh): void;
  35703. /**
  35704. * Detaches the behavior from the mesh
  35705. */
  35706. detach(): void;
  35707. }
  35708. }
  35709. declare module BABYLON {
  35710. /**
  35711. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35712. */
  35713. export class FadeInOutBehavior implements Behavior<Mesh> {
  35714. /**
  35715. * Time in milliseconds to delay before fading in (Default: 0)
  35716. */
  35717. delay: number;
  35718. /**
  35719. * Time in milliseconds for the mesh to fade in (Default: 300)
  35720. */
  35721. fadeInTime: number;
  35722. private _millisecondsPerFrame;
  35723. private _hovered;
  35724. private _hoverValue;
  35725. private _ownerNode;
  35726. /**
  35727. * Instatiates the FadeInOutBehavior
  35728. */
  35729. constructor();
  35730. /**
  35731. * The name of the behavior
  35732. */
  35733. readonly name: string;
  35734. /**
  35735. * Initializes the behavior
  35736. */
  35737. init(): void;
  35738. /**
  35739. * Attaches the fade behavior on the passed in mesh
  35740. * @param ownerNode The mesh that will be faded in/out once attached
  35741. */
  35742. attach(ownerNode: Mesh): void;
  35743. /**
  35744. * Detaches the behavior from the mesh
  35745. */
  35746. detach(): void;
  35747. /**
  35748. * Triggers the mesh to begin fading in or out
  35749. * @param value if the object should fade in or out (true to fade in)
  35750. */
  35751. fadeIn(value: boolean): void;
  35752. private _update;
  35753. private _setAllVisibility;
  35754. }
  35755. }
  35756. declare module BABYLON {
  35757. /**
  35758. * Class containing a set of static utilities functions for managing Pivots
  35759. * @hidden
  35760. */
  35761. export class PivotTools {
  35762. private static _PivotCached;
  35763. private static _OldPivotPoint;
  35764. private static _PivotTranslation;
  35765. private static _PivotTmpVector;
  35766. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35767. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35768. }
  35769. }
  35770. declare module BABYLON {
  35771. /**
  35772. * Class containing static functions to help procedurally build meshes
  35773. */
  35774. export class PlaneBuilder {
  35775. /**
  35776. * Creates a plane mesh
  35777. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35778. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35779. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35781. * * 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
  35782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35783. * @param name defines the name of the mesh
  35784. * @param options defines the options used to create the mesh
  35785. * @param scene defines the hosting scene
  35786. * @returns the plane mesh
  35787. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35788. */
  35789. static CreatePlane(name: string, options: {
  35790. size?: number;
  35791. width?: number;
  35792. height?: number;
  35793. sideOrientation?: number;
  35794. frontUVs?: Vector4;
  35795. backUVs?: Vector4;
  35796. updatable?: boolean;
  35797. sourcePlane?: Plane;
  35798. }, scene?: Nullable<Scene>): Mesh;
  35799. }
  35800. }
  35801. declare module BABYLON {
  35802. /**
  35803. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35804. */
  35805. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35806. private static _AnyMouseID;
  35807. /**
  35808. * Abstract mesh the behavior is set on
  35809. */
  35810. attachedNode: AbstractMesh;
  35811. private _dragPlane;
  35812. private _scene;
  35813. private _pointerObserver;
  35814. private _beforeRenderObserver;
  35815. private static _planeScene;
  35816. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35817. /**
  35818. * 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)
  35819. */
  35820. maxDragAngle: number;
  35821. /**
  35822. * @hidden
  35823. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35824. /**
  35825. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35826. */
  35827. currentDraggingPointerID: number;
  35828. /**
  35829. * The last position where the pointer hit the drag plane in world space
  35830. */
  35831. lastDragPosition: Vector3;
  35832. /**
  35833. * If the behavior is currently in a dragging state
  35834. */
  35835. dragging: boolean;
  35836. /**
  35837. * 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)
  35838. */
  35839. dragDeltaRatio: number;
  35840. /**
  35841. * If the drag plane orientation should be updated during the dragging (Default: true)
  35842. */
  35843. updateDragPlane: boolean;
  35844. private _debugMode;
  35845. private _moving;
  35846. /**
  35847. * Fires each time the attached mesh is dragged with the pointer
  35848. * * delta between last drag position and current drag position in world space
  35849. * * dragDistance along the drag axis
  35850. * * dragPlaneNormal normal of the current drag plane used during the drag
  35851. * * dragPlanePoint in world space where the drag intersects the drag plane
  35852. */
  35853. onDragObservable: Observable<{
  35854. delta: Vector3;
  35855. dragPlanePoint: Vector3;
  35856. dragPlaneNormal: Vector3;
  35857. dragDistance: number;
  35858. pointerId: number;
  35859. }>;
  35860. /**
  35861. * Fires each time a drag begins (eg. mouse down on mesh)
  35862. */
  35863. onDragStartObservable: Observable<{
  35864. dragPlanePoint: Vector3;
  35865. pointerId: number;
  35866. }>;
  35867. /**
  35868. * Fires each time a drag ends (eg. mouse release after drag)
  35869. */
  35870. onDragEndObservable: Observable<{
  35871. dragPlanePoint: Vector3;
  35872. pointerId: number;
  35873. }>;
  35874. /**
  35875. * If the attached mesh should be moved when dragged
  35876. */
  35877. moveAttached: boolean;
  35878. /**
  35879. * If the drag behavior will react to drag events (Default: true)
  35880. */
  35881. enabled: boolean;
  35882. /**
  35883. * If pointer events should start and release the drag (Default: true)
  35884. */
  35885. startAndReleaseDragOnPointerEvents: boolean;
  35886. /**
  35887. * If camera controls should be detached during the drag
  35888. */
  35889. detachCameraControls: boolean;
  35890. /**
  35891. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35892. */
  35893. useObjectOrienationForDragging: boolean;
  35894. private _options;
  35895. /**
  35896. * Creates a pointer drag behavior that can be attached to a mesh
  35897. * @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)
  35898. */
  35899. constructor(options?: {
  35900. dragAxis?: Vector3;
  35901. dragPlaneNormal?: Vector3;
  35902. });
  35903. /**
  35904. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35905. */
  35906. validateDrag: (targetPosition: Vector3) => boolean;
  35907. /**
  35908. * The name of the behavior
  35909. */
  35910. readonly name: string;
  35911. /**
  35912. * Initializes the behavior
  35913. */
  35914. init(): void;
  35915. private _tmpVector;
  35916. private _alternatePickedPoint;
  35917. private _worldDragAxis;
  35918. private _targetPosition;
  35919. private _attachedElement;
  35920. /**
  35921. * Attaches the drag behavior the passed in mesh
  35922. * @param ownerNode The mesh that will be dragged around once attached
  35923. */
  35924. attach(ownerNode: AbstractMesh): void;
  35925. /**
  35926. * Force relase the drag action by code.
  35927. */
  35928. releaseDrag(): void;
  35929. private _startDragRay;
  35930. private _lastPointerRay;
  35931. /**
  35932. * Simulates the start of a pointer drag event on the behavior
  35933. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35934. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35935. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35936. */
  35937. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35938. private _startDrag;
  35939. private _dragDelta;
  35940. private _moveDrag;
  35941. private _pickWithRayOnDragPlane;
  35942. private _pointA;
  35943. private _pointB;
  35944. private _pointC;
  35945. private _lineA;
  35946. private _lineB;
  35947. private _localAxis;
  35948. private _lookAt;
  35949. private _updateDragPlanePosition;
  35950. /**
  35951. * Detaches the behavior from the mesh
  35952. */
  35953. detach(): void;
  35954. }
  35955. }
  35956. declare module BABYLON {
  35957. /**
  35958. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35959. */
  35960. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35961. private _dragBehaviorA;
  35962. private _dragBehaviorB;
  35963. private _startDistance;
  35964. private _initialScale;
  35965. private _targetScale;
  35966. private _ownerNode;
  35967. private _sceneRenderObserver;
  35968. /**
  35969. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35970. */
  35971. constructor();
  35972. /**
  35973. * The name of the behavior
  35974. */
  35975. readonly name: string;
  35976. /**
  35977. * Initializes the behavior
  35978. */
  35979. init(): void;
  35980. private _getCurrentDistance;
  35981. /**
  35982. * Attaches the scale behavior the passed in mesh
  35983. * @param ownerNode The mesh that will be scaled around once attached
  35984. */
  35985. attach(ownerNode: Mesh): void;
  35986. /**
  35987. * Detaches the behavior from the mesh
  35988. */
  35989. detach(): void;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. /**
  35994. * 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
  35995. */
  35996. export class SixDofDragBehavior implements Behavior<Mesh> {
  35997. private static _virtualScene;
  35998. private _ownerNode;
  35999. private _sceneRenderObserver;
  36000. private _scene;
  36001. private _targetPosition;
  36002. private _virtualOriginMesh;
  36003. private _virtualDragMesh;
  36004. private _pointerObserver;
  36005. private _moving;
  36006. private _startingOrientation;
  36007. /**
  36008. * 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)
  36009. */
  36010. private zDragFactor;
  36011. /**
  36012. * If the object should rotate to face the drag origin
  36013. */
  36014. rotateDraggedObject: boolean;
  36015. /**
  36016. * If the behavior is currently in a dragging state
  36017. */
  36018. dragging: boolean;
  36019. /**
  36020. * 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)
  36021. */
  36022. dragDeltaRatio: number;
  36023. /**
  36024. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36025. */
  36026. currentDraggingPointerID: number;
  36027. /**
  36028. * If camera controls should be detached during the drag
  36029. */
  36030. detachCameraControls: boolean;
  36031. /**
  36032. * Fires each time a drag starts
  36033. */
  36034. onDragStartObservable: Observable<{}>;
  36035. /**
  36036. * Fires each time a drag ends (eg. mouse release after drag)
  36037. */
  36038. onDragEndObservable: Observable<{}>;
  36039. /**
  36040. * 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
  36041. */
  36042. constructor();
  36043. /**
  36044. * The name of the behavior
  36045. */
  36046. readonly name: string;
  36047. /**
  36048. * Initializes the behavior
  36049. */
  36050. init(): void;
  36051. /**
  36052. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36053. */
  36054. private readonly _pointerCamera;
  36055. /**
  36056. * Attaches the scale behavior the passed in mesh
  36057. * @param ownerNode The mesh that will be scaled around once attached
  36058. */
  36059. attach(ownerNode: Mesh): void;
  36060. /**
  36061. * Detaches the behavior from the mesh
  36062. */
  36063. detach(): void;
  36064. }
  36065. }
  36066. declare module BABYLON {
  36067. /**
  36068. * Class used to apply inverse kinematics to bones
  36069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36070. */
  36071. export class BoneIKController {
  36072. private static _tmpVecs;
  36073. private static _tmpQuat;
  36074. private static _tmpMats;
  36075. /**
  36076. * Gets or sets the target mesh
  36077. */
  36078. targetMesh: AbstractMesh;
  36079. /** Gets or sets the mesh used as pole */
  36080. poleTargetMesh: AbstractMesh;
  36081. /**
  36082. * Gets or sets the bone used as pole
  36083. */
  36084. poleTargetBone: Nullable<Bone>;
  36085. /**
  36086. * Gets or sets the target position
  36087. */
  36088. targetPosition: Vector3;
  36089. /**
  36090. * Gets or sets the pole target position
  36091. */
  36092. poleTargetPosition: Vector3;
  36093. /**
  36094. * Gets or sets the pole target local offset
  36095. */
  36096. poleTargetLocalOffset: Vector3;
  36097. /**
  36098. * Gets or sets the pole angle
  36099. */
  36100. poleAngle: number;
  36101. /**
  36102. * Gets or sets the mesh associated with the controller
  36103. */
  36104. mesh: AbstractMesh;
  36105. /**
  36106. * 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)
  36107. */
  36108. slerpAmount: number;
  36109. private _bone1Quat;
  36110. private _bone1Mat;
  36111. private _bone2Ang;
  36112. private _bone1;
  36113. private _bone2;
  36114. private _bone1Length;
  36115. private _bone2Length;
  36116. private _maxAngle;
  36117. private _maxReach;
  36118. private _rightHandedSystem;
  36119. private _bendAxis;
  36120. private _slerping;
  36121. private _adjustRoll;
  36122. /**
  36123. * Gets or sets maximum allowed angle
  36124. */
  36125. maxAngle: number;
  36126. /**
  36127. * Creates a new BoneIKController
  36128. * @param mesh defines the mesh to control
  36129. * @param bone defines the bone to control
  36130. * @param options defines options to set up the controller
  36131. */
  36132. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36133. targetMesh?: AbstractMesh;
  36134. poleTargetMesh?: AbstractMesh;
  36135. poleTargetBone?: Bone;
  36136. poleTargetLocalOffset?: Vector3;
  36137. poleAngle?: number;
  36138. bendAxis?: Vector3;
  36139. maxAngle?: number;
  36140. slerpAmount?: number;
  36141. });
  36142. private _setMaxAngle;
  36143. /**
  36144. * Force the controller to update the bones
  36145. */
  36146. update(): void;
  36147. }
  36148. }
  36149. declare module BABYLON {
  36150. /**
  36151. * Class used to make a bone look toward a point in space
  36152. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36153. */
  36154. export class BoneLookController {
  36155. private static _tmpVecs;
  36156. private static _tmpQuat;
  36157. private static _tmpMats;
  36158. /**
  36159. * The target Vector3 that the bone will look at
  36160. */
  36161. target: Vector3;
  36162. /**
  36163. * The mesh that the bone is attached to
  36164. */
  36165. mesh: AbstractMesh;
  36166. /**
  36167. * The bone that will be looking to the target
  36168. */
  36169. bone: Bone;
  36170. /**
  36171. * The up axis of the coordinate system that is used when the bone is rotated
  36172. */
  36173. upAxis: Vector3;
  36174. /**
  36175. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36176. */
  36177. upAxisSpace: Space;
  36178. /**
  36179. * Used to make an adjustment to the yaw of the bone
  36180. */
  36181. adjustYaw: number;
  36182. /**
  36183. * Used to make an adjustment to the pitch of the bone
  36184. */
  36185. adjustPitch: number;
  36186. /**
  36187. * Used to make an adjustment to the roll of the bone
  36188. */
  36189. adjustRoll: number;
  36190. /**
  36191. * 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)
  36192. */
  36193. slerpAmount: number;
  36194. private _minYaw;
  36195. private _maxYaw;
  36196. private _minPitch;
  36197. private _maxPitch;
  36198. private _minYawSin;
  36199. private _minYawCos;
  36200. private _maxYawSin;
  36201. private _maxYawCos;
  36202. private _midYawConstraint;
  36203. private _minPitchTan;
  36204. private _maxPitchTan;
  36205. private _boneQuat;
  36206. private _slerping;
  36207. private _transformYawPitch;
  36208. private _transformYawPitchInv;
  36209. private _firstFrameSkipped;
  36210. private _yawRange;
  36211. private _fowardAxis;
  36212. /**
  36213. * Gets or sets the minimum yaw angle that the bone can look to
  36214. */
  36215. minYaw: number;
  36216. /**
  36217. * Gets or sets the maximum yaw angle that the bone can look to
  36218. */
  36219. maxYaw: number;
  36220. /**
  36221. * Gets or sets the minimum pitch angle that the bone can look to
  36222. */
  36223. minPitch: number;
  36224. /**
  36225. * Gets or sets the maximum pitch angle that the bone can look to
  36226. */
  36227. maxPitch: number;
  36228. /**
  36229. * Create a BoneLookController
  36230. * @param mesh the mesh that the bone belongs to
  36231. * @param bone the bone that will be looking to the target
  36232. * @param target the target Vector3 to look at
  36233. * @param options optional settings:
  36234. * * maxYaw: the maximum angle the bone will yaw to
  36235. * * minYaw: the minimum angle the bone will yaw to
  36236. * * maxPitch: the maximum angle the bone will pitch to
  36237. * * minPitch: the minimum angle the bone will yaw to
  36238. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36239. * * upAxis: the up axis of the coordinate system
  36240. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36241. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36242. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36243. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36244. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36245. * * adjustRoll: used to make an adjustment to the roll of the bone
  36246. **/
  36247. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36248. maxYaw?: number;
  36249. minYaw?: number;
  36250. maxPitch?: number;
  36251. minPitch?: number;
  36252. slerpAmount?: number;
  36253. upAxis?: Vector3;
  36254. upAxisSpace?: Space;
  36255. yawAxis?: Vector3;
  36256. pitchAxis?: Vector3;
  36257. adjustYaw?: number;
  36258. adjustPitch?: number;
  36259. adjustRoll?: number;
  36260. });
  36261. /**
  36262. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36263. */
  36264. update(): void;
  36265. private _getAngleDiff;
  36266. private _getAngleBetween;
  36267. private _isAngleBetween;
  36268. }
  36269. }
  36270. declare module BABYLON {
  36271. /**
  36272. * Manage the gamepad inputs to control an arc rotate camera.
  36273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36274. */
  36275. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36276. /**
  36277. * Defines the camera the input is attached to.
  36278. */
  36279. camera: ArcRotateCamera;
  36280. /**
  36281. * Defines the gamepad the input is gathering event from.
  36282. */
  36283. gamepad: Nullable<Gamepad>;
  36284. /**
  36285. * Defines the gamepad rotation sensiblity.
  36286. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36287. */
  36288. gamepadRotationSensibility: number;
  36289. /**
  36290. * Defines the gamepad move sensiblity.
  36291. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36292. */
  36293. gamepadMoveSensibility: number;
  36294. private _onGamepadConnectedObserver;
  36295. private _onGamepadDisconnectedObserver;
  36296. /**
  36297. * Attach the input controls to a specific dom element to get the input from.
  36298. * @param element Defines the element the controls should be listened from
  36299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36300. */
  36301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36302. /**
  36303. * Detach the current controls from the specified dom element.
  36304. * @param element Defines the element to stop listening the inputs from
  36305. */
  36306. detachControl(element: Nullable<HTMLElement>): void;
  36307. /**
  36308. * Update the current camera state depending on the inputs that have been used this frame.
  36309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36310. */
  36311. checkInputs(): void;
  36312. /**
  36313. * Gets the class name of the current intput.
  36314. * @returns the class name
  36315. */
  36316. getClassName(): string;
  36317. /**
  36318. * Get the friendly name associated with the input class.
  36319. * @returns the input friendly name
  36320. */
  36321. getSimpleName(): string;
  36322. }
  36323. }
  36324. declare module BABYLON {
  36325. interface ArcRotateCameraInputsManager {
  36326. /**
  36327. * Add orientation input support to the input manager.
  36328. * @returns the current input manager
  36329. */
  36330. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36331. }
  36332. /**
  36333. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36335. */
  36336. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36337. /**
  36338. * Defines the camera the input is attached to.
  36339. */
  36340. camera: ArcRotateCamera;
  36341. /**
  36342. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36343. */
  36344. alphaCorrection: number;
  36345. /**
  36346. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36347. */
  36348. gammaCorrection: number;
  36349. private _alpha;
  36350. private _gamma;
  36351. private _dirty;
  36352. private _deviceOrientationHandler;
  36353. /**
  36354. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36355. */
  36356. constructor();
  36357. /**
  36358. * Attach the input controls to a specific dom element to get the input from.
  36359. * @param element Defines the element the controls should be listened from
  36360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36361. */
  36362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36363. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36364. /**
  36365. * Update the current camera state depending on the inputs that have been used this frame.
  36366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36367. */
  36368. checkInputs(): void;
  36369. /**
  36370. * Detach the current controls from the specified dom element.
  36371. * @param element Defines the element to stop listening the inputs from
  36372. */
  36373. detachControl(element: Nullable<HTMLElement>): void;
  36374. /**
  36375. * Gets the class name of the current intput.
  36376. * @returns the class name
  36377. */
  36378. getClassName(): string;
  36379. /**
  36380. * Get the friendly name associated with the input class.
  36381. * @returns the input friendly name
  36382. */
  36383. getSimpleName(): string;
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. /**
  36388. * Listen to mouse events to control the camera.
  36389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36390. */
  36391. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36392. /**
  36393. * Defines the camera the input is attached to.
  36394. */
  36395. camera: FlyCamera;
  36396. /**
  36397. * Defines if touch is enabled. (Default is true.)
  36398. */
  36399. touchEnabled: boolean;
  36400. /**
  36401. * Defines the buttons associated with the input to handle camera rotation.
  36402. */
  36403. buttons: number[];
  36404. /**
  36405. * Assign buttons for Yaw control.
  36406. */
  36407. buttonsYaw: number[];
  36408. /**
  36409. * Assign buttons for Pitch control.
  36410. */
  36411. buttonsPitch: number[];
  36412. /**
  36413. * Assign buttons for Roll control.
  36414. */
  36415. buttonsRoll: number[];
  36416. /**
  36417. * Detect if any button is being pressed while mouse is moved.
  36418. * -1 = Mouse locked.
  36419. * 0 = Left button.
  36420. * 1 = Middle Button.
  36421. * 2 = Right Button.
  36422. */
  36423. activeButton: number;
  36424. /**
  36425. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36426. * Higher values reduce its sensitivity.
  36427. */
  36428. angularSensibility: number;
  36429. private _mousemoveCallback;
  36430. private _observer;
  36431. private _rollObserver;
  36432. private previousPosition;
  36433. private noPreventDefault;
  36434. private element;
  36435. /**
  36436. * Listen to mouse events to control the camera.
  36437. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36439. */
  36440. constructor(touchEnabled?: boolean);
  36441. /**
  36442. * Attach the mouse control to the HTML DOM element.
  36443. * @param element Defines the element that listens to the input events.
  36444. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36445. */
  36446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36447. /**
  36448. * Detach the current controls from the specified dom element.
  36449. * @param element Defines the element to stop listening the inputs from
  36450. */
  36451. detachControl(element: Nullable<HTMLElement>): void;
  36452. /**
  36453. * Gets the class name of the current input.
  36454. * @returns the class name.
  36455. */
  36456. getClassName(): string;
  36457. /**
  36458. * Get the friendly name associated with the input class.
  36459. * @returns the input's friendly name.
  36460. */
  36461. getSimpleName(): string;
  36462. private _pointerInput;
  36463. private _onMouseMove;
  36464. /**
  36465. * Rotate camera by mouse offset.
  36466. */
  36467. private rotateCamera;
  36468. }
  36469. }
  36470. declare module BABYLON {
  36471. /**
  36472. * Default Inputs manager for the FlyCamera.
  36473. * It groups all the default supported inputs for ease of use.
  36474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36475. */
  36476. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36477. /**
  36478. * Instantiates a new FlyCameraInputsManager.
  36479. * @param camera Defines the camera the inputs belong to.
  36480. */
  36481. constructor(camera: FlyCamera);
  36482. /**
  36483. * Add keyboard input support to the input manager.
  36484. * @returns the new FlyCameraKeyboardMoveInput().
  36485. */
  36486. addKeyboard(): FlyCameraInputsManager;
  36487. /**
  36488. * Add mouse input support to the input manager.
  36489. * @param touchEnabled Enable touch screen support.
  36490. * @returns the new FlyCameraMouseInput().
  36491. */
  36492. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36493. }
  36494. }
  36495. declare module BABYLON {
  36496. /**
  36497. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36498. * such as in a 3D Space Shooter or a Flight Simulator.
  36499. */
  36500. export class FlyCamera extends TargetCamera {
  36501. /**
  36502. * Define the collision ellipsoid of the camera.
  36503. * This is helpful for simulating a camera body, like a player's body.
  36504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36505. */
  36506. ellipsoid: Vector3;
  36507. /**
  36508. * Define an offset for the position of the ellipsoid around the camera.
  36509. * This can be helpful if the camera is attached away from the player's body center,
  36510. * such as at its head.
  36511. */
  36512. ellipsoidOffset: Vector3;
  36513. /**
  36514. * Enable or disable collisions of the camera with the rest of the scene objects.
  36515. */
  36516. checkCollisions: boolean;
  36517. /**
  36518. * Enable or disable gravity on the camera.
  36519. */
  36520. applyGravity: boolean;
  36521. /**
  36522. * Define the current direction the camera is moving to.
  36523. */
  36524. cameraDirection: Vector3;
  36525. /**
  36526. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36527. * This overrides and empties cameraRotation.
  36528. */
  36529. rotationQuaternion: Quaternion;
  36530. /**
  36531. * Track Roll to maintain the wanted Rolling when looking around.
  36532. */ private _trackRoll: number;
  36533. /**
  36534. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36535. */
  36536. rollCorrect: number;
  36537. /**
  36538. * Mimic a banked turn, Rolling the camera when Yawing.
  36539. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36540. */
  36541. bankedTurn: boolean;
  36542. /**
  36543. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36544. */
  36545. bankedTurnLimit: number;
  36546. /**
  36547. * Value of 0 disables the banked Roll.
  36548. * Value of 1 is equal to the Yaw angle in radians.
  36549. */
  36550. bankedTurnMultiplier: number;
  36551. /**
  36552. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36553. */
  36554. inputs: FlyCameraInputsManager;
  36555. /**
  36556. * Gets the input sensibility for mouse input.
  36557. * Higher values reduce sensitivity.
  36558. */
  36559. /**
  36560. * Sets the input sensibility for a mouse input.
  36561. * Higher values reduce sensitivity.
  36562. */
  36563. angularSensibility: number;
  36564. /**
  36565. * Get the keys for camera movement forward.
  36566. */
  36567. /**
  36568. * Set the keys for camera movement forward.
  36569. */
  36570. keysForward: number[];
  36571. /**
  36572. * Get the keys for camera movement backward.
  36573. */
  36574. keysBackward: number[];
  36575. /**
  36576. * Get the keys for camera movement up.
  36577. */
  36578. /**
  36579. * Set the keys for camera movement up.
  36580. */
  36581. keysUp: number[];
  36582. /**
  36583. * Get the keys for camera movement down.
  36584. */
  36585. /**
  36586. * Set the keys for camera movement down.
  36587. */
  36588. keysDown: number[];
  36589. /**
  36590. * Get the keys for camera movement left.
  36591. */
  36592. /**
  36593. * Set the keys for camera movement left.
  36594. */
  36595. keysLeft: number[];
  36596. /**
  36597. * Set the keys for camera movement right.
  36598. */
  36599. /**
  36600. * Set the keys for camera movement right.
  36601. */
  36602. keysRight: number[];
  36603. /**
  36604. * Event raised when the camera collides with a mesh in the scene.
  36605. */
  36606. onCollide: (collidedMesh: AbstractMesh) => void;
  36607. private _collider;
  36608. private _needMoveForGravity;
  36609. private _oldPosition;
  36610. private _diffPosition;
  36611. private _newPosition;
  36612. /** @hidden */ private _localDirection: Vector3;
  36613. /** @hidden */ private _transformedDirection: Vector3;
  36614. /**
  36615. * Instantiates a FlyCamera.
  36616. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36617. * such as in a 3D Space Shooter or a Flight Simulator.
  36618. * @param name Define the name of the camera in the scene.
  36619. * @param position Define the starting position of the camera in the scene.
  36620. * @param scene Define the scene the camera belongs to.
  36621. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36622. */
  36623. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36624. /**
  36625. * Attach a control to the HTML DOM element.
  36626. * @param element Defines the element that listens to the input events.
  36627. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36628. */
  36629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36630. /**
  36631. * Detach a control from the HTML DOM element.
  36632. * The camera will stop reacting to that input.
  36633. * @param element Defines the element that listens to the input events.
  36634. */
  36635. detachControl(element: HTMLElement): void;
  36636. private _collisionMask;
  36637. /**
  36638. * Get the mask that the camera ignores in collision events.
  36639. */
  36640. /**
  36641. * Set the mask that the camera ignores in collision events.
  36642. */
  36643. collisionMask: number;
  36644. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36645. /** @hidden */
  36646. private _onCollisionPositionChange;
  36647. /** @hidden */ private _checkInputs(): void;
  36648. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36649. /** @hidden */ private _updatePosition(): void;
  36650. /**
  36651. * Restore the Roll to its target value at the rate specified.
  36652. * @param rate - Higher means slower restoring.
  36653. * @hidden
  36654. */
  36655. restoreRoll(rate: number): void;
  36656. /**
  36657. * Destroy the camera and release the current resources held by it.
  36658. */
  36659. dispose(): void;
  36660. /**
  36661. * Get the current object class name.
  36662. * @returns the class name.
  36663. */
  36664. getClassName(): string;
  36665. }
  36666. }
  36667. declare module BABYLON {
  36668. /**
  36669. * Listen to keyboard events to control the camera.
  36670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36671. */
  36672. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36673. /**
  36674. * Defines the camera the input is attached to.
  36675. */
  36676. camera: FlyCamera;
  36677. /**
  36678. * The list of keyboard keys used to control the forward move of the camera.
  36679. */
  36680. keysForward: number[];
  36681. /**
  36682. * The list of keyboard keys used to control the backward move of the camera.
  36683. */
  36684. keysBackward: number[];
  36685. /**
  36686. * The list of keyboard keys used to control the forward move of the camera.
  36687. */
  36688. keysUp: number[];
  36689. /**
  36690. * The list of keyboard keys used to control the backward move of the camera.
  36691. */
  36692. keysDown: number[];
  36693. /**
  36694. * The list of keyboard keys used to control the right strafe move of the camera.
  36695. */
  36696. keysRight: number[];
  36697. /**
  36698. * The list of keyboard keys used to control the left strafe move of the camera.
  36699. */
  36700. keysLeft: number[];
  36701. private _keys;
  36702. private _onCanvasBlurObserver;
  36703. private _onKeyboardObserver;
  36704. private _engine;
  36705. private _scene;
  36706. /**
  36707. * Attach the input controls to a specific dom element to get the input from.
  36708. * @param element Defines the element the controls should be listened from
  36709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36710. */
  36711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36712. /**
  36713. * Detach the current controls from the specified dom element.
  36714. * @param element Defines the element to stop listening the inputs from
  36715. */
  36716. detachControl(element: Nullable<HTMLElement>): void;
  36717. /**
  36718. * Gets the class name of the current intput.
  36719. * @returns the class name
  36720. */
  36721. getClassName(): string;
  36722. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36723. /**
  36724. * Get the friendly name associated with the input class.
  36725. * @returns the input friendly name
  36726. */
  36727. getSimpleName(): string;
  36728. /**
  36729. * Update the current camera state depending on the inputs that have been used this frame.
  36730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36731. */
  36732. checkInputs(): void;
  36733. }
  36734. }
  36735. declare module BABYLON {
  36736. /**
  36737. * Manage the mouse wheel inputs to control a follow camera.
  36738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36739. */
  36740. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36741. /**
  36742. * Defines the camera the input is attached to.
  36743. */
  36744. camera: FollowCamera;
  36745. /**
  36746. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36747. */
  36748. axisControlRadius: boolean;
  36749. /**
  36750. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36751. */
  36752. axisControlHeight: boolean;
  36753. /**
  36754. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36755. */
  36756. axisControlRotation: boolean;
  36757. /**
  36758. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36759. * relation to mouseWheel events.
  36760. */
  36761. wheelPrecision: number;
  36762. /**
  36763. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36764. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36765. */
  36766. wheelDeltaPercentage: number;
  36767. private _wheel;
  36768. private _observer;
  36769. /**
  36770. * Attach the input controls to a specific dom element to get the input from.
  36771. * @param element Defines the element the controls should be listened from
  36772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36773. */
  36774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36775. /**
  36776. * Detach the current controls from the specified dom element.
  36777. * @param element Defines the element to stop listening the inputs from
  36778. */
  36779. detachControl(element: Nullable<HTMLElement>): void;
  36780. /**
  36781. * Gets the class name of the current intput.
  36782. * @returns the class name
  36783. */
  36784. getClassName(): string;
  36785. /**
  36786. * Get the friendly name associated with the input class.
  36787. * @returns the input friendly name
  36788. */
  36789. getSimpleName(): string;
  36790. }
  36791. }
  36792. declare module BABYLON {
  36793. /**
  36794. * Manage the pointers inputs to control an follow camera.
  36795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36796. */
  36797. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36798. /**
  36799. * Defines the camera the input is attached to.
  36800. */
  36801. camera: FollowCamera;
  36802. /**
  36803. * Gets the class name of the current input.
  36804. * @returns the class name
  36805. */
  36806. getClassName(): string;
  36807. /**
  36808. * Defines the pointer angular sensibility along the X axis or how fast is
  36809. * the camera rotating.
  36810. * A negative number will reverse the axis direction.
  36811. */
  36812. angularSensibilityX: number;
  36813. /**
  36814. * Defines the pointer angular sensibility along the Y axis or how fast is
  36815. * the camera rotating.
  36816. * A negative number will reverse the axis direction.
  36817. */
  36818. angularSensibilityY: number;
  36819. /**
  36820. * Defines the pointer pinch precision or how fast is the camera zooming.
  36821. * A negative number will reverse the axis direction.
  36822. */
  36823. pinchPrecision: number;
  36824. /**
  36825. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36826. * from 0.
  36827. * It defines the percentage of current camera.radius to use as delta when
  36828. * pinch zoom is used.
  36829. */
  36830. pinchDeltaPercentage: number;
  36831. /**
  36832. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36833. */
  36834. axisXControlRadius: boolean;
  36835. /**
  36836. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36837. */
  36838. axisXControlHeight: boolean;
  36839. /**
  36840. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36841. */
  36842. axisXControlRotation: boolean;
  36843. /**
  36844. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36845. */
  36846. axisYControlRadius: boolean;
  36847. /**
  36848. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36849. */
  36850. axisYControlHeight: boolean;
  36851. /**
  36852. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36853. */
  36854. axisYControlRotation: boolean;
  36855. /**
  36856. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36857. */
  36858. axisPinchControlRadius: boolean;
  36859. /**
  36860. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36861. */
  36862. axisPinchControlHeight: boolean;
  36863. /**
  36864. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36865. */
  36866. axisPinchControlRotation: boolean;
  36867. /**
  36868. * Log error messages if basic misconfiguration has occurred.
  36869. */
  36870. warningEnable: boolean;
  36871. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36872. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36873. private _warningCounter;
  36874. private _warning;
  36875. }
  36876. }
  36877. declare module BABYLON {
  36878. /**
  36879. * Default Inputs manager for the FollowCamera.
  36880. * It groups all the default supported inputs for ease of use.
  36881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36882. */
  36883. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36884. /**
  36885. * Instantiates a new FollowCameraInputsManager.
  36886. * @param camera Defines the camera the inputs belong to
  36887. */
  36888. constructor(camera: FollowCamera);
  36889. /**
  36890. * Add keyboard input support to the input manager.
  36891. * @returns the current input manager
  36892. */
  36893. addKeyboard(): FollowCameraInputsManager;
  36894. /**
  36895. * Add mouse wheel input support to the input manager.
  36896. * @returns the current input manager
  36897. */
  36898. addMouseWheel(): FollowCameraInputsManager;
  36899. /**
  36900. * Add pointers input support to the input manager.
  36901. * @returns the current input manager
  36902. */
  36903. addPointers(): FollowCameraInputsManager;
  36904. /**
  36905. * Add orientation input support to the input manager.
  36906. * @returns the current input manager
  36907. */
  36908. addVRDeviceOrientation(): FollowCameraInputsManager;
  36909. }
  36910. }
  36911. declare module BABYLON {
  36912. /**
  36913. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36914. * an arc rotate version arcFollowCamera are available.
  36915. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36916. */
  36917. export class FollowCamera extends TargetCamera {
  36918. /**
  36919. * Distance the follow camera should follow an object at
  36920. */
  36921. radius: number;
  36922. /**
  36923. * Minimum allowed distance of the camera to the axis of rotation
  36924. * (The camera can not get closer).
  36925. * This can help limiting how the Camera is able to move in the scene.
  36926. */
  36927. lowerRadiusLimit: Nullable<number>;
  36928. /**
  36929. * Maximum allowed distance of the camera to the axis of rotation
  36930. * (The camera can not get further).
  36931. * This can help limiting how the Camera is able to move in the scene.
  36932. */
  36933. upperRadiusLimit: Nullable<number>;
  36934. /**
  36935. * Define a rotation offset between the camera and the object it follows
  36936. */
  36937. rotationOffset: number;
  36938. /**
  36939. * Minimum allowed angle to camera position relative to target object.
  36940. * This can help limiting how the Camera is able to move in the scene.
  36941. */
  36942. lowerRotationOffsetLimit: Nullable<number>;
  36943. /**
  36944. * Maximum allowed angle to camera position relative to target object.
  36945. * This can help limiting how the Camera is able to move in the scene.
  36946. */
  36947. upperRotationOffsetLimit: Nullable<number>;
  36948. /**
  36949. * Define a height offset between the camera and the object it follows.
  36950. * It can help following an object from the top (like a car chaing a plane)
  36951. */
  36952. heightOffset: number;
  36953. /**
  36954. * Minimum allowed height of camera position relative to target object.
  36955. * This can help limiting how the Camera is able to move in the scene.
  36956. */
  36957. lowerHeightOffsetLimit: Nullable<number>;
  36958. /**
  36959. * Maximum allowed height of camera position relative to target object.
  36960. * This can help limiting how the Camera is able to move in the scene.
  36961. */
  36962. upperHeightOffsetLimit: Nullable<number>;
  36963. /**
  36964. * Define how fast the camera can accelerate to follow it s target.
  36965. */
  36966. cameraAcceleration: number;
  36967. /**
  36968. * Define the speed limit of the camera following an object.
  36969. */
  36970. maxCameraSpeed: number;
  36971. /**
  36972. * Define the target of the camera.
  36973. */
  36974. lockedTarget: Nullable<AbstractMesh>;
  36975. /**
  36976. * Defines the input associated with the camera.
  36977. */
  36978. inputs: FollowCameraInputsManager;
  36979. /**
  36980. * Instantiates the follow camera.
  36981. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36982. * @param name Define the name of the camera in the scene
  36983. * @param position Define the position of the camera
  36984. * @param scene Define the scene the camera belong to
  36985. * @param lockedTarget Define the target of the camera
  36986. */
  36987. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36988. private _follow;
  36989. /**
  36990. * Attached controls to the current camera.
  36991. * @param element Defines the element the controls should be listened from
  36992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36993. */
  36994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36995. /**
  36996. * Detach the current controls from the camera.
  36997. * The camera will stop reacting to inputs.
  36998. * @param element Defines the element to stop listening the inputs from
  36999. */
  37000. detachControl(element: HTMLElement): void;
  37001. /** @hidden */ private _checkInputs(): void;
  37002. private _checkLimits;
  37003. /**
  37004. * Gets the camera class name.
  37005. * @returns the class name
  37006. */
  37007. getClassName(): string;
  37008. }
  37009. /**
  37010. * Arc Rotate version of the follow camera.
  37011. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37012. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37013. */
  37014. export class ArcFollowCamera extends TargetCamera {
  37015. /** The longitudinal angle of the camera */
  37016. alpha: number;
  37017. /** The latitudinal angle of the camera */
  37018. beta: number;
  37019. /** The radius of the camera from its target */
  37020. radius: number;
  37021. /** Define the camera target (the messh it should follow) */
  37022. target: Nullable<AbstractMesh>;
  37023. private _cartesianCoordinates;
  37024. /**
  37025. * Instantiates a new ArcFollowCamera
  37026. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37027. * @param name Define the name of the camera
  37028. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37029. * @param beta Define the rotation angle of the camera around the elevation axis
  37030. * @param radius Define the radius of the camera from its target point
  37031. * @param target Define the target of the camera
  37032. * @param scene Define the scene the camera belongs to
  37033. */
  37034. constructor(name: string,
  37035. /** The longitudinal angle of the camera */
  37036. alpha: number,
  37037. /** The latitudinal angle of the camera */
  37038. beta: number,
  37039. /** The radius of the camera from its target */
  37040. radius: number,
  37041. /** Define the camera target (the messh it should follow) */
  37042. target: Nullable<AbstractMesh>, scene: Scene);
  37043. private _follow;
  37044. /** @hidden */ private _checkInputs(): void;
  37045. /**
  37046. * Returns the class name of the object.
  37047. * It is mostly used internally for serialization purposes.
  37048. */
  37049. getClassName(): string;
  37050. }
  37051. }
  37052. declare module BABYLON {
  37053. /**
  37054. * Manage the keyboard inputs to control the movement of a follow camera.
  37055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37056. */
  37057. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37058. /**
  37059. * Defines the camera the input is attached to.
  37060. */
  37061. camera: FollowCamera;
  37062. /**
  37063. * Defines the list of key codes associated with the up action (increase heightOffset)
  37064. */
  37065. keysHeightOffsetIncr: number[];
  37066. /**
  37067. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37068. */
  37069. keysHeightOffsetDecr: number[];
  37070. /**
  37071. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37072. */
  37073. keysHeightOffsetModifierAlt: boolean;
  37074. /**
  37075. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37076. */
  37077. keysHeightOffsetModifierCtrl: boolean;
  37078. /**
  37079. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37080. */
  37081. keysHeightOffsetModifierShift: boolean;
  37082. /**
  37083. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37084. */
  37085. keysRotationOffsetIncr: number[];
  37086. /**
  37087. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37088. */
  37089. keysRotationOffsetDecr: number[];
  37090. /**
  37091. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37092. */
  37093. keysRotationOffsetModifierAlt: boolean;
  37094. /**
  37095. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37096. */
  37097. keysRotationOffsetModifierCtrl: boolean;
  37098. /**
  37099. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37100. */
  37101. keysRotationOffsetModifierShift: boolean;
  37102. /**
  37103. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37104. */
  37105. keysRadiusIncr: number[];
  37106. /**
  37107. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37108. */
  37109. keysRadiusDecr: number[];
  37110. /**
  37111. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37112. */
  37113. keysRadiusModifierAlt: boolean;
  37114. /**
  37115. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37116. */
  37117. keysRadiusModifierCtrl: boolean;
  37118. /**
  37119. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37120. */
  37121. keysRadiusModifierShift: boolean;
  37122. /**
  37123. * Defines the rate of change of heightOffset.
  37124. */
  37125. heightSensibility: number;
  37126. /**
  37127. * Defines the rate of change of rotationOffset.
  37128. */
  37129. rotationSensibility: number;
  37130. /**
  37131. * Defines the rate of change of radius.
  37132. */
  37133. radiusSensibility: number;
  37134. private _keys;
  37135. private _ctrlPressed;
  37136. private _altPressed;
  37137. private _shiftPressed;
  37138. private _onCanvasBlurObserver;
  37139. private _onKeyboardObserver;
  37140. private _engine;
  37141. private _scene;
  37142. /**
  37143. * Attach the input controls to a specific dom element to get the input from.
  37144. * @param element Defines the element the controls should be listened from
  37145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37146. */
  37147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37148. /**
  37149. * Detach the current controls from the specified dom element.
  37150. * @param element Defines the element to stop listening the inputs from
  37151. */
  37152. detachControl(element: Nullable<HTMLElement>): void;
  37153. /**
  37154. * Update the current camera state depending on the inputs that have been used this frame.
  37155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37156. */
  37157. checkInputs(): void;
  37158. /**
  37159. * Gets the class name of the current input.
  37160. * @returns the class name
  37161. */
  37162. getClassName(): string;
  37163. /**
  37164. * Get the friendly name associated with the input class.
  37165. * @returns the input friendly name
  37166. */
  37167. getSimpleName(): string;
  37168. /**
  37169. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37170. * allow modification of the heightOffset value.
  37171. */
  37172. private _modifierHeightOffset;
  37173. /**
  37174. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37175. * allow modification of the rotationOffset value.
  37176. */
  37177. private _modifierRotationOffset;
  37178. /**
  37179. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37180. * allow modification of the radius value.
  37181. */
  37182. private _modifierRadius;
  37183. }
  37184. }
  37185. declare module BABYLON {
  37186. interface FreeCameraInputsManager {
  37187. /**
  37188. * @hidden
  37189. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37190. /**
  37191. * Add orientation input support to the input manager.
  37192. * @returns the current input manager
  37193. */
  37194. addDeviceOrientation(): FreeCameraInputsManager;
  37195. }
  37196. /**
  37197. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37198. * Screen rotation is taken into account.
  37199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37200. */
  37201. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37202. private _camera;
  37203. private _screenOrientationAngle;
  37204. private _constantTranform;
  37205. private _screenQuaternion;
  37206. private _alpha;
  37207. private _beta;
  37208. private _gamma;
  37209. /**
  37210. * Can be used to detect if a device orientation sensor is availible on a device
  37211. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37212. * @returns a promise that will resolve on orientation change
  37213. */
  37214. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37215. /**
  37216. * @hidden
  37217. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37218. /**
  37219. * Instantiates a new input
  37220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37221. */
  37222. constructor();
  37223. /**
  37224. * Define the camera controlled by the input.
  37225. */
  37226. camera: FreeCamera;
  37227. /**
  37228. * Attach the input controls to a specific dom element to get the input from.
  37229. * @param element Defines the element the controls should be listened from
  37230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37231. */
  37232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37233. private _orientationChanged;
  37234. private _deviceOrientation;
  37235. /**
  37236. * Detach the current controls from the specified dom element.
  37237. * @param element Defines the element to stop listening the inputs from
  37238. */
  37239. detachControl(element: Nullable<HTMLElement>): void;
  37240. /**
  37241. * Update the current camera state depending on the inputs that have been used this frame.
  37242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37243. */
  37244. checkInputs(): void;
  37245. /**
  37246. * Gets the class name of the current intput.
  37247. * @returns the class name
  37248. */
  37249. getClassName(): string;
  37250. /**
  37251. * Get the friendly name associated with the input class.
  37252. * @returns the input friendly name
  37253. */
  37254. getSimpleName(): string;
  37255. }
  37256. }
  37257. declare module BABYLON {
  37258. /**
  37259. * Manage the gamepad inputs to control a free camera.
  37260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37261. */
  37262. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37263. /**
  37264. * Define the camera the input is attached to.
  37265. */
  37266. camera: FreeCamera;
  37267. /**
  37268. * Define the Gamepad controlling the input
  37269. */
  37270. gamepad: Nullable<Gamepad>;
  37271. /**
  37272. * Defines the gamepad rotation sensiblity.
  37273. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37274. */
  37275. gamepadAngularSensibility: number;
  37276. /**
  37277. * Defines the gamepad move sensiblity.
  37278. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37279. */
  37280. gamepadMoveSensibility: number;
  37281. private _onGamepadConnectedObserver;
  37282. private _onGamepadDisconnectedObserver;
  37283. private _cameraTransform;
  37284. private _deltaTransform;
  37285. private _vector3;
  37286. private _vector2;
  37287. /**
  37288. * Attach the input controls to a specific dom element to get the input from.
  37289. * @param element Defines the element the controls should be listened from
  37290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37291. */
  37292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37293. /**
  37294. * Detach the current controls from the specified dom element.
  37295. * @param element Defines the element to stop listening the inputs from
  37296. */
  37297. detachControl(element: Nullable<HTMLElement>): void;
  37298. /**
  37299. * Update the current camera state depending on the inputs that have been used this frame.
  37300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37301. */
  37302. checkInputs(): void;
  37303. /**
  37304. * Gets the class name of the current intput.
  37305. * @returns the class name
  37306. */
  37307. getClassName(): string;
  37308. /**
  37309. * Get the friendly name associated with the input class.
  37310. * @returns the input friendly name
  37311. */
  37312. getSimpleName(): string;
  37313. }
  37314. }
  37315. declare module BABYLON {
  37316. /**
  37317. * Defines the potential axis of a Joystick
  37318. */
  37319. export enum JoystickAxis {
  37320. /** X axis */
  37321. X = 0,
  37322. /** Y axis */
  37323. Y = 1,
  37324. /** Z axis */
  37325. Z = 2
  37326. }
  37327. /**
  37328. * Class used to define virtual joystick (used in touch mode)
  37329. */
  37330. export class VirtualJoystick {
  37331. /**
  37332. * Gets or sets a boolean indicating that left and right values must be inverted
  37333. */
  37334. reverseLeftRight: boolean;
  37335. /**
  37336. * Gets or sets a boolean indicating that up and down values must be inverted
  37337. */
  37338. reverseUpDown: boolean;
  37339. /**
  37340. * Gets the offset value for the position (ie. the change of the position value)
  37341. */
  37342. deltaPosition: Vector3;
  37343. /**
  37344. * Gets a boolean indicating if the virtual joystick was pressed
  37345. */
  37346. pressed: boolean;
  37347. /**
  37348. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37349. */
  37350. static Canvas: Nullable<HTMLCanvasElement>;
  37351. private static _globalJoystickIndex;
  37352. private static vjCanvasContext;
  37353. private static vjCanvasWidth;
  37354. private static vjCanvasHeight;
  37355. private static halfWidth;
  37356. private _action;
  37357. private _axisTargetedByLeftAndRight;
  37358. private _axisTargetedByUpAndDown;
  37359. private _joystickSensibility;
  37360. private _inversedSensibility;
  37361. private _joystickPointerID;
  37362. private _joystickColor;
  37363. private _joystickPointerPos;
  37364. private _joystickPreviousPointerPos;
  37365. private _joystickPointerStartPos;
  37366. private _deltaJoystickVector;
  37367. private _leftJoystick;
  37368. private _touches;
  37369. private _onPointerDownHandlerRef;
  37370. private _onPointerMoveHandlerRef;
  37371. private _onPointerUpHandlerRef;
  37372. private _onResize;
  37373. /**
  37374. * Creates a new virtual joystick
  37375. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37376. */
  37377. constructor(leftJoystick?: boolean);
  37378. /**
  37379. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37380. * @param newJoystickSensibility defines the new sensibility
  37381. */
  37382. setJoystickSensibility(newJoystickSensibility: number): void;
  37383. private _onPointerDown;
  37384. private _onPointerMove;
  37385. private _onPointerUp;
  37386. /**
  37387. * Change the color of the virtual joystick
  37388. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37389. */
  37390. setJoystickColor(newColor: string): void;
  37391. /**
  37392. * Defines a callback to call when the joystick is touched
  37393. * @param action defines the callback
  37394. */
  37395. setActionOnTouch(action: () => any): void;
  37396. /**
  37397. * Defines which axis you'd like to control for left & right
  37398. * @param axis defines the axis to use
  37399. */
  37400. setAxisForLeftRight(axis: JoystickAxis): void;
  37401. /**
  37402. * Defines which axis you'd like to control for up & down
  37403. * @param axis defines the axis to use
  37404. */
  37405. setAxisForUpDown(axis: JoystickAxis): void;
  37406. private _drawVirtualJoystick;
  37407. /**
  37408. * Release internal HTML canvas
  37409. */
  37410. releaseCanvas(): void;
  37411. }
  37412. }
  37413. declare module BABYLON {
  37414. interface FreeCameraInputsManager {
  37415. /**
  37416. * Add virtual joystick input support to the input manager.
  37417. * @returns the current input manager
  37418. */
  37419. addVirtualJoystick(): FreeCameraInputsManager;
  37420. }
  37421. /**
  37422. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37424. */
  37425. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37426. /**
  37427. * Defines the camera the input is attached to.
  37428. */
  37429. camera: FreeCamera;
  37430. private _leftjoystick;
  37431. private _rightjoystick;
  37432. /**
  37433. * Gets the left stick of the virtual joystick.
  37434. * @returns The virtual Joystick
  37435. */
  37436. getLeftJoystick(): VirtualJoystick;
  37437. /**
  37438. * Gets the right stick of the virtual joystick.
  37439. * @returns The virtual Joystick
  37440. */
  37441. getRightJoystick(): VirtualJoystick;
  37442. /**
  37443. * Update the current camera state depending on the inputs that have been used this frame.
  37444. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37445. */
  37446. checkInputs(): void;
  37447. /**
  37448. * Attach the input controls to a specific dom element to get the input from.
  37449. * @param element Defines the element the controls should be listened from
  37450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37451. */
  37452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37453. /**
  37454. * Detach the current controls from the specified dom element.
  37455. * @param element Defines the element to stop listening the inputs from
  37456. */
  37457. detachControl(element: Nullable<HTMLElement>): void;
  37458. /**
  37459. * Gets the class name of the current intput.
  37460. * @returns the class name
  37461. */
  37462. getClassName(): string;
  37463. /**
  37464. * Get the friendly name associated with the input class.
  37465. * @returns the input friendly name
  37466. */
  37467. getSimpleName(): string;
  37468. }
  37469. }
  37470. declare module BABYLON {
  37471. /**
  37472. * This represents a FPS type of camera controlled by touch.
  37473. * This is like a universal camera minus the Gamepad controls.
  37474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37475. */
  37476. export class TouchCamera extends FreeCamera {
  37477. /**
  37478. * Defines the touch sensibility for rotation.
  37479. * The higher the faster.
  37480. */
  37481. touchAngularSensibility: number;
  37482. /**
  37483. * Defines the touch sensibility for move.
  37484. * The higher the faster.
  37485. */
  37486. touchMoveSensibility: number;
  37487. /**
  37488. * Instantiates a new touch camera.
  37489. * This represents a FPS type of camera controlled by touch.
  37490. * This is like a universal camera minus the Gamepad controls.
  37491. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37492. * @param name Define the name of the camera in the scene
  37493. * @param position Define the start position of the camera in the scene
  37494. * @param scene Define the scene the camera belongs to
  37495. */
  37496. constructor(name: string, position: Vector3, scene: Scene);
  37497. /**
  37498. * Gets the current object class name.
  37499. * @return the class name
  37500. */
  37501. getClassName(): string;
  37502. /** @hidden */ private _setupInputs(): void;
  37503. }
  37504. }
  37505. declare module BABYLON {
  37506. /**
  37507. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37508. * being tilted forward or back and left or right.
  37509. */
  37510. export class DeviceOrientationCamera extends FreeCamera {
  37511. private _initialQuaternion;
  37512. private _quaternionCache;
  37513. private _tmpDragQuaternion;
  37514. /**
  37515. * Creates a new device orientation camera
  37516. * @param name The name of the camera
  37517. * @param position The start position camera
  37518. * @param scene The scene the camera belongs to
  37519. */
  37520. constructor(name: string, position: Vector3, scene: Scene);
  37521. /**
  37522. * @hidden
  37523. * Disabled pointer input on first orientation sensor update (Default: true)
  37524. */ private _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37525. private _dragFactor;
  37526. /**
  37527. * Enabled turning on the y axis when the orientation sensor is active
  37528. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37529. */
  37530. enableHorizontalDragging(dragFactor?: number): void;
  37531. /**
  37532. * Gets the current instance class name ("DeviceOrientationCamera").
  37533. * This helps avoiding instanceof at run time.
  37534. * @returns the class name
  37535. */
  37536. getClassName(): string;
  37537. /**
  37538. * @hidden
  37539. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37540. */ private _checkInputs(): void;
  37541. /**
  37542. * Reset the camera to its default orientation on the specified axis only.
  37543. * @param axis The axis to reset
  37544. */
  37545. resetToCurrentRotation(axis?: Axis): void;
  37546. }
  37547. }
  37548. declare module BABYLON {
  37549. /**
  37550. * Defines supported buttons for XBox360 compatible gamepads
  37551. */
  37552. export enum Xbox360Button {
  37553. /** A */
  37554. A = 0,
  37555. /** B */
  37556. B = 1,
  37557. /** X */
  37558. X = 2,
  37559. /** Y */
  37560. Y = 3,
  37561. /** Start */
  37562. Start = 4,
  37563. /** Back */
  37564. Back = 5,
  37565. /** Left button */
  37566. LB = 6,
  37567. /** Right button */
  37568. RB = 7,
  37569. /** Left stick */
  37570. LeftStick = 8,
  37571. /** Right stick */
  37572. RightStick = 9
  37573. }
  37574. /** Defines values for XBox360 DPad */
  37575. export enum Xbox360Dpad {
  37576. /** Up */
  37577. Up = 0,
  37578. /** Down */
  37579. Down = 1,
  37580. /** Left */
  37581. Left = 2,
  37582. /** Right */
  37583. Right = 3
  37584. }
  37585. /**
  37586. * Defines a XBox360 gamepad
  37587. */
  37588. export class Xbox360Pad extends Gamepad {
  37589. private _leftTrigger;
  37590. private _rightTrigger;
  37591. private _onlefttriggerchanged;
  37592. private _onrighttriggerchanged;
  37593. private _onbuttondown;
  37594. private _onbuttonup;
  37595. private _ondpaddown;
  37596. private _ondpadup;
  37597. /** Observable raised when a button is pressed */
  37598. onButtonDownObservable: Observable<Xbox360Button>;
  37599. /** Observable raised when a button is released */
  37600. onButtonUpObservable: Observable<Xbox360Button>;
  37601. /** Observable raised when a pad is pressed */
  37602. onPadDownObservable: Observable<Xbox360Dpad>;
  37603. /** Observable raised when a pad is released */
  37604. onPadUpObservable: Observable<Xbox360Dpad>;
  37605. private _buttonA;
  37606. private _buttonB;
  37607. private _buttonX;
  37608. private _buttonY;
  37609. private _buttonBack;
  37610. private _buttonStart;
  37611. private _buttonLB;
  37612. private _buttonRB;
  37613. private _buttonLeftStick;
  37614. private _buttonRightStick;
  37615. private _dPadUp;
  37616. private _dPadDown;
  37617. private _dPadLeft;
  37618. private _dPadRight;
  37619. private _isXboxOnePad;
  37620. /**
  37621. * Creates a new XBox360 gamepad object
  37622. * @param id defines the id of this gamepad
  37623. * @param index defines its index
  37624. * @param gamepad defines the internal HTML gamepad object
  37625. * @param xboxOne defines if it is a XBox One gamepad
  37626. */
  37627. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37628. /**
  37629. * Defines the callback to call when left trigger is pressed
  37630. * @param callback defines the callback to use
  37631. */
  37632. onlefttriggerchanged(callback: (value: number) => void): void;
  37633. /**
  37634. * Defines the callback to call when right trigger is pressed
  37635. * @param callback defines the callback to use
  37636. */
  37637. onrighttriggerchanged(callback: (value: number) => void): void;
  37638. /**
  37639. * Gets the left trigger value
  37640. */
  37641. /**
  37642. * Sets the left trigger value
  37643. */
  37644. leftTrigger: number;
  37645. /**
  37646. * Gets the right trigger value
  37647. */
  37648. /**
  37649. * Sets the right trigger value
  37650. */
  37651. rightTrigger: number;
  37652. /**
  37653. * Defines the callback to call when a button is pressed
  37654. * @param callback defines the callback to use
  37655. */
  37656. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37657. /**
  37658. * Defines the callback to call when a button is released
  37659. * @param callback defines the callback to use
  37660. */
  37661. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37662. /**
  37663. * Defines the callback to call when a pad is pressed
  37664. * @param callback defines the callback to use
  37665. */
  37666. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37667. /**
  37668. * Defines the callback to call when a pad is released
  37669. * @param callback defines the callback to use
  37670. */
  37671. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37672. private _setButtonValue;
  37673. private _setDPadValue;
  37674. /**
  37675. * Gets the value of the `A` button
  37676. */
  37677. /**
  37678. * Sets the value of the `A` button
  37679. */
  37680. buttonA: number;
  37681. /**
  37682. * Gets the value of the `B` button
  37683. */
  37684. /**
  37685. * Sets the value of the `B` button
  37686. */
  37687. buttonB: number;
  37688. /**
  37689. * Gets the value of the `X` button
  37690. */
  37691. /**
  37692. * Sets the value of the `X` button
  37693. */
  37694. buttonX: number;
  37695. /**
  37696. * Gets the value of the `Y` button
  37697. */
  37698. /**
  37699. * Sets the value of the `Y` button
  37700. */
  37701. buttonY: number;
  37702. /**
  37703. * Gets the value of the `Start` button
  37704. */
  37705. /**
  37706. * Sets the value of the `Start` button
  37707. */
  37708. buttonStart: number;
  37709. /**
  37710. * Gets the value of the `Back` button
  37711. */
  37712. /**
  37713. * Sets the value of the `Back` button
  37714. */
  37715. buttonBack: number;
  37716. /**
  37717. * Gets the value of the `Left` button
  37718. */
  37719. /**
  37720. * Sets the value of the `Left` button
  37721. */
  37722. buttonLB: number;
  37723. /**
  37724. * Gets the value of the `Right` button
  37725. */
  37726. /**
  37727. * Sets the value of the `Right` button
  37728. */
  37729. buttonRB: number;
  37730. /**
  37731. * Gets the value of the Left joystick
  37732. */
  37733. /**
  37734. * Sets the value of the Left joystick
  37735. */
  37736. buttonLeftStick: number;
  37737. /**
  37738. * Gets the value of the Right joystick
  37739. */
  37740. /**
  37741. * Sets the value of the Right joystick
  37742. */
  37743. buttonRightStick: number;
  37744. /**
  37745. * Gets the value of D-pad up
  37746. */
  37747. /**
  37748. * Sets the value of D-pad up
  37749. */
  37750. dPadUp: number;
  37751. /**
  37752. * Gets the value of D-pad down
  37753. */
  37754. /**
  37755. * Sets the value of D-pad down
  37756. */
  37757. dPadDown: number;
  37758. /**
  37759. * Gets the value of D-pad left
  37760. */
  37761. /**
  37762. * Sets the value of D-pad left
  37763. */
  37764. dPadLeft: number;
  37765. /**
  37766. * Gets the value of D-pad right
  37767. */
  37768. /**
  37769. * Sets the value of D-pad right
  37770. */
  37771. dPadRight: number;
  37772. /**
  37773. * Force the gamepad to synchronize with device values
  37774. */
  37775. update(): void;
  37776. /**
  37777. * Disposes the gamepad
  37778. */
  37779. dispose(): void;
  37780. }
  37781. }
  37782. declare module BABYLON {
  37783. /**
  37784. * Manager for handling gamepads
  37785. */
  37786. export class GamepadManager {
  37787. private _scene?;
  37788. private _babylonGamepads;
  37789. private _oneGamepadConnected;
  37790. /** @hidden */ private _isMonitoring: boolean;
  37791. private _gamepadEventSupported;
  37792. private _gamepadSupport;
  37793. /**
  37794. * observable to be triggered when the gamepad controller has been connected
  37795. */
  37796. onGamepadConnectedObservable: Observable<Gamepad>;
  37797. /**
  37798. * observable to be triggered when the gamepad controller has been disconnected
  37799. */
  37800. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37801. private _onGamepadConnectedEvent;
  37802. private _onGamepadDisconnectedEvent;
  37803. /**
  37804. * Initializes the gamepad manager
  37805. * @param _scene BabylonJS scene
  37806. */
  37807. constructor(_scene?: Scene | undefined);
  37808. /**
  37809. * The gamepads in the game pad manager
  37810. */
  37811. readonly gamepads: Gamepad[];
  37812. /**
  37813. * Get the gamepad controllers based on type
  37814. * @param type The type of gamepad controller
  37815. * @returns Nullable gamepad
  37816. */
  37817. getGamepadByType(type?: number): Nullable<Gamepad>;
  37818. /**
  37819. * Disposes the gamepad manager
  37820. */
  37821. dispose(): void;
  37822. private _addNewGamepad;
  37823. private _startMonitoringGamepads;
  37824. private _stopMonitoringGamepads;
  37825. /** @hidden */ private _checkGamepadsStatus(): void;
  37826. private _updateGamepadObjects;
  37827. }
  37828. }
  37829. declare module BABYLON {
  37830. interface Scene {
  37831. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  37832. /**
  37833. * Gets the gamepad manager associated with the scene
  37834. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37835. */
  37836. gamepadManager: GamepadManager;
  37837. }
  37838. /**
  37839. * Interface representing a free camera inputs manager
  37840. */
  37841. interface FreeCameraInputsManager {
  37842. /**
  37843. * Adds gamepad input support to the FreeCameraInputsManager.
  37844. * @returns the FreeCameraInputsManager
  37845. */
  37846. addGamepad(): FreeCameraInputsManager;
  37847. }
  37848. /**
  37849. * Interface representing an arc rotate camera inputs manager
  37850. */
  37851. interface ArcRotateCameraInputsManager {
  37852. /**
  37853. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37854. * @returns the camera inputs manager
  37855. */
  37856. addGamepad(): ArcRotateCameraInputsManager;
  37857. }
  37858. /**
  37859. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37860. */
  37861. export class GamepadSystemSceneComponent implements ISceneComponent {
  37862. /**
  37863. * The component name helpfull to identify the component in the list of scene components.
  37864. */
  37865. readonly name: string;
  37866. /**
  37867. * The scene the component belongs to.
  37868. */
  37869. scene: Scene;
  37870. /**
  37871. * Creates a new instance of the component for the given scene
  37872. * @param scene Defines the scene to register the component in
  37873. */
  37874. constructor(scene: Scene);
  37875. /**
  37876. * Registers the component in a given scene
  37877. */
  37878. register(): void;
  37879. /**
  37880. * Rebuilds the elements related to this component in case of
  37881. * context lost for instance.
  37882. */
  37883. rebuild(): void;
  37884. /**
  37885. * Disposes the component and the associated ressources
  37886. */
  37887. dispose(): void;
  37888. private _beforeCameraUpdate;
  37889. }
  37890. }
  37891. declare module BABYLON {
  37892. /**
  37893. * 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,
  37894. * which still works and will still be found in many Playgrounds.
  37895. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37896. */
  37897. export class UniversalCamera extends TouchCamera {
  37898. /**
  37899. * Defines the gamepad rotation sensiblity.
  37900. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37901. */
  37902. gamepadAngularSensibility: number;
  37903. /**
  37904. * Defines the gamepad move sensiblity.
  37905. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37906. */
  37907. gamepadMoveSensibility: number;
  37908. /**
  37909. * 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,
  37910. * which still works and will still be found in many Playgrounds.
  37911. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37912. * @param name Define the name of the camera in the scene
  37913. * @param position Define the start position of the camera in the scene
  37914. * @param scene Define the scene the camera belongs to
  37915. */
  37916. constructor(name: string, position: Vector3, scene: Scene);
  37917. /**
  37918. * Gets the current object class name.
  37919. * @return the class name
  37920. */
  37921. getClassName(): string;
  37922. }
  37923. }
  37924. declare module BABYLON {
  37925. /**
  37926. * This represents a FPS type of camera. This is only here for back compat purpose.
  37927. * Please use the UniversalCamera instead as both are identical.
  37928. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37929. */
  37930. export class GamepadCamera extends UniversalCamera {
  37931. /**
  37932. * Instantiates a new Gamepad Camera
  37933. * This represents a FPS type of camera. This is only here for back compat purpose.
  37934. * Please use the UniversalCamera instead as both are identical.
  37935. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37936. * @param name Define the name of the camera in the scene
  37937. * @param position Define the start position of the camera in the scene
  37938. * @param scene Define the scene the camera belongs to
  37939. */
  37940. constructor(name: string, position: Vector3, scene: Scene);
  37941. /**
  37942. * Gets the current object class name.
  37943. * @return the class name
  37944. */
  37945. getClassName(): string;
  37946. }
  37947. }
  37948. declare module BABYLON {
  37949. /** @hidden */
  37950. export var passPixelShader: {
  37951. name: string;
  37952. shader: string;
  37953. };
  37954. }
  37955. declare module BABYLON {
  37956. /** @hidden */
  37957. export var passCubePixelShader: {
  37958. name: string;
  37959. shader: string;
  37960. };
  37961. }
  37962. declare module BABYLON {
  37963. /**
  37964. * PassPostProcess which produces an output the same as it's input
  37965. */
  37966. export class PassPostProcess extends PostProcess {
  37967. /**
  37968. * Creates the PassPostProcess
  37969. * @param name The name of the effect.
  37970. * @param options The required width/height ratio to downsize to before computing the render pass.
  37971. * @param camera The camera to apply the render pass to.
  37972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37973. * @param engine The engine which the post process will be applied. (default: current engine)
  37974. * @param reusable If the post process can be reused on the same frame. (default: false)
  37975. * @param textureType The type of texture to be used when performing the post processing.
  37976. * @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)
  37977. */
  37978. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37979. }
  37980. /**
  37981. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37982. */
  37983. export class PassCubePostProcess extends PostProcess {
  37984. private _face;
  37985. /**
  37986. * Gets or sets the cube face to display.
  37987. * * 0 is +X
  37988. * * 1 is -X
  37989. * * 2 is +Y
  37990. * * 3 is -Y
  37991. * * 4 is +Z
  37992. * * 5 is -Z
  37993. */
  37994. face: number;
  37995. /**
  37996. * Creates the PassCubePostProcess
  37997. * @param name The name of the effect.
  37998. * @param options The required width/height ratio to downsize to before computing the render pass.
  37999. * @param camera The camera to apply the render pass to.
  38000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38001. * @param engine The engine which the post process will be applied. (default: current engine)
  38002. * @param reusable If the post process can be reused on the same frame. (default: false)
  38003. * @param textureType The type of texture to be used when performing the post processing.
  38004. * @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)
  38005. */
  38006. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38007. }
  38008. }
  38009. declare module BABYLON {
  38010. /** @hidden */
  38011. export var anaglyphPixelShader: {
  38012. name: string;
  38013. shader: string;
  38014. };
  38015. }
  38016. declare module BABYLON {
  38017. /**
  38018. * Postprocess used to generate anaglyphic rendering
  38019. */
  38020. export class AnaglyphPostProcess extends PostProcess {
  38021. private _passedProcess;
  38022. /**
  38023. * Creates a new AnaglyphPostProcess
  38024. * @param name defines postprocess name
  38025. * @param options defines creation options or target ratio scale
  38026. * @param rigCameras defines cameras using this postprocess
  38027. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38028. * @param engine defines hosting engine
  38029. * @param reusable defines if the postprocess will be reused multiple times per frame
  38030. */
  38031. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38032. }
  38033. }
  38034. declare module BABYLON {
  38035. /**
  38036. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38037. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38038. */
  38039. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38040. /**
  38041. * Creates a new AnaglyphArcRotateCamera
  38042. * @param name defines camera name
  38043. * @param alpha defines alpha angle (in radians)
  38044. * @param beta defines beta angle (in radians)
  38045. * @param radius defines radius
  38046. * @param target defines camera target
  38047. * @param interaxialDistance defines distance between each color axis
  38048. * @param scene defines the hosting scene
  38049. */
  38050. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38051. /**
  38052. * Gets camera class name
  38053. * @returns AnaglyphArcRotateCamera
  38054. */
  38055. getClassName(): string;
  38056. }
  38057. }
  38058. declare module BABYLON {
  38059. /**
  38060. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38061. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38062. */
  38063. export class AnaglyphFreeCamera extends FreeCamera {
  38064. /**
  38065. * Creates a new AnaglyphFreeCamera
  38066. * @param name defines camera name
  38067. * @param position defines initial position
  38068. * @param interaxialDistance defines distance between each color axis
  38069. * @param scene defines the hosting scene
  38070. */
  38071. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38072. /**
  38073. * Gets camera class name
  38074. * @returns AnaglyphFreeCamera
  38075. */
  38076. getClassName(): string;
  38077. }
  38078. }
  38079. declare module BABYLON {
  38080. /**
  38081. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38082. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38083. */
  38084. export class AnaglyphGamepadCamera extends GamepadCamera {
  38085. /**
  38086. * Creates a new AnaglyphGamepadCamera
  38087. * @param name defines camera name
  38088. * @param position defines initial position
  38089. * @param interaxialDistance defines distance between each color axis
  38090. * @param scene defines the hosting scene
  38091. */
  38092. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38093. /**
  38094. * Gets camera class name
  38095. * @returns AnaglyphGamepadCamera
  38096. */
  38097. getClassName(): string;
  38098. }
  38099. }
  38100. declare module BABYLON {
  38101. /**
  38102. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38103. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38104. */
  38105. export class AnaglyphUniversalCamera extends UniversalCamera {
  38106. /**
  38107. * Creates a new AnaglyphUniversalCamera
  38108. * @param name defines camera name
  38109. * @param position defines initial position
  38110. * @param interaxialDistance defines distance between each color axis
  38111. * @param scene defines the hosting scene
  38112. */
  38113. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38114. /**
  38115. * Gets camera class name
  38116. * @returns AnaglyphUniversalCamera
  38117. */
  38118. getClassName(): string;
  38119. }
  38120. }
  38121. declare module BABYLON {
  38122. /** @hidden */
  38123. export var stereoscopicInterlacePixelShader: {
  38124. name: string;
  38125. shader: string;
  38126. };
  38127. }
  38128. declare module BABYLON {
  38129. /**
  38130. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38131. */
  38132. export class StereoscopicInterlacePostProcess extends PostProcess {
  38133. private _stepSize;
  38134. private _passedProcess;
  38135. /**
  38136. * Initializes a StereoscopicInterlacePostProcess
  38137. * @param name The name of the effect.
  38138. * @param rigCameras The rig cameras to be appled to the post process
  38139. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38141. * @param engine The engine which the post process will be applied. (default: current engine)
  38142. * @param reusable If the post process can be reused on the same frame. (default: false)
  38143. */
  38144. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38145. }
  38146. }
  38147. declare module BABYLON {
  38148. /**
  38149. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38150. * @see http://doc.babylonjs.com/features/cameras
  38151. */
  38152. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38153. /**
  38154. * Creates a new StereoscopicArcRotateCamera
  38155. * @param name defines camera name
  38156. * @param alpha defines alpha angle (in radians)
  38157. * @param beta defines beta angle (in radians)
  38158. * @param radius defines radius
  38159. * @param target defines camera target
  38160. * @param interaxialDistance defines distance between each color axis
  38161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38162. * @param scene defines the hosting scene
  38163. */
  38164. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38165. /**
  38166. * Gets camera class name
  38167. * @returns StereoscopicArcRotateCamera
  38168. */
  38169. getClassName(): string;
  38170. }
  38171. }
  38172. declare module BABYLON {
  38173. /**
  38174. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38175. * @see http://doc.babylonjs.com/features/cameras
  38176. */
  38177. export class StereoscopicFreeCamera extends FreeCamera {
  38178. /**
  38179. * Creates a new StereoscopicFreeCamera
  38180. * @param name defines camera name
  38181. * @param position defines initial position
  38182. * @param interaxialDistance defines distance between each color axis
  38183. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38184. * @param scene defines the hosting scene
  38185. */
  38186. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38187. /**
  38188. * Gets camera class name
  38189. * @returns StereoscopicFreeCamera
  38190. */
  38191. getClassName(): string;
  38192. }
  38193. }
  38194. declare module BABYLON {
  38195. /**
  38196. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38197. * @see http://doc.babylonjs.com/features/cameras
  38198. */
  38199. export class StereoscopicGamepadCamera extends GamepadCamera {
  38200. /**
  38201. * Creates a new StereoscopicGamepadCamera
  38202. * @param name defines camera name
  38203. * @param position defines initial position
  38204. * @param interaxialDistance defines distance between each color axis
  38205. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38206. * @param scene defines the hosting scene
  38207. */
  38208. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38209. /**
  38210. * Gets camera class name
  38211. * @returns StereoscopicGamepadCamera
  38212. */
  38213. getClassName(): string;
  38214. }
  38215. }
  38216. declare module BABYLON {
  38217. /**
  38218. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38219. * @see http://doc.babylonjs.com/features/cameras
  38220. */
  38221. export class StereoscopicUniversalCamera extends UniversalCamera {
  38222. /**
  38223. * Creates a new StereoscopicUniversalCamera
  38224. * @param name defines camera name
  38225. * @param position defines initial position
  38226. * @param interaxialDistance defines distance between each color axis
  38227. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38228. * @param scene defines the hosting scene
  38229. */
  38230. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38231. /**
  38232. * Gets camera class name
  38233. * @returns StereoscopicUniversalCamera
  38234. */
  38235. getClassName(): string;
  38236. }
  38237. }
  38238. declare module BABYLON {
  38239. /**
  38240. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38241. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38242. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38243. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38244. */
  38245. export class VirtualJoysticksCamera extends FreeCamera {
  38246. /**
  38247. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38248. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38249. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38250. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38251. * @param name Define the name of the camera in the scene
  38252. * @param position Define the start position of the camera in the scene
  38253. * @param scene Define the scene the camera belongs to
  38254. */
  38255. constructor(name: string, position: Vector3, scene: Scene);
  38256. /**
  38257. * Gets the current object class name.
  38258. * @return the class name
  38259. */
  38260. getClassName(): string;
  38261. }
  38262. }
  38263. declare module BABYLON {
  38264. /**
  38265. * This represents all the required metrics to create a VR camera.
  38266. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38267. */
  38268. export class VRCameraMetrics {
  38269. /**
  38270. * Define the horizontal resolution off the screen.
  38271. */
  38272. hResolution: number;
  38273. /**
  38274. * Define the vertical resolution off the screen.
  38275. */
  38276. vResolution: number;
  38277. /**
  38278. * Define the horizontal screen size.
  38279. */
  38280. hScreenSize: number;
  38281. /**
  38282. * Define the vertical screen size.
  38283. */
  38284. vScreenSize: number;
  38285. /**
  38286. * Define the vertical screen center position.
  38287. */
  38288. vScreenCenter: number;
  38289. /**
  38290. * Define the distance of the eyes to the screen.
  38291. */
  38292. eyeToScreenDistance: number;
  38293. /**
  38294. * Define the distance between both lenses
  38295. */
  38296. lensSeparationDistance: number;
  38297. /**
  38298. * Define the distance between both viewer's eyes.
  38299. */
  38300. interpupillaryDistance: number;
  38301. /**
  38302. * Define the distortion factor of the VR postprocess.
  38303. * Please, touch with care.
  38304. */
  38305. distortionK: number[];
  38306. /**
  38307. * Define the chromatic aberration correction factors for the VR post process.
  38308. */
  38309. chromaAbCorrection: number[];
  38310. /**
  38311. * Define the scale factor of the post process.
  38312. * The smaller the better but the slower.
  38313. */
  38314. postProcessScaleFactor: number;
  38315. /**
  38316. * Define an offset for the lens center.
  38317. */
  38318. lensCenterOffset: number;
  38319. /**
  38320. * Define if the current vr camera should compensate the distortion of the lense or not.
  38321. */
  38322. compensateDistortion: boolean;
  38323. /**
  38324. * Defines if multiview should be enabled when rendering (Default: false)
  38325. */
  38326. multiviewEnabled: boolean;
  38327. /**
  38328. * Gets the rendering aspect ratio based on the provided resolutions.
  38329. */
  38330. readonly aspectRatio: number;
  38331. /**
  38332. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38333. */
  38334. readonly aspectRatioFov: number;
  38335. /**
  38336. * @hidden
  38337. */
  38338. readonly leftHMatrix: Matrix;
  38339. /**
  38340. * @hidden
  38341. */
  38342. readonly rightHMatrix: Matrix;
  38343. /**
  38344. * @hidden
  38345. */
  38346. readonly leftPreViewMatrix: Matrix;
  38347. /**
  38348. * @hidden
  38349. */
  38350. readonly rightPreViewMatrix: Matrix;
  38351. /**
  38352. * Get the default VRMetrics based on the most generic setup.
  38353. * @returns the default vr metrics
  38354. */
  38355. static GetDefault(): VRCameraMetrics;
  38356. }
  38357. }
  38358. declare module BABYLON {
  38359. /** @hidden */
  38360. export var vrDistortionCorrectionPixelShader: {
  38361. name: string;
  38362. shader: string;
  38363. };
  38364. }
  38365. declare module BABYLON {
  38366. /**
  38367. * VRDistortionCorrectionPostProcess used for mobile VR
  38368. */
  38369. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38370. private _isRightEye;
  38371. private _distortionFactors;
  38372. private _postProcessScaleFactor;
  38373. private _lensCenterOffset;
  38374. private _scaleIn;
  38375. private _scaleFactor;
  38376. private _lensCenter;
  38377. /**
  38378. * Initializes the VRDistortionCorrectionPostProcess
  38379. * @param name The name of the effect.
  38380. * @param camera The camera to apply the render pass to.
  38381. * @param isRightEye If this is for the right eye distortion
  38382. * @param vrMetrics All the required metrics for the VR camera
  38383. */
  38384. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38385. }
  38386. }
  38387. declare module BABYLON {
  38388. /**
  38389. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38390. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38391. */
  38392. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38393. /**
  38394. * Creates a new VRDeviceOrientationArcRotateCamera
  38395. * @param name defines camera name
  38396. * @param alpha defines the camera rotation along the logitudinal axis
  38397. * @param beta defines the camera rotation along the latitudinal axis
  38398. * @param radius defines the camera distance from its target
  38399. * @param target defines the camera target
  38400. * @param scene defines the scene the camera belongs to
  38401. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38402. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38403. */
  38404. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38405. /**
  38406. * Gets camera class name
  38407. * @returns VRDeviceOrientationArcRotateCamera
  38408. */
  38409. getClassName(): string;
  38410. }
  38411. }
  38412. declare module BABYLON {
  38413. /**
  38414. * Camera used to simulate VR rendering (based on FreeCamera)
  38415. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38416. */
  38417. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38418. /**
  38419. * Creates a new VRDeviceOrientationFreeCamera
  38420. * @param name defines camera name
  38421. * @param position defines the start position of the camera
  38422. * @param scene defines the scene the camera belongs to
  38423. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38424. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38425. */
  38426. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38427. /**
  38428. * Gets camera class name
  38429. * @returns VRDeviceOrientationFreeCamera
  38430. */
  38431. getClassName(): string;
  38432. }
  38433. }
  38434. declare module BABYLON {
  38435. /**
  38436. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38437. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38438. */
  38439. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38440. /**
  38441. * Creates a new VRDeviceOrientationGamepadCamera
  38442. * @param name defines camera name
  38443. * @param position defines the start position of the camera
  38444. * @param scene defines the scene the camera belongs to
  38445. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38446. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38447. */
  38448. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38449. /**
  38450. * Gets camera class name
  38451. * @returns VRDeviceOrientationGamepadCamera
  38452. */
  38453. getClassName(): string;
  38454. }
  38455. }
  38456. declare module BABYLON {
  38457. /**
  38458. * Base class of materials working in push mode in babylon JS
  38459. * @hidden
  38460. */
  38461. export class PushMaterial extends Material {
  38462. protected _activeEffect: Effect;
  38463. protected _normalMatrix: Matrix;
  38464. /**
  38465. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38466. * This means that the material can keep using a previous shader while a new one is being compiled.
  38467. * This is mostly used when shader parallel compilation is supported (true by default)
  38468. */
  38469. allowShaderHotSwapping: boolean;
  38470. constructor(name: string, scene: Scene);
  38471. getEffect(): Effect;
  38472. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38473. /**
  38474. * Binds the given world matrix to the active effect
  38475. *
  38476. * @param world the matrix to bind
  38477. */
  38478. bindOnlyWorldMatrix(world: Matrix): void;
  38479. /**
  38480. * Binds the given normal matrix to the active effect
  38481. *
  38482. * @param normalMatrix the matrix to bind
  38483. */
  38484. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38485. bind(world: Matrix, mesh?: Mesh): void;
  38486. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38487. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38488. }
  38489. }
  38490. declare module BABYLON {
  38491. /**
  38492. * This groups all the flags used to control the materials channel.
  38493. */
  38494. export class MaterialFlags {
  38495. private static _DiffuseTextureEnabled;
  38496. /**
  38497. * Are diffuse textures enabled in the application.
  38498. */
  38499. static DiffuseTextureEnabled: boolean;
  38500. private static _AmbientTextureEnabled;
  38501. /**
  38502. * Are ambient textures enabled in the application.
  38503. */
  38504. static AmbientTextureEnabled: boolean;
  38505. private static _OpacityTextureEnabled;
  38506. /**
  38507. * Are opacity textures enabled in the application.
  38508. */
  38509. static OpacityTextureEnabled: boolean;
  38510. private static _ReflectionTextureEnabled;
  38511. /**
  38512. * Are reflection textures enabled in the application.
  38513. */
  38514. static ReflectionTextureEnabled: boolean;
  38515. private static _EmissiveTextureEnabled;
  38516. /**
  38517. * Are emissive textures enabled in the application.
  38518. */
  38519. static EmissiveTextureEnabled: boolean;
  38520. private static _SpecularTextureEnabled;
  38521. /**
  38522. * Are specular textures enabled in the application.
  38523. */
  38524. static SpecularTextureEnabled: boolean;
  38525. private static _BumpTextureEnabled;
  38526. /**
  38527. * Are bump textures enabled in the application.
  38528. */
  38529. static BumpTextureEnabled: boolean;
  38530. private static _LightmapTextureEnabled;
  38531. /**
  38532. * Are lightmap textures enabled in the application.
  38533. */
  38534. static LightmapTextureEnabled: boolean;
  38535. private static _RefractionTextureEnabled;
  38536. /**
  38537. * Are refraction textures enabled in the application.
  38538. */
  38539. static RefractionTextureEnabled: boolean;
  38540. private static _ColorGradingTextureEnabled;
  38541. /**
  38542. * Are color grading textures enabled in the application.
  38543. */
  38544. static ColorGradingTextureEnabled: boolean;
  38545. private static _FresnelEnabled;
  38546. /**
  38547. * Are fresnels enabled in the application.
  38548. */
  38549. static FresnelEnabled: boolean;
  38550. private static _ClearCoatTextureEnabled;
  38551. /**
  38552. * Are clear coat textures enabled in the application.
  38553. */
  38554. static ClearCoatTextureEnabled: boolean;
  38555. private static _ClearCoatBumpTextureEnabled;
  38556. /**
  38557. * Are clear coat bump textures enabled in the application.
  38558. */
  38559. static ClearCoatBumpTextureEnabled: boolean;
  38560. private static _ClearCoatTintTextureEnabled;
  38561. /**
  38562. * Are clear coat tint textures enabled in the application.
  38563. */
  38564. static ClearCoatTintTextureEnabled: boolean;
  38565. private static _SheenTextureEnabled;
  38566. /**
  38567. * Are sheen textures enabled in the application.
  38568. */
  38569. static SheenTextureEnabled: boolean;
  38570. private static _AnisotropicTextureEnabled;
  38571. /**
  38572. * Are anisotropic textures enabled in the application.
  38573. */
  38574. static AnisotropicTextureEnabled: boolean;
  38575. private static _ThicknessTextureEnabled;
  38576. /**
  38577. * Are thickness textures enabled in the application.
  38578. */
  38579. static ThicknessTextureEnabled: boolean;
  38580. }
  38581. }
  38582. declare module BABYLON {
  38583. /** @hidden */
  38584. export var defaultFragmentDeclaration: {
  38585. name: string;
  38586. shader: string;
  38587. };
  38588. }
  38589. declare module BABYLON {
  38590. /** @hidden */
  38591. export var defaultUboDeclaration: {
  38592. name: string;
  38593. shader: string;
  38594. };
  38595. }
  38596. declare module BABYLON {
  38597. /** @hidden */
  38598. export var lightFragmentDeclaration: {
  38599. name: string;
  38600. shader: string;
  38601. };
  38602. }
  38603. declare module BABYLON {
  38604. /** @hidden */
  38605. export var lightUboDeclaration: {
  38606. name: string;
  38607. shader: string;
  38608. };
  38609. }
  38610. declare module BABYLON {
  38611. /** @hidden */
  38612. export var lightsFragmentFunctions: {
  38613. name: string;
  38614. shader: string;
  38615. };
  38616. }
  38617. declare module BABYLON {
  38618. /** @hidden */
  38619. export var shadowsFragmentFunctions: {
  38620. name: string;
  38621. shader: string;
  38622. };
  38623. }
  38624. declare module BABYLON {
  38625. /** @hidden */
  38626. export var fresnelFunction: {
  38627. name: string;
  38628. shader: string;
  38629. };
  38630. }
  38631. declare module BABYLON {
  38632. /** @hidden */
  38633. export var reflectionFunction: {
  38634. name: string;
  38635. shader: string;
  38636. };
  38637. }
  38638. declare module BABYLON {
  38639. /** @hidden */
  38640. export var bumpFragmentFunctions: {
  38641. name: string;
  38642. shader: string;
  38643. };
  38644. }
  38645. declare module BABYLON {
  38646. /** @hidden */
  38647. export var logDepthDeclaration: {
  38648. name: string;
  38649. shader: string;
  38650. };
  38651. }
  38652. declare module BABYLON {
  38653. /** @hidden */
  38654. export var bumpFragment: {
  38655. name: string;
  38656. shader: string;
  38657. };
  38658. }
  38659. declare module BABYLON {
  38660. /** @hidden */
  38661. export var depthPrePass: {
  38662. name: string;
  38663. shader: string;
  38664. };
  38665. }
  38666. declare module BABYLON {
  38667. /** @hidden */
  38668. export var lightFragment: {
  38669. name: string;
  38670. shader: string;
  38671. };
  38672. }
  38673. declare module BABYLON {
  38674. /** @hidden */
  38675. export var logDepthFragment: {
  38676. name: string;
  38677. shader: string;
  38678. };
  38679. }
  38680. declare module BABYLON {
  38681. /** @hidden */
  38682. export var defaultPixelShader: {
  38683. name: string;
  38684. shader: string;
  38685. };
  38686. }
  38687. declare module BABYLON {
  38688. /** @hidden */
  38689. export var defaultVertexDeclaration: {
  38690. name: string;
  38691. shader: string;
  38692. };
  38693. }
  38694. declare module BABYLON {
  38695. /** @hidden */
  38696. export var bumpVertexDeclaration: {
  38697. name: string;
  38698. shader: string;
  38699. };
  38700. }
  38701. declare module BABYLON {
  38702. /** @hidden */
  38703. export var bumpVertex: {
  38704. name: string;
  38705. shader: string;
  38706. };
  38707. }
  38708. declare module BABYLON {
  38709. /** @hidden */
  38710. export var fogVertex: {
  38711. name: string;
  38712. shader: string;
  38713. };
  38714. }
  38715. declare module BABYLON {
  38716. /** @hidden */
  38717. export var shadowsVertex: {
  38718. name: string;
  38719. shader: string;
  38720. };
  38721. }
  38722. declare module BABYLON {
  38723. /** @hidden */
  38724. export var pointCloudVertex: {
  38725. name: string;
  38726. shader: string;
  38727. };
  38728. }
  38729. declare module BABYLON {
  38730. /** @hidden */
  38731. export var logDepthVertex: {
  38732. name: string;
  38733. shader: string;
  38734. };
  38735. }
  38736. declare module BABYLON {
  38737. /** @hidden */
  38738. export var defaultVertexShader: {
  38739. name: string;
  38740. shader: string;
  38741. };
  38742. }
  38743. declare module BABYLON {
  38744. /** @hidden */
  38745. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38746. MAINUV1: boolean;
  38747. MAINUV2: boolean;
  38748. DIFFUSE: boolean;
  38749. DIFFUSEDIRECTUV: number;
  38750. AMBIENT: boolean;
  38751. AMBIENTDIRECTUV: number;
  38752. OPACITY: boolean;
  38753. OPACITYDIRECTUV: number;
  38754. OPACITYRGB: boolean;
  38755. REFLECTION: boolean;
  38756. EMISSIVE: boolean;
  38757. EMISSIVEDIRECTUV: number;
  38758. SPECULAR: boolean;
  38759. SPECULARDIRECTUV: number;
  38760. BUMP: boolean;
  38761. BUMPDIRECTUV: number;
  38762. PARALLAX: boolean;
  38763. PARALLAXOCCLUSION: boolean;
  38764. SPECULAROVERALPHA: boolean;
  38765. CLIPPLANE: boolean;
  38766. CLIPPLANE2: boolean;
  38767. CLIPPLANE3: boolean;
  38768. CLIPPLANE4: boolean;
  38769. ALPHATEST: boolean;
  38770. DEPTHPREPASS: boolean;
  38771. ALPHAFROMDIFFUSE: boolean;
  38772. POINTSIZE: boolean;
  38773. FOG: boolean;
  38774. SPECULARTERM: boolean;
  38775. DIFFUSEFRESNEL: boolean;
  38776. OPACITYFRESNEL: boolean;
  38777. REFLECTIONFRESNEL: boolean;
  38778. REFRACTIONFRESNEL: boolean;
  38779. EMISSIVEFRESNEL: boolean;
  38780. FRESNEL: boolean;
  38781. NORMAL: boolean;
  38782. UV1: boolean;
  38783. UV2: boolean;
  38784. VERTEXCOLOR: boolean;
  38785. VERTEXALPHA: boolean;
  38786. NUM_BONE_INFLUENCERS: number;
  38787. BonesPerMesh: number;
  38788. BONETEXTURE: boolean;
  38789. INSTANCES: boolean;
  38790. GLOSSINESS: boolean;
  38791. ROUGHNESS: boolean;
  38792. EMISSIVEASILLUMINATION: boolean;
  38793. LINKEMISSIVEWITHDIFFUSE: boolean;
  38794. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38795. LIGHTMAP: boolean;
  38796. LIGHTMAPDIRECTUV: number;
  38797. OBJECTSPACE_NORMALMAP: boolean;
  38798. USELIGHTMAPASSHADOWMAP: boolean;
  38799. REFLECTIONMAP_3D: boolean;
  38800. REFLECTIONMAP_SPHERICAL: boolean;
  38801. REFLECTIONMAP_PLANAR: boolean;
  38802. REFLECTIONMAP_CUBIC: boolean;
  38803. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38804. REFLECTIONMAP_PROJECTION: boolean;
  38805. REFLECTIONMAP_SKYBOX: boolean;
  38806. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38807. REFLECTIONMAP_EXPLICIT: boolean;
  38808. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38809. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38810. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38811. INVERTCUBICMAP: boolean;
  38812. LOGARITHMICDEPTH: boolean;
  38813. REFRACTION: boolean;
  38814. REFRACTIONMAP_3D: boolean;
  38815. REFLECTIONOVERALPHA: boolean;
  38816. TWOSIDEDLIGHTING: boolean;
  38817. SHADOWFLOAT: boolean;
  38818. MORPHTARGETS: boolean;
  38819. MORPHTARGETS_NORMAL: boolean;
  38820. MORPHTARGETS_TANGENT: boolean;
  38821. MORPHTARGETS_UV: boolean;
  38822. NUM_MORPH_INFLUENCERS: number;
  38823. NONUNIFORMSCALING: boolean;
  38824. PREMULTIPLYALPHA: boolean;
  38825. IMAGEPROCESSING: boolean;
  38826. VIGNETTE: boolean;
  38827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38828. VIGNETTEBLENDMODEOPAQUE: boolean;
  38829. TONEMAPPING: boolean;
  38830. TONEMAPPING_ACES: boolean;
  38831. CONTRAST: boolean;
  38832. COLORCURVES: boolean;
  38833. COLORGRADING: boolean;
  38834. COLORGRADING3D: boolean;
  38835. SAMPLER3DGREENDEPTH: boolean;
  38836. SAMPLER3DBGRMAP: boolean;
  38837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38838. MULTIVIEW: boolean;
  38839. /**
  38840. * If the reflection texture on this material is in linear color space
  38841. * @hidden
  38842. */
  38843. IS_REFLECTION_LINEAR: boolean;
  38844. /**
  38845. * If the refraction texture on this material is in linear color space
  38846. * @hidden
  38847. */
  38848. IS_REFRACTION_LINEAR: boolean;
  38849. EXPOSURE: boolean;
  38850. constructor();
  38851. setReflectionMode(modeToEnable: string): void;
  38852. }
  38853. /**
  38854. * This is the default material used in Babylon. It is the best trade off between quality
  38855. * and performances.
  38856. * @see http://doc.babylonjs.com/babylon101/materials
  38857. */
  38858. export class StandardMaterial extends PushMaterial {
  38859. private _diffuseTexture;
  38860. /**
  38861. * The basic texture of the material as viewed under a light.
  38862. */
  38863. diffuseTexture: Nullable<BaseTexture>;
  38864. private _ambientTexture;
  38865. /**
  38866. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38867. */
  38868. ambientTexture: Nullable<BaseTexture>;
  38869. private _opacityTexture;
  38870. /**
  38871. * Define the transparency of the material from a texture.
  38872. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38873. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38874. */
  38875. opacityTexture: Nullable<BaseTexture>;
  38876. private _reflectionTexture;
  38877. /**
  38878. * Define the texture used to display the reflection.
  38879. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38880. */
  38881. reflectionTexture: Nullable<BaseTexture>;
  38882. private _emissiveTexture;
  38883. /**
  38884. * Define texture of the material as if self lit.
  38885. * This will be mixed in the final result even in the absence of light.
  38886. */
  38887. emissiveTexture: Nullable<BaseTexture>;
  38888. private _specularTexture;
  38889. /**
  38890. * Define how the color and intensity of the highlight given by the light in the material.
  38891. */
  38892. specularTexture: Nullable<BaseTexture>;
  38893. private _bumpTexture;
  38894. /**
  38895. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38896. * 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.
  38897. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38898. */
  38899. bumpTexture: Nullable<BaseTexture>;
  38900. private _lightmapTexture;
  38901. /**
  38902. * Complex lighting can be computationally expensive to compute at runtime.
  38903. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38904. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38905. */
  38906. lightmapTexture: Nullable<BaseTexture>;
  38907. private _refractionTexture;
  38908. /**
  38909. * Define the texture used to display the refraction.
  38910. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38911. */
  38912. refractionTexture: Nullable<BaseTexture>;
  38913. /**
  38914. * The color of the material lit by the environmental background lighting.
  38915. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38916. */
  38917. ambientColor: Color3;
  38918. /**
  38919. * The basic color of the material as viewed under a light.
  38920. */
  38921. diffuseColor: Color3;
  38922. /**
  38923. * Define how the color and intensity of the highlight given by the light in the material.
  38924. */
  38925. specularColor: Color3;
  38926. /**
  38927. * Define the color of the material as if self lit.
  38928. * This will be mixed in the final result even in the absence of light.
  38929. */
  38930. emissiveColor: Color3;
  38931. /**
  38932. * Defines how sharp are the highlights in the material.
  38933. * The bigger the value the sharper giving a more glossy feeling to the result.
  38934. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38935. */
  38936. specularPower: number;
  38937. private _useAlphaFromDiffuseTexture;
  38938. /**
  38939. * Does the transparency come from the diffuse texture alpha channel.
  38940. */
  38941. useAlphaFromDiffuseTexture: boolean;
  38942. private _useEmissiveAsIllumination;
  38943. /**
  38944. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38945. */
  38946. useEmissiveAsIllumination: boolean;
  38947. private _linkEmissiveWithDiffuse;
  38948. /**
  38949. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38950. * the emissive level when the final color is close to one.
  38951. */
  38952. linkEmissiveWithDiffuse: boolean;
  38953. private _useSpecularOverAlpha;
  38954. /**
  38955. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38956. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38957. */
  38958. useSpecularOverAlpha: boolean;
  38959. private _useReflectionOverAlpha;
  38960. /**
  38961. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38962. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38963. */
  38964. useReflectionOverAlpha: boolean;
  38965. private _disableLighting;
  38966. /**
  38967. * Does lights from the scene impacts this material.
  38968. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38969. */
  38970. disableLighting: boolean;
  38971. private _useObjectSpaceNormalMap;
  38972. /**
  38973. * Allows using an object space normal map (instead of tangent space).
  38974. */
  38975. useObjectSpaceNormalMap: boolean;
  38976. private _useParallax;
  38977. /**
  38978. * Is parallax enabled or not.
  38979. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38980. */
  38981. useParallax: boolean;
  38982. private _useParallaxOcclusion;
  38983. /**
  38984. * Is parallax occlusion enabled or not.
  38985. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38986. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38987. */
  38988. useParallaxOcclusion: boolean;
  38989. /**
  38990. * 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.
  38991. */
  38992. parallaxScaleBias: number;
  38993. private _roughness;
  38994. /**
  38995. * Helps to define how blurry the reflections should appears in the material.
  38996. */
  38997. roughness: number;
  38998. /**
  38999. * In case of refraction, define the value of the index of refraction.
  39000. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39001. */
  39002. indexOfRefraction: number;
  39003. /**
  39004. * Invert the refraction texture alongside the y axis.
  39005. * It can be useful with procedural textures or probe for instance.
  39006. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39007. */
  39008. invertRefractionY: boolean;
  39009. /**
  39010. * Defines the alpha limits in alpha test mode.
  39011. */
  39012. alphaCutOff: number;
  39013. private _useLightmapAsShadowmap;
  39014. /**
  39015. * In case of light mapping, define whether the map contains light or shadow informations.
  39016. */
  39017. useLightmapAsShadowmap: boolean;
  39018. private _diffuseFresnelParameters;
  39019. /**
  39020. * Define the diffuse fresnel parameters of the material.
  39021. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39022. */
  39023. diffuseFresnelParameters: FresnelParameters;
  39024. private _opacityFresnelParameters;
  39025. /**
  39026. * Define the opacity fresnel parameters of the material.
  39027. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39028. */
  39029. opacityFresnelParameters: FresnelParameters;
  39030. private _reflectionFresnelParameters;
  39031. /**
  39032. * Define the reflection fresnel parameters of the material.
  39033. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39034. */
  39035. reflectionFresnelParameters: FresnelParameters;
  39036. private _refractionFresnelParameters;
  39037. /**
  39038. * Define the refraction fresnel parameters of the material.
  39039. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39040. */
  39041. refractionFresnelParameters: FresnelParameters;
  39042. private _emissiveFresnelParameters;
  39043. /**
  39044. * Define the emissive fresnel parameters of the material.
  39045. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39046. */
  39047. emissiveFresnelParameters: FresnelParameters;
  39048. private _useReflectionFresnelFromSpecular;
  39049. /**
  39050. * If true automatically deducts the fresnels values from the material specularity.
  39051. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39052. */
  39053. useReflectionFresnelFromSpecular: boolean;
  39054. private _useGlossinessFromSpecularMapAlpha;
  39055. /**
  39056. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39057. */
  39058. useGlossinessFromSpecularMapAlpha: boolean;
  39059. private _maxSimultaneousLights;
  39060. /**
  39061. * Defines the maximum number of lights that can be used in the material
  39062. */
  39063. maxSimultaneousLights: number;
  39064. private _invertNormalMapX;
  39065. /**
  39066. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39067. */
  39068. invertNormalMapX: boolean;
  39069. private _invertNormalMapY;
  39070. /**
  39071. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39072. */
  39073. invertNormalMapY: boolean;
  39074. private _twoSidedLighting;
  39075. /**
  39076. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39077. */
  39078. twoSidedLighting: boolean;
  39079. /**
  39080. * Default configuration related to image processing available in the standard Material.
  39081. */
  39082. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39083. /**
  39084. * Gets the image processing configuration used either in this material.
  39085. */
  39086. /**
  39087. * Sets the Default image processing configuration used either in the this material.
  39088. *
  39089. * If sets to null, the scene one is in use.
  39090. */
  39091. imageProcessingConfiguration: ImageProcessingConfiguration;
  39092. /**
  39093. * Keep track of the image processing observer to allow dispose and replace.
  39094. */
  39095. private _imageProcessingObserver;
  39096. /**
  39097. * Attaches a new image processing configuration to the Standard Material.
  39098. * @param configuration
  39099. */
  39100. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39101. /**
  39102. * Gets wether the color curves effect is enabled.
  39103. */
  39104. /**
  39105. * Sets wether the color curves effect is enabled.
  39106. */
  39107. cameraColorCurvesEnabled: boolean;
  39108. /**
  39109. * Gets wether the color grading effect is enabled.
  39110. */
  39111. /**
  39112. * Gets wether the color grading effect is enabled.
  39113. */
  39114. cameraColorGradingEnabled: boolean;
  39115. /**
  39116. * Gets wether tonemapping is enabled or not.
  39117. */
  39118. /**
  39119. * Sets wether tonemapping is enabled or not
  39120. */
  39121. cameraToneMappingEnabled: boolean;
  39122. /**
  39123. * The camera exposure used on this material.
  39124. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39125. * This corresponds to a photographic exposure.
  39126. */
  39127. /**
  39128. * The camera exposure used on this material.
  39129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39130. * This corresponds to a photographic exposure.
  39131. */
  39132. cameraExposure: number;
  39133. /**
  39134. * Gets The camera contrast used on this material.
  39135. */
  39136. /**
  39137. * Sets The camera contrast used on this material.
  39138. */
  39139. cameraContrast: number;
  39140. /**
  39141. * Gets the Color Grading 2D Lookup Texture.
  39142. */
  39143. /**
  39144. * Sets the Color Grading 2D Lookup Texture.
  39145. */
  39146. cameraColorGradingTexture: Nullable<BaseTexture>;
  39147. /**
  39148. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39149. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39150. * 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;
  39151. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39152. */
  39153. /**
  39154. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39155. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39156. * 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;
  39157. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39158. */
  39159. cameraColorCurves: Nullable<ColorCurves>;
  39160. /**
  39161. * Custom callback helping to override the default shader used in the material.
  39162. */
  39163. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39164. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39165. protected _worldViewProjectionMatrix: Matrix;
  39166. protected _globalAmbientColor: Color3;
  39167. protected _useLogarithmicDepth: boolean;
  39168. /**
  39169. * Instantiates a new standard material.
  39170. * This is the default material used in Babylon. It is the best trade off between quality
  39171. * and performances.
  39172. * @see http://doc.babylonjs.com/babylon101/materials
  39173. * @param name Define the name of the material in the scene
  39174. * @param scene Define the scene the material belong to
  39175. */
  39176. constructor(name: string, scene: Scene);
  39177. /**
  39178. * Gets a boolean indicating that current material needs to register RTT
  39179. */
  39180. readonly hasRenderTargetTextures: boolean;
  39181. /**
  39182. * Gets the current class name of the material e.g. "StandardMaterial"
  39183. * Mainly use in serialization.
  39184. * @returns the class name
  39185. */
  39186. getClassName(): string;
  39187. /**
  39188. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39189. * You can try switching to logarithmic depth.
  39190. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39191. */
  39192. useLogarithmicDepth: boolean;
  39193. /**
  39194. * Specifies if the material will require alpha blending
  39195. * @returns a boolean specifying if alpha blending is needed
  39196. */
  39197. needAlphaBlending(): boolean;
  39198. /**
  39199. * Specifies if this material should be rendered in alpha test mode
  39200. * @returns a boolean specifying if an alpha test is needed.
  39201. */
  39202. needAlphaTesting(): boolean;
  39203. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39204. /**
  39205. * Get the texture used for alpha test purpose.
  39206. * @returns the diffuse texture in case of the standard material.
  39207. */
  39208. getAlphaTestTexture(): Nullable<BaseTexture>;
  39209. /**
  39210. * Get if the submesh is ready to be used and all its information available.
  39211. * Child classes can use it to update shaders
  39212. * @param mesh defines the mesh to check
  39213. * @param subMesh defines which submesh to check
  39214. * @param useInstances specifies that instances should be used
  39215. * @returns a boolean indicating that the submesh is ready or not
  39216. */
  39217. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39218. /**
  39219. * Builds the material UBO layouts.
  39220. * Used internally during the effect preparation.
  39221. */
  39222. buildUniformLayout(): void;
  39223. /**
  39224. * Unbinds the material from the mesh
  39225. */
  39226. unbind(): void;
  39227. /**
  39228. * Binds the submesh to this material by preparing the effect and shader to draw
  39229. * @param world defines the world transformation matrix
  39230. * @param mesh defines the mesh containing the submesh
  39231. * @param subMesh defines the submesh to bind the material to
  39232. */
  39233. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39234. /**
  39235. * Get the list of animatables in the material.
  39236. * @returns the list of animatables object used in the material
  39237. */
  39238. getAnimatables(): IAnimatable[];
  39239. /**
  39240. * Gets the active textures from the material
  39241. * @returns an array of textures
  39242. */
  39243. getActiveTextures(): BaseTexture[];
  39244. /**
  39245. * Specifies if the material uses a texture
  39246. * @param texture defines the texture to check against the material
  39247. * @returns a boolean specifying if the material uses the texture
  39248. */
  39249. hasTexture(texture: BaseTexture): boolean;
  39250. /**
  39251. * Disposes the material
  39252. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39253. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39254. */
  39255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39256. /**
  39257. * Makes a duplicate of the material, and gives it a new name
  39258. * @param name defines the new name for the duplicated material
  39259. * @returns the cloned material
  39260. */
  39261. clone(name: string): StandardMaterial;
  39262. /**
  39263. * Serializes this material in a JSON representation
  39264. * @returns the serialized material object
  39265. */
  39266. serialize(): any;
  39267. /**
  39268. * Creates a standard material from parsed material data
  39269. * @param source defines the JSON representation of the material
  39270. * @param scene defines the hosting scene
  39271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39272. * @returns a new standard material
  39273. */
  39274. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39275. /**
  39276. * Are diffuse textures enabled in the application.
  39277. */
  39278. static DiffuseTextureEnabled: boolean;
  39279. /**
  39280. * Are ambient textures enabled in the application.
  39281. */
  39282. static AmbientTextureEnabled: boolean;
  39283. /**
  39284. * Are opacity textures enabled in the application.
  39285. */
  39286. static OpacityTextureEnabled: boolean;
  39287. /**
  39288. * Are reflection textures enabled in the application.
  39289. */
  39290. static ReflectionTextureEnabled: boolean;
  39291. /**
  39292. * Are emissive textures enabled in the application.
  39293. */
  39294. static EmissiveTextureEnabled: boolean;
  39295. /**
  39296. * Are specular textures enabled in the application.
  39297. */
  39298. static SpecularTextureEnabled: boolean;
  39299. /**
  39300. * Are bump textures enabled in the application.
  39301. */
  39302. static BumpTextureEnabled: boolean;
  39303. /**
  39304. * Are lightmap textures enabled in the application.
  39305. */
  39306. static LightmapTextureEnabled: boolean;
  39307. /**
  39308. * Are refraction textures enabled in the application.
  39309. */
  39310. static RefractionTextureEnabled: boolean;
  39311. /**
  39312. * Are color grading textures enabled in the application.
  39313. */
  39314. static ColorGradingTextureEnabled: boolean;
  39315. /**
  39316. * Are fresnels enabled in the application.
  39317. */
  39318. static FresnelEnabled: boolean;
  39319. }
  39320. }
  39321. declare module BABYLON {
  39322. /**
  39323. * A class extending Texture allowing drawing on a texture
  39324. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39325. */
  39326. export class DynamicTexture extends Texture {
  39327. private _generateMipMaps;
  39328. private _canvas;
  39329. private _context;
  39330. private _engine;
  39331. /**
  39332. * Creates a DynamicTexture
  39333. * @param name defines the name of the texture
  39334. * @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
  39335. * @param scene defines the scene where you want the texture
  39336. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39337. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39338. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39339. */
  39340. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39341. /**
  39342. * Get the current class name of the texture useful for serialization or dynamic coding.
  39343. * @returns "DynamicTexture"
  39344. */
  39345. getClassName(): string;
  39346. /**
  39347. * Gets the current state of canRescale
  39348. */
  39349. readonly canRescale: boolean;
  39350. private _recreate;
  39351. /**
  39352. * Scales the texture
  39353. * @param ratio the scale factor to apply to both width and height
  39354. */
  39355. scale(ratio: number): void;
  39356. /**
  39357. * Resizes the texture
  39358. * @param width the new width
  39359. * @param height the new height
  39360. */
  39361. scaleTo(width: number, height: number): void;
  39362. /**
  39363. * Gets the context of the canvas used by the texture
  39364. * @returns the canvas context of the dynamic texture
  39365. */
  39366. getContext(): CanvasRenderingContext2D;
  39367. /**
  39368. * Clears the texture
  39369. */
  39370. clear(): void;
  39371. /**
  39372. * Updates the texture
  39373. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39374. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39375. */
  39376. update(invertY?: boolean, premulAlpha?: boolean): void;
  39377. /**
  39378. * Draws text onto the texture
  39379. * @param text defines the text to be drawn
  39380. * @param x defines the placement of the text from the left
  39381. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39382. * @param font defines the font to be used with font-style, font-size, font-name
  39383. * @param color defines the color used for the text
  39384. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39385. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39386. * @param update defines whether texture is immediately update (default is true)
  39387. */
  39388. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39389. /**
  39390. * Clones the texture
  39391. * @returns the clone of the texture.
  39392. */
  39393. clone(): DynamicTexture;
  39394. /**
  39395. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39396. * @returns a serialized dynamic texture object
  39397. */
  39398. serialize(): any;
  39399. /** @hidden */ private _rebuild(): void;
  39400. }
  39401. }
  39402. declare module BABYLON {
  39403. /** @hidden */
  39404. export var imageProcessingPixelShader: {
  39405. name: string;
  39406. shader: string;
  39407. };
  39408. }
  39409. declare module BABYLON {
  39410. /**
  39411. * ImageProcessingPostProcess
  39412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39413. */
  39414. export class ImageProcessingPostProcess extends PostProcess {
  39415. /**
  39416. * Default configuration related to image processing available in the PBR Material.
  39417. */
  39418. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39419. /**
  39420. * Gets the image processing configuration used either in this material.
  39421. */
  39422. /**
  39423. * Sets the Default image processing configuration used either in the this material.
  39424. *
  39425. * If sets to null, the scene one is in use.
  39426. */
  39427. imageProcessingConfiguration: ImageProcessingConfiguration;
  39428. /**
  39429. * Keep track of the image processing observer to allow dispose and replace.
  39430. */
  39431. private _imageProcessingObserver;
  39432. /**
  39433. * Attaches a new image processing configuration to the PBR Material.
  39434. * @param configuration
  39435. */
  39436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39437. /**
  39438. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39439. */
  39440. /**
  39441. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39442. */
  39443. colorCurves: Nullable<ColorCurves>;
  39444. /**
  39445. * Gets wether the color curves effect is enabled.
  39446. */
  39447. /**
  39448. * Sets wether the color curves effect is enabled.
  39449. */
  39450. colorCurvesEnabled: boolean;
  39451. /**
  39452. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39453. */
  39454. /**
  39455. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39456. */
  39457. colorGradingTexture: Nullable<BaseTexture>;
  39458. /**
  39459. * Gets wether the color grading effect is enabled.
  39460. */
  39461. /**
  39462. * Gets wether the color grading effect is enabled.
  39463. */
  39464. colorGradingEnabled: boolean;
  39465. /**
  39466. * Gets exposure used in the effect.
  39467. */
  39468. /**
  39469. * Sets exposure used in the effect.
  39470. */
  39471. exposure: number;
  39472. /**
  39473. * Gets wether tonemapping is enabled or not.
  39474. */
  39475. /**
  39476. * Sets wether tonemapping is enabled or not
  39477. */
  39478. toneMappingEnabled: boolean;
  39479. /**
  39480. * Gets the type of tone mapping effect.
  39481. */
  39482. /**
  39483. * Sets the type of tone mapping effect.
  39484. */
  39485. toneMappingType: number;
  39486. /**
  39487. * Gets contrast used in the effect.
  39488. */
  39489. /**
  39490. * Sets contrast used in the effect.
  39491. */
  39492. contrast: number;
  39493. /**
  39494. * Gets Vignette stretch size.
  39495. */
  39496. /**
  39497. * Sets Vignette stretch size.
  39498. */
  39499. vignetteStretch: number;
  39500. /**
  39501. * Gets Vignette centre X Offset.
  39502. */
  39503. /**
  39504. * Sets Vignette centre X Offset.
  39505. */
  39506. vignetteCentreX: number;
  39507. /**
  39508. * Gets Vignette centre Y Offset.
  39509. */
  39510. /**
  39511. * Sets Vignette centre Y Offset.
  39512. */
  39513. vignetteCentreY: number;
  39514. /**
  39515. * Gets Vignette weight or intensity of the vignette effect.
  39516. */
  39517. /**
  39518. * Sets Vignette weight or intensity of the vignette effect.
  39519. */
  39520. vignetteWeight: number;
  39521. /**
  39522. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39523. * if vignetteEnabled is set to true.
  39524. */
  39525. /**
  39526. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39527. * if vignetteEnabled is set to true.
  39528. */
  39529. vignetteColor: Color4;
  39530. /**
  39531. * Gets Camera field of view used by the Vignette effect.
  39532. */
  39533. /**
  39534. * Sets Camera field of view used by the Vignette effect.
  39535. */
  39536. vignetteCameraFov: number;
  39537. /**
  39538. * Gets the vignette blend mode allowing different kind of effect.
  39539. */
  39540. /**
  39541. * Sets the vignette blend mode allowing different kind of effect.
  39542. */
  39543. vignetteBlendMode: number;
  39544. /**
  39545. * Gets wether the vignette effect is enabled.
  39546. */
  39547. /**
  39548. * Sets wether the vignette effect is enabled.
  39549. */
  39550. vignetteEnabled: boolean;
  39551. private _fromLinearSpace;
  39552. /**
  39553. * Gets wether the input of the processing is in Gamma or Linear Space.
  39554. */
  39555. /**
  39556. * Sets wether the input of the processing is in Gamma or Linear Space.
  39557. */
  39558. fromLinearSpace: boolean;
  39559. /**
  39560. * Defines cache preventing GC.
  39561. */
  39562. private _defines;
  39563. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39564. /**
  39565. * "ImageProcessingPostProcess"
  39566. * @returns "ImageProcessingPostProcess"
  39567. */
  39568. getClassName(): string;
  39569. protected _updateParameters(): void;
  39570. dispose(camera?: Camera): void;
  39571. }
  39572. }
  39573. declare module BABYLON {
  39574. /**
  39575. * Class containing static functions to help procedurally build meshes
  39576. */
  39577. export class GroundBuilder {
  39578. /**
  39579. * Creates a ground mesh
  39580. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39581. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39583. * @param name defines the name of the mesh
  39584. * @param options defines the options used to create the mesh
  39585. * @param scene defines the hosting scene
  39586. * @returns the ground mesh
  39587. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39588. */
  39589. static CreateGround(name: string, options: {
  39590. width?: number;
  39591. height?: number;
  39592. subdivisions?: number;
  39593. subdivisionsX?: number;
  39594. subdivisionsY?: number;
  39595. updatable?: boolean;
  39596. }, scene: any): Mesh;
  39597. /**
  39598. * Creates a tiled ground mesh
  39599. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39600. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39601. * * 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
  39602. * * 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
  39603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39604. * @param name defines the name of the mesh
  39605. * @param options defines the options used to create the mesh
  39606. * @param scene defines the hosting scene
  39607. * @returns the tiled ground mesh
  39608. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39609. */
  39610. static CreateTiledGround(name: string, options: {
  39611. xmin: number;
  39612. zmin: number;
  39613. xmax: number;
  39614. zmax: number;
  39615. subdivisions?: {
  39616. w: number;
  39617. h: number;
  39618. };
  39619. precision?: {
  39620. w: number;
  39621. h: number;
  39622. };
  39623. updatable?: boolean;
  39624. }, scene?: Nullable<Scene>): Mesh;
  39625. /**
  39626. * Creates a ground mesh from a height map
  39627. * * The parameter `url` sets the URL of the height map image resource.
  39628. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39629. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39630. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39631. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39632. * * 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.
  39633. * * 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).
  39634. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39636. * @param name defines the name of the mesh
  39637. * @param url defines the url to the height map
  39638. * @param options defines the options used to create the mesh
  39639. * @param scene defines the hosting scene
  39640. * @returns the ground mesh
  39641. * @see https://doc.babylonjs.com/babylon101/height_map
  39642. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39643. */
  39644. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39645. width?: number;
  39646. height?: number;
  39647. subdivisions?: number;
  39648. minHeight?: number;
  39649. maxHeight?: number;
  39650. colorFilter?: Color3;
  39651. alphaFilter?: number;
  39652. updatable?: boolean;
  39653. onReady?: (mesh: GroundMesh) => void;
  39654. }, scene?: Nullable<Scene>): GroundMesh;
  39655. }
  39656. }
  39657. declare module BABYLON {
  39658. /**
  39659. * Class containing static functions to help procedurally build meshes
  39660. */
  39661. export class TorusBuilder {
  39662. /**
  39663. * Creates a torus mesh
  39664. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39665. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39666. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39668. * * 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
  39669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39670. * @param name defines the name of the mesh
  39671. * @param options defines the options used to create the mesh
  39672. * @param scene defines the hosting scene
  39673. * @returns the torus mesh
  39674. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39675. */
  39676. static CreateTorus(name: string, options: {
  39677. diameter?: number;
  39678. thickness?: number;
  39679. tessellation?: number;
  39680. updatable?: boolean;
  39681. sideOrientation?: number;
  39682. frontUVs?: Vector4;
  39683. backUVs?: Vector4;
  39684. }, scene: any): Mesh;
  39685. }
  39686. }
  39687. declare module BABYLON {
  39688. /**
  39689. * Class containing static functions to help procedurally build meshes
  39690. */
  39691. export class CylinderBuilder {
  39692. /**
  39693. * Creates a cylinder or a cone mesh
  39694. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39695. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39696. * * 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.
  39697. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39698. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39699. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39700. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39701. * * 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).
  39702. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39703. * * 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).
  39704. * * 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
  39705. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39706. * * 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
  39707. * * 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.
  39708. * * If `enclose` is false, a ring surface is one element.
  39709. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39710. * * 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
  39711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39712. * * 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
  39713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39714. * @param name defines the name of the mesh
  39715. * @param options defines the options used to create the mesh
  39716. * @param scene defines the hosting scene
  39717. * @returns the cylinder mesh
  39718. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39719. */
  39720. static CreateCylinder(name: string, options: {
  39721. height?: number;
  39722. diameterTop?: number;
  39723. diameterBottom?: number;
  39724. diameter?: number;
  39725. tessellation?: number;
  39726. subdivisions?: number;
  39727. arc?: number;
  39728. faceColors?: Color4[];
  39729. faceUV?: Vector4[];
  39730. updatable?: boolean;
  39731. hasRings?: boolean;
  39732. enclose?: boolean;
  39733. cap?: number;
  39734. sideOrientation?: number;
  39735. frontUVs?: Vector4;
  39736. backUVs?: Vector4;
  39737. }, scene: any): Mesh;
  39738. }
  39739. }
  39740. declare module BABYLON {
  39741. /**
  39742. * Options to modify the vr teleportation behavior.
  39743. */
  39744. export interface VRTeleportationOptions {
  39745. /**
  39746. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39747. */
  39748. floorMeshName?: string;
  39749. /**
  39750. * A list of meshes to be used as the teleportation floor. (default: empty)
  39751. */
  39752. floorMeshes?: Mesh[];
  39753. }
  39754. /**
  39755. * Options to modify the vr experience helper's behavior.
  39756. */
  39757. export interface VRExperienceHelperOptions extends WebVROptions {
  39758. /**
  39759. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39760. */
  39761. createDeviceOrientationCamera?: boolean;
  39762. /**
  39763. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39764. */
  39765. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39766. /**
  39767. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39768. */
  39769. laserToggle?: boolean;
  39770. /**
  39771. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39772. */
  39773. floorMeshes?: Mesh[];
  39774. /**
  39775. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39776. */
  39777. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39778. }
  39779. /**
  39780. * Event containing information after VR has been entered
  39781. */
  39782. export class OnAfterEnteringVRObservableEvent {
  39783. /**
  39784. * If entering vr was successful
  39785. */
  39786. success: boolean;
  39787. }
  39788. /**
  39789. * Helps to quickly add VR support to an existing scene.
  39790. * See http://doc.babylonjs.com/how_to/webvr_helper
  39791. */
  39792. export class VRExperienceHelper {
  39793. /** Options to modify the vr experience helper's behavior. */
  39794. webVROptions: VRExperienceHelperOptions;
  39795. private _scene;
  39796. private _position;
  39797. private _btnVR;
  39798. private _btnVRDisplayed;
  39799. private _webVRsupported;
  39800. private _webVRready;
  39801. private _webVRrequesting;
  39802. private _webVRpresenting;
  39803. private _hasEnteredVR;
  39804. private _fullscreenVRpresenting;
  39805. private _canvas;
  39806. private _webVRCamera;
  39807. private _vrDeviceOrientationCamera;
  39808. private _deviceOrientationCamera;
  39809. private _existingCamera;
  39810. private _onKeyDown;
  39811. private _onVrDisplayPresentChange;
  39812. private _onVRDisplayChanged;
  39813. private _onVRRequestPresentStart;
  39814. private _onVRRequestPresentComplete;
  39815. /**
  39816. * 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)
  39817. */
  39818. enableGazeEvenWhenNoPointerLock: boolean;
  39819. /**
  39820. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  39821. */
  39822. exitVROnDoubleTap: boolean;
  39823. /**
  39824. * Observable raised right before entering VR.
  39825. */
  39826. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39827. /**
  39828. * Observable raised when entering VR has completed.
  39829. */
  39830. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39831. /**
  39832. * Observable raised when exiting VR.
  39833. */
  39834. onExitingVRObservable: Observable<VRExperienceHelper>;
  39835. /**
  39836. * Observable raised when controller mesh is loaded.
  39837. */
  39838. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39839. /** Return this.onEnteringVRObservable
  39840. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39841. */
  39842. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39843. /** Return this.onExitingVRObservable
  39844. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39845. */
  39846. readonly onExitingVR: Observable<VRExperienceHelper>;
  39847. /** Return this.onControllerMeshLoadedObservable
  39848. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39849. */
  39850. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39851. private _rayLength;
  39852. private _useCustomVRButton;
  39853. private _teleportationRequested;
  39854. private _teleportActive;
  39855. private _floorMeshName;
  39856. private _floorMeshesCollection;
  39857. private _rotationAllowed;
  39858. private _teleportBackwardsVector;
  39859. private _teleportationTarget;
  39860. private _isDefaultTeleportationTarget;
  39861. private _postProcessMove;
  39862. private _teleportationFillColor;
  39863. private _teleportationBorderColor;
  39864. private _rotationAngle;
  39865. private _haloCenter;
  39866. private _cameraGazer;
  39867. private _padSensibilityUp;
  39868. private _padSensibilityDown;
  39869. private _leftController;
  39870. private _rightController;
  39871. /**
  39872. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39873. */
  39874. onNewMeshSelected: Observable<AbstractMesh>;
  39875. /**
  39876. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39877. */
  39878. onNewMeshPicked: Observable<PickingInfo>;
  39879. private _circleEase;
  39880. /**
  39881. * Observable raised before camera teleportation
  39882. */
  39883. onBeforeCameraTeleport: Observable<Vector3>;
  39884. /**
  39885. * Observable raised after camera teleportation
  39886. */
  39887. onAfterCameraTeleport: Observable<Vector3>;
  39888. /**
  39889. * Observable raised when current selected mesh gets unselected
  39890. */
  39891. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39892. private _raySelectionPredicate;
  39893. /**
  39894. * To be optionaly changed by user to define custom ray selection
  39895. */
  39896. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39897. /**
  39898. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39899. */
  39900. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39901. /**
  39902. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39903. */
  39904. teleportationEnabled: boolean;
  39905. private _defaultHeight;
  39906. private _teleportationInitialized;
  39907. private _interactionsEnabled;
  39908. private _interactionsRequested;
  39909. private _displayGaze;
  39910. private _displayLaserPointer;
  39911. /**
  39912. * The mesh used to display where the user is going to teleport.
  39913. */
  39914. /**
  39915. * Sets the mesh to be used to display where the user is going to teleport.
  39916. */
  39917. teleportationTarget: Mesh;
  39918. /**
  39919. * 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
  39920. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39921. * See http://doc.babylonjs.com/resources/baking_transformations
  39922. */
  39923. gazeTrackerMesh: Mesh;
  39924. /**
  39925. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39926. */
  39927. updateGazeTrackerScale: boolean;
  39928. /**
  39929. * If the gaze trackers color should be updated when selecting meshes
  39930. */
  39931. updateGazeTrackerColor: boolean;
  39932. /**
  39933. * The gaze tracking mesh corresponding to the left controller
  39934. */
  39935. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39936. /**
  39937. * The gaze tracking mesh corresponding to the right controller
  39938. */
  39939. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39940. /**
  39941. * If the ray of the gaze should be displayed.
  39942. */
  39943. /**
  39944. * Sets if the ray of the gaze should be displayed.
  39945. */
  39946. displayGaze: boolean;
  39947. /**
  39948. * If the ray of the LaserPointer should be displayed.
  39949. */
  39950. /**
  39951. * Sets if the ray of the LaserPointer should be displayed.
  39952. */
  39953. displayLaserPointer: boolean;
  39954. /**
  39955. * The deviceOrientationCamera used as the camera when not in VR.
  39956. */
  39957. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39958. /**
  39959. * Based on the current WebVR support, returns the current VR camera used.
  39960. */
  39961. readonly currentVRCamera: Nullable<Camera>;
  39962. /**
  39963. * The webVRCamera which is used when in VR.
  39964. */
  39965. readonly webVRCamera: WebVRFreeCamera;
  39966. /**
  39967. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39968. */
  39969. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39970. /**
  39971. * The html button that is used to trigger entering into VR.
  39972. */
  39973. readonly vrButton: Nullable<HTMLButtonElement>;
  39974. private readonly _teleportationRequestInitiated;
  39975. /**
  39976. * Defines wether or not Pointer lock should be requested when switching to
  39977. * full screen.
  39978. */
  39979. requestPointerLockOnFullScreen: boolean;
  39980. /**
  39981. * Instantiates a VRExperienceHelper.
  39982. * Helps to quickly add VR support to an existing scene.
  39983. * @param scene The scene the VRExperienceHelper belongs to.
  39984. * @param webVROptions Options to modify the vr experience helper's behavior.
  39985. */
  39986. constructor(scene: Scene,
  39987. /** Options to modify the vr experience helper's behavior. */
  39988. webVROptions?: VRExperienceHelperOptions);
  39989. private _onDefaultMeshLoaded;
  39990. private _onResize;
  39991. private _onFullscreenChange;
  39992. /**
  39993. * Gets a value indicating if we are currently in VR mode.
  39994. */
  39995. readonly isInVRMode: boolean;
  39996. private onVrDisplayPresentChange;
  39997. private onVRDisplayChanged;
  39998. private moveButtonToBottomRight;
  39999. private displayVRButton;
  40000. private updateButtonVisibility;
  40001. private _cachedAngularSensibility;
  40002. /**
  40003. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40004. * Otherwise, will use the fullscreen API.
  40005. */
  40006. enterVR(): void;
  40007. /**
  40008. * Attempt to exit VR, or fullscreen.
  40009. */
  40010. exitVR(): void;
  40011. /**
  40012. * The position of the vr experience helper.
  40013. */
  40014. /**
  40015. * Sets the position of the vr experience helper.
  40016. */
  40017. position: Vector3;
  40018. /**
  40019. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40020. */
  40021. enableInteractions(): void;
  40022. private readonly _noControllerIsActive;
  40023. private beforeRender;
  40024. private _isTeleportationFloor;
  40025. /**
  40026. * Adds a floor mesh to be used for teleportation.
  40027. * @param floorMesh the mesh to be used for teleportation.
  40028. */
  40029. addFloorMesh(floorMesh: Mesh): void;
  40030. /**
  40031. * Removes a floor mesh from being used for teleportation.
  40032. * @param floorMesh the mesh to be removed.
  40033. */
  40034. removeFloorMesh(floorMesh: Mesh): void;
  40035. /**
  40036. * Enables interactions and teleportation using the VR controllers and gaze.
  40037. * @param vrTeleportationOptions options to modify teleportation behavior.
  40038. */
  40039. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40040. private _onNewGamepadConnected;
  40041. private _tryEnableInteractionOnController;
  40042. private _onNewGamepadDisconnected;
  40043. private _enableInteractionOnController;
  40044. private _checkTeleportWithRay;
  40045. private _checkRotate;
  40046. private _checkTeleportBackwards;
  40047. private _enableTeleportationOnController;
  40048. private _createTeleportationCircles;
  40049. private _displayTeleportationTarget;
  40050. private _hideTeleportationTarget;
  40051. private _rotateCamera;
  40052. private _moveTeleportationSelectorTo;
  40053. private _workingVector;
  40054. private _workingQuaternion;
  40055. private _workingMatrix;
  40056. /**
  40057. * Teleports the users feet to the desired location
  40058. * @param location The location where the user's feet should be placed
  40059. */
  40060. teleportCamera(location: Vector3): void;
  40061. private _convertNormalToDirectionOfRay;
  40062. private _castRayAndSelectObject;
  40063. private _notifySelectedMeshUnselected;
  40064. /**
  40065. * Sets the color of the laser ray from the vr controllers.
  40066. * @param color new color for the ray.
  40067. */
  40068. changeLaserColor(color: Color3): void;
  40069. /**
  40070. * Sets the color of the ray from the vr headsets gaze.
  40071. * @param color new color for the ray.
  40072. */
  40073. changeGazeColor(color: Color3): void;
  40074. /**
  40075. * Exits VR and disposes of the vr experience helper
  40076. */
  40077. dispose(): void;
  40078. /**
  40079. * Gets the name of the VRExperienceHelper class
  40080. * @returns "VRExperienceHelper"
  40081. */
  40082. getClassName(): string;
  40083. }
  40084. }
  40085. declare module BABYLON {
  40086. /**
  40087. * Manages an XRSession to work with Babylon's engine
  40088. * @see https://doc.babylonjs.com/how_to/webxr
  40089. */
  40090. export class WebXRSessionManager implements IDisposable {
  40091. private scene;
  40092. /**
  40093. * Fires every time a new xrFrame arrives which can be used to update the camera
  40094. */
  40095. onXRFrameObservable: Observable<any>;
  40096. /**
  40097. * Fires when the xr session is ended either by the device or manually done
  40098. */
  40099. onXRSessionEnded: Observable<any>;
  40100. /**
  40101. * Underlying xr session
  40102. */
  40103. session: XRSession;
  40104. /**
  40105. * Type of reference space used when creating the session
  40106. */
  40107. referenceSpace: XRReferenceSpace;
  40108. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40109. /**
  40110. * Current XR frame
  40111. */
  40112. currentFrame: Nullable<XRFrame>;
  40113. private _xrNavigator;
  40114. private baseLayer;
  40115. /**
  40116. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40117. * @param scene The scene which the session should be created for
  40118. */
  40119. constructor(scene: Scene);
  40120. /**
  40121. * Initializes the manager
  40122. * After initialization enterXR can be called to start an XR session
  40123. * @returns Promise which resolves after it is initialized
  40124. */
  40125. initializeAsync(): Promise<void>;
  40126. /**
  40127. * Initializes an xr session
  40128. * @param xrSessionMode mode to initialize
  40129. * @returns a promise which will resolve once the session has been initialized
  40130. */
  40131. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40132. /**
  40133. * Sets the reference space on the xr session
  40134. * @param referenceSpace space to set
  40135. * @returns a promise that will resolve once the reference space has been set
  40136. */
  40137. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40138. /**
  40139. * Updates the render state of the session
  40140. * @param state state to set
  40141. * @returns a promise that resolves once the render state has been updated
  40142. */
  40143. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40144. /**
  40145. * Starts rendering to the xr layer
  40146. * @returns a promise that will resolve once rendering has started
  40147. */
  40148. startRenderingToXRAsync(): Promise<void>;
  40149. /**
  40150. * Stops the xrSession and restores the renderloop
  40151. * @returns Promise which resolves after it exits XR
  40152. */
  40153. exitXRAsync(): Promise<unknown>;
  40154. /**
  40155. * Checks if a session would be supported for the creation options specified
  40156. * @param sessionMode session mode to check if supported eg. immersive-vr
  40157. * @returns true if supported
  40158. */
  40159. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40160. /**
  40161. * @hidden
  40162. * Converts the render layer of xrSession to a render target
  40163. * @param session session to create render target for
  40164. * @param scene scene the new render target should be created for
  40165. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40166. /**
  40167. * Disposes of the session manager
  40168. */
  40169. dispose(): void;
  40170. }
  40171. }
  40172. declare module BABYLON {
  40173. /**
  40174. * WebXR Camera which holds the views for the xrSession
  40175. * @see https://doc.babylonjs.com/how_to/webxr
  40176. */
  40177. export class WebXRCamera extends FreeCamera {
  40178. private static _TmpMatrix;
  40179. /**
  40180. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40181. * @param name the name of the camera
  40182. * @param scene the scene to add the camera to
  40183. */
  40184. constructor(name: string, scene: Scene);
  40185. private _updateNumberOfRigCameras;
  40186. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40187. /**
  40188. * Updates the cameras position from the current pose information of the XR session
  40189. * @param xrSessionManager the session containing pose information
  40190. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40191. */
  40192. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40193. }
  40194. }
  40195. declare module BABYLON {
  40196. /**
  40197. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40198. */
  40199. export class WebXRManagedOutputCanvas implements IDisposable {
  40200. private helper;
  40201. private _canvas;
  40202. /**
  40203. * xrpresent context of the canvas which can be used to display/mirror xr content
  40204. */
  40205. canvasContext: WebGLRenderingContext;
  40206. /**
  40207. * xr layer for the canvas
  40208. */
  40209. xrLayer: Nullable<XRWebGLLayer>;
  40210. /**
  40211. * Initializes the xr layer for the session
  40212. * @param xrSession xr session
  40213. * @returns a promise that will resolve once the XR Layer has been created
  40214. */
  40215. initializeXRLayerAsync(xrSession: any): any;
  40216. /**
  40217. * Initializes the canvas to be added/removed upon entering/exiting xr
  40218. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40219. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40220. */
  40221. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40222. /**
  40223. * Disposes of the object
  40224. */
  40225. dispose(): void;
  40226. private _setManagedOutputCanvas;
  40227. private _addCanvas;
  40228. private _removeCanvas;
  40229. }
  40230. }
  40231. declare module BABYLON {
  40232. /**
  40233. * States of the webXR experience
  40234. */
  40235. export enum WebXRState {
  40236. /**
  40237. * Transitioning to being in XR mode
  40238. */
  40239. ENTERING_XR = 0,
  40240. /**
  40241. * Transitioning to non XR mode
  40242. */
  40243. EXITING_XR = 1,
  40244. /**
  40245. * In XR mode and presenting
  40246. */
  40247. IN_XR = 2,
  40248. /**
  40249. * Not entered XR mode
  40250. */
  40251. NOT_IN_XR = 3
  40252. }
  40253. /**
  40254. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40255. * @see https://doc.babylonjs.com/how_to/webxr
  40256. */
  40257. export class WebXRExperienceHelper implements IDisposable {
  40258. private scene;
  40259. /**
  40260. * 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
  40261. */
  40262. container: AbstractMesh;
  40263. /**
  40264. * Camera used to render xr content
  40265. */
  40266. camera: WebXRCamera;
  40267. /**
  40268. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40269. */
  40270. state: WebXRState;
  40271. private _setState;
  40272. private static _TmpVector;
  40273. /**
  40274. * Fires when the state of the experience helper has changed
  40275. */
  40276. onStateChangedObservable: Observable<WebXRState>;
  40277. /** Session manager used to keep track of xr session */
  40278. sessionManager: WebXRSessionManager;
  40279. private _nonVRCamera;
  40280. private _originalSceneAutoClear;
  40281. private _supported;
  40282. /**
  40283. * Creates the experience helper
  40284. * @param scene the scene to attach the experience helper to
  40285. * @returns a promise for the experience helper
  40286. */
  40287. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40288. /**
  40289. * Creates a WebXRExperienceHelper
  40290. * @param scene The scene the helper should be created in
  40291. */
  40292. private constructor();
  40293. /**
  40294. * Exits XR mode and returns the scene to its original state
  40295. * @returns promise that resolves after xr mode has exited
  40296. */
  40297. exitXRAsync(): Promise<unknown>;
  40298. /**
  40299. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40300. * @param sessionCreationOptions options for the XR session
  40301. * @param referenceSpaceType frame of reference of the XR session
  40302. * @param outputCanvas the output canvas that will be used to enter XR mode
  40303. * @returns promise that resolves after xr mode has entered
  40304. */
  40305. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40306. /**
  40307. * Updates the global position of the camera by moving the camera's container
  40308. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40309. * @param position The desired global position of the camera
  40310. */
  40311. setPositionOfCameraUsingContainer(position: Vector3): void;
  40312. /**
  40313. * Rotates the xr camera by rotating the camera's container around the camera's position
  40314. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40315. * @param rotation the desired quaternion rotation to apply to the camera
  40316. */
  40317. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40318. /**
  40319. * Disposes of the experience helper
  40320. */
  40321. dispose(): void;
  40322. }
  40323. }
  40324. declare module BABYLON {
  40325. /**
  40326. * Button which can be used to enter a different mode of XR
  40327. */
  40328. export class WebXREnterExitUIButton {
  40329. /** button element */
  40330. element: HTMLElement;
  40331. /** XR initialization options for the button */
  40332. sessionMode: XRSessionMode;
  40333. /** Reference space type */
  40334. referenceSpaceType: XRReferenceSpaceType;
  40335. /**
  40336. * Creates a WebXREnterExitUIButton
  40337. * @param element button element
  40338. * @param sessionMode XR initialization session mode
  40339. * @param referenceSpaceType the type of reference space to be used
  40340. */
  40341. constructor(
  40342. /** button element */
  40343. element: HTMLElement,
  40344. /** XR initialization options for the button */
  40345. sessionMode: XRSessionMode,
  40346. /** Reference space type */
  40347. referenceSpaceType: XRReferenceSpaceType);
  40348. /**
  40349. * Overwritable function which can be used to update the button's visuals when the state changes
  40350. * @param activeButton the current active button in the UI
  40351. */
  40352. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40353. }
  40354. /**
  40355. * Options to create the webXR UI
  40356. */
  40357. export class WebXREnterExitUIOptions {
  40358. /**
  40359. * Context to enter xr with
  40360. */
  40361. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40362. /**
  40363. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40364. */
  40365. customButtons?: Array<WebXREnterExitUIButton>;
  40366. }
  40367. /**
  40368. * UI to allow the user to enter/exit XR mode
  40369. */
  40370. export class WebXREnterExitUI implements IDisposable {
  40371. private scene;
  40372. private _overlay;
  40373. private _buttons;
  40374. private _activeButton;
  40375. /**
  40376. * Fired every time the active button is changed.
  40377. *
  40378. * When xr is entered via a button that launches xr that button will be the callback parameter
  40379. *
  40380. * When exiting xr the callback parameter will be null)
  40381. */
  40382. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40383. /**
  40384. * Creates UI to allow the user to enter/exit XR mode
  40385. * @param scene the scene to add the ui to
  40386. * @param helper the xr experience helper to enter/exit xr with
  40387. * @param options options to configure the UI
  40388. * @returns the created ui
  40389. */
  40390. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40391. private constructor();
  40392. private _updateButtons;
  40393. /**
  40394. * Disposes of the object
  40395. */
  40396. dispose(): void;
  40397. }
  40398. }
  40399. declare module BABYLON {
  40400. /**
  40401. * Represents an XR input
  40402. */
  40403. export class WebXRController {
  40404. private scene;
  40405. /** The underlying input source for the controller */
  40406. inputSource: XRInputSource;
  40407. private parentContainer;
  40408. /**
  40409. * 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
  40410. */
  40411. grip?: AbstractMesh;
  40412. /**
  40413. * Pointer which can be used to select objects or attach a visible laser to
  40414. */
  40415. pointer: AbstractMesh;
  40416. /**
  40417. * Event that fires when the controller is removed/disposed
  40418. */
  40419. onDisposeObservable: Observable<{}>;
  40420. private _tmpMatrix;
  40421. private _tmpQuaternion;
  40422. private _tmpVector;
  40423. /**
  40424. * Creates the controller
  40425. * @see https://doc.babylonjs.com/how_to/webxr
  40426. * @param scene the scene which the controller should be associated to
  40427. * @param inputSource the underlying input source for the controller
  40428. * @param parentContainer parent that the controller meshes should be children of
  40429. */
  40430. constructor(scene: Scene,
  40431. /** The underlying input source for the controller */
  40432. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40433. /**
  40434. * Updates the controller pose based on the given XRFrame
  40435. * @param xrFrame xr frame to update the pose with
  40436. * @param referenceSpace reference space to use
  40437. */
  40438. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40439. /**
  40440. * Gets a world space ray coming from the controller
  40441. * @param result the resulting ray
  40442. */
  40443. getWorldPointerRayToRef(result: Ray): void;
  40444. /**
  40445. * Disposes of the object
  40446. */
  40447. dispose(): void;
  40448. }
  40449. }
  40450. declare module BABYLON {
  40451. /**
  40452. * XR input used to track XR inputs such as controllers/rays
  40453. */
  40454. export class WebXRInput implements IDisposable {
  40455. /**
  40456. * Base experience the input listens to
  40457. */
  40458. baseExperience: WebXRExperienceHelper;
  40459. /**
  40460. * XR controllers being tracked
  40461. */
  40462. controllers: Array<WebXRController>;
  40463. private _frameObserver;
  40464. private _stateObserver;
  40465. /**
  40466. * Event when a controller has been connected/added
  40467. */
  40468. onControllerAddedObservable: Observable<WebXRController>;
  40469. /**
  40470. * Event when a controller has been removed/disconnected
  40471. */
  40472. onControllerRemovedObservable: Observable<WebXRController>;
  40473. /**
  40474. * Initializes the WebXRInput
  40475. * @param baseExperience experience helper which the input should be created for
  40476. */
  40477. constructor(
  40478. /**
  40479. * Base experience the input listens to
  40480. */
  40481. baseExperience: WebXRExperienceHelper);
  40482. private _onInputSourcesChange;
  40483. private _addAndRemoveControllers;
  40484. /**
  40485. * Disposes of the object
  40486. */
  40487. dispose(): void;
  40488. }
  40489. }
  40490. declare module BABYLON {
  40491. /**
  40492. * Enables teleportation
  40493. */
  40494. export class WebXRControllerTeleportation {
  40495. private _teleportationFillColor;
  40496. private _teleportationBorderColor;
  40497. private _tmpRay;
  40498. private _tmpVector;
  40499. /**
  40500. * Creates a WebXRControllerTeleportation
  40501. * @param input input manager to add teleportation to
  40502. * @param floorMeshes floormeshes which can be teleported to
  40503. */
  40504. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40505. }
  40506. }
  40507. declare module BABYLON {
  40508. /**
  40509. * Handles pointer input automatically for the pointer of XR controllers
  40510. */
  40511. export class WebXRControllerPointerSelection {
  40512. private static _idCounter;
  40513. private _tmpRay;
  40514. /**
  40515. * Creates a WebXRControllerPointerSelection
  40516. * @param input input manager to setup pointer selection
  40517. */
  40518. constructor(input: WebXRInput);
  40519. private _convertNormalToDirectionOfRay;
  40520. private _updatePointerDistance;
  40521. }
  40522. }
  40523. declare module BABYLON {
  40524. /**
  40525. * Class used to represent data loading progression
  40526. */
  40527. export class SceneLoaderProgressEvent {
  40528. /** defines if data length to load can be evaluated */
  40529. readonly lengthComputable: boolean;
  40530. /** defines the loaded data length */
  40531. readonly loaded: number;
  40532. /** defines the data length to load */
  40533. readonly total: number;
  40534. /**
  40535. * Create a new progress event
  40536. * @param lengthComputable defines if data length to load can be evaluated
  40537. * @param loaded defines the loaded data length
  40538. * @param total defines the data length to load
  40539. */
  40540. constructor(
  40541. /** defines if data length to load can be evaluated */
  40542. lengthComputable: boolean,
  40543. /** defines the loaded data length */
  40544. loaded: number,
  40545. /** defines the data length to load */
  40546. total: number);
  40547. /**
  40548. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40549. * @param event defines the source event
  40550. * @returns a new SceneLoaderProgressEvent
  40551. */
  40552. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40553. }
  40554. /**
  40555. * Interface used by SceneLoader plugins to define supported file extensions
  40556. */
  40557. export interface ISceneLoaderPluginExtensions {
  40558. /**
  40559. * Defines the list of supported extensions
  40560. */
  40561. [extension: string]: {
  40562. isBinary: boolean;
  40563. };
  40564. }
  40565. /**
  40566. * Interface used by SceneLoader plugin factory
  40567. */
  40568. export interface ISceneLoaderPluginFactory {
  40569. /**
  40570. * Defines the name of the factory
  40571. */
  40572. name: string;
  40573. /**
  40574. * Function called to create a new plugin
  40575. * @return the new plugin
  40576. */
  40577. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40578. /**
  40579. * Boolean indicating if the plugin can direct load specific data
  40580. */
  40581. canDirectLoad?: (data: string) => boolean;
  40582. }
  40583. /**
  40584. * Interface used to define a SceneLoader plugin
  40585. */
  40586. export interface ISceneLoaderPlugin {
  40587. /**
  40588. * The friendly name of this plugin.
  40589. */
  40590. name: string;
  40591. /**
  40592. * The file extensions supported by this plugin.
  40593. */
  40594. extensions: string | ISceneLoaderPluginExtensions;
  40595. /**
  40596. * Import meshes into a scene.
  40597. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40598. * @param scene The scene to import into
  40599. * @param data The data to import
  40600. * @param rootUrl The root url for scene and resources
  40601. * @param meshes The meshes array to import into
  40602. * @param particleSystems The particle systems array to import into
  40603. * @param skeletons The skeletons array to import into
  40604. * @param onError The callback when import fails
  40605. * @returns True if successful or false otherwise
  40606. */
  40607. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40608. /**
  40609. * Load into a scene.
  40610. * @param scene The scene to load into
  40611. * @param data The data to import
  40612. * @param rootUrl The root url for scene and resources
  40613. * @param onError The callback when import fails
  40614. * @returns true if successful or false otherwise
  40615. */
  40616. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40617. /**
  40618. * The callback that returns true if the data can be directly loaded.
  40619. */
  40620. canDirectLoad?: (data: string) => boolean;
  40621. /**
  40622. * The callback that allows custom handling of the root url based on the response url.
  40623. */
  40624. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40625. /**
  40626. * Load into an asset container.
  40627. * @param scene The scene to load into
  40628. * @param data The data to import
  40629. * @param rootUrl The root url for scene and resources
  40630. * @param onError The callback when import fails
  40631. * @returns The loaded asset container
  40632. */
  40633. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40634. }
  40635. /**
  40636. * Interface used to define an async SceneLoader plugin
  40637. */
  40638. export interface ISceneLoaderPluginAsync {
  40639. /**
  40640. * The friendly name of this plugin.
  40641. */
  40642. name: string;
  40643. /**
  40644. * The file extensions supported by this plugin.
  40645. */
  40646. extensions: string | ISceneLoaderPluginExtensions;
  40647. /**
  40648. * Import meshes into a scene.
  40649. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40650. * @param scene The scene to import into
  40651. * @param data The data to import
  40652. * @param rootUrl The root url for scene and resources
  40653. * @param onProgress The callback when the load progresses
  40654. * @param fileName Defines the name of the file to load
  40655. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40656. */
  40657. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40658. meshes: AbstractMesh[];
  40659. particleSystems: IParticleSystem[];
  40660. skeletons: Skeleton[];
  40661. animationGroups: AnimationGroup[];
  40662. }>;
  40663. /**
  40664. * Load into a scene.
  40665. * @param scene The scene to load into
  40666. * @param data The data to import
  40667. * @param rootUrl The root url for scene and resources
  40668. * @param onProgress The callback when the load progresses
  40669. * @param fileName Defines the name of the file to load
  40670. * @returns Nothing
  40671. */
  40672. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40673. /**
  40674. * The callback that returns true if the data can be directly loaded.
  40675. */
  40676. canDirectLoad?: (data: string) => boolean;
  40677. /**
  40678. * The callback that allows custom handling of the root url based on the response url.
  40679. */
  40680. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40681. /**
  40682. * Load into an asset container.
  40683. * @param scene The scene to load into
  40684. * @param data The data to import
  40685. * @param rootUrl The root url for scene and resources
  40686. * @param onProgress The callback when the load progresses
  40687. * @param fileName Defines the name of the file to load
  40688. * @returns The loaded asset container
  40689. */
  40690. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40691. }
  40692. /**
  40693. * Class used to load scene from various file formats using registered plugins
  40694. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40695. */
  40696. export class SceneLoader {
  40697. /**
  40698. * No logging while loading
  40699. */
  40700. static readonly NO_LOGGING: number;
  40701. /**
  40702. * Minimal logging while loading
  40703. */
  40704. static readonly MINIMAL_LOGGING: number;
  40705. /**
  40706. * Summary logging while loading
  40707. */
  40708. static readonly SUMMARY_LOGGING: number;
  40709. /**
  40710. * Detailled logging while loading
  40711. */
  40712. static readonly DETAILED_LOGGING: number;
  40713. /**
  40714. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40715. */
  40716. static ForceFullSceneLoadingForIncremental: boolean;
  40717. /**
  40718. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40719. */
  40720. static ShowLoadingScreen: boolean;
  40721. /**
  40722. * Defines the current logging level (while loading the scene)
  40723. * @ignorenaming
  40724. */
  40725. static loggingLevel: number;
  40726. /**
  40727. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40728. */
  40729. static CleanBoneMatrixWeights: boolean;
  40730. /**
  40731. * Event raised when a plugin is used to load a scene
  40732. */
  40733. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40734. private static _registeredPlugins;
  40735. private static _getDefaultPlugin;
  40736. private static _getPluginForExtension;
  40737. private static _getPluginForDirectLoad;
  40738. private static _getPluginForFilename;
  40739. private static _getDirectLoad;
  40740. private static _loadData;
  40741. private static _getFileInfo;
  40742. /**
  40743. * Gets a plugin that can load the given extension
  40744. * @param extension defines the extension to load
  40745. * @returns a plugin or null if none works
  40746. */
  40747. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40748. /**
  40749. * Gets a boolean indicating that the given extension can be loaded
  40750. * @param extension defines the extension to load
  40751. * @returns true if the extension is supported
  40752. */
  40753. static IsPluginForExtensionAvailable(extension: string): boolean;
  40754. /**
  40755. * Adds a new plugin to the list of registered plugins
  40756. * @param plugin defines the plugin to add
  40757. */
  40758. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40759. /**
  40760. * Import meshes into a scene
  40761. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40762. * @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)
  40763. * @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)
  40764. * @param scene the instance of BABYLON.Scene to append to
  40765. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40766. * @param onProgress a callback with a progress event for each file being loaded
  40767. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40768. * @param pluginExtension the extension used to determine the plugin
  40769. * @returns The loaded plugin
  40770. */
  40771. 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>;
  40772. /**
  40773. * Import meshes into a scene
  40774. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40775. * @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)
  40776. * @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)
  40777. * @param scene the instance of BABYLON.Scene to append to
  40778. * @param onProgress a callback with a progress event for each file being loaded
  40779. * @param pluginExtension the extension used to determine the plugin
  40780. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  40781. */
  40782. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  40783. meshes: AbstractMesh[];
  40784. particleSystems: IParticleSystem[];
  40785. skeletons: Skeleton[];
  40786. animationGroups: AnimationGroup[];
  40787. }>;
  40788. /**
  40789. * Load a scene
  40790. * @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)
  40791. * @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)
  40792. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40793. * @param onSuccess a callback with the scene when import succeeds
  40794. * @param onProgress a callback with a progress event for each file being loaded
  40795. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40796. * @param pluginExtension the extension used to determine the plugin
  40797. * @returns The loaded plugin
  40798. */
  40799. 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>;
  40800. /**
  40801. * Load a scene
  40802. * @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)
  40803. * @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)
  40804. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40805. * @param onProgress a callback with a progress event for each file being loaded
  40806. * @param pluginExtension the extension used to determine the plugin
  40807. * @returns The loaded scene
  40808. */
  40809. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40810. /**
  40811. * Append a scene
  40812. * @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)
  40813. * @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)
  40814. * @param scene is the instance of BABYLON.Scene to append to
  40815. * @param onSuccess a callback with the scene when import succeeds
  40816. * @param onProgress a callback with a progress event for each file being loaded
  40817. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40818. * @param pluginExtension the extension used to determine the plugin
  40819. * @returns The loaded plugin
  40820. */
  40821. 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>;
  40822. /**
  40823. * Append a scene
  40824. * @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)
  40825. * @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)
  40826. * @param scene is the instance of BABYLON.Scene to append to
  40827. * @param onProgress a callback with a progress event for each file being loaded
  40828. * @param pluginExtension the extension used to determine the plugin
  40829. * @returns The given scene
  40830. */
  40831. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40832. /**
  40833. * Load a scene into an asset container
  40834. * @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)
  40835. * @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)
  40836. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40837. * @param onSuccess a callback with the scene when import succeeds
  40838. * @param onProgress a callback with a progress event for each file being loaded
  40839. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40840. * @param pluginExtension the extension used to determine the plugin
  40841. * @returns The loaded plugin
  40842. */
  40843. 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>;
  40844. /**
  40845. * Load a scene into an asset container
  40846. * @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)
  40847. * @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)
  40848. * @param scene is the instance of Scene to append to
  40849. * @param onProgress a callback with a progress event for each file being loaded
  40850. * @param pluginExtension the extension used to determine the plugin
  40851. * @returns The loaded asset container
  40852. */
  40853. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40854. }
  40855. }
  40856. declare module BABYLON {
  40857. /**
  40858. * Generic Controller
  40859. */
  40860. export class GenericController extends WebVRController {
  40861. /**
  40862. * Base Url for the controller model.
  40863. */
  40864. static readonly MODEL_BASE_URL: string;
  40865. /**
  40866. * File name for the controller model.
  40867. */
  40868. static readonly MODEL_FILENAME: string;
  40869. /**
  40870. * Creates a new GenericController from a gamepad
  40871. * @param vrGamepad the gamepad that the controller should be created from
  40872. */
  40873. constructor(vrGamepad: any);
  40874. /**
  40875. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40876. * @param scene scene in which to add meshes
  40877. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40878. */
  40879. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40880. /**
  40881. * Called once for each button that changed state since the last frame
  40882. * @param buttonIdx Which button index changed
  40883. * @param state New state of the button
  40884. * @param changes Which properties on the state changed since last frame
  40885. */
  40886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40887. }
  40888. }
  40889. declare module BABYLON {
  40890. /**
  40891. * Defines the WindowsMotionController object that the state of the windows motion controller
  40892. */
  40893. export class WindowsMotionController extends WebVRController {
  40894. /**
  40895. * The base url used to load the left and right controller models
  40896. */
  40897. static MODEL_BASE_URL: string;
  40898. /**
  40899. * The name of the left controller model file
  40900. */
  40901. static MODEL_LEFT_FILENAME: string;
  40902. /**
  40903. * The name of the right controller model file
  40904. */
  40905. static MODEL_RIGHT_FILENAME: string;
  40906. /**
  40907. * The controller name prefix for this controller type
  40908. */
  40909. static readonly GAMEPAD_ID_PREFIX: string;
  40910. /**
  40911. * The controller id pattern for this controller type
  40912. */
  40913. private static readonly GAMEPAD_ID_PATTERN;
  40914. private _loadedMeshInfo;
  40915. private readonly _mapping;
  40916. /**
  40917. * Fired when the trackpad on this controller is clicked
  40918. */
  40919. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40920. /**
  40921. * Fired when the trackpad on this controller is modified
  40922. */
  40923. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40924. /**
  40925. * The current x and y values of this controller's trackpad
  40926. */
  40927. trackpad: StickValues;
  40928. /**
  40929. * Creates a new WindowsMotionController from a gamepad
  40930. * @param vrGamepad the gamepad that the controller should be created from
  40931. */
  40932. constructor(vrGamepad: any);
  40933. /**
  40934. * Fired when the trigger on this controller is modified
  40935. */
  40936. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40937. /**
  40938. * Fired when the menu button on this controller is modified
  40939. */
  40940. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40941. /**
  40942. * Fired when the grip button on this controller is modified
  40943. */
  40944. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40945. /**
  40946. * Fired when the thumbstick button on this controller is modified
  40947. */
  40948. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40949. /**
  40950. * Fired when the touchpad button on this controller is modified
  40951. */
  40952. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40953. /**
  40954. * Fired when the touchpad values on this controller are modified
  40955. */
  40956. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40957. private _updateTrackpad;
  40958. /**
  40959. * Called once per frame by the engine.
  40960. */
  40961. update(): void;
  40962. /**
  40963. * Called once for each button that changed state since the last frame
  40964. * @param buttonIdx Which button index changed
  40965. * @param state New state of the button
  40966. * @param changes Which properties on the state changed since last frame
  40967. */
  40968. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40969. /**
  40970. * Moves the buttons on the controller mesh based on their current state
  40971. * @param buttonName the name of the button to move
  40972. * @param buttonValue the value of the button which determines the buttons new position
  40973. */
  40974. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40975. /**
  40976. * Moves the axis on the controller mesh based on its current state
  40977. * @param axis the index of the axis
  40978. * @param axisValue the value of the axis which determines the meshes new position
  40979. * @hidden
  40980. */
  40981. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40982. /**
  40983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40984. * @param scene scene in which to add meshes
  40985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40986. */
  40987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  40988. /**
  40989. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  40990. * can be transformed by button presses and axes values, based on this._mapping.
  40991. *
  40992. * @param scene scene in which the meshes exist
  40993. * @param meshes list of meshes that make up the controller model to process
  40994. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  40995. */
  40996. private processModel;
  40997. private createMeshInfo;
  40998. /**
  40999. * Gets the ray of the controller in the direction the controller is pointing
  41000. * @param length the length the resulting ray should be
  41001. * @returns a ray in the direction the controller is pointing
  41002. */
  41003. getForwardRay(length?: number): Ray;
  41004. /**
  41005. * Disposes of the controller
  41006. */
  41007. dispose(): void;
  41008. }
  41009. }
  41010. declare module BABYLON {
  41011. /**
  41012. * Oculus Touch Controller
  41013. */
  41014. export class OculusTouchController extends WebVRController {
  41015. /**
  41016. * Base Url for the controller model.
  41017. */
  41018. static MODEL_BASE_URL: string;
  41019. /**
  41020. * File name for the left controller model.
  41021. */
  41022. static MODEL_LEFT_FILENAME: string;
  41023. /**
  41024. * File name for the right controller model.
  41025. */
  41026. static MODEL_RIGHT_FILENAME: string;
  41027. /**
  41028. * Base Url for the Quest controller model.
  41029. */
  41030. static QUEST_MODEL_BASE_URL: string;
  41031. /**
  41032. * @hidden
  41033. * If the controllers are running on a device that needs the updated Quest controller models
  41034. */ private static _IsQuest: boolean;
  41035. /**
  41036. * Fired when the secondary trigger on this controller is modified
  41037. */
  41038. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41039. /**
  41040. * Fired when the thumb rest on this controller is modified
  41041. */
  41042. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41043. /**
  41044. * Creates a new OculusTouchController from a gamepad
  41045. * @param vrGamepad the gamepad that the controller should be created from
  41046. */
  41047. constructor(vrGamepad: any);
  41048. /**
  41049. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41050. * @param scene scene in which to add meshes
  41051. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41052. */
  41053. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41054. /**
  41055. * Fired when the A button on this controller is modified
  41056. */
  41057. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41058. /**
  41059. * Fired when the B button on this controller is modified
  41060. */
  41061. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41062. /**
  41063. * Fired when the X button on this controller is modified
  41064. */
  41065. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41066. /**
  41067. * Fired when the Y button on this controller is modified
  41068. */
  41069. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41070. /**
  41071. * Called once for each button that changed state since the last frame
  41072. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41073. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41074. * 2) secondary trigger (same)
  41075. * 3) A (right) X (left), touch, pressed = value
  41076. * 4) B / Y
  41077. * 5) thumb rest
  41078. * @param buttonIdx Which button index changed
  41079. * @param state New state of the button
  41080. * @param changes Which properties on the state changed since last frame
  41081. */
  41082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41083. }
  41084. }
  41085. declare module BABYLON {
  41086. /**
  41087. * Vive Controller
  41088. */
  41089. export class ViveController extends WebVRController {
  41090. /**
  41091. * Base Url for the controller model.
  41092. */
  41093. static MODEL_BASE_URL: string;
  41094. /**
  41095. * File name for the controller model.
  41096. */
  41097. static MODEL_FILENAME: string;
  41098. /**
  41099. * Creates a new ViveController from a gamepad
  41100. * @param vrGamepad the gamepad that the controller should be created from
  41101. */
  41102. constructor(vrGamepad: any);
  41103. /**
  41104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41105. * @param scene scene in which to add meshes
  41106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41107. */
  41108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41109. /**
  41110. * Fired when the left button on this controller is modified
  41111. */
  41112. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41113. /**
  41114. * Fired when the right button on this controller is modified
  41115. */
  41116. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41117. /**
  41118. * Fired when the menu button on this controller is modified
  41119. */
  41120. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41121. /**
  41122. * Called once for each button that changed state since the last frame
  41123. * Vive mapping:
  41124. * 0: touchpad
  41125. * 1: trigger
  41126. * 2: left AND right buttons
  41127. * 3: menu button
  41128. * @param buttonIdx Which button index changed
  41129. * @param state New state of the button
  41130. * @param changes Which properties on the state changed since last frame
  41131. */
  41132. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41133. }
  41134. }
  41135. declare module BABYLON {
  41136. /**
  41137. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41138. */
  41139. export class WebXRControllerModelLoader {
  41140. /**
  41141. * Creates the WebXRControllerModelLoader
  41142. * @param input xr input that creates the controllers
  41143. */
  41144. constructor(input: WebXRInput);
  41145. }
  41146. }
  41147. declare module BABYLON {
  41148. /**
  41149. * Contains an array of blocks representing the octree
  41150. */
  41151. export interface IOctreeContainer<T> {
  41152. /**
  41153. * Blocks within the octree
  41154. */
  41155. blocks: Array<OctreeBlock<T>>;
  41156. }
  41157. /**
  41158. * Class used to store a cell in an octree
  41159. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41160. */
  41161. export class OctreeBlock<T> {
  41162. /**
  41163. * Gets the content of the current block
  41164. */
  41165. entries: T[];
  41166. /**
  41167. * Gets the list of block children
  41168. */
  41169. blocks: Array<OctreeBlock<T>>;
  41170. private _depth;
  41171. private _maxDepth;
  41172. private _capacity;
  41173. private _minPoint;
  41174. private _maxPoint;
  41175. private _boundingVectors;
  41176. private _creationFunc;
  41177. /**
  41178. * Creates a new block
  41179. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41180. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41181. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41182. * @param depth defines the current depth of this block in the octree
  41183. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41184. * @param creationFunc defines a callback to call when an element is added to the block
  41185. */
  41186. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41187. /**
  41188. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41189. */
  41190. readonly capacity: number;
  41191. /**
  41192. * Gets the minimum vector (in world space) of the block's bounding box
  41193. */
  41194. readonly minPoint: Vector3;
  41195. /**
  41196. * Gets the maximum vector (in world space) of the block's bounding box
  41197. */
  41198. readonly maxPoint: Vector3;
  41199. /**
  41200. * Add a new element to this block
  41201. * @param entry defines the element to add
  41202. */
  41203. addEntry(entry: T): void;
  41204. /**
  41205. * Remove an element from this block
  41206. * @param entry defines the element to remove
  41207. */
  41208. removeEntry(entry: T): void;
  41209. /**
  41210. * Add an array of elements to this block
  41211. * @param entries defines the array of elements to add
  41212. */
  41213. addEntries(entries: T[]): void;
  41214. /**
  41215. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41216. * @param frustumPlanes defines the frustum planes to test
  41217. * @param selection defines the array to store current content if selection is positive
  41218. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41219. */
  41220. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41221. /**
  41222. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41223. * @param sphereCenter defines the bounding sphere center
  41224. * @param sphereRadius defines the bounding sphere radius
  41225. * @param selection defines the array to store current content if selection is positive
  41226. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41227. */
  41228. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41229. /**
  41230. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41231. * @param ray defines the ray to test with
  41232. * @param selection defines the array to store current content if selection is positive
  41233. */
  41234. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41235. /**
  41236. * Subdivide the content into child blocks (this block will then be empty)
  41237. */
  41238. createInnerBlocks(): void;
  41239. /**
  41240. * @hidden
  41241. */ 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;
  41242. }
  41243. }
  41244. declare module BABYLON {
  41245. /**
  41246. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41248. */
  41249. export class Octree<T> {
  41250. /** 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.) */
  41251. maxDepth: number;
  41252. /**
  41253. * Blocks within the octree containing objects
  41254. */
  41255. blocks: Array<OctreeBlock<T>>;
  41256. /**
  41257. * Content stored in the octree
  41258. */
  41259. dynamicContent: T[];
  41260. private _maxBlockCapacity;
  41261. private _selectionContent;
  41262. private _creationFunc;
  41263. /**
  41264. * Creates a octree
  41265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41266. * @param creationFunc function to be used to instatiate the octree
  41267. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41268. * @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.)
  41269. */
  41270. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41271. /** 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.) */
  41272. maxDepth?: number);
  41273. /**
  41274. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41275. * @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);
  41276. * @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);
  41277. * @param entries meshes to be added to the octree blocks
  41278. */
  41279. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41280. /**
  41281. * Adds a mesh to the octree
  41282. * @param entry Mesh to add to the octree
  41283. */
  41284. addMesh(entry: T): void;
  41285. /**
  41286. * Remove an element from the octree
  41287. * @param entry defines the element to remove
  41288. */
  41289. removeMesh(entry: T): void;
  41290. /**
  41291. * Selects an array of meshes within the frustum
  41292. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41293. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41294. * @returns array of meshes within the frustum
  41295. */
  41296. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41297. /**
  41298. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41299. * @param sphereCenter defines the bounding sphere center
  41300. * @param sphereRadius defines the bounding sphere radius
  41301. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41302. * @returns an array of objects that intersect the sphere
  41303. */
  41304. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41305. /**
  41306. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41307. * @param ray defines the ray to test with
  41308. * @returns array of intersected objects
  41309. */
  41310. intersectsRay(ray: Ray): SmartArray<T>;
  41311. /**
  41312. * Adds a mesh into the octree block if it intersects the block
  41313. */
  41314. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41315. /**
  41316. * Adds a submesh into the octree block if it intersects the block
  41317. */
  41318. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41319. }
  41320. }
  41321. declare module BABYLON {
  41322. interface Scene {
  41323. /**
  41324. * @hidden
  41325. * Backing Filed
  41326. */ private _selectionOctree: Octree<AbstractMesh>;
  41327. /**
  41328. * Gets the octree used to boost mesh selection (picking)
  41329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41330. */
  41331. selectionOctree: Octree<AbstractMesh>;
  41332. /**
  41333. * Creates or updates the octree used to boost selection (picking)
  41334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41335. * @param maxCapacity defines the maximum capacity per leaf
  41336. * @param maxDepth defines the maximum depth of the octree
  41337. * @returns an octree of AbstractMesh
  41338. */
  41339. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41340. }
  41341. interface AbstractMesh {
  41342. /**
  41343. * @hidden
  41344. * Backing Field
  41345. */ private _submeshesOctree: Octree<SubMesh>;
  41346. /**
  41347. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41348. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41349. * @param maxCapacity defines the maximum size of each block (64 by default)
  41350. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41351. * @returns the new octree
  41352. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41354. */
  41355. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41356. }
  41357. /**
  41358. * Defines the octree scene component responsible to manage any octrees
  41359. * in a given scene.
  41360. */
  41361. export class OctreeSceneComponent {
  41362. /**
  41363. * The component name help to identify the component in the list of scene components.
  41364. */
  41365. readonly name: string;
  41366. /**
  41367. * The scene the component belongs to.
  41368. */
  41369. scene: Scene;
  41370. /**
  41371. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41372. */
  41373. readonly checksIsEnabled: boolean;
  41374. /**
  41375. * Creates a new instance of the component for the given scene
  41376. * @param scene Defines the scene to register the component in
  41377. */
  41378. constructor(scene: Scene);
  41379. /**
  41380. * Registers the component in a given scene
  41381. */
  41382. register(): void;
  41383. /**
  41384. * Return the list of active meshes
  41385. * @returns the list of active meshes
  41386. */
  41387. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41388. /**
  41389. * Return the list of active sub meshes
  41390. * @param mesh The mesh to get the candidates sub meshes from
  41391. * @returns the list of active sub meshes
  41392. */
  41393. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41394. private _tempRay;
  41395. /**
  41396. * Return the list of sub meshes intersecting with a given local ray
  41397. * @param mesh defines the mesh to find the submesh for
  41398. * @param localRay defines the ray in local space
  41399. * @returns the list of intersecting sub meshes
  41400. */
  41401. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41402. /**
  41403. * Return the list of sub meshes colliding with a collider
  41404. * @param mesh defines the mesh to find the submesh for
  41405. * @param collider defines the collider to evaluate the collision against
  41406. * @returns the list of colliding sub meshes
  41407. */
  41408. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41409. /**
  41410. * Rebuilds the elements related to this component in case of
  41411. * context lost for instance.
  41412. */
  41413. rebuild(): void;
  41414. /**
  41415. * Disposes the component and the associated ressources.
  41416. */
  41417. dispose(): void;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /**
  41422. * Renders a layer on top of an existing scene
  41423. */
  41424. export class UtilityLayerRenderer implements IDisposable {
  41425. /** the original scene that will be rendered on top of */
  41426. originalScene: Scene;
  41427. private _pointerCaptures;
  41428. private _lastPointerEvents;
  41429. private static _DefaultUtilityLayer;
  41430. private static _DefaultKeepDepthUtilityLayer;
  41431. private _sharedGizmoLight;
  41432. private _renderCamera;
  41433. /**
  41434. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41435. * @returns the camera that is used when rendering the utility layer
  41436. */
  41437. getRenderCamera(): Nullable<Camera>;
  41438. /**
  41439. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41440. * @param cam the camera that should be used when rendering the utility layer
  41441. */
  41442. setRenderCamera(cam: Nullable<Camera>): void;
  41443. /**
  41444. * @hidden
  41445. * Light which used by gizmos to get light shading
  41446. */ private _getSharedGizmoLight(): HemisphericLight;
  41447. /**
  41448. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41449. */
  41450. pickUtilitySceneFirst: boolean;
  41451. /**
  41452. * 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)
  41453. */
  41454. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41455. /**
  41456. * 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)
  41457. */
  41458. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41459. /**
  41460. * The scene that is rendered on top of the original scene
  41461. */
  41462. utilityLayerScene: Scene;
  41463. /**
  41464. * If the utility layer should automatically be rendered on top of existing scene
  41465. */
  41466. shouldRender: boolean;
  41467. /**
  41468. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41469. */
  41470. onlyCheckPointerDownEvents: boolean;
  41471. /**
  41472. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41473. */
  41474. processAllEvents: boolean;
  41475. /**
  41476. * Observable raised when the pointer move from the utility layer scene to the main scene
  41477. */
  41478. onPointerOutObservable: Observable<number>;
  41479. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41480. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41481. private _afterRenderObserver;
  41482. private _sceneDisposeObserver;
  41483. private _originalPointerObserver;
  41484. /**
  41485. * Instantiates a UtilityLayerRenderer
  41486. * @param originalScene the original scene that will be rendered on top of
  41487. * @param handleEvents boolean indicating if the utility layer should handle events
  41488. */
  41489. constructor(
  41490. /** the original scene that will be rendered on top of */
  41491. originalScene: Scene, handleEvents?: boolean);
  41492. private _notifyObservers;
  41493. /**
  41494. * Renders the utility layers scene on top of the original scene
  41495. */
  41496. render(): void;
  41497. /**
  41498. * Disposes of the renderer
  41499. */
  41500. dispose(): void;
  41501. private _updateCamera;
  41502. }
  41503. }
  41504. declare module BABYLON {
  41505. /**
  41506. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41507. */
  41508. export class Gizmo implements IDisposable {
  41509. /** The utility layer the gizmo will be added to */
  41510. gizmoLayer: UtilityLayerRenderer;
  41511. /**
  41512. * The root mesh of the gizmo
  41513. */ private _rootMesh: Mesh;
  41514. private _attachedMesh;
  41515. /**
  41516. * Ratio for the scale of the gizmo (Default: 1)
  41517. */
  41518. scaleRatio: number;
  41519. /**
  41520. * If a custom mesh has been set (Default: false)
  41521. */
  41522. protected _customMeshSet: boolean;
  41523. /**
  41524. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41525. * * When set, interactions will be enabled
  41526. */
  41527. attachedMesh: Nullable<AbstractMesh>;
  41528. /**
  41529. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41530. * @param mesh The mesh to replace the default mesh of the gizmo
  41531. */
  41532. setCustomMesh(mesh: Mesh): void;
  41533. /**
  41534. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41535. */
  41536. updateGizmoRotationToMatchAttachedMesh: boolean;
  41537. /**
  41538. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41539. */
  41540. updateGizmoPositionToMatchAttachedMesh: boolean;
  41541. /**
  41542. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41543. */
  41544. updateScale: boolean;
  41545. protected _interactionsEnabled: boolean;
  41546. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41547. private _beforeRenderObserver;
  41548. private _tempVector;
  41549. /**
  41550. * Creates a gizmo
  41551. * @param gizmoLayer The utility layer the gizmo will be added to
  41552. */
  41553. constructor(
  41554. /** The utility layer the gizmo will be added to */
  41555. gizmoLayer?: UtilityLayerRenderer);
  41556. /**
  41557. * Updates the gizmo to match the attached mesh's position/rotation
  41558. */
  41559. protected _update(): void;
  41560. /**
  41561. * Disposes of the gizmo
  41562. */
  41563. dispose(): void;
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /**
  41568. * Single plane drag gizmo
  41569. */
  41570. export class PlaneDragGizmo extends Gizmo {
  41571. /**
  41572. * Drag behavior responsible for the gizmos dragging interactions
  41573. */
  41574. dragBehavior: PointerDragBehavior;
  41575. private _pointerObserver;
  41576. /**
  41577. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41578. */
  41579. snapDistance: number;
  41580. /**
  41581. * Event that fires each time the gizmo snaps to a new location.
  41582. * * snapDistance is the the change in distance
  41583. */
  41584. onSnapObservable: Observable<{
  41585. snapDistance: number;
  41586. }>;
  41587. private _plane;
  41588. private _coloredMaterial;
  41589. private _hoverMaterial;
  41590. private _isEnabled;
  41591. private _parent;
  41592. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41593. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41594. /**
  41595. * Creates a PlaneDragGizmo
  41596. * @param gizmoLayer The utility layer the gizmo will be added to
  41597. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41598. * @param color The color of the gizmo
  41599. */
  41600. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41601. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41602. /**
  41603. * If the gizmo is enabled
  41604. */
  41605. isEnabled: boolean;
  41606. /**
  41607. * Disposes of the gizmo
  41608. */
  41609. dispose(): void;
  41610. }
  41611. }
  41612. declare module BABYLON {
  41613. /**
  41614. * Gizmo that enables dragging a mesh along 3 axis
  41615. */
  41616. export class PositionGizmo extends Gizmo {
  41617. /**
  41618. * Internal gizmo used for interactions on the x axis
  41619. */
  41620. xGizmo: AxisDragGizmo;
  41621. /**
  41622. * Internal gizmo used for interactions on the y axis
  41623. */
  41624. yGizmo: AxisDragGizmo;
  41625. /**
  41626. * Internal gizmo used for interactions on the z axis
  41627. */
  41628. zGizmo: AxisDragGizmo;
  41629. /**
  41630. * Internal gizmo used for interactions on the yz plane
  41631. */
  41632. xPlaneGizmo: PlaneDragGizmo;
  41633. /**
  41634. * Internal gizmo used for interactions on the xz plane
  41635. */
  41636. yPlaneGizmo: PlaneDragGizmo;
  41637. /**
  41638. * Internal gizmo used for interactions on the xy plane
  41639. */
  41640. zPlaneGizmo: PlaneDragGizmo;
  41641. /**
  41642. * private variables
  41643. */
  41644. private _meshAttached;
  41645. private _updateGizmoRotationToMatchAttachedMesh;
  41646. private _snapDistance;
  41647. private _scaleRatio;
  41648. /** Fires an event when any of it's sub gizmos are dragged */
  41649. onDragStartObservable: Observable<unknown>;
  41650. /** Fires an event when any of it's sub gizmos are released from dragging */
  41651. onDragEndObservable: Observable<unknown>;
  41652. /**
  41653. * If set to true, planar drag is enabled
  41654. */
  41655. private _planarGizmoEnabled;
  41656. attachedMesh: Nullable<AbstractMesh>;
  41657. /**
  41658. * Creates a PositionGizmo
  41659. * @param gizmoLayer The utility layer the gizmo will be added to
  41660. */
  41661. constructor(gizmoLayer?: UtilityLayerRenderer);
  41662. /**
  41663. * If the planar drag gizmo is enabled
  41664. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41665. */
  41666. planarGizmoEnabled: boolean;
  41667. updateGizmoRotationToMatchAttachedMesh: boolean;
  41668. /**
  41669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41670. */
  41671. snapDistance: number;
  41672. /**
  41673. * Ratio for the scale of the gizmo (Default: 1)
  41674. */
  41675. scaleRatio: number;
  41676. /**
  41677. * Disposes of the gizmo
  41678. */
  41679. dispose(): void;
  41680. /**
  41681. * CustomMeshes are not supported by this gizmo
  41682. * @param mesh The mesh to replace the default mesh of the gizmo
  41683. */
  41684. setCustomMesh(mesh: Mesh): void;
  41685. }
  41686. }
  41687. declare module BABYLON {
  41688. /**
  41689. * Single axis drag gizmo
  41690. */
  41691. export class AxisDragGizmo extends Gizmo {
  41692. /**
  41693. * Drag behavior responsible for the gizmos dragging interactions
  41694. */
  41695. dragBehavior: PointerDragBehavior;
  41696. private _pointerObserver;
  41697. /**
  41698. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41699. */
  41700. snapDistance: number;
  41701. /**
  41702. * Event that fires each time the gizmo snaps to a new location.
  41703. * * snapDistance is the the change in distance
  41704. */
  41705. onSnapObservable: Observable<{
  41706. snapDistance: number;
  41707. }>;
  41708. private _isEnabled;
  41709. private _parent;
  41710. private _arrow;
  41711. private _coloredMaterial;
  41712. private _hoverMaterial;
  41713. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41714. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41715. /**
  41716. * Creates an AxisDragGizmo
  41717. * @param gizmoLayer The utility layer the gizmo will be added to
  41718. * @param dragAxis The axis which the gizmo will be able to drag on
  41719. * @param color The color of the gizmo
  41720. */
  41721. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41722. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41723. /**
  41724. * If the gizmo is enabled
  41725. */
  41726. isEnabled: boolean;
  41727. /**
  41728. * Disposes of the gizmo
  41729. */
  41730. dispose(): void;
  41731. }
  41732. }
  41733. declare module BABYLON.Debug {
  41734. /**
  41735. * The Axes viewer will show 3 axes in a specific point in space
  41736. */
  41737. export class AxesViewer {
  41738. private _xAxis;
  41739. private _yAxis;
  41740. private _zAxis;
  41741. private _scaleLinesFactor;
  41742. private _instanced;
  41743. /**
  41744. * Gets the hosting scene
  41745. */
  41746. scene: Scene;
  41747. /**
  41748. * Gets or sets a number used to scale line length
  41749. */
  41750. scaleLines: number;
  41751. /** Gets the node hierarchy used to render x-axis */
  41752. readonly xAxis: TransformNode;
  41753. /** Gets the node hierarchy used to render y-axis */
  41754. readonly yAxis: TransformNode;
  41755. /** Gets the node hierarchy used to render z-axis */
  41756. readonly zAxis: TransformNode;
  41757. /**
  41758. * Creates a new AxesViewer
  41759. * @param scene defines the hosting scene
  41760. * @param scaleLines defines a number used to scale line length (1 by default)
  41761. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41762. * @param xAxis defines the node hierarchy used to render the x-axis
  41763. * @param yAxis defines the node hierarchy used to render the y-axis
  41764. * @param zAxis defines the node hierarchy used to render the z-axis
  41765. */
  41766. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41767. /**
  41768. * Force the viewer to update
  41769. * @param position defines the position of the viewer
  41770. * @param xaxis defines the x axis of the viewer
  41771. * @param yaxis defines the y axis of the viewer
  41772. * @param zaxis defines the z axis of the viewer
  41773. */
  41774. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41775. /**
  41776. * Creates an instance of this axes viewer.
  41777. * @returns a new axes viewer with instanced meshes
  41778. */
  41779. createInstance(): AxesViewer;
  41780. /** Releases resources */
  41781. dispose(): void;
  41782. private static _SetRenderingGroupId;
  41783. }
  41784. }
  41785. declare module BABYLON.Debug {
  41786. /**
  41787. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41788. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41789. */
  41790. export class BoneAxesViewer extends AxesViewer {
  41791. /**
  41792. * Gets or sets the target mesh where to display the axes viewer
  41793. */
  41794. mesh: Nullable<Mesh>;
  41795. /**
  41796. * Gets or sets the target bone where to display the axes viewer
  41797. */
  41798. bone: Nullable<Bone>;
  41799. /** Gets current position */
  41800. pos: Vector3;
  41801. /** Gets direction of X axis */
  41802. xaxis: Vector3;
  41803. /** Gets direction of Y axis */
  41804. yaxis: Vector3;
  41805. /** Gets direction of Z axis */
  41806. zaxis: Vector3;
  41807. /**
  41808. * Creates a new BoneAxesViewer
  41809. * @param scene defines the hosting scene
  41810. * @param bone defines the target bone
  41811. * @param mesh defines the target mesh
  41812. * @param scaleLines defines a scaling factor for line length (1 by default)
  41813. */
  41814. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41815. /**
  41816. * Force the viewer to update
  41817. */
  41818. update(): void;
  41819. /** Releases resources */
  41820. dispose(): void;
  41821. }
  41822. }
  41823. declare module BABYLON {
  41824. /**
  41825. * Interface used to define scene explorer extensibility option
  41826. */
  41827. export interface IExplorerExtensibilityOption {
  41828. /**
  41829. * Define the option label
  41830. */
  41831. label: string;
  41832. /**
  41833. * Defines the action to execute on click
  41834. */
  41835. action: (entity: any) => void;
  41836. }
  41837. /**
  41838. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41839. */
  41840. export interface IExplorerExtensibilityGroup {
  41841. /**
  41842. * Defines a predicate to test if a given type mut be extended
  41843. */
  41844. predicate: (entity: any) => boolean;
  41845. /**
  41846. * Gets the list of options added to a type
  41847. */
  41848. entries: IExplorerExtensibilityOption[];
  41849. }
  41850. /**
  41851. * Interface used to define the options to use to create the Inspector
  41852. */
  41853. export interface IInspectorOptions {
  41854. /**
  41855. * Display in overlay mode (default: false)
  41856. */
  41857. overlay?: boolean;
  41858. /**
  41859. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41860. */
  41861. globalRoot?: HTMLElement;
  41862. /**
  41863. * Display the Scene explorer
  41864. */
  41865. showExplorer?: boolean;
  41866. /**
  41867. * Display the property inspector
  41868. */
  41869. showInspector?: boolean;
  41870. /**
  41871. * Display in embed mode (both panes on the right)
  41872. */
  41873. embedMode?: boolean;
  41874. /**
  41875. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41876. */
  41877. handleResize?: boolean;
  41878. /**
  41879. * Allow the panes to popup (default: true)
  41880. */
  41881. enablePopup?: boolean;
  41882. /**
  41883. * Allow the panes to be closed by users (default: true)
  41884. */
  41885. enableClose?: boolean;
  41886. /**
  41887. * Optional list of extensibility entries
  41888. */
  41889. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41890. /**
  41891. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41892. */
  41893. inspectorURL?: string;
  41894. }
  41895. interface Scene {
  41896. /**
  41897. * @hidden
  41898. * Backing field
  41899. */ private _debugLayer: DebugLayer;
  41900. /**
  41901. * Gets the debug layer (aka Inspector) associated with the scene
  41902. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41903. */
  41904. debugLayer: DebugLayer;
  41905. }
  41906. /**
  41907. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41908. * what is happening in your scene
  41909. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41910. */
  41911. export class DebugLayer {
  41912. /**
  41913. * Define the url to get the inspector script from.
  41914. * By default it uses the babylonjs CDN.
  41915. * @ignoreNaming
  41916. */
  41917. static InspectorURL: string;
  41918. private _scene;
  41919. private BJSINSPECTOR;
  41920. private _onPropertyChangedObservable?;
  41921. /**
  41922. * Observable triggered when a property is changed through the inspector.
  41923. */
  41924. readonly onPropertyChangedObservable: any;
  41925. /**
  41926. * Instantiates a new debug layer.
  41927. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41928. * what is happening in your scene
  41929. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41930. * @param scene Defines the scene to inspect
  41931. */
  41932. constructor(scene: Scene);
  41933. /** Creates the inspector window. */
  41934. private _createInspector;
  41935. /**
  41936. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41937. * @param entity defines the entity to select
  41938. * @param lineContainerTitle defines the specific block to highlight
  41939. */
  41940. select(entity: any, lineContainerTitle?: string): void;
  41941. /** Get the inspector from bundle or global */
  41942. private _getGlobalInspector;
  41943. /**
  41944. * Get if the inspector is visible or not.
  41945. * @returns true if visible otherwise, false
  41946. */
  41947. isVisible(): boolean;
  41948. /**
  41949. * Hide the inspector and close its window.
  41950. */
  41951. hide(): void;
  41952. /**
  41953. * Launch the debugLayer.
  41954. * @param config Define the configuration of the inspector
  41955. * @return a promise fulfilled when the debug layer is visible
  41956. */
  41957. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /**
  41962. * Class containing static functions to help procedurally build meshes
  41963. */
  41964. export class BoxBuilder {
  41965. /**
  41966. * Creates a box mesh
  41967. * * The parameter `size` sets the size (float) of each box side (default 1)
  41968. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41969. * * 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)
  41970. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41972. * * 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
  41973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41974. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41975. * @param name defines the name of the mesh
  41976. * @param options defines the options used to create the mesh
  41977. * @param scene defines the hosting scene
  41978. * @returns the box mesh
  41979. */
  41980. static CreateBox(name: string, options: {
  41981. size?: number;
  41982. width?: number;
  41983. height?: number;
  41984. depth?: number;
  41985. faceUV?: Vector4[];
  41986. faceColors?: Color4[];
  41987. sideOrientation?: number;
  41988. frontUVs?: Vector4;
  41989. backUVs?: Vector4;
  41990. wrap?: boolean;
  41991. topBaseAt?: number;
  41992. bottomBaseAt?: number;
  41993. updatable?: boolean;
  41994. }, scene?: Nullable<Scene>): Mesh;
  41995. }
  41996. }
  41997. declare module BABYLON {
  41998. /**
  41999. * Class containing static functions to help procedurally build meshes
  42000. */
  42001. export class SphereBuilder {
  42002. /**
  42003. * Creates a sphere mesh
  42004. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42005. * * 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`)
  42006. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42007. * * 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
  42008. * * 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)
  42009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42010. * * 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
  42011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42012. * @param name defines the name of the mesh
  42013. * @param options defines the options used to create the mesh
  42014. * @param scene defines the hosting scene
  42015. * @returns the sphere mesh
  42016. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42017. */
  42018. static CreateSphere(name: string, options: {
  42019. segments?: number;
  42020. diameter?: number;
  42021. diameterX?: number;
  42022. diameterY?: number;
  42023. diameterZ?: number;
  42024. arc?: number;
  42025. slice?: number;
  42026. sideOrientation?: number;
  42027. frontUVs?: Vector4;
  42028. backUVs?: Vector4;
  42029. updatable?: boolean;
  42030. }, scene: any): Mesh;
  42031. }
  42032. }
  42033. declare module BABYLON.Debug {
  42034. /**
  42035. * Used to show the physics impostor around the specific mesh
  42036. */
  42037. export class PhysicsViewer {
  42038. /** @hidden */
  42039. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42040. /** @hidden */
  42041. protected _meshes: Array<Nullable<AbstractMesh>>;
  42042. /** @hidden */
  42043. protected _scene: Nullable<Scene>;
  42044. /** @hidden */
  42045. protected _numMeshes: number;
  42046. /** @hidden */
  42047. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42048. private _renderFunction;
  42049. private _utilityLayer;
  42050. private _debugBoxMesh;
  42051. private _debugSphereMesh;
  42052. private _debugCylinderMesh;
  42053. private _debugMaterial;
  42054. private _debugMeshMeshes;
  42055. /**
  42056. * Creates a new PhysicsViewer
  42057. * @param scene defines the hosting scene
  42058. */
  42059. constructor(scene: Scene);
  42060. /** @hidden */
  42061. protected _updateDebugMeshes(): void;
  42062. /**
  42063. * Renders a specified physic impostor
  42064. * @param impostor defines the impostor to render
  42065. * @param targetMesh defines the mesh represented by the impostor
  42066. * @returns the new debug mesh used to render the impostor
  42067. */
  42068. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42069. /**
  42070. * Hides a specified physic impostor
  42071. * @param impostor defines the impostor to hide
  42072. */
  42073. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42074. private _getDebugMaterial;
  42075. private _getDebugBoxMesh;
  42076. private _getDebugSphereMesh;
  42077. private _getDebugCylinderMesh;
  42078. private _getDebugMeshMesh;
  42079. private _getDebugMesh;
  42080. /** Releases all resources */
  42081. dispose(): void;
  42082. }
  42083. }
  42084. declare module BABYLON {
  42085. /**
  42086. * Class containing static functions to help procedurally build meshes
  42087. */
  42088. export class LinesBuilder {
  42089. /**
  42090. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42091. * * 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
  42092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42093. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42094. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42095. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42097. * * 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
  42098. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42101. * @param name defines the name of the new line system
  42102. * @param options defines the options used to create the line system
  42103. * @param scene defines the hosting scene
  42104. * @returns a new line system mesh
  42105. */
  42106. static CreateLineSystem(name: string, options: {
  42107. lines: Vector3[][];
  42108. updatable?: boolean;
  42109. instance?: Nullable<LinesMesh>;
  42110. colors?: Nullable<Color4[][]>;
  42111. useVertexAlpha?: boolean;
  42112. }, scene: Nullable<Scene>): LinesMesh;
  42113. /**
  42114. * Creates a line mesh
  42115. * 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
  42116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42117. * * The parameter `points` is an array successive Vector3
  42118. * * 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
  42119. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42120. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42121. * * When updating an instance, remember that only point positions can change, not the number of points
  42122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42124. * @param name defines the name of the new line system
  42125. * @param options defines the options used to create the line system
  42126. * @param scene defines the hosting scene
  42127. * @returns a new line mesh
  42128. */
  42129. static CreateLines(name: string, options: {
  42130. points: Vector3[];
  42131. updatable?: boolean;
  42132. instance?: Nullable<LinesMesh>;
  42133. colors?: Color4[];
  42134. useVertexAlpha?: boolean;
  42135. }, scene?: Nullable<Scene>): LinesMesh;
  42136. /**
  42137. * Creates a dashed line mesh
  42138. * * 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
  42139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42140. * * The parameter `points` is an array successive Vector3
  42141. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42142. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42143. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42144. * * 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
  42145. * * When updating an instance, remember that only point positions can change, not the number of points
  42146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42147. * @param name defines the name of the mesh
  42148. * @param options defines the options used to create the mesh
  42149. * @param scene defines the hosting scene
  42150. * @returns the dashed line mesh
  42151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42152. */
  42153. static CreateDashedLines(name: string, options: {
  42154. points: Vector3[];
  42155. dashSize?: number;
  42156. gapSize?: number;
  42157. dashNb?: number;
  42158. updatable?: boolean;
  42159. instance?: LinesMesh;
  42160. }, scene?: Nullable<Scene>): LinesMesh;
  42161. }
  42162. }
  42163. declare module BABYLON {
  42164. /**
  42165. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42166. * in order to better appreciate the issue one might have.
  42167. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42168. */
  42169. export class RayHelper {
  42170. /**
  42171. * Defines the ray we are currently tryin to visualize.
  42172. */
  42173. ray: Nullable<Ray>;
  42174. private _renderPoints;
  42175. private _renderLine;
  42176. private _renderFunction;
  42177. private _scene;
  42178. private _updateToMeshFunction;
  42179. private _attachedToMesh;
  42180. private _meshSpaceDirection;
  42181. private _meshSpaceOrigin;
  42182. /**
  42183. * Helper function to create a colored helper in a scene in one line.
  42184. * @param ray Defines the ray we are currently tryin to visualize
  42185. * @param scene Defines the scene the ray is used in
  42186. * @param color Defines the color we want to see the ray in
  42187. * @returns The newly created ray helper.
  42188. */
  42189. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42190. /**
  42191. * Instantiate a new ray helper.
  42192. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42193. * in order to better appreciate the issue one might have.
  42194. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42195. * @param ray Defines the ray we are currently tryin to visualize
  42196. */
  42197. constructor(ray: Ray);
  42198. /**
  42199. * Shows the ray we are willing to debug.
  42200. * @param scene Defines the scene the ray needs to be rendered in
  42201. * @param color Defines the color the ray needs to be rendered in
  42202. */
  42203. show(scene: Scene, color?: Color3): void;
  42204. /**
  42205. * Hides the ray we are debugging.
  42206. */
  42207. hide(): void;
  42208. private _render;
  42209. /**
  42210. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42211. * @param mesh Defines the mesh we want the helper attached to
  42212. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42213. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42214. * @param length Defines the length of the ray
  42215. */
  42216. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42217. /**
  42218. * Detach the ray helper from the mesh it has previously been attached to.
  42219. */
  42220. detachFromMesh(): void;
  42221. private _updateToMesh;
  42222. /**
  42223. * Dispose the helper and release its associated resources.
  42224. */
  42225. dispose(): void;
  42226. }
  42227. }
  42228. declare module BABYLON.Debug {
  42229. /**
  42230. * Class used to render a debug view of a given skeleton
  42231. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42232. */
  42233. export class SkeletonViewer {
  42234. /** defines the skeleton to render */
  42235. skeleton: Skeleton;
  42236. /** defines the mesh attached to the skeleton */
  42237. mesh: AbstractMesh;
  42238. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42239. autoUpdateBonesMatrices: boolean;
  42240. /** defines the rendering group id to use with the viewer */
  42241. renderingGroupId: number;
  42242. /** Gets or sets the color used to render the skeleton */
  42243. color: Color3;
  42244. private _scene;
  42245. private _debugLines;
  42246. private _debugMesh;
  42247. private _isEnabled;
  42248. private _renderFunction;
  42249. private _utilityLayer;
  42250. /**
  42251. * Returns the mesh used to render the bones
  42252. */
  42253. readonly debugMesh: Nullable<LinesMesh>;
  42254. /**
  42255. * Creates a new SkeletonViewer
  42256. * @param skeleton defines the skeleton to render
  42257. * @param mesh defines the mesh attached to the skeleton
  42258. * @param scene defines the hosting scene
  42259. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42260. * @param renderingGroupId defines the rendering group id to use with the viewer
  42261. */
  42262. constructor(
  42263. /** defines the skeleton to render */
  42264. skeleton: Skeleton,
  42265. /** defines the mesh attached to the skeleton */
  42266. mesh: AbstractMesh, scene: Scene,
  42267. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42268. autoUpdateBonesMatrices?: boolean,
  42269. /** defines the rendering group id to use with the viewer */
  42270. renderingGroupId?: number);
  42271. /** Gets or sets a boolean indicating if the viewer is enabled */
  42272. isEnabled: boolean;
  42273. private _getBonePosition;
  42274. private _getLinesForBonesWithLength;
  42275. private _getLinesForBonesNoLength;
  42276. /** Update the viewer to sync with current skeleton state */
  42277. update(): void;
  42278. /** Release associated resources */
  42279. dispose(): void;
  42280. }
  42281. }
  42282. declare module BABYLON {
  42283. /**
  42284. * Options to create the null engine
  42285. */
  42286. export class NullEngineOptions {
  42287. /**
  42288. * Render width (Default: 512)
  42289. */
  42290. renderWidth: number;
  42291. /**
  42292. * Render height (Default: 256)
  42293. */
  42294. renderHeight: number;
  42295. /**
  42296. * Texture size (Default: 512)
  42297. */
  42298. textureSize: number;
  42299. /**
  42300. * If delta time between frames should be constant
  42301. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42302. */
  42303. deterministicLockstep: boolean;
  42304. /**
  42305. * Maximum about of steps between frames (Default: 4)
  42306. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42307. */
  42308. lockstepMaxSteps: number;
  42309. }
  42310. /**
  42311. * The null engine class provides support for headless version of babylon.js.
  42312. * This can be used in server side scenario or for testing purposes
  42313. */
  42314. export class NullEngine extends Engine {
  42315. private _options;
  42316. /**
  42317. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42318. */
  42319. isDeterministicLockStep(): boolean;
  42320. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42321. getLockstepMaxSteps(): number;
  42322. /**
  42323. * Sets hardware scaling, used to save performance if needed
  42324. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42325. */
  42326. getHardwareScalingLevel(): number;
  42327. constructor(options?: NullEngineOptions);
  42328. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42329. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42330. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42331. getRenderWidth(useScreen?: boolean): number;
  42332. getRenderHeight(useScreen?: boolean): number;
  42333. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42334. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42335. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42336. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42337. bindSamplers(effect: Effect): void;
  42338. enableEffect(effect: Effect): void;
  42339. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42340. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42341. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42342. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42343. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42344. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42345. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42346. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42347. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42348. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42349. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42350. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42351. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42352. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42353. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42354. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42355. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42356. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42357. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42358. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42359. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42360. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42361. bindBuffers(vertexBuffers: {
  42362. [key: string]: VertexBuffer;
  42363. }, indexBuffer: DataBuffer, effect: Effect): void;
  42364. wipeCaches(bruteForce?: boolean): void;
  42365. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42366. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42367. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42368. /** @hidden */ private _createTexture(): WebGLTexture;
  42369. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42370. 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;
  42371. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42372. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42374. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42375. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42376. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42377. areAllEffectsReady(): boolean;
  42378. /**
  42379. * @hidden
  42380. * Get the current error code of the webGL context
  42381. * @returns the error code
  42382. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42383. */
  42384. getError(): number;
  42385. /** @hidden */ private _getUnpackAlignement(): number;
  42386. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42387. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42388. /**
  42389. * Updates a dynamic vertex buffer.
  42390. * @param vertexBuffer the vertex buffer to update
  42391. * @param data the data used to update the vertex buffer
  42392. * @param byteOffset the byte offset of the data (optional)
  42393. * @param byteLength the byte length of the data (optional)
  42394. */
  42395. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42396. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42397. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  42398. releaseEffects(): void;
  42399. displayLoadingUI(): void;
  42400. hideLoadingUI(): void;
  42401. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42402. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42403. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42404. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42405. }
  42406. }
  42407. declare module BABYLON {
  42408. /** @hidden */
  42409. export class _OcclusionDataStorage {
  42410. /** @hidden */
  42411. occlusionInternalRetryCounter: number;
  42412. /** @hidden */
  42413. isOcclusionQueryInProgress: boolean;
  42414. /** @hidden */
  42415. isOccluded: boolean;
  42416. /** @hidden */
  42417. occlusionRetryCount: number;
  42418. /** @hidden */
  42419. occlusionType: number;
  42420. /** @hidden */
  42421. occlusionQueryAlgorithmType: number;
  42422. }
  42423. interface Engine {
  42424. /**
  42425. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42426. * @return the new query
  42427. */
  42428. createQuery(): WebGLQuery;
  42429. /**
  42430. * Delete and release a webGL query
  42431. * @param query defines the query to delete
  42432. * @return the current engine
  42433. */
  42434. deleteQuery(query: WebGLQuery): Engine;
  42435. /**
  42436. * Check if a given query has resolved and got its value
  42437. * @param query defines the query to check
  42438. * @returns true if the query got its value
  42439. */
  42440. isQueryResultAvailable(query: WebGLQuery): boolean;
  42441. /**
  42442. * Gets the value of a given query
  42443. * @param query defines the query to check
  42444. * @returns the value of the query
  42445. */
  42446. getQueryResult(query: WebGLQuery): number;
  42447. /**
  42448. * Initiates an occlusion query
  42449. * @param algorithmType defines the algorithm to use
  42450. * @param query defines the query to use
  42451. * @returns the current engine
  42452. * @see http://doc.babylonjs.com/features/occlusionquery
  42453. */
  42454. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42455. /**
  42456. * Ends an occlusion query
  42457. * @see http://doc.babylonjs.com/features/occlusionquery
  42458. * @param algorithmType defines the algorithm to use
  42459. * @returns the current engine
  42460. */
  42461. endOcclusionQuery(algorithmType: number): Engine;
  42462. /**
  42463. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42464. * Please note that only one query can be issued at a time
  42465. * @returns a time token used to track the time span
  42466. */
  42467. startTimeQuery(): Nullable<_TimeToken>;
  42468. /**
  42469. * Ends a time query
  42470. * @param token defines the token used to measure the time span
  42471. * @returns the time spent (in ns)
  42472. */
  42473. endTimeQuery(token: _TimeToken): int;
  42474. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42475. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42476. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42477. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42478. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42479. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42480. }
  42481. interface AbstractMesh {
  42482. /**
  42483. * Backing filed
  42484. * @hidden
  42485. */ private __occlusionDataStorage: _OcclusionDataStorage;
  42486. /**
  42487. * Access property
  42488. * @hidden
  42489. */ private _occlusionDataStorage: _OcclusionDataStorage;
  42490. /**
  42491. * 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.
  42492. * The default value is -1 which means don't break the query and wait till the result
  42493. * @see http://doc.babylonjs.com/features/occlusionquery
  42494. */
  42495. occlusionRetryCount: number;
  42496. /**
  42497. * 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:
  42498. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42499. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42500. * * 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.
  42501. * @see http://doc.babylonjs.com/features/occlusionquery
  42502. */
  42503. occlusionType: number;
  42504. /**
  42505. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42506. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42507. * * 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.
  42508. * @see http://doc.babylonjs.com/features/occlusionquery
  42509. */
  42510. occlusionQueryAlgorithmType: number;
  42511. /**
  42512. * 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
  42513. * @see http://doc.babylonjs.com/features/occlusionquery
  42514. */
  42515. isOccluded: boolean;
  42516. /**
  42517. * Flag to check the progress status of the query
  42518. * @see http://doc.babylonjs.com/features/occlusionquery
  42519. */
  42520. isOcclusionQueryInProgress: boolean;
  42521. }
  42522. }
  42523. declare module BABYLON {
  42524. /** @hidden */
  42525. export var _forceTransformFeedbackToBundle: boolean;
  42526. interface Engine {
  42527. /**
  42528. * Creates a webGL transform feedback object
  42529. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42530. * @returns the webGL transform feedback object
  42531. */
  42532. createTransformFeedback(): WebGLTransformFeedback;
  42533. /**
  42534. * Delete a webGL transform feedback object
  42535. * @param value defines the webGL transform feedback object to delete
  42536. */
  42537. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42538. /**
  42539. * Bind a webGL transform feedback object to the webgl context
  42540. * @param value defines the webGL transform feedback object to bind
  42541. */
  42542. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42543. /**
  42544. * Begins a transform feedback operation
  42545. * @param usePoints defines if points or triangles must be used
  42546. */
  42547. beginTransformFeedback(usePoints: boolean): void;
  42548. /**
  42549. * Ends a transform feedback operation
  42550. */
  42551. endTransformFeedback(): void;
  42552. /**
  42553. * Specify the varyings to use with transform feedback
  42554. * @param program defines the associated webGL program
  42555. * @param value defines the list of strings representing the varying names
  42556. */
  42557. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42558. /**
  42559. * Bind a webGL buffer for a transform feedback operation
  42560. * @param value defines the webGL buffer to bind
  42561. */
  42562. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Creation options of the multi render target texture.
  42568. */
  42569. export interface IMultiRenderTargetOptions {
  42570. /**
  42571. * Define if the texture needs to create mip maps after render.
  42572. */
  42573. generateMipMaps?: boolean;
  42574. /**
  42575. * Define the types of all the draw buffers we want to create
  42576. */
  42577. types?: number[];
  42578. /**
  42579. * Define the sampling modes of all the draw buffers we want to create
  42580. */
  42581. samplingModes?: number[];
  42582. /**
  42583. * Define if a depth buffer is required
  42584. */
  42585. generateDepthBuffer?: boolean;
  42586. /**
  42587. * Define if a stencil buffer is required
  42588. */
  42589. generateStencilBuffer?: boolean;
  42590. /**
  42591. * Define if a depth texture is required instead of a depth buffer
  42592. */
  42593. generateDepthTexture?: boolean;
  42594. /**
  42595. * Define the number of desired draw buffers
  42596. */
  42597. textureCount?: number;
  42598. /**
  42599. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42600. */
  42601. doNotChangeAspectRatio?: boolean;
  42602. /**
  42603. * Define the default type of the buffers we are creating
  42604. */
  42605. defaultType?: number;
  42606. }
  42607. /**
  42608. * A multi render target, like a render target provides the ability to render to a texture.
  42609. * Unlike the render target, it can render to several draw buffers in one draw.
  42610. * This is specially interesting in deferred rendering or for any effects requiring more than
  42611. * just one color from a single pass.
  42612. */
  42613. export class MultiRenderTarget extends RenderTargetTexture {
  42614. private _internalTextures;
  42615. private _textures;
  42616. private _multiRenderTargetOptions;
  42617. /**
  42618. * Get if draw buffers are currently supported by the used hardware and browser.
  42619. */
  42620. readonly isSupported: boolean;
  42621. /**
  42622. * Get the list of textures generated by the multi render target.
  42623. */
  42624. readonly textures: Texture[];
  42625. /**
  42626. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42627. */
  42628. readonly depthTexture: Texture;
  42629. /**
  42630. * Set the wrapping mode on U of all the textures we are rendering to.
  42631. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42632. */
  42633. wrapU: number;
  42634. /**
  42635. * Set the wrapping mode on V of all the textures we are rendering to.
  42636. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42637. */
  42638. wrapV: number;
  42639. /**
  42640. * Instantiate a new multi render target texture.
  42641. * A multi render target, like a render target provides the ability to render to a texture.
  42642. * Unlike the render target, it can render to several draw buffers in one draw.
  42643. * This is specially interesting in deferred rendering or for any effects requiring more than
  42644. * just one color from a single pass.
  42645. * @param name Define the name of the texture
  42646. * @param size Define the size of the buffers to render to
  42647. * @param count Define the number of target we are rendering into
  42648. * @param scene Define the scene the texture belongs to
  42649. * @param options Define the options used to create the multi render target
  42650. */
  42651. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42652. /** @hidden */ private _rebuild(): void;
  42653. private _createInternalTextures;
  42654. private _createTextures;
  42655. /**
  42656. * Define the number of samples used if MSAA is enabled.
  42657. */
  42658. samples: number;
  42659. /**
  42660. * Resize all the textures in the multi render target.
  42661. * Be carrefull as it will recreate all the data in the new texture.
  42662. * @param size Define the new size
  42663. */
  42664. resize(size: any): void;
  42665. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42666. /**
  42667. * Dispose the render targets and their associated resources
  42668. */
  42669. dispose(): void;
  42670. /**
  42671. * Release all the underlying texture used as draw buffers.
  42672. */
  42673. releaseInternalTextures(): void;
  42674. }
  42675. }
  42676. declare module BABYLON {
  42677. interface Engine {
  42678. /**
  42679. * Unbind a list of render target textures from the webGL context
  42680. * This is used only when drawBuffer extension or webGL2 are active
  42681. * @param textures defines the render target textures to unbind
  42682. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42683. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42684. */
  42685. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42686. /**
  42687. * Create a multi render target texture
  42688. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42689. * @param size defines the size of the texture
  42690. * @param options defines the creation options
  42691. * @returns the cube texture as an InternalTexture
  42692. */
  42693. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42694. /**
  42695. * Update the sample count for a given multiple render target texture
  42696. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42697. * @param textures defines the textures to update
  42698. * @param samples defines the sample count to set
  42699. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42700. */
  42701. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42702. }
  42703. }
  42704. declare module BABYLON {
  42705. /**
  42706. * Gather the list of clipboard event types as constants.
  42707. */
  42708. export class ClipboardEventTypes {
  42709. /**
  42710. * The clipboard event is fired when a copy command is active (pressed).
  42711. */
  42712. static readonly COPY: number;
  42713. /**
  42714. * The clipboard event is fired when a cut command is active (pressed).
  42715. */
  42716. static readonly CUT: number;
  42717. /**
  42718. * The clipboard event is fired when a paste command is active (pressed).
  42719. */
  42720. static readonly PASTE: number;
  42721. }
  42722. /**
  42723. * This class is used to store clipboard related info for the onClipboardObservable event.
  42724. */
  42725. export class ClipboardInfo {
  42726. /**
  42727. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42728. */
  42729. type: number;
  42730. /**
  42731. * Defines the related dom event
  42732. */
  42733. event: ClipboardEvent;
  42734. /**
  42735. *Creates an instance of ClipboardInfo.
  42736. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42737. * @param event Defines the related dom event
  42738. */
  42739. constructor(
  42740. /**
  42741. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42742. */
  42743. type: number,
  42744. /**
  42745. * Defines the related dom event
  42746. */
  42747. event: ClipboardEvent);
  42748. /**
  42749. * Get the clipboard event's type from the keycode.
  42750. * @param keyCode Defines the keyCode for the current keyboard event.
  42751. * @return {number}
  42752. */
  42753. static GetTypeFromCharacter(keyCode: number): number;
  42754. }
  42755. }
  42756. declare module BABYLON {
  42757. /**
  42758. * Google Daydream controller
  42759. */
  42760. export class DaydreamController extends WebVRController {
  42761. /**
  42762. * Base Url for the controller model.
  42763. */
  42764. static MODEL_BASE_URL: string;
  42765. /**
  42766. * File name for the controller model.
  42767. */
  42768. static MODEL_FILENAME: string;
  42769. /**
  42770. * Gamepad Id prefix used to identify Daydream Controller.
  42771. */
  42772. static readonly GAMEPAD_ID_PREFIX: string;
  42773. /**
  42774. * Creates a new DaydreamController from a gamepad
  42775. * @param vrGamepad the gamepad that the controller should be created from
  42776. */
  42777. constructor(vrGamepad: any);
  42778. /**
  42779. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42780. * @param scene scene in which to add meshes
  42781. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42782. */
  42783. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42784. /**
  42785. * Called once for each button that changed state since the last frame
  42786. * @param buttonIdx Which button index changed
  42787. * @param state New state of the button
  42788. * @param changes Which properties on the state changed since last frame
  42789. */
  42790. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42791. }
  42792. }
  42793. declare module BABYLON {
  42794. /**
  42795. * Gear VR Controller
  42796. */
  42797. export class GearVRController extends WebVRController {
  42798. /**
  42799. * Base Url for the controller model.
  42800. */
  42801. static MODEL_BASE_URL: string;
  42802. /**
  42803. * File name for the controller model.
  42804. */
  42805. static MODEL_FILENAME: string;
  42806. /**
  42807. * Gamepad Id prefix used to identify this controller.
  42808. */
  42809. static readonly GAMEPAD_ID_PREFIX: string;
  42810. private readonly _buttonIndexToObservableNameMap;
  42811. /**
  42812. * Creates a new GearVRController from a gamepad
  42813. * @param vrGamepad the gamepad that the controller should be created from
  42814. */
  42815. constructor(vrGamepad: any);
  42816. /**
  42817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42818. * @param scene scene in which to add meshes
  42819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42820. */
  42821. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42822. /**
  42823. * Called once for each button that changed state since the last frame
  42824. * @param buttonIdx Which button index changed
  42825. * @param state New state of the button
  42826. * @param changes Which properties on the state changed since last frame
  42827. */
  42828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42829. }
  42830. }
  42831. declare module BABYLON {
  42832. /**
  42833. * Class containing static functions to help procedurally build meshes
  42834. */
  42835. export class PolyhedronBuilder {
  42836. /**
  42837. * Creates a polyhedron mesh
  42838. * * 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
  42839. * * The parameter `size` (positive float, default 1) sets the polygon size
  42840. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42841. * * 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`
  42842. * * 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
  42843. * * 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)`)
  42844. * * 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
  42845. * * 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
  42846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42847. * * 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
  42848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42849. * @param name defines the name of the mesh
  42850. * @param options defines the options used to create the mesh
  42851. * @param scene defines the hosting scene
  42852. * @returns the polyhedron mesh
  42853. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42854. */
  42855. static CreatePolyhedron(name: string, options: {
  42856. type?: number;
  42857. size?: number;
  42858. sizeX?: number;
  42859. sizeY?: number;
  42860. sizeZ?: number;
  42861. custom?: any;
  42862. faceUV?: Vector4[];
  42863. faceColors?: Color4[];
  42864. flat?: boolean;
  42865. updatable?: boolean;
  42866. sideOrientation?: number;
  42867. frontUVs?: Vector4;
  42868. backUVs?: Vector4;
  42869. }, scene?: Nullable<Scene>): Mesh;
  42870. }
  42871. }
  42872. declare module BABYLON {
  42873. /**
  42874. * Gizmo that enables scaling a mesh along 3 axis
  42875. */
  42876. export class ScaleGizmo extends Gizmo {
  42877. /**
  42878. * Internal gizmo used for interactions on the x axis
  42879. */
  42880. xGizmo: AxisScaleGizmo;
  42881. /**
  42882. * Internal gizmo used for interactions on the y axis
  42883. */
  42884. yGizmo: AxisScaleGizmo;
  42885. /**
  42886. * Internal gizmo used for interactions on the z axis
  42887. */
  42888. zGizmo: AxisScaleGizmo;
  42889. /**
  42890. * Internal gizmo used to scale all axis equally
  42891. */
  42892. uniformScaleGizmo: AxisScaleGizmo;
  42893. private _meshAttached;
  42894. private _updateGizmoRotationToMatchAttachedMesh;
  42895. private _snapDistance;
  42896. private _scaleRatio;
  42897. private _uniformScalingMesh;
  42898. private _octahedron;
  42899. /** Fires an event when any of it's sub gizmos are dragged */
  42900. onDragStartObservable: Observable<unknown>;
  42901. /** Fires an event when any of it's sub gizmos are released from dragging */
  42902. onDragEndObservable: Observable<unknown>;
  42903. attachedMesh: Nullable<AbstractMesh>;
  42904. /**
  42905. * Creates a ScaleGizmo
  42906. * @param gizmoLayer The utility layer the gizmo will be added to
  42907. */
  42908. constructor(gizmoLayer?: UtilityLayerRenderer);
  42909. updateGizmoRotationToMatchAttachedMesh: boolean;
  42910. /**
  42911. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42912. */
  42913. snapDistance: number;
  42914. /**
  42915. * Ratio for the scale of the gizmo (Default: 1)
  42916. */
  42917. scaleRatio: number;
  42918. /**
  42919. * Disposes of the gizmo
  42920. */
  42921. dispose(): void;
  42922. }
  42923. }
  42924. declare module BABYLON {
  42925. /**
  42926. * Single axis scale gizmo
  42927. */
  42928. export class AxisScaleGizmo extends Gizmo {
  42929. /**
  42930. * Drag behavior responsible for the gizmos dragging interactions
  42931. */
  42932. dragBehavior: PointerDragBehavior;
  42933. private _pointerObserver;
  42934. /**
  42935. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42936. */
  42937. snapDistance: number;
  42938. /**
  42939. * Event that fires each time the gizmo snaps to a new location.
  42940. * * snapDistance is the the change in distance
  42941. */
  42942. onSnapObservable: Observable<{
  42943. snapDistance: number;
  42944. }>;
  42945. /**
  42946. * If the scaling operation should be done on all axis (default: false)
  42947. */
  42948. uniformScaling: boolean;
  42949. private _isEnabled;
  42950. private _parent;
  42951. private _arrow;
  42952. private _coloredMaterial;
  42953. private _hoverMaterial;
  42954. /**
  42955. * Creates an AxisScaleGizmo
  42956. * @param gizmoLayer The utility layer the gizmo will be added to
  42957. * @param dragAxis The axis which the gizmo will be able to scale on
  42958. * @param color The color of the gizmo
  42959. */
  42960. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  42961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42962. /**
  42963. * If the gizmo is enabled
  42964. */
  42965. isEnabled: boolean;
  42966. /**
  42967. * Disposes of the gizmo
  42968. */
  42969. dispose(): void;
  42970. /**
  42971. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42972. * @param mesh The mesh to replace the default mesh of the gizmo
  42973. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42974. */
  42975. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42976. }
  42977. }
  42978. declare module BABYLON {
  42979. /**
  42980. * Bounding box gizmo
  42981. */
  42982. export class BoundingBoxGizmo extends Gizmo {
  42983. private _lineBoundingBox;
  42984. private _rotateSpheresParent;
  42985. private _scaleBoxesParent;
  42986. private _boundingDimensions;
  42987. private _renderObserver;
  42988. private _pointerObserver;
  42989. private _scaleDragSpeed;
  42990. private _tmpQuaternion;
  42991. private _tmpVector;
  42992. private _tmpRotationMatrix;
  42993. /**
  42994. * 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)
  42995. */
  42996. ignoreChildren: boolean;
  42997. /**
  42998. * 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)
  42999. */
  43000. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43001. /**
  43002. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43003. */
  43004. rotationSphereSize: number;
  43005. /**
  43006. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43007. */
  43008. scaleBoxSize: number;
  43009. /**
  43010. * 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)
  43011. */
  43012. fixedDragMeshScreenSize: boolean;
  43013. /**
  43014. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43015. */
  43016. fixedDragMeshScreenSizeDistanceFactor: number;
  43017. /**
  43018. * Fired when a rotation sphere or scale box is dragged
  43019. */
  43020. onDragStartObservable: Observable<{}>;
  43021. /**
  43022. * Fired when a scale box is dragged
  43023. */
  43024. onScaleBoxDragObservable: Observable<{}>;
  43025. /**
  43026. * Fired when a scale box drag is ended
  43027. */
  43028. onScaleBoxDragEndObservable: Observable<{}>;
  43029. /**
  43030. * Fired when a rotation sphere is dragged
  43031. */
  43032. onRotationSphereDragObservable: Observable<{}>;
  43033. /**
  43034. * Fired when a rotation sphere drag is ended
  43035. */
  43036. onRotationSphereDragEndObservable: Observable<{}>;
  43037. /**
  43038. * 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)
  43039. */
  43040. scalePivot: Nullable<Vector3>;
  43041. /**
  43042. * Mesh used as a pivot to rotate the attached mesh
  43043. */
  43044. private _anchorMesh;
  43045. private _existingMeshScale;
  43046. private _dragMesh;
  43047. private pointerDragBehavior;
  43048. private coloredMaterial;
  43049. private hoverColoredMaterial;
  43050. /**
  43051. * Sets the color of the bounding box gizmo
  43052. * @param color the color to set
  43053. */
  43054. setColor(color: Color3): void;
  43055. /**
  43056. * Creates an BoundingBoxGizmo
  43057. * @param gizmoLayer The utility layer the gizmo will be added to
  43058. * @param color The color of the gizmo
  43059. */
  43060. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43061. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43062. private _selectNode;
  43063. /**
  43064. * Updates the bounding box information for the Gizmo
  43065. */
  43066. updateBoundingBox(): void;
  43067. private _updateRotationSpheres;
  43068. private _updateScaleBoxes;
  43069. /**
  43070. * Enables rotation on the specified axis and disables rotation on the others
  43071. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43072. */
  43073. setEnabledRotationAxis(axis: string): void;
  43074. /**
  43075. * Enables/disables scaling
  43076. * @param enable if scaling should be enabled
  43077. */
  43078. setEnabledScaling(enable: boolean): void;
  43079. private _updateDummy;
  43080. /**
  43081. * Enables a pointer drag behavior on the bounding box of the gizmo
  43082. */
  43083. enableDragBehavior(): void;
  43084. /**
  43085. * Disposes of the gizmo
  43086. */
  43087. dispose(): void;
  43088. /**
  43089. * 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)
  43090. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43091. * @returns the bounding box mesh with the passed in mesh as a child
  43092. */
  43093. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43094. /**
  43095. * CustomMeshes are not supported by this gizmo
  43096. * @param mesh The mesh to replace the default mesh of the gizmo
  43097. */
  43098. setCustomMesh(mesh: Mesh): void;
  43099. }
  43100. }
  43101. declare module BABYLON {
  43102. /**
  43103. * Single plane rotation gizmo
  43104. */
  43105. export class PlaneRotationGizmo extends Gizmo {
  43106. /**
  43107. * Drag behavior responsible for the gizmos dragging interactions
  43108. */
  43109. dragBehavior: PointerDragBehavior;
  43110. private _pointerObserver;
  43111. /**
  43112. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43113. */
  43114. snapDistance: number;
  43115. /**
  43116. * Event that fires each time the gizmo snaps to a new location.
  43117. * * snapDistance is the the change in distance
  43118. */
  43119. onSnapObservable: Observable<{
  43120. snapDistance: number;
  43121. }>;
  43122. private _isEnabled;
  43123. private _parent;
  43124. /**
  43125. * Creates a PlaneRotationGizmo
  43126. * @param gizmoLayer The utility layer the gizmo will be added to
  43127. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43128. * @param color The color of the gizmo
  43129. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43130. */
  43131. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43132. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43133. /**
  43134. * If the gizmo is enabled
  43135. */
  43136. isEnabled: boolean;
  43137. /**
  43138. * Disposes of the gizmo
  43139. */
  43140. dispose(): void;
  43141. }
  43142. }
  43143. declare module BABYLON {
  43144. /**
  43145. * Gizmo that enables rotating a mesh along 3 axis
  43146. */
  43147. export class RotationGizmo extends Gizmo {
  43148. /**
  43149. * Internal gizmo used for interactions on the x axis
  43150. */
  43151. xGizmo: PlaneRotationGizmo;
  43152. /**
  43153. * Internal gizmo used for interactions on the y axis
  43154. */
  43155. yGizmo: PlaneRotationGizmo;
  43156. /**
  43157. * Internal gizmo used for interactions on the z axis
  43158. */
  43159. zGizmo: PlaneRotationGizmo;
  43160. /** Fires an event when any of it's sub gizmos are dragged */
  43161. onDragStartObservable: Observable<unknown>;
  43162. /** Fires an event when any of it's sub gizmos are released from dragging */
  43163. onDragEndObservable: Observable<unknown>;
  43164. private _meshAttached;
  43165. attachedMesh: Nullable<AbstractMesh>;
  43166. /**
  43167. * Creates a RotationGizmo
  43168. * @param gizmoLayer The utility layer the gizmo will be added to
  43169. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43170. */
  43171. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43172. updateGizmoRotationToMatchAttachedMesh: boolean;
  43173. /**
  43174. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43175. */
  43176. snapDistance: number;
  43177. /**
  43178. * Ratio for the scale of the gizmo (Default: 1)
  43179. */
  43180. scaleRatio: number;
  43181. /**
  43182. * Disposes of the gizmo
  43183. */
  43184. dispose(): void;
  43185. /**
  43186. * CustomMeshes are not supported by this gizmo
  43187. * @param mesh The mesh to replace the default mesh of the gizmo
  43188. */
  43189. setCustomMesh(mesh: Mesh): void;
  43190. }
  43191. }
  43192. declare module BABYLON {
  43193. /**
  43194. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43195. */
  43196. export class GizmoManager implements IDisposable {
  43197. private scene;
  43198. /**
  43199. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43200. */
  43201. gizmos: {
  43202. positionGizmo: Nullable<PositionGizmo>;
  43203. rotationGizmo: Nullable<RotationGizmo>;
  43204. scaleGizmo: Nullable<ScaleGizmo>;
  43205. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43206. };
  43207. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43208. clearGizmoOnEmptyPointerEvent: boolean;
  43209. /** Fires an event when the manager is attached to a mesh */
  43210. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43211. private _gizmosEnabled;
  43212. private _pointerObserver;
  43213. private _attachedMesh;
  43214. private _boundingBoxColor;
  43215. private _defaultUtilityLayer;
  43216. private _defaultKeepDepthUtilityLayer;
  43217. /**
  43218. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43219. */
  43220. boundingBoxDragBehavior: SixDofDragBehavior;
  43221. /**
  43222. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43223. */
  43224. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43225. /**
  43226. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43227. */
  43228. usePointerToAttachGizmos: boolean;
  43229. /**
  43230. * Utility layer that the bounding box gizmo belongs to
  43231. */
  43232. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43233. /**
  43234. * Utility layer that all gizmos besides bounding box belong to
  43235. */
  43236. readonly utilityLayer: UtilityLayerRenderer;
  43237. /**
  43238. * Instatiates a gizmo manager
  43239. * @param scene the scene to overlay the gizmos on top of
  43240. */
  43241. constructor(scene: Scene);
  43242. /**
  43243. * Attaches a set of gizmos to the specified mesh
  43244. * @param mesh The mesh the gizmo's should be attached to
  43245. */
  43246. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43247. /**
  43248. * If the position gizmo is enabled
  43249. */
  43250. positionGizmoEnabled: boolean;
  43251. /**
  43252. * If the rotation gizmo is enabled
  43253. */
  43254. rotationGizmoEnabled: boolean;
  43255. /**
  43256. * If the scale gizmo is enabled
  43257. */
  43258. scaleGizmoEnabled: boolean;
  43259. /**
  43260. * If the boundingBox gizmo is enabled
  43261. */
  43262. boundingBoxGizmoEnabled: boolean;
  43263. /**
  43264. * Disposes of the gizmo manager
  43265. */
  43266. dispose(): void;
  43267. }
  43268. }
  43269. declare module BABYLON {
  43270. /**
  43271. * A directional light is defined by a direction (what a surprise!).
  43272. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43273. * 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.
  43274. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43275. */
  43276. export class DirectionalLight extends ShadowLight {
  43277. private _shadowFrustumSize;
  43278. /**
  43279. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43280. */
  43281. /**
  43282. * Specifies a fix frustum size for the shadow generation.
  43283. */
  43284. shadowFrustumSize: number;
  43285. private _shadowOrthoScale;
  43286. /**
  43287. * Gets the shadow projection scale against the optimal computed one.
  43288. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43289. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43290. */
  43291. /**
  43292. * Sets the shadow projection scale against the optimal computed one.
  43293. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43294. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43295. */
  43296. shadowOrthoScale: number;
  43297. /**
  43298. * Automatically compute the projection matrix to best fit (including all the casters)
  43299. * on each frame.
  43300. */
  43301. autoUpdateExtends: boolean;
  43302. private _orthoLeft;
  43303. private _orthoRight;
  43304. private _orthoTop;
  43305. private _orthoBottom;
  43306. /**
  43307. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43308. * The directional light is emitted from everywhere in the given direction.
  43309. * It can cast shadows.
  43310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43311. * @param name The friendly name of the light
  43312. * @param direction The direction of the light
  43313. * @param scene The scene the light belongs to
  43314. */
  43315. constructor(name: string, direction: Vector3, scene: Scene);
  43316. /**
  43317. * Returns the string "DirectionalLight".
  43318. * @return The class name
  43319. */
  43320. getClassName(): string;
  43321. /**
  43322. * Returns the integer 1.
  43323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43324. */
  43325. getTypeID(): number;
  43326. /**
  43327. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43328. * Returns the DirectionalLight Shadow projection matrix.
  43329. */
  43330. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43331. /**
  43332. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43333. * Returns the DirectionalLight Shadow projection matrix.
  43334. */
  43335. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43336. /**
  43337. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43338. * Returns the DirectionalLight Shadow projection matrix.
  43339. */
  43340. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43341. protected _buildUniformLayout(): void;
  43342. /**
  43343. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43344. * @param effect The effect to update
  43345. * @param lightIndex The index of the light in the effect to update
  43346. * @returns The directional light
  43347. */
  43348. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43349. /**
  43350. * Gets the minZ used for shadow according to both the scene and the light.
  43351. *
  43352. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43353. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43354. * @param activeCamera The camera we are returning the min for
  43355. * @returns the depth min z
  43356. */
  43357. getDepthMinZ(activeCamera: Camera): number;
  43358. /**
  43359. * Gets the maxZ used for shadow according to both the scene and the light.
  43360. *
  43361. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43362. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43363. * @param activeCamera The camera we are returning the max for
  43364. * @returns the depth max z
  43365. */
  43366. getDepthMaxZ(activeCamera: Camera): number;
  43367. /**
  43368. * Prepares the list of defines specific to the light type.
  43369. * @param defines the list of defines
  43370. * @param lightIndex defines the index of the light for the effect
  43371. */
  43372. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43373. }
  43374. }
  43375. declare module BABYLON {
  43376. /**
  43377. * Class containing static functions to help procedurally build meshes
  43378. */
  43379. export class HemisphereBuilder {
  43380. /**
  43381. * Creates a hemisphere mesh
  43382. * @param name defines the name of the mesh
  43383. * @param options defines the options used to create the mesh
  43384. * @param scene defines the hosting scene
  43385. * @returns the hemisphere mesh
  43386. */
  43387. static CreateHemisphere(name: string, options: {
  43388. segments?: number;
  43389. diameter?: number;
  43390. sideOrientation?: number;
  43391. }, scene: any): Mesh;
  43392. }
  43393. }
  43394. declare module BABYLON {
  43395. /**
  43396. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43397. * These values define a cone of light starting from the position, emitting toward the direction.
  43398. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43399. * and the exponent defines the speed of the decay of the light with distance (reach).
  43400. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43401. */
  43402. export class SpotLight extends ShadowLight {
  43403. private _angle;
  43404. private _innerAngle;
  43405. private _cosHalfAngle;
  43406. private _lightAngleScale;
  43407. private _lightAngleOffset;
  43408. /**
  43409. * Gets the cone angle of the spot light in Radians.
  43410. */
  43411. /**
  43412. * Sets the cone angle of the spot light in Radians.
  43413. */
  43414. angle: number;
  43415. /**
  43416. * Only used in gltf falloff mode, this defines the angle where
  43417. * the directional falloff will start before cutting at angle which could be seen
  43418. * as outer angle.
  43419. */
  43420. /**
  43421. * Only used in gltf falloff mode, this defines the angle where
  43422. * the directional falloff will start before cutting at angle which could be seen
  43423. * as outer angle.
  43424. */
  43425. innerAngle: number;
  43426. private _shadowAngleScale;
  43427. /**
  43428. * Allows scaling the angle of the light for shadow generation only.
  43429. */
  43430. /**
  43431. * Allows scaling the angle of the light for shadow generation only.
  43432. */
  43433. shadowAngleScale: number;
  43434. /**
  43435. * The light decay speed with the distance from the emission spot.
  43436. */
  43437. exponent: number;
  43438. private _projectionTextureMatrix;
  43439. /**
  43440. * Allows reading the projecton texture
  43441. */
  43442. readonly projectionTextureMatrix: Matrix;
  43443. protected _projectionTextureLightNear: number;
  43444. /**
  43445. * Gets the near clip of the Spotlight for texture projection.
  43446. */
  43447. /**
  43448. * Sets the near clip of the Spotlight for texture projection.
  43449. */
  43450. projectionTextureLightNear: number;
  43451. protected _projectionTextureLightFar: number;
  43452. /**
  43453. * Gets the far clip of the Spotlight for texture projection.
  43454. */
  43455. /**
  43456. * Sets the far clip of the Spotlight for texture projection.
  43457. */
  43458. projectionTextureLightFar: number;
  43459. protected _projectionTextureUpDirection: Vector3;
  43460. /**
  43461. * Gets the Up vector of the Spotlight for texture projection.
  43462. */
  43463. /**
  43464. * Sets the Up vector of the Spotlight for texture projection.
  43465. */
  43466. projectionTextureUpDirection: Vector3;
  43467. private _projectionTexture;
  43468. /**
  43469. * Gets the projection texture of the light.
  43470. */
  43471. /**
  43472. * Sets the projection texture of the light.
  43473. */
  43474. projectionTexture: Nullable<BaseTexture>;
  43475. private _projectionTextureViewLightDirty;
  43476. private _projectionTextureProjectionLightDirty;
  43477. private _projectionTextureDirty;
  43478. private _projectionTextureViewTargetVector;
  43479. private _projectionTextureViewLightMatrix;
  43480. private _projectionTextureProjectionLightMatrix;
  43481. private _projectionTextureScalingMatrix;
  43482. /**
  43483. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43484. * It can cast shadows.
  43485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43486. * @param name The light friendly name
  43487. * @param position The position of the spot light in the scene
  43488. * @param direction The direction of the light in the scene
  43489. * @param angle The cone angle of the light in Radians
  43490. * @param exponent The light decay speed with the distance from the emission spot
  43491. * @param scene The scene the lights belongs to
  43492. */
  43493. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43494. /**
  43495. * Returns the string "SpotLight".
  43496. * @returns the class name
  43497. */
  43498. getClassName(): string;
  43499. /**
  43500. * Returns the integer 2.
  43501. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43502. */
  43503. getTypeID(): number;
  43504. /**
  43505. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43506. */
  43507. protected _setDirection(value: Vector3): void;
  43508. /**
  43509. * Overrides the position setter to recompute the projection texture view light Matrix.
  43510. */
  43511. protected _setPosition(value: Vector3): void;
  43512. /**
  43513. * 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.
  43514. * Returns the SpotLight.
  43515. */
  43516. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43517. protected _computeProjectionTextureViewLightMatrix(): void;
  43518. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43519. /**
  43520. * Main function for light texture projection matrix computing.
  43521. */
  43522. protected _computeProjectionTextureMatrix(): void;
  43523. protected _buildUniformLayout(): void;
  43524. private _computeAngleValues;
  43525. /**
  43526. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43527. * @param effect The effect to update
  43528. * @param lightIndex The index of the light in the effect to update
  43529. * @returns The spot light
  43530. */
  43531. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43532. /**
  43533. * Disposes the light and the associated resources.
  43534. */
  43535. dispose(): void;
  43536. /**
  43537. * Prepares the list of defines specific to the light type.
  43538. * @param defines the list of defines
  43539. * @param lightIndex defines the index of the light for the effect
  43540. */
  43541. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43542. }
  43543. }
  43544. declare module BABYLON {
  43545. /**
  43546. * Gizmo that enables viewing a light
  43547. */
  43548. export class LightGizmo extends Gizmo {
  43549. private _lightMesh;
  43550. private _material;
  43551. private cachedPosition;
  43552. private cachedForward;
  43553. /**
  43554. * Creates a LightGizmo
  43555. * @param gizmoLayer The utility layer the gizmo will be added to
  43556. */
  43557. constructor(gizmoLayer?: UtilityLayerRenderer);
  43558. private _light;
  43559. /**
  43560. * The light that the gizmo is attached to
  43561. */
  43562. light: Nullable<Light>;
  43563. /**
  43564. * @hidden
  43565. * Updates the gizmo to match the attached mesh's position/rotation
  43566. */
  43567. protected _update(): void;
  43568. private static _Scale;
  43569. /**
  43570. * Creates the lines for a light mesh
  43571. */
  43572. private static _createLightLines;
  43573. /**
  43574. * Disposes of the light gizmo
  43575. */
  43576. dispose(): void;
  43577. private static _CreateHemisphericLightMesh;
  43578. private static _CreatePointLightMesh;
  43579. private static _CreateSpotLightMesh;
  43580. private static _CreateDirectionalLightMesh;
  43581. }
  43582. }
  43583. declare module BABYLON {
  43584. /** @hidden */
  43585. export var backgroundFragmentDeclaration: {
  43586. name: string;
  43587. shader: string;
  43588. };
  43589. }
  43590. declare module BABYLON {
  43591. /** @hidden */
  43592. export var backgroundUboDeclaration: {
  43593. name: string;
  43594. shader: string;
  43595. };
  43596. }
  43597. declare module BABYLON {
  43598. /** @hidden */
  43599. export var backgroundPixelShader: {
  43600. name: string;
  43601. shader: string;
  43602. };
  43603. }
  43604. declare module BABYLON {
  43605. /** @hidden */
  43606. export var backgroundVertexDeclaration: {
  43607. name: string;
  43608. shader: string;
  43609. };
  43610. }
  43611. declare module BABYLON {
  43612. /** @hidden */
  43613. export var backgroundVertexShader: {
  43614. name: string;
  43615. shader: string;
  43616. };
  43617. }
  43618. declare module BABYLON {
  43619. /**
  43620. * Background material used to create an efficient environement around your scene.
  43621. */
  43622. export class BackgroundMaterial extends PushMaterial {
  43623. /**
  43624. * Standard reflectance value at parallel view angle.
  43625. */
  43626. static StandardReflectance0: number;
  43627. /**
  43628. * Standard reflectance value at grazing angle.
  43629. */
  43630. static StandardReflectance90: number;
  43631. protected _primaryColor: Color3;
  43632. /**
  43633. * Key light Color (multiply against the environement texture)
  43634. */
  43635. primaryColor: Color3;
  43636. protected __perceptualColor: Nullable<Color3>;
  43637. /**
  43638. * Experimental Internal Use Only.
  43639. *
  43640. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43641. * This acts as a helper to set the primary color to a more "human friendly" value.
  43642. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43643. * output color as close as possible from the chosen value.
  43644. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43645. * part of lighting setup.)
  43646. */ private _perceptualColor: Nullable<Color3>;
  43647. protected _primaryColorShadowLevel: float;
  43648. /**
  43649. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43650. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43651. */
  43652. primaryColorShadowLevel: float;
  43653. protected _primaryColorHighlightLevel: float;
  43654. /**
  43655. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43656. * The primary color is used at the level chosen to define what the white area would look.
  43657. */
  43658. primaryColorHighlightLevel: float;
  43659. protected _reflectionTexture: Nullable<BaseTexture>;
  43660. /**
  43661. * Reflection Texture used in the material.
  43662. * Should be author in a specific way for the best result (refer to the documentation).
  43663. */
  43664. reflectionTexture: Nullable<BaseTexture>;
  43665. protected _reflectionBlur: float;
  43666. /**
  43667. * Reflection Texture level of blur.
  43668. *
  43669. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43670. * texture twice.
  43671. */
  43672. reflectionBlur: float;
  43673. protected _diffuseTexture: Nullable<BaseTexture>;
  43674. /**
  43675. * Diffuse Texture used in the material.
  43676. * Should be author in a specific way for the best result (refer to the documentation).
  43677. */
  43678. diffuseTexture: Nullable<BaseTexture>;
  43679. protected _shadowLights: Nullable<IShadowLight[]>;
  43680. /**
  43681. * Specify the list of lights casting shadow on the material.
  43682. * All scene shadow lights will be included if null.
  43683. */
  43684. shadowLights: Nullable<IShadowLight[]>;
  43685. protected _shadowLevel: float;
  43686. /**
  43687. * Helps adjusting the shadow to a softer level if required.
  43688. * 0 means black shadows and 1 means no shadows.
  43689. */
  43690. shadowLevel: float;
  43691. protected _sceneCenter: Vector3;
  43692. /**
  43693. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43694. * It is usually zero but might be interesting to modify according to your setup.
  43695. */
  43696. sceneCenter: Vector3;
  43697. protected _opacityFresnel: boolean;
  43698. /**
  43699. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43700. * This helps ensuring a nice transition when the camera goes under the ground.
  43701. */
  43702. opacityFresnel: boolean;
  43703. protected _reflectionFresnel: boolean;
  43704. /**
  43705. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43706. * This helps adding a mirror texture on the ground.
  43707. */
  43708. reflectionFresnel: boolean;
  43709. protected _reflectionFalloffDistance: number;
  43710. /**
  43711. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43712. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43713. */
  43714. reflectionFalloffDistance: number;
  43715. protected _reflectionAmount: number;
  43716. /**
  43717. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43718. */
  43719. reflectionAmount: number;
  43720. protected _reflectionReflectance0: number;
  43721. /**
  43722. * This specifies the weight of the reflection at grazing angle.
  43723. */
  43724. reflectionReflectance0: number;
  43725. protected _reflectionReflectance90: number;
  43726. /**
  43727. * This specifies the weight of the reflection at a perpendicular point of view.
  43728. */
  43729. reflectionReflectance90: number;
  43730. /**
  43731. * Sets the reflection reflectance fresnel values according to the default standard
  43732. * empirically know to work well :-)
  43733. */
  43734. reflectionStandardFresnelWeight: number;
  43735. protected _useRGBColor: boolean;
  43736. /**
  43737. * Helps to directly use the maps channels instead of their level.
  43738. */
  43739. useRGBColor: boolean;
  43740. protected _enableNoise: boolean;
  43741. /**
  43742. * This helps reducing the banding effect that could occur on the background.
  43743. */
  43744. enableNoise: boolean;
  43745. /**
  43746. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43747. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43748. * Recommended to be keep at 1.0 except for special cases.
  43749. */
  43750. fovMultiplier: number;
  43751. private _fovMultiplier;
  43752. /**
  43753. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43754. */
  43755. useEquirectangularFOV: boolean;
  43756. private _maxSimultaneousLights;
  43757. /**
  43758. * Number of Simultaneous lights allowed on the material.
  43759. */
  43760. maxSimultaneousLights: int;
  43761. /**
  43762. * Default configuration related to image processing available in the Background Material.
  43763. */
  43764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43765. /**
  43766. * Keep track of the image processing observer to allow dispose and replace.
  43767. */
  43768. private _imageProcessingObserver;
  43769. /**
  43770. * Attaches a new image processing configuration to the PBR Material.
  43771. * @param configuration (if null the scene configuration will be use)
  43772. */
  43773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43774. /**
  43775. * Gets the image processing configuration used either in this material.
  43776. */
  43777. /**
  43778. * Sets the Default image processing configuration used either in the this material.
  43779. *
  43780. * If sets to null, the scene one is in use.
  43781. */
  43782. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43783. /**
  43784. * Gets wether the color curves effect is enabled.
  43785. */
  43786. /**
  43787. * Sets wether the color curves effect is enabled.
  43788. */
  43789. cameraColorCurvesEnabled: boolean;
  43790. /**
  43791. * Gets wether the color grading effect is enabled.
  43792. */
  43793. /**
  43794. * Gets wether the color grading effect is enabled.
  43795. */
  43796. cameraColorGradingEnabled: boolean;
  43797. /**
  43798. * Gets wether tonemapping is enabled or not.
  43799. */
  43800. /**
  43801. * Sets wether tonemapping is enabled or not
  43802. */
  43803. cameraToneMappingEnabled: boolean;
  43804. /**
  43805. * The camera exposure used on this material.
  43806. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43807. * This corresponds to a photographic exposure.
  43808. */
  43809. /**
  43810. * The camera exposure used on this material.
  43811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43812. * This corresponds to a photographic exposure.
  43813. */
  43814. cameraExposure: float;
  43815. /**
  43816. * Gets The camera contrast used on this material.
  43817. */
  43818. /**
  43819. * Sets The camera contrast used on this material.
  43820. */
  43821. cameraContrast: float;
  43822. /**
  43823. * Gets the Color Grading 2D Lookup Texture.
  43824. */
  43825. /**
  43826. * Sets the Color Grading 2D Lookup Texture.
  43827. */
  43828. cameraColorGradingTexture: Nullable<BaseTexture>;
  43829. /**
  43830. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43831. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43832. * 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;
  43833. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43834. */
  43835. /**
  43836. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43837. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43838. * 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;
  43839. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43840. */
  43841. cameraColorCurves: Nullable<ColorCurves>;
  43842. /**
  43843. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43844. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43845. */
  43846. switchToBGR: boolean;
  43847. private _renderTargets;
  43848. private _reflectionControls;
  43849. private _white;
  43850. private _primaryShadowColor;
  43851. private _primaryHighlightColor;
  43852. /**
  43853. * Instantiates a Background Material in the given scene
  43854. * @param name The friendly name of the material
  43855. * @param scene The scene to add the material to
  43856. */
  43857. constructor(name: string, scene: Scene);
  43858. /**
  43859. * Gets a boolean indicating that current material needs to register RTT
  43860. */
  43861. readonly hasRenderTargetTextures: boolean;
  43862. /**
  43863. * The entire material has been created in order to prevent overdraw.
  43864. * @returns false
  43865. */
  43866. needAlphaTesting(): boolean;
  43867. /**
  43868. * The entire material has been created in order to prevent overdraw.
  43869. * @returns true if blending is enable
  43870. */
  43871. needAlphaBlending(): boolean;
  43872. /**
  43873. * Checks wether the material is ready to be rendered for a given mesh.
  43874. * @param mesh The mesh to render
  43875. * @param subMesh The submesh to check against
  43876. * @param useInstances Specify wether or not the material is used with instances
  43877. * @returns true if all the dependencies are ready (Textures, Effects...)
  43878. */
  43879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43880. /**
  43881. * Compute the primary color according to the chosen perceptual color.
  43882. */
  43883. private _computePrimaryColorFromPerceptualColor;
  43884. /**
  43885. * Compute the highlights and shadow colors according to their chosen levels.
  43886. */
  43887. private _computePrimaryColors;
  43888. /**
  43889. * Build the uniform buffer used in the material.
  43890. */
  43891. buildUniformLayout(): void;
  43892. /**
  43893. * Unbind the material.
  43894. */
  43895. unbind(): void;
  43896. /**
  43897. * Bind only the world matrix to the material.
  43898. * @param world The world matrix to bind.
  43899. */
  43900. bindOnlyWorldMatrix(world: Matrix): void;
  43901. /**
  43902. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43903. * @param world The world matrix to bind.
  43904. * @param subMesh The submesh to bind for.
  43905. */
  43906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43907. /**
  43908. * Dispose the material.
  43909. * @param forceDisposeEffect Force disposal of the associated effect.
  43910. * @param forceDisposeTextures Force disposal of the associated textures.
  43911. */
  43912. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43913. /**
  43914. * Clones the material.
  43915. * @param name The cloned name.
  43916. * @returns The cloned material.
  43917. */
  43918. clone(name: string): BackgroundMaterial;
  43919. /**
  43920. * Serializes the current material to its JSON representation.
  43921. * @returns The JSON representation.
  43922. */
  43923. serialize(): any;
  43924. /**
  43925. * Gets the class name of the material
  43926. * @returns "BackgroundMaterial"
  43927. */
  43928. getClassName(): string;
  43929. /**
  43930. * Parse a JSON input to create back a background material.
  43931. * @param source The JSON data to parse
  43932. * @param scene The scene to create the parsed material in
  43933. * @param rootUrl The root url of the assets the material depends upon
  43934. * @returns the instantiated BackgroundMaterial.
  43935. */
  43936. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43937. }
  43938. }
  43939. declare module BABYLON {
  43940. /**
  43941. * Represents the different options available during the creation of
  43942. * a Environment helper.
  43943. *
  43944. * This can control the default ground, skybox and image processing setup of your scene.
  43945. */
  43946. export interface IEnvironmentHelperOptions {
  43947. /**
  43948. * Specifies wether or not to create a ground.
  43949. * True by default.
  43950. */
  43951. createGround: boolean;
  43952. /**
  43953. * Specifies the ground size.
  43954. * 15 by default.
  43955. */
  43956. groundSize: number;
  43957. /**
  43958. * The texture used on the ground for the main color.
  43959. * Comes from the BabylonJS CDN by default.
  43960. *
  43961. * Remarks: Can be either a texture or a url.
  43962. */
  43963. groundTexture: string | BaseTexture;
  43964. /**
  43965. * The color mixed in the ground texture by default.
  43966. * BabylonJS clearColor by default.
  43967. */
  43968. groundColor: Color3;
  43969. /**
  43970. * Specifies the ground opacity.
  43971. * 1 by default.
  43972. */
  43973. groundOpacity: number;
  43974. /**
  43975. * Enables the ground to receive shadows.
  43976. * True by default.
  43977. */
  43978. enableGroundShadow: boolean;
  43979. /**
  43980. * Helps preventing the shadow to be fully black on the ground.
  43981. * 0.5 by default.
  43982. */
  43983. groundShadowLevel: number;
  43984. /**
  43985. * Creates a mirror texture attach to the ground.
  43986. * false by default.
  43987. */
  43988. enableGroundMirror: boolean;
  43989. /**
  43990. * Specifies the ground mirror size ratio.
  43991. * 0.3 by default as the default kernel is 64.
  43992. */
  43993. groundMirrorSizeRatio: number;
  43994. /**
  43995. * Specifies the ground mirror blur kernel size.
  43996. * 64 by default.
  43997. */
  43998. groundMirrorBlurKernel: number;
  43999. /**
  44000. * Specifies the ground mirror visibility amount.
  44001. * 1 by default
  44002. */
  44003. groundMirrorAmount: number;
  44004. /**
  44005. * Specifies the ground mirror reflectance weight.
  44006. * This uses the standard weight of the background material to setup the fresnel effect
  44007. * of the mirror.
  44008. * 1 by default.
  44009. */
  44010. groundMirrorFresnelWeight: number;
  44011. /**
  44012. * Specifies the ground mirror Falloff distance.
  44013. * This can helps reducing the size of the reflection.
  44014. * 0 by Default.
  44015. */
  44016. groundMirrorFallOffDistance: number;
  44017. /**
  44018. * Specifies the ground mirror texture type.
  44019. * Unsigned Int by Default.
  44020. */
  44021. groundMirrorTextureType: number;
  44022. /**
  44023. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44024. * the shown objects.
  44025. */
  44026. groundYBias: number;
  44027. /**
  44028. * Specifies wether or not to create a skybox.
  44029. * True by default.
  44030. */
  44031. createSkybox: boolean;
  44032. /**
  44033. * Specifies the skybox size.
  44034. * 20 by default.
  44035. */
  44036. skyboxSize: number;
  44037. /**
  44038. * The texture used on the skybox for the main color.
  44039. * Comes from the BabylonJS CDN by default.
  44040. *
  44041. * Remarks: Can be either a texture or a url.
  44042. */
  44043. skyboxTexture: string | BaseTexture;
  44044. /**
  44045. * The color mixed in the skybox texture by default.
  44046. * BabylonJS clearColor by default.
  44047. */
  44048. skyboxColor: Color3;
  44049. /**
  44050. * The background rotation around the Y axis of the scene.
  44051. * This helps aligning the key lights of your scene with the background.
  44052. * 0 by default.
  44053. */
  44054. backgroundYRotation: number;
  44055. /**
  44056. * Compute automatically the size of the elements to best fit with the scene.
  44057. */
  44058. sizeAuto: boolean;
  44059. /**
  44060. * Default position of the rootMesh if autoSize is not true.
  44061. */
  44062. rootPosition: Vector3;
  44063. /**
  44064. * Sets up the image processing in the scene.
  44065. * true by default.
  44066. */
  44067. setupImageProcessing: boolean;
  44068. /**
  44069. * The texture used as your environment texture in the scene.
  44070. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44071. *
  44072. * Remarks: Can be either a texture or a url.
  44073. */
  44074. environmentTexture: string | BaseTexture;
  44075. /**
  44076. * The value of the exposure to apply to the scene.
  44077. * 0.6 by default if setupImageProcessing is true.
  44078. */
  44079. cameraExposure: number;
  44080. /**
  44081. * The value of the contrast to apply to the scene.
  44082. * 1.6 by default if setupImageProcessing is true.
  44083. */
  44084. cameraContrast: number;
  44085. /**
  44086. * Specifies wether or not tonemapping should be enabled in the scene.
  44087. * true by default if setupImageProcessing is true.
  44088. */
  44089. toneMappingEnabled: boolean;
  44090. }
  44091. /**
  44092. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44093. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44094. * It also helps with the default setup of your imageProcessing configuration.
  44095. */
  44096. export class EnvironmentHelper {
  44097. /**
  44098. * Default ground texture URL.
  44099. */
  44100. private static _groundTextureCDNUrl;
  44101. /**
  44102. * Default skybox texture URL.
  44103. */
  44104. private static _skyboxTextureCDNUrl;
  44105. /**
  44106. * Default environment texture URL.
  44107. */
  44108. private static _environmentTextureCDNUrl;
  44109. /**
  44110. * Creates the default options for the helper.
  44111. */
  44112. private static _getDefaultOptions;
  44113. private _rootMesh;
  44114. /**
  44115. * Gets the root mesh created by the helper.
  44116. */
  44117. readonly rootMesh: Mesh;
  44118. private _skybox;
  44119. /**
  44120. * Gets the skybox created by the helper.
  44121. */
  44122. readonly skybox: Nullable<Mesh>;
  44123. private _skyboxTexture;
  44124. /**
  44125. * Gets the skybox texture created by the helper.
  44126. */
  44127. readonly skyboxTexture: Nullable<BaseTexture>;
  44128. private _skyboxMaterial;
  44129. /**
  44130. * Gets the skybox material created by the helper.
  44131. */
  44132. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44133. private _ground;
  44134. /**
  44135. * Gets the ground mesh created by the helper.
  44136. */
  44137. readonly ground: Nullable<Mesh>;
  44138. private _groundTexture;
  44139. /**
  44140. * Gets the ground texture created by the helper.
  44141. */
  44142. readonly groundTexture: Nullable<BaseTexture>;
  44143. private _groundMirror;
  44144. /**
  44145. * Gets the ground mirror created by the helper.
  44146. */
  44147. readonly groundMirror: Nullable<MirrorTexture>;
  44148. /**
  44149. * Gets the ground mirror render list to helps pushing the meshes
  44150. * you wish in the ground reflection.
  44151. */
  44152. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44153. private _groundMaterial;
  44154. /**
  44155. * Gets the ground material created by the helper.
  44156. */
  44157. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44158. /**
  44159. * Stores the creation options.
  44160. */
  44161. private readonly _scene;
  44162. private _options;
  44163. /**
  44164. * This observable will be notified with any error during the creation of the environment,
  44165. * mainly texture creation errors.
  44166. */
  44167. onErrorObservable: Observable<{
  44168. message?: string;
  44169. exception?: any;
  44170. }>;
  44171. /**
  44172. * constructor
  44173. * @param options Defines the options we want to customize the helper
  44174. * @param scene The scene to add the material to
  44175. */
  44176. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44177. /**
  44178. * Updates the background according to the new options
  44179. * @param options
  44180. */
  44181. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44182. /**
  44183. * Sets the primary color of all the available elements.
  44184. * @param color the main color to affect to the ground and the background
  44185. */
  44186. setMainColor(color: Color3): void;
  44187. /**
  44188. * Setup the image processing according to the specified options.
  44189. */
  44190. private _setupImageProcessing;
  44191. /**
  44192. * Setup the environment texture according to the specified options.
  44193. */
  44194. private _setupEnvironmentTexture;
  44195. /**
  44196. * Setup the background according to the specified options.
  44197. */
  44198. private _setupBackground;
  44199. /**
  44200. * Get the scene sizes according to the setup.
  44201. */
  44202. private _getSceneSize;
  44203. /**
  44204. * Setup the ground according to the specified options.
  44205. */
  44206. private _setupGround;
  44207. /**
  44208. * Setup the ground material according to the specified options.
  44209. */
  44210. private _setupGroundMaterial;
  44211. /**
  44212. * Setup the ground diffuse texture according to the specified options.
  44213. */
  44214. private _setupGroundDiffuseTexture;
  44215. /**
  44216. * Setup the ground mirror texture according to the specified options.
  44217. */
  44218. private _setupGroundMirrorTexture;
  44219. /**
  44220. * Setup the ground to receive the mirror texture.
  44221. */
  44222. private _setupMirrorInGroundMaterial;
  44223. /**
  44224. * Setup the skybox according to the specified options.
  44225. */
  44226. private _setupSkybox;
  44227. /**
  44228. * Setup the skybox material according to the specified options.
  44229. */
  44230. private _setupSkyboxMaterial;
  44231. /**
  44232. * Setup the skybox reflection texture according to the specified options.
  44233. */
  44234. private _setupSkyboxReflectionTexture;
  44235. private _errorHandler;
  44236. /**
  44237. * Dispose all the elements created by the Helper.
  44238. */
  44239. dispose(): void;
  44240. }
  44241. }
  44242. declare module BABYLON {
  44243. /**
  44244. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44245. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44246. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44247. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44248. */
  44249. export class PhotoDome extends TransformNode {
  44250. /**
  44251. * Define the image as a Monoscopic panoramic 360 image.
  44252. */
  44253. static readonly MODE_MONOSCOPIC: number;
  44254. /**
  44255. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44256. */
  44257. static readonly MODE_TOPBOTTOM: number;
  44258. /**
  44259. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44260. */
  44261. static readonly MODE_SIDEBYSIDE: number;
  44262. private _useDirectMapping;
  44263. /**
  44264. * The texture being displayed on the sphere
  44265. */
  44266. protected _photoTexture: Texture;
  44267. /**
  44268. * Gets or sets the texture being displayed on the sphere
  44269. */
  44270. photoTexture: Texture;
  44271. /**
  44272. * Observable raised when an error occured while loading the 360 image
  44273. */
  44274. onLoadErrorObservable: Observable<string>;
  44275. /**
  44276. * The skybox material
  44277. */
  44278. protected _material: BackgroundMaterial;
  44279. /**
  44280. * The surface used for the skybox
  44281. */
  44282. protected _mesh: Mesh;
  44283. /**
  44284. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44285. * Also see the options.resolution property.
  44286. */
  44287. fovMultiplier: number;
  44288. private _imageMode;
  44289. /**
  44290. * Gets or set the current video mode for the video. It can be:
  44291. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44292. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44293. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44294. */
  44295. imageMode: number;
  44296. /**
  44297. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44298. * @param name Element's name, child elements will append suffixes for their own names.
  44299. * @param urlsOfPhoto defines the url of the photo to display
  44300. * @param options defines an object containing optional or exposed sub element properties
  44301. * @param onError defines a callback called when an error occured while loading the texture
  44302. */
  44303. constructor(name: string, urlOfPhoto: string, options: {
  44304. resolution?: number;
  44305. size?: number;
  44306. useDirectMapping?: boolean;
  44307. faceForward?: boolean;
  44308. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44309. private _onBeforeCameraRenderObserver;
  44310. private _changeImageMode;
  44311. /**
  44312. * Releases resources associated with this node.
  44313. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44314. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44315. */
  44316. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44317. }
  44318. }
  44319. declare module BABYLON {
  44320. /** @hidden */
  44321. export var rgbdDecodePixelShader: {
  44322. name: string;
  44323. shader: string;
  44324. };
  44325. }
  44326. declare module BABYLON {
  44327. /**
  44328. * Class used to host texture specific utilities
  44329. */
  44330. export class BRDFTextureTools {
  44331. /**
  44332. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44333. * @param texture the texture to expand.
  44334. */
  44335. private static _ExpandDefaultBRDFTexture;
  44336. /**
  44337. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44338. * @param scene defines the hosting scene
  44339. * @returns the environment BRDF texture
  44340. */
  44341. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44342. private static _environmentBRDFBase64Texture;
  44343. }
  44344. }
  44345. declare module BABYLON {
  44346. /**
  44347. * @hidden
  44348. */
  44349. export interface IMaterialClearCoatDefines {
  44350. CLEARCOAT: boolean;
  44351. CLEARCOAT_DEFAULTIOR: boolean;
  44352. CLEARCOAT_TEXTURE: boolean;
  44353. CLEARCOAT_TEXTUREDIRECTUV: number;
  44354. CLEARCOAT_BUMP: boolean;
  44355. CLEARCOAT_BUMPDIRECTUV: number;
  44356. CLEARCOAT_TINT: boolean;
  44357. CLEARCOAT_TINT_TEXTURE: boolean;
  44358. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44359. /** @hidden */ private _areTexturesDirty: boolean;
  44360. }
  44361. /**
  44362. * Define the code related to the clear coat parameters of the pbr material.
  44363. */
  44364. export class PBRClearCoatConfiguration {
  44365. /**
  44366. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44367. * The default fits with a polyurethane material.
  44368. */
  44369. private static readonly _DefaultIndexOfRefraction;
  44370. private _isEnabled;
  44371. /**
  44372. * Defines if the clear coat is enabled in the material.
  44373. */
  44374. isEnabled: boolean;
  44375. /**
  44376. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44377. */
  44378. intensity: number;
  44379. /**
  44380. * Defines the clear coat layer roughness.
  44381. */
  44382. roughness: number;
  44383. private _indexOfRefraction;
  44384. /**
  44385. * Defines the index of refraction of the clear coat.
  44386. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44387. * The default fits with a polyurethane material.
  44388. * Changing the default value is more performance intensive.
  44389. */
  44390. indexOfRefraction: number;
  44391. private _texture;
  44392. /**
  44393. * Stores the clear coat values in a texture.
  44394. */
  44395. texture: Nullable<BaseTexture>;
  44396. private _bumpTexture;
  44397. /**
  44398. * Define the clear coat specific bump texture.
  44399. */
  44400. bumpTexture: Nullable<BaseTexture>;
  44401. private _isTintEnabled;
  44402. /**
  44403. * Defines if the clear coat tint is enabled in the material.
  44404. */
  44405. isTintEnabled: boolean;
  44406. /**
  44407. * Defines the clear coat tint of the material.
  44408. * This is only use if tint is enabled
  44409. */
  44410. tintColor: Color3;
  44411. /**
  44412. * Defines the distance at which the tint color should be found in the
  44413. * clear coat media.
  44414. * This is only use if tint is enabled
  44415. */
  44416. tintColorAtDistance: number;
  44417. /**
  44418. * Defines the clear coat layer thickness.
  44419. * This is only use if tint is enabled
  44420. */
  44421. tintThickness: number;
  44422. private _tintTexture;
  44423. /**
  44424. * Stores the clear tint values in a texture.
  44425. * rgb is tint
  44426. * a is a thickness factor
  44427. */
  44428. tintTexture: Nullable<BaseTexture>;
  44429. /** @hidden */
  44430. private _internalMarkAllSubMeshesAsTexturesDirty;
  44431. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44432. /**
  44433. * Instantiate a new istance of clear coat configuration.
  44434. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44435. */
  44436. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44437. /**
  44438. * Gets wehter the submesh is ready to be used or not.
  44439. * @param defines the list of "defines" to update.
  44440. * @param scene defines the scene the material belongs to.
  44441. * @param engine defines the engine the material belongs to.
  44442. * @param disableBumpMap defines wether the material disables bump or not.
  44443. * @returns - boolean indicating that the submesh is ready or not.
  44444. */
  44445. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44446. /**
  44447. * Checks to see if a texture is used in the material.
  44448. * @param defines the list of "defines" to update.
  44449. * @param scene defines the scene to the material belongs to.
  44450. */
  44451. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44452. /**
  44453. * Binds the material data.
  44454. * @param uniformBuffer defines the Uniform buffer to fill in.
  44455. * @param scene defines the scene the material belongs to.
  44456. * @param engine defines the engine the material belongs to.
  44457. * @param disableBumpMap defines wether the material disables bump or not.
  44458. * @param isFrozen defines wether the material is frozen or not.
  44459. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44460. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44461. */
  44462. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44463. /**
  44464. * Checks to see if a texture is used in the material.
  44465. * @param texture - Base texture to use.
  44466. * @returns - Boolean specifying if a texture is used in the material.
  44467. */
  44468. hasTexture(texture: BaseTexture): boolean;
  44469. /**
  44470. * Returns an array of the actively used textures.
  44471. * @param activeTextures Array of BaseTextures
  44472. */
  44473. getActiveTextures(activeTextures: BaseTexture[]): void;
  44474. /**
  44475. * Returns the animatable textures.
  44476. * @param animatables Array of animatable textures.
  44477. */
  44478. getAnimatables(animatables: IAnimatable[]): void;
  44479. /**
  44480. * Disposes the resources of the material.
  44481. * @param forceDisposeTextures - Forces the disposal of all textures.
  44482. */
  44483. dispose(forceDisposeTextures?: boolean): void;
  44484. /**
  44485. * Get the current class name of the texture useful for serialization or dynamic coding.
  44486. * @returns "PBRClearCoatConfiguration"
  44487. */
  44488. getClassName(): string;
  44489. /**
  44490. * Add fallbacks to the effect fallbacks list.
  44491. * @param defines defines the Base texture to use.
  44492. * @param fallbacks defines the current fallback list.
  44493. * @param currentRank defines the current fallback rank.
  44494. * @returns the new fallback rank.
  44495. */
  44496. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44497. /**
  44498. * Add the required uniforms to the current list.
  44499. * @param uniforms defines the current uniform list.
  44500. */
  44501. static AddUniforms(uniforms: string[]): void;
  44502. /**
  44503. * Add the required samplers to the current list.
  44504. * @param samplers defines the current sampler list.
  44505. */
  44506. static AddSamplers(samplers: string[]): void;
  44507. /**
  44508. * Add the required uniforms to the current buffer.
  44509. * @param uniformBuffer defines the current uniform buffer.
  44510. */
  44511. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44512. /**
  44513. * Makes a duplicate of the current configuration into another one.
  44514. * @param clearCoatConfiguration define the config where to copy the info
  44515. */
  44516. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44517. /**
  44518. * Serializes this clear coat configuration.
  44519. * @returns - An object with the serialized config.
  44520. */
  44521. serialize(): any;
  44522. /**
  44523. * Parses a anisotropy Configuration from a serialized object.
  44524. * @param source - Serialized object.
  44525. * @param scene Defines the scene we are parsing for
  44526. * @param rootUrl Defines the rootUrl to load from
  44527. */
  44528. parse(source: any, scene: Scene, rootUrl: string): void;
  44529. }
  44530. }
  44531. declare module BABYLON {
  44532. /**
  44533. * @hidden
  44534. */
  44535. export interface IMaterialAnisotropicDefines {
  44536. ANISOTROPIC: boolean;
  44537. ANISOTROPIC_TEXTURE: boolean;
  44538. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44539. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  44540. }
  44541. /**
  44542. * Define the code related to the anisotropic parameters of the pbr material.
  44543. */
  44544. export class PBRAnisotropicConfiguration {
  44545. private _isEnabled;
  44546. /**
  44547. * Defines if the anisotropy is enabled in the material.
  44548. */
  44549. isEnabled: boolean;
  44550. /**
  44551. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44552. */
  44553. intensity: number;
  44554. /**
  44555. * Defines if the effect is along the tangents, bitangents or in between.
  44556. * By default, the effect is "strectching" the highlights along the tangents.
  44557. */
  44558. direction: Vector2;
  44559. private _texture;
  44560. /**
  44561. * Stores the anisotropy values in a texture.
  44562. * rg is direction (like normal from -1 to 1)
  44563. * b is a intensity
  44564. */
  44565. texture: Nullable<BaseTexture>;
  44566. /** @hidden */
  44567. private _internalMarkAllSubMeshesAsTexturesDirty;
  44568. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44569. /**
  44570. * Instantiate a new istance of anisotropy configuration.
  44571. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44572. */
  44573. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44574. /**
  44575. * Specifies that the submesh is ready to be used.
  44576. * @param defines the list of "defines" to update.
  44577. * @param scene defines the scene the material belongs to.
  44578. * @returns - boolean indicating that the submesh is ready or not.
  44579. */
  44580. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44581. /**
  44582. * Checks to see if a texture is used in the material.
  44583. * @param defines the list of "defines" to update.
  44584. * @param mesh the mesh we are preparing the defines for.
  44585. * @param scene defines the scene the material belongs to.
  44586. */
  44587. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44588. /**
  44589. * Binds the material data.
  44590. * @param uniformBuffer defines the Uniform buffer to fill in.
  44591. * @param scene defines the scene the material belongs to.
  44592. * @param isFrozen defines wether the material is frozen or not.
  44593. */
  44594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44595. /**
  44596. * Checks to see if a texture is used in the material.
  44597. * @param texture - Base texture to use.
  44598. * @returns - Boolean specifying if a texture is used in the material.
  44599. */
  44600. hasTexture(texture: BaseTexture): boolean;
  44601. /**
  44602. * Returns an array of the actively used textures.
  44603. * @param activeTextures Array of BaseTextures
  44604. */
  44605. getActiveTextures(activeTextures: BaseTexture[]): void;
  44606. /**
  44607. * Returns the animatable textures.
  44608. * @param animatables Array of animatable textures.
  44609. */
  44610. getAnimatables(animatables: IAnimatable[]): void;
  44611. /**
  44612. * Disposes the resources of the material.
  44613. * @param forceDisposeTextures - Forces the disposal of all textures.
  44614. */
  44615. dispose(forceDisposeTextures?: boolean): void;
  44616. /**
  44617. * Get the current class name of the texture useful for serialization or dynamic coding.
  44618. * @returns "PBRAnisotropicConfiguration"
  44619. */
  44620. getClassName(): string;
  44621. /**
  44622. * Add fallbacks to the effect fallbacks list.
  44623. * @param defines defines the Base texture to use.
  44624. * @param fallbacks defines the current fallback list.
  44625. * @param currentRank defines the current fallback rank.
  44626. * @returns the new fallback rank.
  44627. */
  44628. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44629. /**
  44630. * Add the required uniforms to the current list.
  44631. * @param uniforms defines the current uniform list.
  44632. */
  44633. static AddUniforms(uniforms: string[]): void;
  44634. /**
  44635. * Add the required uniforms to the current buffer.
  44636. * @param uniformBuffer defines the current uniform buffer.
  44637. */
  44638. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44639. /**
  44640. * Add the required samplers to the current list.
  44641. * @param samplers defines the current sampler list.
  44642. */
  44643. static AddSamplers(samplers: string[]): void;
  44644. /**
  44645. * Makes a duplicate of the current configuration into another one.
  44646. * @param anisotropicConfiguration define the config where to copy the info
  44647. */
  44648. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44649. /**
  44650. * Serializes this anisotropy configuration.
  44651. * @returns - An object with the serialized config.
  44652. */
  44653. serialize(): any;
  44654. /**
  44655. * Parses a anisotropy Configuration from a serialized object.
  44656. * @param source - Serialized object.
  44657. * @param scene Defines the scene we are parsing for
  44658. * @param rootUrl Defines the rootUrl to load from
  44659. */
  44660. parse(source: any, scene: Scene, rootUrl: string): void;
  44661. }
  44662. }
  44663. declare module BABYLON {
  44664. /**
  44665. * @hidden
  44666. */
  44667. export interface IMaterialBRDFDefines {
  44668. BRDF_V_HEIGHT_CORRELATED: boolean;
  44669. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44670. SPHERICAL_HARMONICS: boolean;
  44671. /** @hidden */ private _areMiscDirty: boolean;
  44672. }
  44673. /**
  44674. * Define the code related to the BRDF parameters of the pbr material.
  44675. */
  44676. export class PBRBRDFConfiguration {
  44677. /**
  44678. * Default value used for the energy conservation.
  44679. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44680. */
  44681. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44682. /**
  44683. * Default value used for the Smith Visibility Height Correlated mode.
  44684. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44685. */
  44686. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44687. /**
  44688. * Default value used for the IBL diffuse part.
  44689. * This can help switching back to the polynomials mode globally which is a tiny bit
  44690. * less GPU intensive at the drawback of a lower quality.
  44691. */
  44692. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44693. private _useEnergyConservation;
  44694. /**
  44695. * Defines if the material uses energy conservation.
  44696. */
  44697. useEnergyConservation: boolean;
  44698. private _useSmithVisibilityHeightCorrelated;
  44699. /**
  44700. * LEGACY Mode set to false
  44701. * Defines if the material uses height smith correlated visibility term.
  44702. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44703. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44704. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44705. * Not relying on height correlated will also disable energy conservation.
  44706. */
  44707. useSmithVisibilityHeightCorrelated: boolean;
  44708. private _useSphericalHarmonics;
  44709. /**
  44710. * LEGACY Mode set to false
  44711. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44712. * diffuse part of the IBL.
  44713. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44714. * to the ground truth.
  44715. */
  44716. useSphericalHarmonics: boolean;
  44717. /** @hidden */
  44718. private _internalMarkAllSubMeshesAsMiscDirty;
  44719. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  44720. /**
  44721. * Instantiate a new istance of clear coat configuration.
  44722. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44723. */
  44724. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44725. /**
  44726. * Checks to see if a texture is used in the material.
  44727. * @param defines the list of "defines" to update.
  44728. */
  44729. prepareDefines(defines: IMaterialBRDFDefines): void;
  44730. /**
  44731. * Get the current class name of the texture useful for serialization or dynamic coding.
  44732. * @returns "PBRClearCoatConfiguration"
  44733. */
  44734. getClassName(): string;
  44735. /**
  44736. * Makes a duplicate of the current configuration into another one.
  44737. * @param brdfConfiguration define the config where to copy the info
  44738. */
  44739. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44740. /**
  44741. * Serializes this BRDF configuration.
  44742. * @returns - An object with the serialized config.
  44743. */
  44744. serialize(): any;
  44745. /**
  44746. * Parses a anisotropy Configuration from a serialized object.
  44747. * @param source - Serialized object.
  44748. * @param scene Defines the scene we are parsing for
  44749. * @param rootUrl Defines the rootUrl to load from
  44750. */
  44751. parse(source: any, scene: Scene, rootUrl: string): void;
  44752. }
  44753. }
  44754. declare module BABYLON {
  44755. /**
  44756. * @hidden
  44757. */
  44758. export interface IMaterialSheenDefines {
  44759. SHEEN: boolean;
  44760. SHEEN_TEXTURE: boolean;
  44761. SHEEN_TEXTUREDIRECTUV: number;
  44762. SHEEN_LINKWITHALBEDO: boolean;
  44763. /** @hidden */ private _areTexturesDirty: boolean;
  44764. }
  44765. /**
  44766. * Define the code related to the Sheen parameters of the pbr material.
  44767. */
  44768. export class PBRSheenConfiguration {
  44769. private _isEnabled;
  44770. /**
  44771. * Defines if the material uses sheen.
  44772. */
  44773. isEnabled: boolean;
  44774. private _linkSheenWithAlbedo;
  44775. /**
  44776. * Defines if the sheen is linked to the sheen color.
  44777. */
  44778. linkSheenWithAlbedo: boolean;
  44779. /**
  44780. * Defines the sheen intensity.
  44781. */
  44782. intensity: number;
  44783. /**
  44784. * Defines the sheen color.
  44785. */
  44786. color: Color3;
  44787. private _texture;
  44788. /**
  44789. * Stores the sheen tint values in a texture.
  44790. * rgb is tint
  44791. * a is a intensity
  44792. */
  44793. texture: Nullable<BaseTexture>;
  44794. /** @hidden */
  44795. private _internalMarkAllSubMeshesAsTexturesDirty;
  44796. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44797. /**
  44798. * Instantiate a new istance of clear coat configuration.
  44799. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44800. */
  44801. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44802. /**
  44803. * Specifies that the submesh is ready to be used.
  44804. * @param defines the list of "defines" to update.
  44805. * @param scene defines the scene the material belongs to.
  44806. * @returns - boolean indicating that the submesh is ready or not.
  44807. */
  44808. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44809. /**
  44810. * Checks to see if a texture is used in the material.
  44811. * @param defines the list of "defines" to update.
  44812. * @param scene defines the scene the material belongs to.
  44813. */
  44814. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44815. /**
  44816. * Binds the material data.
  44817. * @param uniformBuffer defines the Uniform buffer to fill in.
  44818. * @param scene defines the scene the material belongs to.
  44819. * @param isFrozen defines wether the material is frozen or not.
  44820. */
  44821. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44822. /**
  44823. * Checks to see if a texture is used in the material.
  44824. * @param texture - Base texture to use.
  44825. * @returns - Boolean specifying if a texture is used in the material.
  44826. */
  44827. hasTexture(texture: BaseTexture): boolean;
  44828. /**
  44829. * Returns an array of the actively used textures.
  44830. * @param activeTextures Array of BaseTextures
  44831. */
  44832. getActiveTextures(activeTextures: BaseTexture[]): void;
  44833. /**
  44834. * Returns the animatable textures.
  44835. * @param animatables Array of animatable textures.
  44836. */
  44837. getAnimatables(animatables: IAnimatable[]): void;
  44838. /**
  44839. * Disposes the resources of the material.
  44840. * @param forceDisposeTextures - Forces the disposal of all textures.
  44841. */
  44842. dispose(forceDisposeTextures?: boolean): void;
  44843. /**
  44844. * Get the current class name of the texture useful for serialization or dynamic coding.
  44845. * @returns "PBRSheenConfiguration"
  44846. */
  44847. getClassName(): string;
  44848. /**
  44849. * Add fallbacks to the effect fallbacks list.
  44850. * @param defines defines the Base texture to use.
  44851. * @param fallbacks defines the current fallback list.
  44852. * @param currentRank defines the current fallback rank.
  44853. * @returns the new fallback rank.
  44854. */
  44855. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44856. /**
  44857. * Add the required uniforms to the current list.
  44858. * @param uniforms defines the current uniform list.
  44859. */
  44860. static AddUniforms(uniforms: string[]): void;
  44861. /**
  44862. * Add the required uniforms to the current buffer.
  44863. * @param uniformBuffer defines the current uniform buffer.
  44864. */
  44865. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44866. /**
  44867. * Add the required samplers to the current list.
  44868. * @param samplers defines the current sampler list.
  44869. */
  44870. static AddSamplers(samplers: string[]): void;
  44871. /**
  44872. * Makes a duplicate of the current configuration into another one.
  44873. * @param sheenConfiguration define the config where to copy the info
  44874. */
  44875. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44876. /**
  44877. * Serializes this BRDF configuration.
  44878. * @returns - An object with the serialized config.
  44879. */
  44880. serialize(): any;
  44881. /**
  44882. * Parses a anisotropy Configuration from a serialized object.
  44883. * @param source - Serialized object.
  44884. * @param scene Defines the scene we are parsing for
  44885. * @param rootUrl Defines the rootUrl to load from
  44886. */
  44887. parse(source: any, scene: Scene, rootUrl: string): void;
  44888. }
  44889. }
  44890. declare module BABYLON {
  44891. /**
  44892. * @hidden
  44893. */
  44894. export interface IMaterialSubSurfaceDefines {
  44895. SUBSURFACE: boolean;
  44896. SS_REFRACTION: boolean;
  44897. SS_TRANSLUCENCY: boolean;
  44898. SS_SCATERRING: boolean;
  44899. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44900. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44901. SS_REFRACTIONMAP_3D: boolean;
  44902. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44903. SS_LODINREFRACTIONALPHA: boolean;
  44904. SS_GAMMAREFRACTION: boolean;
  44905. SS_RGBDREFRACTION: boolean;
  44906. SS_LINEARSPECULARREFRACTION: boolean;
  44907. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44908. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44909. /** @hidden */ private _areTexturesDirty: boolean;
  44910. }
  44911. /**
  44912. * Define the code related to the sub surface parameters of the pbr material.
  44913. */
  44914. export class PBRSubSurfaceConfiguration {
  44915. private _isRefractionEnabled;
  44916. /**
  44917. * Defines if the refraction is enabled in the material.
  44918. */
  44919. isRefractionEnabled: boolean;
  44920. private _isTranslucencyEnabled;
  44921. /**
  44922. * Defines if the translucency is enabled in the material.
  44923. */
  44924. isTranslucencyEnabled: boolean;
  44925. private _isScatteringEnabled;
  44926. /**
  44927. * Defines the refraction intensity of the material.
  44928. * The refraction when enabled replaces the Diffuse part of the material.
  44929. * The intensity helps transitionning between diffuse and refraction.
  44930. */
  44931. refractionIntensity: number;
  44932. /**
  44933. * Defines the translucency intensity of the material.
  44934. * When translucency has been enabled, this defines how much of the "translucency"
  44935. * is addded to the diffuse part of the material.
  44936. */
  44937. translucencyIntensity: number;
  44938. /**
  44939. * Defines the scattering intensity of the material.
  44940. * When scattering has been enabled, this defines how much of the "scattered light"
  44941. * is addded to the diffuse part of the material.
  44942. */
  44943. scatteringIntensity: number;
  44944. private _thicknessTexture;
  44945. /**
  44946. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44947. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44948. * 0 would mean minimumThickness
  44949. * 1 would mean maximumThickness
  44950. * The other channels might be use as a mask to vary the different effects intensity.
  44951. */
  44952. thicknessTexture: Nullable<BaseTexture>;
  44953. private _refractionTexture;
  44954. /**
  44955. * Defines the texture to use for refraction.
  44956. */
  44957. refractionTexture: Nullable<BaseTexture>;
  44958. private _indexOfRefraction;
  44959. /**
  44960. * Defines the index of refraction used in the material.
  44961. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44962. */
  44963. indexOfRefraction: number;
  44964. private _invertRefractionY;
  44965. /**
  44966. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44967. */
  44968. invertRefractionY: boolean;
  44969. private _linkRefractionWithTransparency;
  44970. /**
  44971. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44972. * Materials half opaque for instance using refraction could benefit from this control.
  44973. */
  44974. linkRefractionWithTransparency: boolean;
  44975. /**
  44976. * Defines the minimum thickness stored in the thickness map.
  44977. * If no thickness map is defined, this value will be used to simulate thickness.
  44978. */
  44979. minimumThickness: number;
  44980. /**
  44981. * Defines the maximum thickness stored in the thickness map.
  44982. */
  44983. maximumThickness: number;
  44984. /**
  44985. * Defines the volume tint of the material.
  44986. * This is used for both translucency and scattering.
  44987. */
  44988. tintColor: Color3;
  44989. /**
  44990. * Defines the distance at which the tint color should be found in the media.
  44991. * This is used for refraction only.
  44992. */
  44993. tintColorAtDistance: number;
  44994. /**
  44995. * Defines how far each channel transmit through the media.
  44996. * It is defined as a color to simplify it selection.
  44997. */
  44998. diffusionDistance: Color3;
  44999. private _useMaskFromThicknessTexture;
  45000. /**
  45001. * Stores the intensity of the different subsurface effects in the thickness texture.
  45002. * * the green channel is the translucency intensity.
  45003. * * the blue channel is the scattering intensity.
  45004. * * the alpha channel is the refraction intensity.
  45005. */
  45006. useMaskFromThicknessTexture: boolean;
  45007. /** @hidden */
  45008. private _internalMarkAllSubMeshesAsTexturesDirty;
  45009. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45010. /**
  45011. * Instantiate a new istance of sub surface configuration.
  45012. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45013. */
  45014. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45015. /**
  45016. * Gets wehter the submesh is ready to be used or not.
  45017. * @param defines the list of "defines" to update.
  45018. * @param scene defines the scene the material belongs to.
  45019. * @returns - boolean indicating that the submesh is ready or not.
  45020. */
  45021. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45022. /**
  45023. * Checks to see if a texture is used in the material.
  45024. * @param defines the list of "defines" to update.
  45025. * @param scene defines the scene to the material belongs to.
  45026. */
  45027. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45028. /**
  45029. * Binds the material data.
  45030. * @param uniformBuffer defines the Uniform buffer to fill in.
  45031. * @param scene defines the scene the material belongs to.
  45032. * @param engine defines the engine the material belongs to.
  45033. * @param isFrozen defines wether the material is frozen or not.
  45034. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45035. */
  45036. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45037. /**
  45038. * Unbinds the material from the mesh.
  45039. * @param activeEffect defines the effect that should be unbound from.
  45040. * @returns true if unbound, otherwise false
  45041. */
  45042. unbind(activeEffect: Effect): boolean;
  45043. /**
  45044. * Returns the texture used for refraction or null if none is used.
  45045. * @param scene defines the scene the material belongs to.
  45046. * @returns - Refraction texture if present. If no refraction texture and refraction
  45047. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45048. */
  45049. private _getRefractionTexture;
  45050. /**
  45051. * Returns true if alpha blending should be disabled.
  45052. */
  45053. readonly disableAlphaBlending: boolean;
  45054. /**
  45055. * Fills the list of render target textures.
  45056. * @param renderTargets the list of render targets to update
  45057. */
  45058. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45059. /**
  45060. * Checks to see if a texture is used in the material.
  45061. * @param texture - Base texture to use.
  45062. * @returns - Boolean specifying if a texture is used in the material.
  45063. */
  45064. hasTexture(texture: BaseTexture): boolean;
  45065. /**
  45066. * Gets a boolean indicating that current material needs to register RTT
  45067. * @returns true if this uses a render target otherwise false.
  45068. */
  45069. hasRenderTargetTextures(): boolean;
  45070. /**
  45071. * Returns an array of the actively used textures.
  45072. * @param activeTextures Array of BaseTextures
  45073. */
  45074. getActiveTextures(activeTextures: BaseTexture[]): void;
  45075. /**
  45076. * Returns the animatable textures.
  45077. * @param animatables Array of animatable textures.
  45078. */
  45079. getAnimatables(animatables: IAnimatable[]): void;
  45080. /**
  45081. * Disposes the resources of the material.
  45082. * @param forceDisposeTextures - Forces the disposal of all textures.
  45083. */
  45084. dispose(forceDisposeTextures?: boolean): void;
  45085. /**
  45086. * Get the current class name of the texture useful for serialization or dynamic coding.
  45087. * @returns "PBRSubSurfaceConfiguration"
  45088. */
  45089. getClassName(): string;
  45090. /**
  45091. * Add fallbacks to the effect fallbacks list.
  45092. * @param defines defines the Base texture to use.
  45093. * @param fallbacks defines the current fallback list.
  45094. * @param currentRank defines the current fallback rank.
  45095. * @returns the new fallback rank.
  45096. */
  45097. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45098. /**
  45099. * Add the required uniforms to the current list.
  45100. * @param uniforms defines the current uniform list.
  45101. */
  45102. static AddUniforms(uniforms: string[]): void;
  45103. /**
  45104. * Add the required samplers to the current list.
  45105. * @param samplers defines the current sampler list.
  45106. */
  45107. static AddSamplers(samplers: string[]): void;
  45108. /**
  45109. * Add the required uniforms to the current buffer.
  45110. * @param uniformBuffer defines the current uniform buffer.
  45111. */
  45112. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45113. /**
  45114. * Makes a duplicate of the current configuration into another one.
  45115. * @param configuration define the config where to copy the info
  45116. */
  45117. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45118. /**
  45119. * Serializes this Sub Surface configuration.
  45120. * @returns - An object with the serialized config.
  45121. */
  45122. serialize(): any;
  45123. /**
  45124. * Parses a anisotropy Configuration from a serialized object.
  45125. * @param source - Serialized object.
  45126. * @param scene Defines the scene we are parsing for
  45127. * @param rootUrl Defines the rootUrl to load from
  45128. */
  45129. parse(source: any, scene: Scene, rootUrl: string): void;
  45130. }
  45131. }
  45132. declare module BABYLON {
  45133. /** @hidden */
  45134. export var pbrFragmentDeclaration: {
  45135. name: string;
  45136. shader: string;
  45137. };
  45138. }
  45139. declare module BABYLON {
  45140. /** @hidden */
  45141. export var pbrUboDeclaration: {
  45142. name: string;
  45143. shader: string;
  45144. };
  45145. }
  45146. declare module BABYLON {
  45147. /** @hidden */
  45148. export var pbrFragmentExtraDeclaration: {
  45149. name: string;
  45150. shader: string;
  45151. };
  45152. }
  45153. declare module BABYLON {
  45154. /** @hidden */
  45155. export var pbrFragmentSamplersDeclaration: {
  45156. name: string;
  45157. shader: string;
  45158. };
  45159. }
  45160. declare module BABYLON {
  45161. /** @hidden */
  45162. export var pbrHelperFunctions: {
  45163. name: string;
  45164. shader: string;
  45165. };
  45166. }
  45167. declare module BABYLON {
  45168. /** @hidden */
  45169. export var harmonicsFunctions: {
  45170. name: string;
  45171. shader: string;
  45172. };
  45173. }
  45174. declare module BABYLON {
  45175. /** @hidden */
  45176. export var pbrDirectLightingSetupFunctions: {
  45177. name: string;
  45178. shader: string;
  45179. };
  45180. }
  45181. declare module BABYLON {
  45182. /** @hidden */
  45183. export var pbrDirectLightingFalloffFunctions: {
  45184. name: string;
  45185. shader: string;
  45186. };
  45187. }
  45188. declare module BABYLON {
  45189. /** @hidden */
  45190. export var pbrBRDFFunctions: {
  45191. name: string;
  45192. shader: string;
  45193. };
  45194. }
  45195. declare module BABYLON {
  45196. /** @hidden */
  45197. export var pbrDirectLightingFunctions: {
  45198. name: string;
  45199. shader: string;
  45200. };
  45201. }
  45202. declare module BABYLON {
  45203. /** @hidden */
  45204. export var pbrIBLFunctions: {
  45205. name: string;
  45206. shader: string;
  45207. };
  45208. }
  45209. declare module BABYLON {
  45210. /** @hidden */
  45211. export var pbrDebug: {
  45212. name: string;
  45213. shader: string;
  45214. };
  45215. }
  45216. declare module BABYLON {
  45217. /** @hidden */
  45218. export var pbrPixelShader: {
  45219. name: string;
  45220. shader: string;
  45221. };
  45222. }
  45223. declare module BABYLON {
  45224. /** @hidden */
  45225. export var pbrVertexDeclaration: {
  45226. name: string;
  45227. shader: string;
  45228. };
  45229. }
  45230. declare module BABYLON {
  45231. /** @hidden */
  45232. export var pbrVertexShader: {
  45233. name: string;
  45234. shader: string;
  45235. };
  45236. }
  45237. declare module BABYLON {
  45238. /**
  45239. * Manages the defines for the PBR Material.
  45240. * @hidden
  45241. */
  45242. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45243. PBR: boolean;
  45244. MAINUV1: boolean;
  45245. MAINUV2: boolean;
  45246. UV1: boolean;
  45247. UV2: boolean;
  45248. ALBEDO: boolean;
  45249. ALBEDODIRECTUV: number;
  45250. VERTEXCOLOR: boolean;
  45251. AMBIENT: boolean;
  45252. AMBIENTDIRECTUV: number;
  45253. AMBIENTINGRAYSCALE: boolean;
  45254. OPACITY: boolean;
  45255. VERTEXALPHA: boolean;
  45256. OPACITYDIRECTUV: number;
  45257. OPACITYRGB: boolean;
  45258. ALPHATEST: boolean;
  45259. DEPTHPREPASS: boolean;
  45260. ALPHABLEND: boolean;
  45261. ALPHAFROMALBEDO: boolean;
  45262. ALPHATESTVALUE: string;
  45263. SPECULAROVERALPHA: boolean;
  45264. RADIANCEOVERALPHA: boolean;
  45265. ALPHAFRESNEL: boolean;
  45266. LINEARALPHAFRESNEL: boolean;
  45267. PREMULTIPLYALPHA: boolean;
  45268. EMISSIVE: boolean;
  45269. EMISSIVEDIRECTUV: number;
  45270. REFLECTIVITY: boolean;
  45271. REFLECTIVITYDIRECTUV: number;
  45272. SPECULARTERM: boolean;
  45273. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45274. MICROSURFACEAUTOMATIC: boolean;
  45275. LODBASEDMICROSFURACE: boolean;
  45276. MICROSURFACEMAP: boolean;
  45277. MICROSURFACEMAPDIRECTUV: number;
  45278. METALLICWORKFLOW: boolean;
  45279. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45280. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45281. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45282. AOSTOREINMETALMAPRED: boolean;
  45283. ENVIRONMENTBRDF: boolean;
  45284. ENVIRONMENTBRDF_RGBD: boolean;
  45285. NORMAL: boolean;
  45286. TANGENT: boolean;
  45287. BUMP: boolean;
  45288. BUMPDIRECTUV: number;
  45289. OBJECTSPACE_NORMALMAP: boolean;
  45290. PARALLAX: boolean;
  45291. PARALLAXOCCLUSION: boolean;
  45292. NORMALXYSCALE: boolean;
  45293. LIGHTMAP: boolean;
  45294. LIGHTMAPDIRECTUV: number;
  45295. USELIGHTMAPASSHADOWMAP: boolean;
  45296. GAMMALIGHTMAP: boolean;
  45297. REFLECTION: boolean;
  45298. REFLECTIONMAP_3D: boolean;
  45299. REFLECTIONMAP_SPHERICAL: boolean;
  45300. REFLECTIONMAP_PLANAR: boolean;
  45301. REFLECTIONMAP_CUBIC: boolean;
  45302. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45303. REFLECTIONMAP_PROJECTION: boolean;
  45304. REFLECTIONMAP_SKYBOX: boolean;
  45305. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45306. REFLECTIONMAP_EXPLICIT: boolean;
  45307. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45308. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45309. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45310. INVERTCUBICMAP: boolean;
  45311. USESPHERICALFROMREFLECTIONMAP: boolean;
  45312. USEIRRADIANCEMAP: boolean;
  45313. SPHERICAL_HARMONICS: boolean;
  45314. USESPHERICALINVERTEX: boolean;
  45315. REFLECTIONMAP_OPPOSITEZ: boolean;
  45316. LODINREFLECTIONALPHA: boolean;
  45317. GAMMAREFLECTION: boolean;
  45318. RGBDREFLECTION: boolean;
  45319. LINEARSPECULARREFLECTION: boolean;
  45320. RADIANCEOCCLUSION: boolean;
  45321. HORIZONOCCLUSION: boolean;
  45322. INSTANCES: boolean;
  45323. NUM_BONE_INFLUENCERS: number;
  45324. BonesPerMesh: number;
  45325. BONETEXTURE: boolean;
  45326. NONUNIFORMSCALING: boolean;
  45327. MORPHTARGETS: boolean;
  45328. MORPHTARGETS_NORMAL: boolean;
  45329. MORPHTARGETS_TANGENT: boolean;
  45330. MORPHTARGETS_UV: boolean;
  45331. NUM_MORPH_INFLUENCERS: number;
  45332. IMAGEPROCESSING: boolean;
  45333. VIGNETTE: boolean;
  45334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45335. VIGNETTEBLENDMODEOPAQUE: boolean;
  45336. TONEMAPPING: boolean;
  45337. TONEMAPPING_ACES: boolean;
  45338. CONTRAST: boolean;
  45339. COLORCURVES: boolean;
  45340. COLORGRADING: boolean;
  45341. COLORGRADING3D: boolean;
  45342. SAMPLER3DGREENDEPTH: boolean;
  45343. SAMPLER3DBGRMAP: boolean;
  45344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45345. EXPOSURE: boolean;
  45346. MULTIVIEW: boolean;
  45347. USEPHYSICALLIGHTFALLOFF: boolean;
  45348. USEGLTFLIGHTFALLOFF: boolean;
  45349. TWOSIDEDLIGHTING: boolean;
  45350. SHADOWFLOAT: boolean;
  45351. CLIPPLANE: boolean;
  45352. CLIPPLANE2: boolean;
  45353. CLIPPLANE3: boolean;
  45354. CLIPPLANE4: boolean;
  45355. POINTSIZE: boolean;
  45356. FOG: boolean;
  45357. LOGARITHMICDEPTH: boolean;
  45358. FORCENORMALFORWARD: boolean;
  45359. SPECULARAA: boolean;
  45360. CLEARCOAT: boolean;
  45361. CLEARCOAT_DEFAULTIOR: boolean;
  45362. CLEARCOAT_TEXTURE: boolean;
  45363. CLEARCOAT_TEXTUREDIRECTUV: number;
  45364. CLEARCOAT_BUMP: boolean;
  45365. CLEARCOAT_BUMPDIRECTUV: number;
  45366. CLEARCOAT_TINT: boolean;
  45367. CLEARCOAT_TINT_TEXTURE: boolean;
  45368. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45369. ANISOTROPIC: boolean;
  45370. ANISOTROPIC_TEXTURE: boolean;
  45371. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45372. BRDF_V_HEIGHT_CORRELATED: boolean;
  45373. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45374. SHEEN: boolean;
  45375. SHEEN_TEXTURE: boolean;
  45376. SHEEN_TEXTUREDIRECTUV: number;
  45377. SHEEN_LINKWITHALBEDO: boolean;
  45378. SUBSURFACE: boolean;
  45379. SS_REFRACTION: boolean;
  45380. SS_TRANSLUCENCY: boolean;
  45381. SS_SCATERRING: boolean;
  45382. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45383. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45384. SS_REFRACTIONMAP_3D: boolean;
  45385. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45386. SS_LODINREFRACTIONALPHA: boolean;
  45387. SS_GAMMAREFRACTION: boolean;
  45388. SS_RGBDREFRACTION: boolean;
  45389. SS_LINEARSPECULARREFRACTION: boolean;
  45390. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45391. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45392. UNLIT: boolean;
  45393. DEBUGMODE: number;
  45394. /**
  45395. * Initializes the PBR Material defines.
  45396. */
  45397. constructor();
  45398. /**
  45399. * Resets the PBR Material defines.
  45400. */
  45401. reset(): void;
  45402. }
  45403. /**
  45404. * The Physically based material base class of BJS.
  45405. *
  45406. * This offers the main features of a standard PBR material.
  45407. * For more information, please refer to the documentation :
  45408. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45409. */
  45410. export abstract class PBRBaseMaterial extends PushMaterial {
  45411. /**
  45412. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45413. */
  45414. static readonly PBRMATERIAL_OPAQUE: number;
  45415. /**
  45416. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45417. */
  45418. static readonly PBRMATERIAL_ALPHATEST: number;
  45419. /**
  45420. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45421. */
  45422. static readonly PBRMATERIAL_ALPHABLEND: number;
  45423. /**
  45424. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45425. * They are also discarded below the alpha cutoff threshold to improve performances.
  45426. */
  45427. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45428. /**
  45429. * Defines the default value of how much AO map is occluding the analytical lights
  45430. * (point spot...).
  45431. */
  45432. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45433. /**
  45434. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45435. */
  45436. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45437. /**
  45438. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45439. * to enhance interoperability with other engines.
  45440. */
  45441. static readonly LIGHTFALLOFF_GLTF: number;
  45442. /**
  45443. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45444. * to enhance interoperability with other materials.
  45445. */
  45446. static readonly LIGHTFALLOFF_STANDARD: number;
  45447. /**
  45448. * Intensity of the direct lights e.g. the four lights available in your scene.
  45449. * This impacts both the direct diffuse and specular highlights.
  45450. */
  45451. protected _directIntensity: number;
  45452. /**
  45453. * Intensity of the emissive part of the material.
  45454. * This helps controlling the emissive effect without modifying the emissive color.
  45455. */
  45456. protected _emissiveIntensity: number;
  45457. /**
  45458. * Intensity of the environment e.g. how much the environment will light the object
  45459. * either through harmonics for rough material or through the refelction for shiny ones.
  45460. */
  45461. protected _environmentIntensity: number;
  45462. /**
  45463. * This is a special control allowing the reduction of the specular highlights coming from the
  45464. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45465. */
  45466. protected _specularIntensity: number;
  45467. /**
  45468. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45469. */
  45470. private _lightingInfos;
  45471. /**
  45472. * Debug Control allowing disabling the bump map on this material.
  45473. */
  45474. protected _disableBumpMap: boolean;
  45475. /**
  45476. * AKA Diffuse Texture in standard nomenclature.
  45477. */
  45478. protected _albedoTexture: Nullable<BaseTexture>;
  45479. /**
  45480. * AKA Occlusion Texture in other nomenclature.
  45481. */
  45482. protected _ambientTexture: Nullable<BaseTexture>;
  45483. /**
  45484. * AKA Occlusion Texture Intensity in other nomenclature.
  45485. */
  45486. protected _ambientTextureStrength: number;
  45487. /**
  45488. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45489. * 1 means it completely occludes it
  45490. * 0 mean it has no impact
  45491. */
  45492. protected _ambientTextureImpactOnAnalyticalLights: number;
  45493. /**
  45494. * Stores the alpha values in a texture.
  45495. */
  45496. protected _opacityTexture: Nullable<BaseTexture>;
  45497. /**
  45498. * Stores the reflection values in a texture.
  45499. */
  45500. protected _reflectionTexture: Nullable<BaseTexture>;
  45501. /**
  45502. * Stores the emissive values in a texture.
  45503. */
  45504. protected _emissiveTexture: Nullable<BaseTexture>;
  45505. /**
  45506. * AKA Specular texture in other nomenclature.
  45507. */
  45508. protected _reflectivityTexture: Nullable<BaseTexture>;
  45509. /**
  45510. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45511. */
  45512. protected _metallicTexture: Nullable<BaseTexture>;
  45513. /**
  45514. * Specifies the metallic scalar of the metallic/roughness workflow.
  45515. * Can also be used to scale the metalness values of the metallic texture.
  45516. */
  45517. protected _metallic: Nullable<number>;
  45518. /**
  45519. * Specifies the roughness scalar of the metallic/roughness workflow.
  45520. * Can also be used to scale the roughness values of the metallic texture.
  45521. */
  45522. protected _roughness: Nullable<number>;
  45523. /**
  45524. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45525. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45526. */
  45527. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45528. /**
  45529. * Stores surface normal data used to displace a mesh in a texture.
  45530. */
  45531. protected _bumpTexture: Nullable<BaseTexture>;
  45532. /**
  45533. * Stores the pre-calculated light information of a mesh in a texture.
  45534. */
  45535. protected _lightmapTexture: Nullable<BaseTexture>;
  45536. /**
  45537. * The color of a material in ambient lighting.
  45538. */
  45539. protected _ambientColor: Color3;
  45540. /**
  45541. * AKA Diffuse Color in other nomenclature.
  45542. */
  45543. protected _albedoColor: Color3;
  45544. /**
  45545. * AKA Specular Color in other nomenclature.
  45546. */
  45547. protected _reflectivityColor: Color3;
  45548. /**
  45549. * The color applied when light is reflected from a material.
  45550. */
  45551. protected _reflectionColor: Color3;
  45552. /**
  45553. * The color applied when light is emitted from a material.
  45554. */
  45555. protected _emissiveColor: Color3;
  45556. /**
  45557. * AKA Glossiness in other nomenclature.
  45558. */
  45559. protected _microSurface: number;
  45560. /**
  45561. * Specifies that the material will use the light map as a show map.
  45562. */
  45563. protected _useLightmapAsShadowmap: boolean;
  45564. /**
  45565. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45566. * makes the reflect vector face the model (under horizon).
  45567. */
  45568. protected _useHorizonOcclusion: boolean;
  45569. /**
  45570. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45571. * too much the area relying on ambient texture to define their ambient occlusion.
  45572. */
  45573. protected _useRadianceOcclusion: boolean;
  45574. /**
  45575. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45576. */
  45577. protected _useAlphaFromAlbedoTexture: boolean;
  45578. /**
  45579. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45580. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45581. */
  45582. protected _useSpecularOverAlpha: boolean;
  45583. /**
  45584. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45585. */
  45586. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45587. /**
  45588. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45589. */
  45590. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45591. /**
  45592. * Specifies if the metallic texture contains the roughness information in its green channel.
  45593. */
  45594. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45595. /**
  45596. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45597. */
  45598. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45599. /**
  45600. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45601. */
  45602. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45603. /**
  45604. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45605. */
  45606. protected _useAmbientInGrayScale: boolean;
  45607. /**
  45608. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45609. * The material will try to infer what glossiness each pixel should be.
  45610. */
  45611. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45612. /**
  45613. * Defines the falloff type used in this material.
  45614. * It by default is Physical.
  45615. */
  45616. protected _lightFalloff: number;
  45617. /**
  45618. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45619. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45620. */
  45621. protected _useRadianceOverAlpha: boolean;
  45622. /**
  45623. * Allows using an object space normal map (instead of tangent space).
  45624. */
  45625. protected _useObjectSpaceNormalMap: boolean;
  45626. /**
  45627. * Allows using the bump map in parallax mode.
  45628. */
  45629. protected _useParallax: boolean;
  45630. /**
  45631. * Allows using the bump map in parallax occlusion mode.
  45632. */
  45633. protected _useParallaxOcclusion: boolean;
  45634. /**
  45635. * Controls the scale bias of the parallax mode.
  45636. */
  45637. protected _parallaxScaleBias: number;
  45638. /**
  45639. * If sets to true, disables all the lights affecting the material.
  45640. */
  45641. protected _disableLighting: boolean;
  45642. /**
  45643. * Number of Simultaneous lights allowed on the material.
  45644. */
  45645. protected _maxSimultaneousLights: number;
  45646. /**
  45647. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45648. */
  45649. protected _invertNormalMapX: boolean;
  45650. /**
  45651. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45652. */
  45653. protected _invertNormalMapY: boolean;
  45654. /**
  45655. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45656. */
  45657. protected _twoSidedLighting: boolean;
  45658. /**
  45659. * Defines the alpha limits in alpha test mode.
  45660. */
  45661. protected _alphaCutOff: number;
  45662. /**
  45663. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45664. */
  45665. protected _forceAlphaTest: boolean;
  45666. /**
  45667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45668. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45669. */
  45670. protected _useAlphaFresnel: boolean;
  45671. /**
  45672. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45673. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45674. */
  45675. protected _useLinearAlphaFresnel: boolean;
  45676. /**
  45677. * The transparency mode of the material.
  45678. */
  45679. protected _transparencyMode: Nullable<number>;
  45680. /**
  45681. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45682. * from cos thetav and roughness:
  45683. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45684. */
  45685. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45686. /**
  45687. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45688. */
  45689. protected _forceIrradianceInFragment: boolean;
  45690. /**
  45691. * Force normal to face away from face.
  45692. */
  45693. protected _forceNormalForward: boolean;
  45694. /**
  45695. * Enables specular anti aliasing in the PBR shader.
  45696. * It will both interacts on the Geometry for analytical and IBL lighting.
  45697. * It also prefilter the roughness map based on the bump values.
  45698. */
  45699. protected _enableSpecularAntiAliasing: boolean;
  45700. /**
  45701. * Default configuration related to image processing available in the PBR Material.
  45702. */
  45703. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45704. /**
  45705. * Keep track of the image processing observer to allow dispose and replace.
  45706. */
  45707. private _imageProcessingObserver;
  45708. /**
  45709. * Attaches a new image processing configuration to the PBR Material.
  45710. * @param configuration
  45711. */
  45712. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45713. /**
  45714. * Stores the available render targets.
  45715. */
  45716. private _renderTargets;
  45717. /**
  45718. * Sets the global ambient color for the material used in lighting calculations.
  45719. */
  45720. private _globalAmbientColor;
  45721. /**
  45722. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45723. */
  45724. private _useLogarithmicDepth;
  45725. /**
  45726. * If set to true, no lighting calculations will be applied.
  45727. */
  45728. private _unlit;
  45729. private _debugMode;
  45730. /**
  45731. * @hidden
  45732. * This is reserved for the inspector.
  45733. * Defines the material debug mode.
  45734. * It helps seeing only some components of the material while troubleshooting.
  45735. */
  45736. debugMode: number;
  45737. /**
  45738. * @hidden
  45739. * This is reserved for the inspector.
  45740. * Specify from where on screen the debug mode should start.
  45741. * The value goes from -1 (full screen) to 1 (not visible)
  45742. * It helps with side by side comparison against the final render
  45743. * This defaults to -1
  45744. */
  45745. private debugLimit;
  45746. /**
  45747. * @hidden
  45748. * This is reserved for the inspector.
  45749. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45750. * You can use the factor to better multiply the final value.
  45751. */
  45752. private debugFactor;
  45753. /**
  45754. * Defines the clear coat layer parameters for the material.
  45755. */
  45756. readonly clearCoat: PBRClearCoatConfiguration;
  45757. /**
  45758. * Defines the anisotropic parameters for the material.
  45759. */
  45760. readonly anisotropy: PBRAnisotropicConfiguration;
  45761. /**
  45762. * Defines the BRDF parameters for the material.
  45763. */
  45764. readonly brdf: PBRBRDFConfiguration;
  45765. /**
  45766. * Defines the Sheen parameters for the material.
  45767. */
  45768. readonly sheen: PBRSheenConfiguration;
  45769. /**
  45770. * Defines the SubSurface parameters for the material.
  45771. */
  45772. readonly subSurface: PBRSubSurfaceConfiguration;
  45773. /**
  45774. * Custom callback helping to override the default shader used in the material.
  45775. */
  45776. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45777. /**
  45778. * Instantiates a new PBRMaterial instance.
  45779. *
  45780. * @param name The material name
  45781. * @param scene The scene the material will be use in.
  45782. */
  45783. constructor(name: string, scene: Scene);
  45784. /**
  45785. * Gets a boolean indicating that current material needs to register RTT
  45786. */
  45787. readonly hasRenderTargetTextures: boolean;
  45788. /**
  45789. * Gets the name of the material class.
  45790. */
  45791. getClassName(): string;
  45792. /**
  45793. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45794. */
  45795. /**
  45796. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45797. */
  45798. useLogarithmicDepth: boolean;
  45799. /**
  45800. * Gets the current transparency mode.
  45801. */
  45802. /**
  45803. * Sets the transparency mode of the material.
  45804. *
  45805. * | Value | Type | Description |
  45806. * | ----- | ----------------------------------- | ----------- |
  45807. * | 0 | OPAQUE | |
  45808. * | 1 | ALPHATEST | |
  45809. * | 2 | ALPHABLEND | |
  45810. * | 3 | ALPHATESTANDBLEND | |
  45811. *
  45812. */
  45813. transparencyMode: Nullable<number>;
  45814. /**
  45815. * Returns true if alpha blending should be disabled.
  45816. */
  45817. private readonly _disableAlphaBlending;
  45818. /**
  45819. * Specifies whether or not this material should be rendered in alpha blend mode.
  45820. */
  45821. needAlphaBlending(): boolean;
  45822. /**
  45823. * Specifies if the mesh will require alpha blending.
  45824. * @param mesh - BJS mesh.
  45825. */
  45826. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45827. /**
  45828. * Specifies whether or not this material should be rendered in alpha test mode.
  45829. */
  45830. needAlphaTesting(): boolean;
  45831. /**
  45832. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45833. */
  45834. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45835. /**
  45836. * Gets the texture used for the alpha test.
  45837. */
  45838. getAlphaTestTexture(): Nullable<BaseTexture>;
  45839. /**
  45840. * Specifies that the submesh is ready to be used.
  45841. * @param mesh - BJS mesh.
  45842. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45843. * @param useInstances - Specifies that instances should be used.
  45844. * @returns - boolean indicating that the submesh is ready or not.
  45845. */
  45846. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45847. /**
  45848. * Specifies if the material uses metallic roughness workflow.
  45849. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45850. */
  45851. isMetallicWorkflow(): boolean;
  45852. private _prepareEffect;
  45853. private _prepareDefines;
  45854. /**
  45855. * Force shader compilation
  45856. */
  45857. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45858. clipPlane: boolean;
  45859. }>): void;
  45860. /**
  45861. * Initializes the uniform buffer layout for the shader.
  45862. */
  45863. buildUniformLayout(): void;
  45864. /**
  45865. * Unbinds the material from the mesh
  45866. */
  45867. unbind(): void;
  45868. /**
  45869. * Binds the submesh data.
  45870. * @param world - The world matrix.
  45871. * @param mesh - The BJS mesh.
  45872. * @param subMesh - A submesh of the BJS mesh.
  45873. */
  45874. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45875. /**
  45876. * Returns the animatable textures.
  45877. * @returns - Array of animatable textures.
  45878. */
  45879. getAnimatables(): IAnimatable[];
  45880. /**
  45881. * Returns the texture used for reflections.
  45882. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45883. */
  45884. private _getReflectionTexture;
  45885. /**
  45886. * Returns an array of the actively used textures.
  45887. * @returns - Array of BaseTextures
  45888. */
  45889. getActiveTextures(): BaseTexture[];
  45890. /**
  45891. * Checks to see if a texture is used in the material.
  45892. * @param texture - Base texture to use.
  45893. * @returns - Boolean specifying if a texture is used in the material.
  45894. */
  45895. hasTexture(texture: BaseTexture): boolean;
  45896. /**
  45897. * Disposes the resources of the material.
  45898. * @param forceDisposeEffect - Forces the disposal of effects.
  45899. * @param forceDisposeTextures - Forces the disposal of all textures.
  45900. */
  45901. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45902. }
  45903. }
  45904. declare module BABYLON {
  45905. /**
  45906. * The Physically based material of BJS.
  45907. *
  45908. * This offers the main features of a standard PBR material.
  45909. * For more information, please refer to the documentation :
  45910. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45911. */
  45912. export class PBRMaterial extends PBRBaseMaterial {
  45913. /**
  45914. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45915. */
  45916. static readonly PBRMATERIAL_OPAQUE: number;
  45917. /**
  45918. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45919. */
  45920. static readonly PBRMATERIAL_ALPHATEST: number;
  45921. /**
  45922. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45923. */
  45924. static readonly PBRMATERIAL_ALPHABLEND: number;
  45925. /**
  45926. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45927. * They are also discarded below the alpha cutoff threshold to improve performances.
  45928. */
  45929. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45930. /**
  45931. * Defines the default value of how much AO map is occluding the analytical lights
  45932. * (point spot...).
  45933. */
  45934. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45935. /**
  45936. * Intensity of the direct lights e.g. the four lights available in your scene.
  45937. * This impacts both the direct diffuse and specular highlights.
  45938. */
  45939. directIntensity: number;
  45940. /**
  45941. * Intensity of the emissive part of the material.
  45942. * This helps controlling the emissive effect without modifying the emissive color.
  45943. */
  45944. emissiveIntensity: number;
  45945. /**
  45946. * Intensity of the environment e.g. how much the environment will light the object
  45947. * either through harmonics for rough material or through the refelction for shiny ones.
  45948. */
  45949. environmentIntensity: number;
  45950. /**
  45951. * This is a special control allowing the reduction of the specular highlights coming from the
  45952. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45953. */
  45954. specularIntensity: number;
  45955. /**
  45956. * Debug Control allowing disabling the bump map on this material.
  45957. */
  45958. disableBumpMap: boolean;
  45959. /**
  45960. * AKA Diffuse Texture in standard nomenclature.
  45961. */
  45962. albedoTexture: BaseTexture;
  45963. /**
  45964. * AKA Occlusion Texture in other nomenclature.
  45965. */
  45966. ambientTexture: BaseTexture;
  45967. /**
  45968. * AKA Occlusion Texture Intensity in other nomenclature.
  45969. */
  45970. ambientTextureStrength: number;
  45971. /**
  45972. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45973. * 1 means it completely occludes it
  45974. * 0 mean it has no impact
  45975. */
  45976. ambientTextureImpactOnAnalyticalLights: number;
  45977. /**
  45978. * Stores the alpha values in a texture.
  45979. */
  45980. opacityTexture: BaseTexture;
  45981. /**
  45982. * Stores the reflection values in a texture.
  45983. */
  45984. reflectionTexture: Nullable<BaseTexture>;
  45985. /**
  45986. * Stores the emissive values in a texture.
  45987. */
  45988. emissiveTexture: BaseTexture;
  45989. /**
  45990. * AKA Specular texture in other nomenclature.
  45991. */
  45992. reflectivityTexture: BaseTexture;
  45993. /**
  45994. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45995. */
  45996. metallicTexture: BaseTexture;
  45997. /**
  45998. * Specifies the metallic scalar of the metallic/roughness workflow.
  45999. * Can also be used to scale the metalness values of the metallic texture.
  46000. */
  46001. metallic: Nullable<number>;
  46002. /**
  46003. * Specifies the roughness scalar of the metallic/roughness workflow.
  46004. * Can also be used to scale the roughness values of the metallic texture.
  46005. */
  46006. roughness: Nullable<number>;
  46007. /**
  46008. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46009. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46010. */
  46011. microSurfaceTexture: BaseTexture;
  46012. /**
  46013. * Stores surface normal data used to displace a mesh in a texture.
  46014. */
  46015. bumpTexture: BaseTexture;
  46016. /**
  46017. * Stores the pre-calculated light information of a mesh in a texture.
  46018. */
  46019. lightmapTexture: BaseTexture;
  46020. /**
  46021. * Stores the refracted light information in a texture.
  46022. */
  46023. refractionTexture: Nullable<BaseTexture>;
  46024. /**
  46025. * The color of a material in ambient lighting.
  46026. */
  46027. ambientColor: Color3;
  46028. /**
  46029. * AKA Diffuse Color in other nomenclature.
  46030. */
  46031. albedoColor: Color3;
  46032. /**
  46033. * AKA Specular Color in other nomenclature.
  46034. */
  46035. reflectivityColor: Color3;
  46036. /**
  46037. * The color reflected from the material.
  46038. */
  46039. reflectionColor: Color3;
  46040. /**
  46041. * The color emitted from the material.
  46042. */
  46043. emissiveColor: Color3;
  46044. /**
  46045. * AKA Glossiness in other nomenclature.
  46046. */
  46047. microSurface: number;
  46048. /**
  46049. * source material index of refraction (IOR)' / 'destination material IOR.
  46050. */
  46051. indexOfRefraction: number;
  46052. /**
  46053. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46054. */
  46055. invertRefractionY: boolean;
  46056. /**
  46057. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46058. * Materials half opaque for instance using refraction could benefit from this control.
  46059. */
  46060. linkRefractionWithTransparency: boolean;
  46061. /**
  46062. * If true, the light map contains occlusion information instead of lighting info.
  46063. */
  46064. useLightmapAsShadowmap: boolean;
  46065. /**
  46066. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46067. */
  46068. useAlphaFromAlbedoTexture: boolean;
  46069. /**
  46070. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46071. */
  46072. forceAlphaTest: boolean;
  46073. /**
  46074. * Defines the alpha limits in alpha test mode.
  46075. */
  46076. alphaCutOff: number;
  46077. /**
  46078. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46079. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46080. */
  46081. useSpecularOverAlpha: boolean;
  46082. /**
  46083. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46084. */
  46085. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46086. /**
  46087. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46088. */
  46089. useRoughnessFromMetallicTextureAlpha: boolean;
  46090. /**
  46091. * Specifies if the metallic texture contains the roughness information in its green channel.
  46092. */
  46093. useRoughnessFromMetallicTextureGreen: boolean;
  46094. /**
  46095. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46096. */
  46097. useMetallnessFromMetallicTextureBlue: boolean;
  46098. /**
  46099. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46100. */
  46101. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46102. /**
  46103. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46104. */
  46105. useAmbientInGrayScale: boolean;
  46106. /**
  46107. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46108. * The material will try to infer what glossiness each pixel should be.
  46109. */
  46110. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46111. /**
  46112. * BJS is using an harcoded light falloff based on a manually sets up range.
  46113. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46114. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46115. */
  46116. /**
  46117. * BJS is using an harcoded light falloff based on a manually sets up range.
  46118. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46119. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46120. */
  46121. usePhysicalLightFalloff: boolean;
  46122. /**
  46123. * In order to support the falloff compatibility with gltf, a special mode has been added
  46124. * to reproduce the gltf light falloff.
  46125. */
  46126. /**
  46127. * In order to support the falloff compatibility with gltf, a special mode has been added
  46128. * to reproduce the gltf light falloff.
  46129. */
  46130. useGLTFLightFalloff: boolean;
  46131. /**
  46132. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46133. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46134. */
  46135. useRadianceOverAlpha: boolean;
  46136. /**
  46137. * Allows using an object space normal map (instead of tangent space).
  46138. */
  46139. useObjectSpaceNormalMap: boolean;
  46140. /**
  46141. * Allows using the bump map in parallax mode.
  46142. */
  46143. useParallax: boolean;
  46144. /**
  46145. * Allows using the bump map in parallax occlusion mode.
  46146. */
  46147. useParallaxOcclusion: boolean;
  46148. /**
  46149. * Controls the scale bias of the parallax mode.
  46150. */
  46151. parallaxScaleBias: number;
  46152. /**
  46153. * If sets to true, disables all the lights affecting the material.
  46154. */
  46155. disableLighting: boolean;
  46156. /**
  46157. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46158. */
  46159. forceIrradianceInFragment: boolean;
  46160. /**
  46161. * Number of Simultaneous lights allowed on the material.
  46162. */
  46163. maxSimultaneousLights: number;
  46164. /**
  46165. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46166. */
  46167. invertNormalMapX: boolean;
  46168. /**
  46169. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46170. */
  46171. invertNormalMapY: boolean;
  46172. /**
  46173. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46174. */
  46175. twoSidedLighting: boolean;
  46176. /**
  46177. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46178. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46179. */
  46180. useAlphaFresnel: boolean;
  46181. /**
  46182. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46183. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46184. */
  46185. useLinearAlphaFresnel: boolean;
  46186. /**
  46187. * Let user defines the brdf lookup texture used for IBL.
  46188. * A default 8bit version is embedded but you could point at :
  46189. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46190. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46191. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46192. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46193. */
  46194. environmentBRDFTexture: Nullable<BaseTexture>;
  46195. /**
  46196. * Force normal to face away from face.
  46197. */
  46198. forceNormalForward: boolean;
  46199. /**
  46200. * Enables specular anti aliasing in the PBR shader.
  46201. * It will both interacts on the Geometry for analytical and IBL lighting.
  46202. * It also prefilter the roughness map based on the bump values.
  46203. */
  46204. enableSpecularAntiAliasing: boolean;
  46205. /**
  46206. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46207. * makes the reflect vector face the model (under horizon).
  46208. */
  46209. useHorizonOcclusion: boolean;
  46210. /**
  46211. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46212. * too much the area relying on ambient texture to define their ambient occlusion.
  46213. */
  46214. useRadianceOcclusion: boolean;
  46215. /**
  46216. * If set to true, no lighting calculations will be applied.
  46217. */
  46218. unlit: boolean;
  46219. /**
  46220. * Gets the image processing configuration used either in this material.
  46221. */
  46222. /**
  46223. * Sets the Default image processing configuration used either in the this material.
  46224. *
  46225. * If sets to null, the scene one is in use.
  46226. */
  46227. imageProcessingConfiguration: ImageProcessingConfiguration;
  46228. /**
  46229. * Gets wether the color curves effect is enabled.
  46230. */
  46231. /**
  46232. * Sets wether the color curves effect is enabled.
  46233. */
  46234. cameraColorCurvesEnabled: boolean;
  46235. /**
  46236. * Gets wether the color grading effect is enabled.
  46237. */
  46238. /**
  46239. * Gets wether the color grading effect is enabled.
  46240. */
  46241. cameraColorGradingEnabled: boolean;
  46242. /**
  46243. * Gets wether tonemapping is enabled or not.
  46244. */
  46245. /**
  46246. * Sets wether tonemapping is enabled or not
  46247. */
  46248. cameraToneMappingEnabled: boolean;
  46249. /**
  46250. * The camera exposure used on this material.
  46251. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46252. * This corresponds to a photographic exposure.
  46253. */
  46254. /**
  46255. * The camera exposure used on this material.
  46256. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46257. * This corresponds to a photographic exposure.
  46258. */
  46259. cameraExposure: number;
  46260. /**
  46261. * Gets The camera contrast used on this material.
  46262. */
  46263. /**
  46264. * Sets The camera contrast used on this material.
  46265. */
  46266. cameraContrast: number;
  46267. /**
  46268. * Gets the Color Grading 2D Lookup Texture.
  46269. */
  46270. /**
  46271. * Sets the Color Grading 2D Lookup Texture.
  46272. */
  46273. cameraColorGradingTexture: Nullable<BaseTexture>;
  46274. /**
  46275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46277. * 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;
  46278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46279. */
  46280. /**
  46281. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46282. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46283. * 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;
  46284. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46285. */
  46286. cameraColorCurves: Nullable<ColorCurves>;
  46287. /**
  46288. * Instantiates a new PBRMaterial instance.
  46289. *
  46290. * @param name The material name
  46291. * @param scene The scene the material will be use in.
  46292. */
  46293. constructor(name: string, scene: Scene);
  46294. /**
  46295. * Returns the name of this material class.
  46296. */
  46297. getClassName(): string;
  46298. /**
  46299. * Makes a duplicate of the current material.
  46300. * @param name - name to use for the new material.
  46301. */
  46302. clone(name: string): PBRMaterial;
  46303. /**
  46304. * Serializes this PBR Material.
  46305. * @returns - An object with the serialized material.
  46306. */
  46307. serialize(): any;
  46308. /**
  46309. * Parses a PBR Material from a serialized object.
  46310. * @param source - Serialized object.
  46311. * @param scene - BJS scene instance.
  46312. * @param rootUrl - url for the scene object
  46313. * @returns - PBRMaterial
  46314. */
  46315. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46316. }
  46317. }
  46318. declare module BABYLON {
  46319. /**
  46320. * Direct draw surface info
  46321. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46322. */
  46323. export interface DDSInfo {
  46324. /**
  46325. * Width of the texture
  46326. */
  46327. width: number;
  46328. /**
  46329. * Width of the texture
  46330. */
  46331. height: number;
  46332. /**
  46333. * Number of Mipmaps for the texture
  46334. * @see https://en.wikipedia.org/wiki/Mipmap
  46335. */
  46336. mipmapCount: number;
  46337. /**
  46338. * If the textures format is a known fourCC format
  46339. * @see https://www.fourcc.org/
  46340. */
  46341. isFourCC: boolean;
  46342. /**
  46343. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46344. */
  46345. isRGB: boolean;
  46346. /**
  46347. * If the texture is a lumincance format
  46348. */
  46349. isLuminance: boolean;
  46350. /**
  46351. * If this is a cube texture
  46352. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46353. */
  46354. isCube: boolean;
  46355. /**
  46356. * If the texture is a compressed format eg. FOURCC_DXT1
  46357. */
  46358. isCompressed: boolean;
  46359. /**
  46360. * The dxgiFormat of the texture
  46361. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46362. */
  46363. dxgiFormat: number;
  46364. /**
  46365. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46366. */
  46367. textureType: number;
  46368. /**
  46369. * Sphericle polynomial created for the dds texture
  46370. */
  46371. sphericalPolynomial?: SphericalPolynomial;
  46372. }
  46373. /**
  46374. * Class used to provide DDS decompression tools
  46375. */
  46376. export class DDSTools {
  46377. /**
  46378. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46379. */
  46380. static StoreLODInAlphaChannel: boolean;
  46381. /**
  46382. * Gets DDS information from an array buffer
  46383. * @param arrayBuffer defines the array buffer to read data from
  46384. * @returns the DDS information
  46385. */
  46386. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46387. private static _FloatView;
  46388. private static _Int32View;
  46389. private static _ToHalfFloat;
  46390. private static _FromHalfFloat;
  46391. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46392. private static _GetHalfFloatRGBAArrayBuffer;
  46393. private static _GetFloatRGBAArrayBuffer;
  46394. private static _GetFloatAsUIntRGBAArrayBuffer;
  46395. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46396. private static _GetRGBAArrayBuffer;
  46397. private static _ExtractLongWordOrder;
  46398. private static _GetRGBArrayBuffer;
  46399. private static _GetLuminanceArrayBuffer;
  46400. /**
  46401. * Uploads DDS Levels to a Babylon Texture
  46402. * @hidden
  46403. */
  46404. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46405. }
  46406. interface Engine {
  46407. /**
  46408. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46409. * @param rootUrl defines the url where the file to load is located
  46410. * @param scene defines the current scene
  46411. * @param lodScale defines scale to apply to the mip map selection
  46412. * @param lodOffset defines offset to apply to the mip map selection
  46413. * @param onLoad defines an optional callback raised when the texture is loaded
  46414. * @param onError defines an optional callback raised if there is an issue to load the texture
  46415. * @param format defines the format of the data
  46416. * @param forcedExtension defines the extension to use to pick the right loader
  46417. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46418. * @returns the cube texture as an InternalTexture
  46419. */
  46420. 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;
  46421. }
  46422. }
  46423. declare module BABYLON {
  46424. /**
  46425. * Implementation of the DDS Texture Loader.
  46426. * @hidden
  46427. */
  46428. export class _DDSTextureLoader implements IInternalTextureLoader {
  46429. /**
  46430. * Defines wether the loader supports cascade loading the different faces.
  46431. */
  46432. readonly supportCascades: boolean;
  46433. /**
  46434. * This returns if the loader support the current file information.
  46435. * @param extension defines the file extension of the file being loaded
  46436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46437. * @param fallback defines the fallback internal texture if any
  46438. * @param isBase64 defines whether the texture is encoded as a base64
  46439. * @param isBuffer defines whether the texture data are stored as a buffer
  46440. * @returns true if the loader can load the specified file
  46441. */
  46442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46443. /**
  46444. * Transform the url before loading if required.
  46445. * @param rootUrl the url of the texture
  46446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46447. * @returns the transformed texture
  46448. */
  46449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46450. /**
  46451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46452. * @param rootUrl the url of the texture
  46453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46454. * @returns the fallback texture
  46455. */
  46456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46457. /**
  46458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46459. * @param data contains the texture data
  46460. * @param texture defines the BabylonJS internal texture
  46461. * @param createPolynomials will be true if polynomials have been requested
  46462. * @param onLoad defines the callback to trigger once the texture is ready
  46463. * @param onError defines the callback to trigger in case of error
  46464. */
  46465. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46466. /**
  46467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46468. * @param data contains the texture data
  46469. * @param texture defines the BabylonJS internal texture
  46470. * @param callback defines the method to call once ready to upload
  46471. */
  46472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /** @hidden */
  46477. export var rgbdEncodePixelShader: {
  46478. name: string;
  46479. shader: string;
  46480. };
  46481. }
  46482. declare module BABYLON {
  46483. /**
  46484. * Raw texture data and descriptor sufficient for WebGL texture upload
  46485. */
  46486. export interface EnvironmentTextureInfo {
  46487. /**
  46488. * Version of the environment map
  46489. */
  46490. version: number;
  46491. /**
  46492. * Width of image
  46493. */
  46494. width: number;
  46495. /**
  46496. * Irradiance information stored in the file.
  46497. */
  46498. irradiance: any;
  46499. /**
  46500. * Specular information stored in the file.
  46501. */
  46502. specular: any;
  46503. }
  46504. /**
  46505. * Sets of helpers addressing the serialization and deserialization of environment texture
  46506. * stored in a BabylonJS env file.
  46507. * Those files are usually stored as .env files.
  46508. */
  46509. export class EnvironmentTextureTools {
  46510. /**
  46511. * Magic number identifying the env file.
  46512. */
  46513. private static _MagicBytes;
  46514. /**
  46515. * Gets the environment info from an env file.
  46516. * @param data The array buffer containing the .env bytes.
  46517. * @returns the environment file info (the json header) if successfully parsed.
  46518. */
  46519. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46520. /**
  46521. * Creates an environment texture from a loaded cube texture.
  46522. * @param texture defines the cube texture to convert in env file
  46523. * @return a promise containing the environment data if succesfull.
  46524. */
  46525. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46526. /**
  46527. * Creates a JSON representation of the spherical data.
  46528. * @param texture defines the texture containing the polynomials
  46529. * @return the JSON representation of the spherical info
  46530. */
  46531. private static _CreateEnvTextureIrradiance;
  46532. /**
  46533. * Uploads the texture info contained in the env file to the GPU.
  46534. * @param texture defines the internal texture to upload to
  46535. * @param arrayBuffer defines the buffer cotaining the data to load
  46536. * @param info defines the texture info retrieved through the GetEnvInfo method
  46537. * @returns a promise
  46538. */
  46539. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46540. /**
  46541. * Uploads the levels of image data to the GPU.
  46542. * @param texture defines the internal texture to upload to
  46543. * @param imageData defines the array buffer views of image data [mipmap][face]
  46544. * @returns a promise
  46545. */
  46546. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46547. /**
  46548. * Uploads spherical polynomials information to the texture.
  46549. * @param texture defines the texture we are trying to upload the information to
  46550. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46551. */
  46552. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46553. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46554. }
  46555. }
  46556. declare module BABYLON {
  46557. /**
  46558. * Implementation of the ENV Texture Loader.
  46559. * @hidden
  46560. */
  46561. export class _ENVTextureLoader implements IInternalTextureLoader {
  46562. /**
  46563. * Defines wether the loader supports cascade loading the different faces.
  46564. */
  46565. readonly supportCascades: boolean;
  46566. /**
  46567. * This returns if the loader support the current file information.
  46568. * @param extension defines the file extension of the file being loaded
  46569. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46570. * @param fallback defines the fallback internal texture if any
  46571. * @param isBase64 defines whether the texture is encoded as a base64
  46572. * @param isBuffer defines whether the texture data are stored as a buffer
  46573. * @returns true if the loader can load the specified file
  46574. */
  46575. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46576. /**
  46577. * Transform the url before loading if required.
  46578. * @param rootUrl the url of the texture
  46579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46580. * @returns the transformed texture
  46581. */
  46582. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46583. /**
  46584. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46585. * @param rootUrl the url of the texture
  46586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46587. * @returns the fallback texture
  46588. */
  46589. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46590. /**
  46591. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46592. * @param data contains the texture data
  46593. * @param texture defines the BabylonJS internal texture
  46594. * @param createPolynomials will be true if polynomials have been requested
  46595. * @param onLoad defines the callback to trigger once the texture is ready
  46596. * @param onError defines the callback to trigger in case of error
  46597. */
  46598. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46599. /**
  46600. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46601. * @param data contains the texture data
  46602. * @param texture defines the BabylonJS internal texture
  46603. * @param callback defines the method to call once ready to upload
  46604. */
  46605. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46606. }
  46607. }
  46608. declare module BABYLON {
  46609. /**
  46610. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46611. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46612. */
  46613. export class KhronosTextureContainer {
  46614. /** contents of the KTX container file */
  46615. arrayBuffer: any;
  46616. private static HEADER_LEN;
  46617. private static COMPRESSED_2D;
  46618. private static COMPRESSED_3D;
  46619. private static TEX_2D;
  46620. private static TEX_3D;
  46621. /**
  46622. * Gets the openGL type
  46623. */
  46624. glType: number;
  46625. /**
  46626. * Gets the openGL type size
  46627. */
  46628. glTypeSize: number;
  46629. /**
  46630. * Gets the openGL format
  46631. */
  46632. glFormat: number;
  46633. /**
  46634. * Gets the openGL internal format
  46635. */
  46636. glInternalFormat: number;
  46637. /**
  46638. * Gets the base internal format
  46639. */
  46640. glBaseInternalFormat: number;
  46641. /**
  46642. * Gets image width in pixel
  46643. */
  46644. pixelWidth: number;
  46645. /**
  46646. * Gets image height in pixel
  46647. */
  46648. pixelHeight: number;
  46649. /**
  46650. * Gets image depth in pixels
  46651. */
  46652. pixelDepth: number;
  46653. /**
  46654. * Gets the number of array elements
  46655. */
  46656. numberOfArrayElements: number;
  46657. /**
  46658. * Gets the number of faces
  46659. */
  46660. numberOfFaces: number;
  46661. /**
  46662. * Gets the number of mipmap levels
  46663. */
  46664. numberOfMipmapLevels: number;
  46665. /**
  46666. * Gets the bytes of key value data
  46667. */
  46668. bytesOfKeyValueData: number;
  46669. /**
  46670. * Gets the load type
  46671. */
  46672. loadType: number;
  46673. /**
  46674. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46675. */
  46676. isInvalid: boolean;
  46677. /**
  46678. * Creates a new KhronosTextureContainer
  46679. * @param arrayBuffer contents of the KTX container file
  46680. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46681. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46682. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46683. */
  46684. constructor(
  46685. /** contents of the KTX container file */
  46686. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46687. /**
  46688. * Uploads KTX content to a Babylon Texture.
  46689. * It is assumed that the texture has already been created & is currently bound
  46690. * @hidden
  46691. */
  46692. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46693. private _upload2DCompressedLevels;
  46694. }
  46695. }
  46696. declare module BABYLON {
  46697. /**
  46698. * Implementation of the KTX Texture Loader.
  46699. * @hidden
  46700. */
  46701. export class _KTXTextureLoader implements IInternalTextureLoader {
  46702. /**
  46703. * Defines wether the loader supports cascade loading the different faces.
  46704. */
  46705. readonly supportCascades: boolean;
  46706. /**
  46707. * This returns if the loader support the current file information.
  46708. * @param extension defines the file extension of the file being loaded
  46709. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46710. * @param fallback defines the fallback internal texture if any
  46711. * @param isBase64 defines whether the texture is encoded as a base64
  46712. * @param isBuffer defines whether the texture data are stored as a buffer
  46713. * @returns true if the loader can load the specified file
  46714. */
  46715. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46716. /**
  46717. * Transform the url before loading if required.
  46718. * @param rootUrl the url of the texture
  46719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46720. * @returns the transformed texture
  46721. */
  46722. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46723. /**
  46724. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46725. * @param rootUrl the url of the texture
  46726. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46727. * @returns the fallback texture
  46728. */
  46729. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46730. /**
  46731. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46732. * @param data contains the texture data
  46733. * @param texture defines the BabylonJS internal texture
  46734. * @param createPolynomials will be true if polynomials have been requested
  46735. * @param onLoad defines the callback to trigger once the texture is ready
  46736. * @param onError defines the callback to trigger in case of error
  46737. */
  46738. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46739. /**
  46740. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46741. * @param data contains the texture data
  46742. * @param texture defines the BabylonJS internal texture
  46743. * @param callback defines the method to call once ready to upload
  46744. */
  46745. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46746. }
  46747. }
  46748. declare module BABYLON {
  46749. /**
  46750. * Options for the default xr helper
  46751. */
  46752. export class WebXRDefaultExperienceOptions {
  46753. /**
  46754. * Floor meshes that should be used for teleporting
  46755. */
  46756. floorMeshes: Array<AbstractMesh>;
  46757. }
  46758. /**
  46759. * Default experience which provides a similar setup to the previous webVRExperience
  46760. */
  46761. export class WebXRDefaultExperience {
  46762. /**
  46763. * Base experience
  46764. */
  46765. baseExperience: WebXRExperienceHelper;
  46766. /**
  46767. * Input experience extension
  46768. */
  46769. input: WebXRInput;
  46770. /**
  46771. * Loads the controller models
  46772. */
  46773. controllerModelLoader: WebXRControllerModelLoader;
  46774. /**
  46775. * Enables laser pointer and selection
  46776. */
  46777. pointerSelection: WebXRControllerPointerSelection;
  46778. /**
  46779. * Enables teleportation
  46780. */
  46781. teleportation: WebXRControllerTeleportation;
  46782. /**
  46783. * Enables ui for enetering/exiting xr
  46784. */
  46785. enterExitUI: WebXREnterExitUI;
  46786. /**
  46787. * Default output canvas xr should render to
  46788. */
  46789. outputCanvas: WebXRManagedOutputCanvas;
  46790. /**
  46791. * Creates the default xr experience
  46792. * @param scene scene
  46793. * @param options options for basic configuration
  46794. * @returns resulting WebXRDefaultExperience
  46795. */
  46796. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46797. private constructor();
  46798. /**
  46799. * DIsposes of the experience helper
  46800. */
  46801. dispose(): void;
  46802. }
  46803. }
  46804. declare module BABYLON {
  46805. /** @hidden */
  46806. export var _forceSceneHelpersToBundle: boolean;
  46807. interface Scene {
  46808. /**
  46809. * Creates a default light for the scene.
  46810. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46811. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46812. */
  46813. createDefaultLight(replace?: boolean): void;
  46814. /**
  46815. * Creates a default camera for the scene.
  46816. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46817. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46818. * @param replace has default false, when true replaces the active camera in the scene
  46819. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46820. */
  46821. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46822. /**
  46823. * Creates a default camera and a default light.
  46824. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46825. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46826. * @param replace has the default false, when true replaces the active camera/light in the scene
  46827. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46828. */
  46829. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46830. /**
  46831. * Creates a new sky box
  46832. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46833. * @param environmentTexture defines the texture to use as environment texture
  46834. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46835. * @param scale defines the overall scale of the skybox
  46836. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46837. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46838. * @returns a new mesh holding the sky box
  46839. */
  46840. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46841. /**
  46842. * Creates a new environment
  46843. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46844. * @param options defines the options you can use to configure the environment
  46845. * @returns the new EnvironmentHelper
  46846. */
  46847. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46848. /**
  46849. * Creates a new VREXperienceHelper
  46850. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46851. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46852. * @returns a new VREXperienceHelper
  46853. */
  46854. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46855. /**
  46856. * Creates a new WebXRDefaultExperience
  46857. * @see http://doc.babylonjs.com/how_to/webxr
  46858. * @param options experience options
  46859. * @returns a promise for a new WebXRDefaultExperience
  46860. */
  46861. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46862. }
  46863. }
  46864. declare module BABYLON {
  46865. /**
  46866. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46867. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46868. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46869. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46870. */
  46871. export class VideoDome extends TransformNode {
  46872. /**
  46873. * Define the video source as a Monoscopic panoramic 360 video.
  46874. */
  46875. static readonly MODE_MONOSCOPIC: number;
  46876. /**
  46877. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46878. */
  46879. static readonly MODE_TOPBOTTOM: number;
  46880. /**
  46881. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46882. */
  46883. static readonly MODE_SIDEBYSIDE: number;
  46884. private _useDirectMapping;
  46885. /**
  46886. * The video texture being displayed on the sphere
  46887. */
  46888. protected _videoTexture: VideoTexture;
  46889. /**
  46890. * Gets the video texture being displayed on the sphere
  46891. */
  46892. readonly videoTexture: VideoTexture;
  46893. /**
  46894. * The skybox material
  46895. */
  46896. protected _material: BackgroundMaterial;
  46897. /**
  46898. * The surface used for the skybox
  46899. */
  46900. protected _mesh: Mesh;
  46901. /**
  46902. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46903. * Also see the options.resolution property.
  46904. */
  46905. fovMultiplier: number;
  46906. private _videoMode;
  46907. /**
  46908. * Gets or set the current video mode for the video. It can be:
  46909. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46910. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46911. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46912. */
  46913. videoMode: number;
  46914. /**
  46915. * Oberserver used in Stereoscopic VR Mode.
  46916. */
  46917. private _onBeforeCameraRenderObserver;
  46918. /**
  46919. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46920. * @param name Element's name, child elements will append suffixes for their own names.
  46921. * @param urlsOrVideo defines the url(s) or the video element to use
  46922. * @param options An object containing optional or exposed sub element properties
  46923. */
  46924. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46925. resolution?: number;
  46926. clickToPlay?: boolean;
  46927. autoPlay?: boolean;
  46928. loop?: boolean;
  46929. size?: number;
  46930. poster?: string;
  46931. faceForward?: boolean;
  46932. useDirectMapping?: boolean;
  46933. }, scene: Scene);
  46934. private _changeVideoMode;
  46935. /**
  46936. * Releases resources associated with this node.
  46937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46939. */
  46940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46941. }
  46942. }
  46943. declare module BABYLON {
  46944. /**
  46945. * This class can be used to get instrumentation data from a Babylon engine
  46946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46947. */
  46948. export class EngineInstrumentation implements IDisposable {
  46949. /**
  46950. * Define the instrumented engine.
  46951. */
  46952. engine: Engine;
  46953. private _captureGPUFrameTime;
  46954. private _gpuFrameTimeToken;
  46955. private _gpuFrameTime;
  46956. private _captureShaderCompilationTime;
  46957. private _shaderCompilationTime;
  46958. private _onBeginFrameObserver;
  46959. private _onEndFrameObserver;
  46960. private _onBeforeShaderCompilationObserver;
  46961. private _onAfterShaderCompilationObserver;
  46962. /**
  46963. * Gets the perf counter used for GPU frame time
  46964. */
  46965. readonly gpuFrameTimeCounter: PerfCounter;
  46966. /**
  46967. * Gets the GPU frame time capture status
  46968. */
  46969. /**
  46970. * Enable or disable the GPU frame time capture
  46971. */
  46972. captureGPUFrameTime: boolean;
  46973. /**
  46974. * Gets the perf counter used for shader compilation time
  46975. */
  46976. readonly shaderCompilationTimeCounter: PerfCounter;
  46977. /**
  46978. * Gets the shader compilation time capture status
  46979. */
  46980. /**
  46981. * Enable or disable the shader compilation time capture
  46982. */
  46983. captureShaderCompilationTime: boolean;
  46984. /**
  46985. * Instantiates a new engine instrumentation.
  46986. * This class can be used to get instrumentation data from a Babylon engine
  46987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46988. * @param engine Defines the engine to instrument
  46989. */
  46990. constructor(
  46991. /**
  46992. * Define the instrumented engine.
  46993. */
  46994. engine: Engine);
  46995. /**
  46996. * Dispose and release associated resources.
  46997. */
  46998. dispose(): void;
  46999. }
  47000. }
  47001. declare module BABYLON {
  47002. /**
  47003. * This class can be used to get instrumentation data from a Babylon engine
  47004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47005. */
  47006. export class SceneInstrumentation implements IDisposable {
  47007. /**
  47008. * Defines the scene to instrument
  47009. */
  47010. scene: Scene;
  47011. private _captureActiveMeshesEvaluationTime;
  47012. private _activeMeshesEvaluationTime;
  47013. private _captureRenderTargetsRenderTime;
  47014. private _renderTargetsRenderTime;
  47015. private _captureFrameTime;
  47016. private _frameTime;
  47017. private _captureRenderTime;
  47018. private _renderTime;
  47019. private _captureInterFrameTime;
  47020. private _interFrameTime;
  47021. private _captureParticlesRenderTime;
  47022. private _particlesRenderTime;
  47023. private _captureSpritesRenderTime;
  47024. private _spritesRenderTime;
  47025. private _capturePhysicsTime;
  47026. private _physicsTime;
  47027. private _captureAnimationsTime;
  47028. private _animationsTime;
  47029. private _captureCameraRenderTime;
  47030. private _cameraRenderTime;
  47031. private _onBeforeActiveMeshesEvaluationObserver;
  47032. private _onAfterActiveMeshesEvaluationObserver;
  47033. private _onBeforeRenderTargetsRenderObserver;
  47034. private _onAfterRenderTargetsRenderObserver;
  47035. private _onAfterRenderObserver;
  47036. private _onBeforeDrawPhaseObserver;
  47037. private _onAfterDrawPhaseObserver;
  47038. private _onBeforeAnimationsObserver;
  47039. private _onBeforeParticlesRenderingObserver;
  47040. private _onAfterParticlesRenderingObserver;
  47041. private _onBeforeSpritesRenderingObserver;
  47042. private _onAfterSpritesRenderingObserver;
  47043. private _onBeforePhysicsObserver;
  47044. private _onAfterPhysicsObserver;
  47045. private _onAfterAnimationsObserver;
  47046. private _onBeforeCameraRenderObserver;
  47047. private _onAfterCameraRenderObserver;
  47048. /**
  47049. * Gets the perf counter used for active meshes evaluation time
  47050. */
  47051. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47052. /**
  47053. * Gets the active meshes evaluation time capture status
  47054. */
  47055. /**
  47056. * Enable or disable the active meshes evaluation time capture
  47057. */
  47058. captureActiveMeshesEvaluationTime: boolean;
  47059. /**
  47060. * Gets the perf counter used for render targets render time
  47061. */
  47062. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47063. /**
  47064. * Gets the render targets render time capture status
  47065. */
  47066. /**
  47067. * Enable or disable the render targets render time capture
  47068. */
  47069. captureRenderTargetsRenderTime: boolean;
  47070. /**
  47071. * Gets the perf counter used for particles render time
  47072. */
  47073. readonly particlesRenderTimeCounter: PerfCounter;
  47074. /**
  47075. * Gets the particles render time capture status
  47076. */
  47077. /**
  47078. * Enable or disable the particles render time capture
  47079. */
  47080. captureParticlesRenderTime: boolean;
  47081. /**
  47082. * Gets the perf counter used for sprites render time
  47083. */
  47084. readonly spritesRenderTimeCounter: PerfCounter;
  47085. /**
  47086. * Gets the sprites render time capture status
  47087. */
  47088. /**
  47089. * Enable or disable the sprites render time capture
  47090. */
  47091. captureSpritesRenderTime: boolean;
  47092. /**
  47093. * Gets the perf counter used for physics time
  47094. */
  47095. readonly physicsTimeCounter: PerfCounter;
  47096. /**
  47097. * Gets the physics time capture status
  47098. */
  47099. /**
  47100. * Enable or disable the physics time capture
  47101. */
  47102. capturePhysicsTime: boolean;
  47103. /**
  47104. * Gets the perf counter used for animations time
  47105. */
  47106. readonly animationsTimeCounter: PerfCounter;
  47107. /**
  47108. * Gets the animations time capture status
  47109. */
  47110. /**
  47111. * Enable or disable the animations time capture
  47112. */
  47113. captureAnimationsTime: boolean;
  47114. /**
  47115. * Gets the perf counter used for frame time capture
  47116. */
  47117. readonly frameTimeCounter: PerfCounter;
  47118. /**
  47119. * Gets the frame time capture status
  47120. */
  47121. /**
  47122. * Enable or disable the frame time capture
  47123. */
  47124. captureFrameTime: boolean;
  47125. /**
  47126. * Gets the perf counter used for inter-frames time capture
  47127. */
  47128. readonly interFrameTimeCounter: PerfCounter;
  47129. /**
  47130. * Gets the inter-frames time capture status
  47131. */
  47132. /**
  47133. * Enable or disable the inter-frames time capture
  47134. */
  47135. captureInterFrameTime: boolean;
  47136. /**
  47137. * Gets the perf counter used for render time capture
  47138. */
  47139. readonly renderTimeCounter: PerfCounter;
  47140. /**
  47141. * Gets the render time capture status
  47142. */
  47143. /**
  47144. * Enable or disable the render time capture
  47145. */
  47146. captureRenderTime: boolean;
  47147. /**
  47148. * Gets the perf counter used for camera render time capture
  47149. */
  47150. readonly cameraRenderTimeCounter: PerfCounter;
  47151. /**
  47152. * Gets the camera render time capture status
  47153. */
  47154. /**
  47155. * Enable or disable the camera render time capture
  47156. */
  47157. captureCameraRenderTime: boolean;
  47158. /**
  47159. * Gets the perf counter used for draw calls
  47160. */
  47161. readonly drawCallsCounter: PerfCounter;
  47162. /**
  47163. * Instantiates a new scene instrumentation.
  47164. * This class can be used to get instrumentation data from a Babylon engine
  47165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47166. * @param scene Defines the scene to instrument
  47167. */
  47168. constructor(
  47169. /**
  47170. * Defines the scene to instrument
  47171. */
  47172. scene: Scene);
  47173. /**
  47174. * Dispose and release associated resources.
  47175. */
  47176. dispose(): void;
  47177. }
  47178. }
  47179. declare module BABYLON {
  47180. /** @hidden */
  47181. export var glowMapGenerationPixelShader: {
  47182. name: string;
  47183. shader: string;
  47184. };
  47185. }
  47186. declare module BABYLON {
  47187. /** @hidden */
  47188. export var glowMapGenerationVertexShader: {
  47189. name: string;
  47190. shader: string;
  47191. };
  47192. }
  47193. declare module BABYLON {
  47194. /**
  47195. * Effect layer options. This helps customizing the behaviour
  47196. * of the effect layer.
  47197. */
  47198. export interface IEffectLayerOptions {
  47199. /**
  47200. * Multiplication factor apply to the canvas size to compute the render target size
  47201. * used to generated the objects (the smaller the faster).
  47202. */
  47203. mainTextureRatio: number;
  47204. /**
  47205. * Enforces a fixed size texture to ensure effect stability across devices.
  47206. */
  47207. mainTextureFixedSize?: number;
  47208. /**
  47209. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47210. */
  47211. alphaBlendingMode: number;
  47212. /**
  47213. * The camera attached to the layer.
  47214. */
  47215. camera: Nullable<Camera>;
  47216. /**
  47217. * The rendering group to draw the layer in.
  47218. */
  47219. renderingGroupId: number;
  47220. }
  47221. /**
  47222. * The effect layer Helps adding post process effect blended with the main pass.
  47223. *
  47224. * This can be for instance use to generate glow or higlight effects on the scene.
  47225. *
  47226. * The effect layer class can not be used directly and is intented to inherited from to be
  47227. * customized per effects.
  47228. */
  47229. export abstract class EffectLayer {
  47230. private _vertexBuffers;
  47231. private _indexBuffer;
  47232. private _cachedDefines;
  47233. private _effectLayerMapGenerationEffect;
  47234. private _effectLayerOptions;
  47235. private _mergeEffect;
  47236. protected _scene: Scene;
  47237. protected _engine: Engine;
  47238. protected _maxSize: number;
  47239. protected _mainTextureDesiredSize: ISize;
  47240. protected _mainTexture: RenderTargetTexture;
  47241. protected _shouldRender: boolean;
  47242. protected _postProcesses: PostProcess[];
  47243. protected _textures: BaseTexture[];
  47244. protected _emissiveTextureAndColor: {
  47245. texture: Nullable<BaseTexture>;
  47246. color: Color4;
  47247. };
  47248. /**
  47249. * The name of the layer
  47250. */
  47251. name: string;
  47252. /**
  47253. * The clear color of the texture used to generate the glow map.
  47254. */
  47255. neutralColor: Color4;
  47256. /**
  47257. * Specifies wether the highlight layer is enabled or not.
  47258. */
  47259. isEnabled: boolean;
  47260. /**
  47261. * Gets the camera attached to the layer.
  47262. */
  47263. readonly camera: Nullable<Camera>;
  47264. /**
  47265. * Gets the rendering group id the layer should render in.
  47266. */
  47267. renderingGroupId: number;
  47268. /**
  47269. * An event triggered when the effect layer has been disposed.
  47270. */
  47271. onDisposeObservable: Observable<EffectLayer>;
  47272. /**
  47273. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47274. */
  47275. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47276. /**
  47277. * An event triggered when the generated texture is being merged in the scene.
  47278. */
  47279. onBeforeComposeObservable: Observable<EffectLayer>;
  47280. /**
  47281. * An event triggered when the generated texture has been merged in the scene.
  47282. */
  47283. onAfterComposeObservable: Observable<EffectLayer>;
  47284. /**
  47285. * An event triggered when the efffect layer changes its size.
  47286. */
  47287. onSizeChangedObservable: Observable<EffectLayer>;
  47288. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47289. /**
  47290. * Instantiates a new effect Layer and references it in the scene.
  47291. * @param name The name of the layer
  47292. * @param scene The scene to use the layer in
  47293. */
  47294. constructor(
  47295. /** The Friendly of the effect in the scene */
  47296. name: string, scene: Scene);
  47297. /**
  47298. * Get the effect name of the layer.
  47299. * @return The effect name
  47300. */
  47301. abstract getEffectName(): string;
  47302. /**
  47303. * Checks for the readiness of the element composing the layer.
  47304. * @param subMesh the mesh to check for
  47305. * @param useInstances specify wether or not to use instances to render the mesh
  47306. * @return true if ready otherwise, false
  47307. */
  47308. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47309. /**
  47310. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47311. * @returns true if the effect requires stencil during the main canvas render pass.
  47312. */
  47313. abstract needStencil(): boolean;
  47314. /**
  47315. * Create the merge effect. This is the shader use to blit the information back
  47316. * to the main canvas at the end of the scene rendering.
  47317. * @returns The effect containing the shader used to merge the effect on the main canvas
  47318. */
  47319. protected abstract _createMergeEffect(): Effect;
  47320. /**
  47321. * Creates the render target textures and post processes used in the effect layer.
  47322. */
  47323. protected abstract _createTextureAndPostProcesses(): void;
  47324. /**
  47325. * Implementation specific of rendering the generating effect on the main canvas.
  47326. * @param effect The effect used to render through
  47327. */
  47328. protected abstract _internalRender(effect: Effect): void;
  47329. /**
  47330. * Sets the required values for both the emissive texture and and the main color.
  47331. */
  47332. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47333. /**
  47334. * Free any resources and references associated to a mesh.
  47335. * Internal use
  47336. * @param mesh The mesh to free.
  47337. */
  47338. abstract _disposeMesh(mesh: Mesh): void;
  47339. /**
  47340. * Serializes this layer (Glow or Highlight for example)
  47341. * @returns a serialized layer object
  47342. */
  47343. abstract serialize?(): any;
  47344. /**
  47345. * Initializes the effect layer with the required options.
  47346. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47347. */
  47348. protected _init(options: Partial<IEffectLayerOptions>): void;
  47349. /**
  47350. * Generates the index buffer of the full screen quad blending to the main canvas.
  47351. */
  47352. private _generateIndexBuffer;
  47353. /**
  47354. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47355. */
  47356. private _generateVertexBuffer;
  47357. /**
  47358. * Sets the main texture desired size which is the closest power of two
  47359. * of the engine canvas size.
  47360. */
  47361. private _setMainTextureSize;
  47362. /**
  47363. * Creates the main texture for the effect layer.
  47364. */
  47365. protected _createMainTexture(): void;
  47366. /**
  47367. * Adds specific effects defines.
  47368. * @param defines The defines to add specifics to.
  47369. */
  47370. protected _addCustomEffectDefines(defines: string[]): void;
  47371. /**
  47372. * Checks for the readiness of the element composing the layer.
  47373. * @param subMesh the mesh to check for
  47374. * @param useInstances specify wether or not to use instances to render the mesh
  47375. * @param emissiveTexture the associated emissive texture used to generate the glow
  47376. * @return true if ready otherwise, false
  47377. */
  47378. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47379. /**
  47380. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47381. */
  47382. render(): void;
  47383. /**
  47384. * Determine if a given mesh will be used in the current effect.
  47385. * @param mesh mesh to test
  47386. * @returns true if the mesh will be used
  47387. */
  47388. hasMesh(mesh: AbstractMesh): boolean;
  47389. /**
  47390. * Returns true if the layer contains information to display, otherwise false.
  47391. * @returns true if the glow layer should be rendered
  47392. */
  47393. shouldRender(): boolean;
  47394. /**
  47395. * Returns true if the mesh should render, otherwise false.
  47396. * @param mesh The mesh to render
  47397. * @returns true if it should render otherwise false
  47398. */
  47399. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47400. /**
  47401. * Returns true if the mesh can be rendered, otherwise false.
  47402. * @param mesh The mesh to render
  47403. * @param material The material used on the mesh
  47404. * @returns true if it can be rendered otherwise false
  47405. */
  47406. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47407. /**
  47408. * Returns true if the mesh should render, otherwise false.
  47409. * @param mesh The mesh to render
  47410. * @returns true if it should render otherwise false
  47411. */
  47412. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47413. /**
  47414. * Renders the submesh passed in parameter to the generation map.
  47415. */
  47416. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47417. /**
  47418. * Rebuild the required buffers.
  47419. * @hidden Internal use only.
  47420. */ private _rebuild(): void;
  47421. /**
  47422. * Dispose only the render target textures and post process.
  47423. */
  47424. private _disposeTextureAndPostProcesses;
  47425. /**
  47426. * Dispose the highlight layer and free resources.
  47427. */
  47428. dispose(): void;
  47429. /**
  47430. * Gets the class name of the effect layer
  47431. * @returns the string with the class name of the effect layer
  47432. */
  47433. getClassName(): string;
  47434. /**
  47435. * Creates an effect layer from parsed effect layer data
  47436. * @param parsedEffectLayer defines effect layer data
  47437. * @param scene defines the current scene
  47438. * @param rootUrl defines the root URL containing the effect layer information
  47439. * @returns a parsed effect Layer
  47440. */
  47441. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47442. }
  47443. }
  47444. declare module BABYLON {
  47445. interface AbstractScene {
  47446. /**
  47447. * The list of effect layers (highlights/glow) added to the scene
  47448. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47449. * @see http://doc.babylonjs.com/how_to/glow_layer
  47450. */
  47451. effectLayers: Array<EffectLayer>;
  47452. /**
  47453. * Removes the given effect layer from this scene.
  47454. * @param toRemove defines the effect layer to remove
  47455. * @returns the index of the removed effect layer
  47456. */
  47457. removeEffectLayer(toRemove: EffectLayer): number;
  47458. /**
  47459. * Adds the given effect layer to this scene
  47460. * @param newEffectLayer defines the effect layer to add
  47461. */
  47462. addEffectLayer(newEffectLayer: EffectLayer): void;
  47463. }
  47464. /**
  47465. * Defines the layer scene component responsible to manage any effect layers
  47466. * in a given scene.
  47467. */
  47468. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47469. /**
  47470. * The component name helpfull to identify the component in the list of scene components.
  47471. */
  47472. readonly name: string;
  47473. /**
  47474. * The scene the component belongs to.
  47475. */
  47476. scene: Scene;
  47477. private _engine;
  47478. private _renderEffects;
  47479. private _needStencil;
  47480. private _previousStencilState;
  47481. /**
  47482. * Creates a new instance of the component for the given scene
  47483. * @param scene Defines the scene to register the component in
  47484. */
  47485. constructor(scene: Scene);
  47486. /**
  47487. * Registers the component in a given scene
  47488. */
  47489. register(): void;
  47490. /**
  47491. * Rebuilds the elements related to this component in case of
  47492. * context lost for instance.
  47493. */
  47494. rebuild(): void;
  47495. /**
  47496. * Serializes the component data to the specified json object
  47497. * @param serializationObject The object to serialize to
  47498. */
  47499. serialize(serializationObject: any): void;
  47500. /**
  47501. * Adds all the elements from the container to the scene
  47502. * @param container the container holding the elements
  47503. */
  47504. addFromContainer(container: AbstractScene): void;
  47505. /**
  47506. * Removes all the elements in the container from the scene
  47507. * @param container contains the elements to remove
  47508. * @param dispose if the removed element should be disposed (default: false)
  47509. */
  47510. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47511. /**
  47512. * Disposes the component and the associated ressources.
  47513. */
  47514. dispose(): void;
  47515. private _isReadyForMesh;
  47516. private _renderMainTexture;
  47517. private _setStencil;
  47518. private _setStencilBack;
  47519. private _draw;
  47520. private _drawCamera;
  47521. private _drawRenderingGroup;
  47522. }
  47523. }
  47524. declare module BABYLON {
  47525. /** @hidden */
  47526. export var glowMapMergePixelShader: {
  47527. name: string;
  47528. shader: string;
  47529. };
  47530. }
  47531. declare module BABYLON {
  47532. /** @hidden */
  47533. export var glowMapMergeVertexShader: {
  47534. name: string;
  47535. shader: string;
  47536. };
  47537. }
  47538. declare module BABYLON {
  47539. interface AbstractScene {
  47540. /**
  47541. * Return a the first highlight layer of the scene with a given name.
  47542. * @param name The name of the highlight layer to look for.
  47543. * @return The highlight layer if found otherwise null.
  47544. */
  47545. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47546. }
  47547. /**
  47548. * Glow layer options. This helps customizing the behaviour
  47549. * of the glow layer.
  47550. */
  47551. export interface IGlowLayerOptions {
  47552. /**
  47553. * Multiplication factor apply to the canvas size to compute the render target size
  47554. * used to generated the glowing objects (the smaller the faster).
  47555. */
  47556. mainTextureRatio: number;
  47557. /**
  47558. * Enforces a fixed size texture to ensure resize independant blur.
  47559. */
  47560. mainTextureFixedSize?: number;
  47561. /**
  47562. * How big is the kernel of the blur texture.
  47563. */
  47564. blurKernelSize: number;
  47565. /**
  47566. * The camera attached to the layer.
  47567. */
  47568. camera: Nullable<Camera>;
  47569. /**
  47570. * Enable MSAA by chosing the number of samples.
  47571. */
  47572. mainTextureSamples?: number;
  47573. /**
  47574. * The rendering group to draw the layer in.
  47575. */
  47576. renderingGroupId: number;
  47577. }
  47578. /**
  47579. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47580. *
  47581. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47582. * glowy meshes to your scene.
  47583. *
  47584. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47585. */
  47586. export class GlowLayer extends EffectLayer {
  47587. /**
  47588. * Effect Name of the layer.
  47589. */
  47590. static readonly EffectName: string;
  47591. /**
  47592. * The default blur kernel size used for the glow.
  47593. */
  47594. static DefaultBlurKernelSize: number;
  47595. /**
  47596. * The default texture size ratio used for the glow.
  47597. */
  47598. static DefaultTextureRatio: number;
  47599. /**
  47600. * Sets the kernel size of the blur.
  47601. */
  47602. /**
  47603. * Gets the kernel size of the blur.
  47604. */
  47605. blurKernelSize: number;
  47606. /**
  47607. * Sets the glow intensity.
  47608. */
  47609. /**
  47610. * Gets the glow intensity.
  47611. */
  47612. intensity: number;
  47613. private _options;
  47614. private _intensity;
  47615. private _horizontalBlurPostprocess1;
  47616. private _verticalBlurPostprocess1;
  47617. private _horizontalBlurPostprocess2;
  47618. private _verticalBlurPostprocess2;
  47619. private _blurTexture1;
  47620. private _blurTexture2;
  47621. private _postProcesses1;
  47622. private _postProcesses2;
  47623. private _includedOnlyMeshes;
  47624. private _excludedMeshes;
  47625. /**
  47626. * Callback used to let the user override the color selection on a per mesh basis
  47627. */
  47628. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47629. /**
  47630. * Callback used to let the user override the texture selection on a per mesh basis
  47631. */
  47632. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47633. /**
  47634. * Instantiates a new glow Layer and references it to the scene.
  47635. * @param name The name of the layer
  47636. * @param scene The scene to use the layer in
  47637. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47638. */
  47639. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47640. /**
  47641. * Get the effect name of the layer.
  47642. * @return The effect name
  47643. */
  47644. getEffectName(): string;
  47645. /**
  47646. * Create the merge effect. This is the shader use to blit the information back
  47647. * to the main canvas at the end of the scene rendering.
  47648. */
  47649. protected _createMergeEffect(): Effect;
  47650. /**
  47651. * Creates the render target textures and post processes used in the glow layer.
  47652. */
  47653. protected _createTextureAndPostProcesses(): void;
  47654. /**
  47655. * Checks for the readiness of the element composing the layer.
  47656. * @param subMesh the mesh to check for
  47657. * @param useInstances specify wether or not to use instances to render the mesh
  47658. * @param emissiveTexture the associated emissive texture used to generate the glow
  47659. * @return true if ready otherwise, false
  47660. */
  47661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47662. /**
  47663. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47664. */
  47665. needStencil(): boolean;
  47666. /**
  47667. * Returns true if the mesh can be rendered, otherwise false.
  47668. * @param mesh The mesh to render
  47669. * @param material The material used on the mesh
  47670. * @returns true if it can be rendered otherwise false
  47671. */
  47672. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47673. /**
  47674. * Implementation specific of rendering the generating effect on the main canvas.
  47675. * @param effect The effect used to render through
  47676. */
  47677. protected _internalRender(effect: Effect): void;
  47678. /**
  47679. * Sets the required values for both the emissive texture and and the main color.
  47680. */
  47681. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47682. /**
  47683. * Returns true if the mesh should render, otherwise false.
  47684. * @param mesh The mesh to render
  47685. * @returns true if it should render otherwise false
  47686. */
  47687. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47688. /**
  47689. * Adds specific effects defines.
  47690. * @param defines The defines to add specifics to.
  47691. */
  47692. protected _addCustomEffectDefines(defines: string[]): void;
  47693. /**
  47694. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47695. * @param mesh The mesh to exclude from the glow layer
  47696. */
  47697. addExcludedMesh(mesh: Mesh): void;
  47698. /**
  47699. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47700. * @param mesh The mesh to remove
  47701. */
  47702. removeExcludedMesh(mesh: Mesh): void;
  47703. /**
  47704. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47705. * @param mesh The mesh to include in the glow layer
  47706. */
  47707. addIncludedOnlyMesh(mesh: Mesh): void;
  47708. /**
  47709. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47710. * @param mesh The mesh to remove
  47711. */
  47712. removeIncludedOnlyMesh(mesh: Mesh): void;
  47713. /**
  47714. * Determine if a given mesh will be used in the glow layer
  47715. * @param mesh The mesh to test
  47716. * @returns true if the mesh will be highlighted by the current glow layer
  47717. */
  47718. hasMesh(mesh: AbstractMesh): boolean;
  47719. /**
  47720. * Free any resources and references associated to a mesh.
  47721. * Internal use
  47722. * @param mesh The mesh to free.
  47723. * @hidden
  47724. */ private _disposeMesh(mesh: Mesh): void;
  47725. /**
  47726. * Gets the class name of the effect layer
  47727. * @returns the string with the class name of the effect layer
  47728. */
  47729. getClassName(): string;
  47730. /**
  47731. * Serializes this glow layer
  47732. * @returns a serialized glow layer object
  47733. */
  47734. serialize(): any;
  47735. /**
  47736. * Creates a Glow Layer from parsed glow layer data
  47737. * @param parsedGlowLayer defines glow layer data
  47738. * @param scene defines the current scene
  47739. * @param rootUrl defines the root URL containing the glow layer information
  47740. * @returns a parsed Glow Layer
  47741. */
  47742. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47743. }
  47744. }
  47745. declare module BABYLON {
  47746. /** @hidden */
  47747. export var glowBlurPostProcessPixelShader: {
  47748. name: string;
  47749. shader: string;
  47750. };
  47751. }
  47752. declare module BABYLON {
  47753. interface AbstractScene {
  47754. /**
  47755. * Return a the first highlight layer of the scene with a given name.
  47756. * @param name The name of the highlight layer to look for.
  47757. * @return The highlight layer if found otherwise null.
  47758. */
  47759. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47760. }
  47761. /**
  47762. * Highlight layer options. This helps customizing the behaviour
  47763. * of the highlight layer.
  47764. */
  47765. export interface IHighlightLayerOptions {
  47766. /**
  47767. * Multiplication factor apply to the canvas size to compute the render target size
  47768. * used to generated the glowing objects (the smaller the faster).
  47769. */
  47770. mainTextureRatio: number;
  47771. /**
  47772. * Enforces a fixed size texture to ensure resize independant blur.
  47773. */
  47774. mainTextureFixedSize?: number;
  47775. /**
  47776. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47777. * of the picture to blur (the smaller the faster).
  47778. */
  47779. blurTextureSizeRatio: number;
  47780. /**
  47781. * How big in texel of the blur texture is the vertical blur.
  47782. */
  47783. blurVerticalSize: number;
  47784. /**
  47785. * How big in texel of the blur texture is the horizontal blur.
  47786. */
  47787. blurHorizontalSize: number;
  47788. /**
  47789. * Alpha blending mode used to apply the blur. Default is combine.
  47790. */
  47791. alphaBlendingMode: number;
  47792. /**
  47793. * The camera attached to the layer.
  47794. */
  47795. camera: Nullable<Camera>;
  47796. /**
  47797. * Should we display highlight as a solid stroke?
  47798. */
  47799. isStroke?: boolean;
  47800. /**
  47801. * The rendering group to draw the layer in.
  47802. */
  47803. renderingGroupId: number;
  47804. }
  47805. /**
  47806. * The highlight layer Helps adding a glow effect around a mesh.
  47807. *
  47808. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47809. * glowy meshes to your scene.
  47810. *
  47811. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47812. */
  47813. export class HighlightLayer extends EffectLayer {
  47814. name: string;
  47815. /**
  47816. * Effect Name of the highlight layer.
  47817. */
  47818. static readonly EffectName: string;
  47819. /**
  47820. * The neutral color used during the preparation of the glow effect.
  47821. * This is black by default as the blend operation is a blend operation.
  47822. */
  47823. static NeutralColor: Color4;
  47824. /**
  47825. * Stencil value used for glowing meshes.
  47826. */
  47827. static GlowingMeshStencilReference: number;
  47828. /**
  47829. * Stencil value used for the other meshes in the scene.
  47830. */
  47831. static NormalMeshStencilReference: number;
  47832. /**
  47833. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47834. */
  47835. innerGlow: boolean;
  47836. /**
  47837. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47838. */
  47839. outerGlow: boolean;
  47840. /**
  47841. * Specifies the horizontal size of the blur.
  47842. */
  47843. /**
  47844. * Gets the horizontal size of the blur.
  47845. */
  47846. blurHorizontalSize: number;
  47847. /**
  47848. * Specifies the vertical size of the blur.
  47849. */
  47850. /**
  47851. * Gets the vertical size of the blur.
  47852. */
  47853. blurVerticalSize: number;
  47854. /**
  47855. * An event triggered when the highlight layer is being blurred.
  47856. */
  47857. onBeforeBlurObservable: Observable<HighlightLayer>;
  47858. /**
  47859. * An event triggered when the highlight layer has been blurred.
  47860. */
  47861. onAfterBlurObservable: Observable<HighlightLayer>;
  47862. private _instanceGlowingMeshStencilReference;
  47863. private _options;
  47864. private _downSamplePostprocess;
  47865. private _horizontalBlurPostprocess;
  47866. private _verticalBlurPostprocess;
  47867. private _blurTexture;
  47868. private _meshes;
  47869. private _excludedMeshes;
  47870. /**
  47871. * Instantiates a new highlight Layer and references it to the scene..
  47872. * @param name The name of the layer
  47873. * @param scene The scene to use the layer in
  47874. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47875. */
  47876. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47877. /**
  47878. * Get the effect name of the layer.
  47879. * @return The effect name
  47880. */
  47881. getEffectName(): string;
  47882. /**
  47883. * Create the merge effect. This is the shader use to blit the information back
  47884. * to the main canvas at the end of the scene rendering.
  47885. */
  47886. protected _createMergeEffect(): Effect;
  47887. /**
  47888. * Creates the render target textures and post processes used in the highlight layer.
  47889. */
  47890. protected _createTextureAndPostProcesses(): void;
  47891. /**
  47892. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47893. */
  47894. needStencil(): boolean;
  47895. /**
  47896. * Checks for the readiness of the element composing the layer.
  47897. * @param subMesh the mesh to check for
  47898. * @param useInstances specify wether or not to use instances to render the mesh
  47899. * @param emissiveTexture the associated emissive texture used to generate the glow
  47900. * @return true if ready otherwise, false
  47901. */
  47902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47903. /**
  47904. * Implementation specific of rendering the generating effect on the main canvas.
  47905. * @param effect The effect used to render through
  47906. */
  47907. protected _internalRender(effect: Effect): void;
  47908. /**
  47909. * Returns true if the layer contains information to display, otherwise false.
  47910. */
  47911. shouldRender(): boolean;
  47912. /**
  47913. * Returns true if the mesh should render, otherwise false.
  47914. * @param mesh The mesh to render
  47915. * @returns true if it should render otherwise false
  47916. */
  47917. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47918. /**
  47919. * Sets the required values for both the emissive texture and and the main color.
  47920. */
  47921. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47922. /**
  47923. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47924. * @param mesh The mesh to exclude from the highlight layer
  47925. */
  47926. addExcludedMesh(mesh: Mesh): void;
  47927. /**
  47928. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47929. * @param mesh The mesh to highlight
  47930. */
  47931. removeExcludedMesh(mesh: Mesh): void;
  47932. /**
  47933. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47934. * @param mesh mesh to test
  47935. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47936. */
  47937. hasMesh(mesh: AbstractMesh): boolean;
  47938. /**
  47939. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47940. * @param mesh The mesh to highlight
  47941. * @param color The color of the highlight
  47942. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47943. */
  47944. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47945. /**
  47946. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47947. * @param mesh The mesh to highlight
  47948. */
  47949. removeMesh(mesh: Mesh): void;
  47950. /**
  47951. * Force the stencil to the normal expected value for none glowing parts
  47952. */
  47953. private _defaultStencilReference;
  47954. /**
  47955. * Free any resources and references associated to a mesh.
  47956. * Internal use
  47957. * @param mesh The mesh to free.
  47958. * @hidden
  47959. */ private _disposeMesh(mesh: Mesh): void;
  47960. /**
  47961. * Dispose the highlight layer and free resources.
  47962. */
  47963. dispose(): void;
  47964. /**
  47965. * Gets the class name of the effect layer
  47966. * @returns the string with the class name of the effect layer
  47967. */
  47968. getClassName(): string;
  47969. /**
  47970. * Serializes this Highlight layer
  47971. * @returns a serialized Highlight layer object
  47972. */
  47973. serialize(): any;
  47974. /**
  47975. * Creates a Highlight layer from parsed Highlight layer data
  47976. * @param parsedHightlightLayer defines the Highlight layer data
  47977. * @param scene defines the current scene
  47978. * @param rootUrl defines the root URL containing the Highlight layer information
  47979. * @returns a parsed Highlight layer
  47980. */
  47981. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47982. }
  47983. }
  47984. declare module BABYLON {
  47985. interface AbstractScene {
  47986. /**
  47987. * The list of layers (background and foreground) of the scene
  47988. */
  47989. layers: Array<Layer>;
  47990. }
  47991. /**
  47992. * Defines the layer scene component responsible to manage any layers
  47993. * in a given scene.
  47994. */
  47995. export class LayerSceneComponent implements ISceneComponent {
  47996. /**
  47997. * The component name helpfull to identify the component in the list of scene components.
  47998. */
  47999. readonly name: string;
  48000. /**
  48001. * The scene the component belongs to.
  48002. */
  48003. scene: Scene;
  48004. private _engine;
  48005. /**
  48006. * Creates a new instance of the component for the given scene
  48007. * @param scene Defines the scene to register the component in
  48008. */
  48009. constructor(scene: Scene);
  48010. /**
  48011. * Registers the component in a given scene
  48012. */
  48013. register(): void;
  48014. /**
  48015. * Rebuilds the elements related to this component in case of
  48016. * context lost for instance.
  48017. */
  48018. rebuild(): void;
  48019. /**
  48020. * Disposes the component and the associated ressources.
  48021. */
  48022. dispose(): void;
  48023. private _draw;
  48024. private _drawCameraPredicate;
  48025. private _drawCameraBackground;
  48026. private _drawCameraForeground;
  48027. private _drawRenderTargetPredicate;
  48028. private _drawRenderTargetBackground;
  48029. private _drawRenderTargetForeground;
  48030. /**
  48031. * Adds all the elements from the container to the scene
  48032. * @param container the container holding the elements
  48033. */
  48034. addFromContainer(container: AbstractScene): void;
  48035. /**
  48036. * Removes all the elements in the container from the scene
  48037. * @param container contains the elements to remove
  48038. * @param dispose if the removed element should be disposed (default: false)
  48039. */
  48040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48041. }
  48042. }
  48043. declare module BABYLON {
  48044. /** @hidden */
  48045. export var layerPixelShader: {
  48046. name: string;
  48047. shader: string;
  48048. };
  48049. }
  48050. declare module BABYLON {
  48051. /** @hidden */
  48052. export var layerVertexShader: {
  48053. name: string;
  48054. shader: string;
  48055. };
  48056. }
  48057. declare module BABYLON {
  48058. /**
  48059. * This represents a full screen 2d layer.
  48060. * This can be useful to display a picture in the background of your scene for instance.
  48061. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48062. */
  48063. export class Layer {
  48064. /**
  48065. * Define the name of the layer.
  48066. */
  48067. name: string;
  48068. /**
  48069. * Define the texture the layer should display.
  48070. */
  48071. texture: Nullable<Texture>;
  48072. /**
  48073. * Is the layer in background or foreground.
  48074. */
  48075. isBackground: boolean;
  48076. /**
  48077. * Define the color of the layer (instead of texture).
  48078. */
  48079. color: Color4;
  48080. /**
  48081. * Define the scale of the layer in order to zoom in out of the texture.
  48082. */
  48083. scale: Vector2;
  48084. /**
  48085. * Define an offset for the layer in order to shift the texture.
  48086. */
  48087. offset: Vector2;
  48088. /**
  48089. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48090. */
  48091. alphaBlendingMode: number;
  48092. /**
  48093. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48094. * Alpha test will not mix with the background color in case of transparency.
  48095. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48096. */
  48097. alphaTest: boolean;
  48098. /**
  48099. * Define a mask to restrict the layer to only some of the scene cameras.
  48100. */
  48101. layerMask: number;
  48102. /**
  48103. * Define the list of render target the layer is visible into.
  48104. */
  48105. renderTargetTextures: RenderTargetTexture[];
  48106. /**
  48107. * Define if the layer is only used in renderTarget or if it also
  48108. * renders in the main frame buffer of the canvas.
  48109. */
  48110. renderOnlyInRenderTargetTextures: boolean;
  48111. private _scene;
  48112. private _vertexBuffers;
  48113. private _indexBuffer;
  48114. private _effect;
  48115. private _alphaTestEffect;
  48116. /**
  48117. * An event triggered when the layer is disposed.
  48118. */
  48119. onDisposeObservable: Observable<Layer>;
  48120. private _onDisposeObserver;
  48121. /**
  48122. * Back compatibility with callback before the onDisposeObservable existed.
  48123. * The set callback will be triggered when the layer has been disposed.
  48124. */
  48125. onDispose: () => void;
  48126. /**
  48127. * An event triggered before rendering the scene
  48128. */
  48129. onBeforeRenderObservable: Observable<Layer>;
  48130. private _onBeforeRenderObserver;
  48131. /**
  48132. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48133. * The set callback will be triggered just before rendering the layer.
  48134. */
  48135. onBeforeRender: () => void;
  48136. /**
  48137. * An event triggered after rendering the scene
  48138. */
  48139. onAfterRenderObservable: Observable<Layer>;
  48140. private _onAfterRenderObserver;
  48141. /**
  48142. * Back compatibility with callback before the onAfterRenderObservable existed.
  48143. * The set callback will be triggered just after rendering the layer.
  48144. */
  48145. onAfterRender: () => void;
  48146. /**
  48147. * Instantiates a new layer.
  48148. * This represents a full screen 2d layer.
  48149. * This can be useful to display a picture in the background of your scene for instance.
  48150. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48151. * @param name Define the name of the layer in the scene
  48152. * @param imgUrl Define the url of the texture to display in the layer
  48153. * @param scene Define the scene the layer belongs to
  48154. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48155. * @param color Defines a color for the layer
  48156. */
  48157. constructor(
  48158. /**
  48159. * Define the name of the layer.
  48160. */
  48161. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48162. private _createIndexBuffer;
  48163. /** @hidden */ private _rebuild(): void;
  48164. /**
  48165. * Renders the layer in the scene.
  48166. */
  48167. render(): void;
  48168. /**
  48169. * Disposes and releases the associated ressources.
  48170. */
  48171. dispose(): void;
  48172. }
  48173. }
  48174. declare module BABYLON {
  48175. /** @hidden */
  48176. export var lensFlarePixelShader: {
  48177. name: string;
  48178. shader: string;
  48179. };
  48180. }
  48181. declare module BABYLON {
  48182. /** @hidden */
  48183. export var lensFlareVertexShader: {
  48184. name: string;
  48185. shader: string;
  48186. };
  48187. }
  48188. declare module BABYLON {
  48189. /**
  48190. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48191. * It is usually composed of several `lensFlare`.
  48192. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48193. */
  48194. export class LensFlareSystem {
  48195. /**
  48196. * Define the name of the lens flare system
  48197. */
  48198. name: string;
  48199. /**
  48200. * List of lens flares used in this system.
  48201. */
  48202. lensFlares: LensFlare[];
  48203. /**
  48204. * Define a limit from the border the lens flare can be visible.
  48205. */
  48206. borderLimit: number;
  48207. /**
  48208. * Define a viewport border we do not want to see the lens flare in.
  48209. */
  48210. viewportBorder: number;
  48211. /**
  48212. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48213. */
  48214. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48215. /**
  48216. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48217. */
  48218. layerMask: number;
  48219. /**
  48220. * Define the id of the lens flare system in the scene.
  48221. * (equal to name by default)
  48222. */
  48223. id: string;
  48224. private _scene;
  48225. private _emitter;
  48226. private _vertexBuffers;
  48227. private _indexBuffer;
  48228. private _effect;
  48229. private _positionX;
  48230. private _positionY;
  48231. private _isEnabled;
  48232. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48233. /**
  48234. * Instantiates a lens flare system.
  48235. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48236. * It is usually composed of several `lensFlare`.
  48237. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48238. * @param name Define the name of the lens flare system in the scene
  48239. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48240. * @param scene Define the scene the lens flare system belongs to
  48241. */
  48242. constructor(
  48243. /**
  48244. * Define the name of the lens flare system
  48245. */
  48246. name: string, emitter: any, scene: Scene);
  48247. /**
  48248. * Define if the lens flare system is enabled.
  48249. */
  48250. isEnabled: boolean;
  48251. /**
  48252. * Get the scene the effects belongs to.
  48253. * @returns the scene holding the lens flare system
  48254. */
  48255. getScene(): Scene;
  48256. /**
  48257. * Get the emitter of the lens flare system.
  48258. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48259. * @returns the emitter of the lens flare system
  48260. */
  48261. getEmitter(): any;
  48262. /**
  48263. * Set the emitter of the lens flare system.
  48264. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48265. * @param newEmitter Define the new emitter of the system
  48266. */
  48267. setEmitter(newEmitter: any): void;
  48268. /**
  48269. * Get the lens flare system emitter position.
  48270. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48271. * @returns the position
  48272. */
  48273. getEmitterPosition(): Vector3;
  48274. /**
  48275. * @hidden
  48276. */
  48277. computeEffectivePosition(globalViewport: Viewport): boolean;
  48278. /** @hidden */ private _isVisible(): boolean;
  48279. /**
  48280. * @hidden
  48281. */
  48282. render(): boolean;
  48283. /**
  48284. * Dispose and release the lens flare with its associated resources.
  48285. */
  48286. dispose(): void;
  48287. /**
  48288. * Parse a lens flare system from a JSON repressentation
  48289. * @param parsedLensFlareSystem Define the JSON to parse
  48290. * @param scene Define the scene the parsed system should be instantiated in
  48291. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48292. * @returns the parsed system
  48293. */
  48294. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48295. /**
  48296. * Serialize the current Lens Flare System into a JSON representation.
  48297. * @returns the serialized JSON
  48298. */
  48299. serialize(): any;
  48300. }
  48301. }
  48302. declare module BABYLON {
  48303. /**
  48304. * This represents one of the lens effect in a `lensFlareSystem`.
  48305. * It controls one of the indiviual texture used in the effect.
  48306. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48307. */
  48308. export class LensFlare {
  48309. /**
  48310. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48311. */
  48312. size: number;
  48313. /**
  48314. * 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.
  48315. */
  48316. position: number;
  48317. /**
  48318. * Define the lens color.
  48319. */
  48320. color: Color3;
  48321. /**
  48322. * Define the lens texture.
  48323. */
  48324. texture: Nullable<Texture>;
  48325. /**
  48326. * Define the alpha mode to render this particular lens.
  48327. */
  48328. alphaMode: number;
  48329. private _system;
  48330. /**
  48331. * Creates a new Lens Flare.
  48332. * This represents one of the lens effect in a `lensFlareSystem`.
  48333. * It controls one of the indiviual texture used in the effect.
  48334. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48335. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48336. * @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.
  48337. * @param color Define the lens color
  48338. * @param imgUrl Define the lens texture url
  48339. * @param system Define the `lensFlareSystem` this flare is part of
  48340. * @returns The newly created Lens Flare
  48341. */
  48342. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48343. /**
  48344. * Instantiates a new Lens Flare.
  48345. * This represents one of the lens effect in a `lensFlareSystem`.
  48346. * It controls one of the indiviual texture used in the effect.
  48347. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48348. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48349. * @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.
  48350. * @param color Define the lens color
  48351. * @param imgUrl Define the lens texture url
  48352. * @param system Define the `lensFlareSystem` this flare is part of
  48353. */
  48354. constructor(
  48355. /**
  48356. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48357. */
  48358. size: number,
  48359. /**
  48360. * 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.
  48361. */
  48362. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48363. /**
  48364. * Dispose and release the lens flare with its associated resources.
  48365. */
  48366. dispose(): void;
  48367. }
  48368. }
  48369. declare module BABYLON {
  48370. interface AbstractScene {
  48371. /**
  48372. * The list of lens flare system added to the scene
  48373. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48374. */
  48375. lensFlareSystems: Array<LensFlareSystem>;
  48376. /**
  48377. * Removes the given lens flare system from this scene.
  48378. * @param toRemove The lens flare system to remove
  48379. * @returns The index of the removed lens flare system
  48380. */
  48381. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48382. /**
  48383. * Adds the given lens flare system to this scene
  48384. * @param newLensFlareSystem The lens flare system to add
  48385. */
  48386. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48387. /**
  48388. * Gets a lens flare system using its name
  48389. * @param name defines the name to look for
  48390. * @returns the lens flare system or null if not found
  48391. */
  48392. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48393. /**
  48394. * Gets a lens flare system using its id
  48395. * @param id defines the id to look for
  48396. * @returns the lens flare system or null if not found
  48397. */
  48398. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48399. }
  48400. /**
  48401. * Defines the lens flare scene component responsible to manage any lens flares
  48402. * in a given scene.
  48403. */
  48404. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48405. /**
  48406. * The component name helpfull to identify the component in the list of scene components.
  48407. */
  48408. readonly name: string;
  48409. /**
  48410. * The scene the component belongs to.
  48411. */
  48412. scene: Scene;
  48413. /**
  48414. * Creates a new instance of the component for the given scene
  48415. * @param scene Defines the scene to register the component in
  48416. */
  48417. constructor(scene: Scene);
  48418. /**
  48419. * Registers the component in a given scene
  48420. */
  48421. register(): void;
  48422. /**
  48423. * Rebuilds the elements related to this component in case of
  48424. * context lost for instance.
  48425. */
  48426. rebuild(): void;
  48427. /**
  48428. * Adds all the elements from the container to the scene
  48429. * @param container the container holding the elements
  48430. */
  48431. addFromContainer(container: AbstractScene): void;
  48432. /**
  48433. * Removes all the elements in the container from the scene
  48434. * @param container contains the elements to remove
  48435. * @param dispose if the removed element should be disposed (default: false)
  48436. */
  48437. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48438. /**
  48439. * Serializes the component data to the specified json object
  48440. * @param serializationObject The object to serialize to
  48441. */
  48442. serialize(serializationObject: any): void;
  48443. /**
  48444. * Disposes the component and the associated ressources.
  48445. */
  48446. dispose(): void;
  48447. private _draw;
  48448. }
  48449. }
  48450. declare module BABYLON {
  48451. /**
  48452. * Defines the shadow generator component responsible to manage any shadow generators
  48453. * in a given scene.
  48454. */
  48455. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48456. /**
  48457. * The component name helpfull to identify the component in the list of scene components.
  48458. */
  48459. readonly name: string;
  48460. /**
  48461. * The scene the component belongs to.
  48462. */
  48463. scene: Scene;
  48464. /**
  48465. * Creates a new instance of the component for the given scene
  48466. * @param scene Defines the scene to register the component in
  48467. */
  48468. constructor(scene: Scene);
  48469. /**
  48470. * Registers the component in a given scene
  48471. */
  48472. register(): void;
  48473. /**
  48474. * Rebuilds the elements related to this component in case of
  48475. * context lost for instance.
  48476. */
  48477. rebuild(): void;
  48478. /**
  48479. * Serializes the component data to the specified json object
  48480. * @param serializationObject The object to serialize to
  48481. */
  48482. serialize(serializationObject: any): void;
  48483. /**
  48484. * Adds all the elements from the container to the scene
  48485. * @param container the container holding the elements
  48486. */
  48487. addFromContainer(container: AbstractScene): void;
  48488. /**
  48489. * Removes all the elements in the container from the scene
  48490. * @param container contains the elements to remove
  48491. * @param dispose if the removed element should be disposed (default: false)
  48492. */
  48493. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48494. /**
  48495. * Rebuilds the elements related to this component in case of
  48496. * context lost for instance.
  48497. */
  48498. dispose(): void;
  48499. private _gatherRenderTargets;
  48500. }
  48501. }
  48502. declare module BABYLON {
  48503. /**
  48504. * A point light is a light defined by an unique point in world space.
  48505. * The light is emitted in every direction from this point.
  48506. * A good example of a point light is a standard light bulb.
  48507. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48508. */
  48509. export class PointLight extends ShadowLight {
  48510. private _shadowAngle;
  48511. /**
  48512. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48513. * This specifies what angle the shadow will use to be created.
  48514. *
  48515. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48516. */
  48517. /**
  48518. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48519. * This specifies what angle the shadow will use to be created.
  48520. *
  48521. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48522. */
  48523. shadowAngle: number;
  48524. /**
  48525. * Gets the direction if it has been set.
  48526. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48527. */
  48528. /**
  48529. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48530. */
  48531. direction: Vector3;
  48532. /**
  48533. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48534. * A PointLight emits the light in every direction.
  48535. * It can cast shadows.
  48536. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48537. * ```javascript
  48538. * var pointLight = new PointLight("pl", camera.position, scene);
  48539. * ```
  48540. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48541. * @param name The light friendly name
  48542. * @param position The position of the point light in the scene
  48543. * @param scene The scene the lights belongs to
  48544. */
  48545. constructor(name: string, position: Vector3, scene: Scene);
  48546. /**
  48547. * Returns the string "PointLight"
  48548. * @returns the class name
  48549. */
  48550. getClassName(): string;
  48551. /**
  48552. * Returns the integer 0.
  48553. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48554. */
  48555. getTypeID(): number;
  48556. /**
  48557. * Specifies wether or not the shadowmap should be a cube texture.
  48558. * @returns true if the shadowmap needs to be a cube texture.
  48559. */
  48560. needCube(): boolean;
  48561. /**
  48562. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48563. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48564. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48565. */
  48566. getShadowDirection(faceIndex?: number): Vector3;
  48567. /**
  48568. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48569. * - fov = PI / 2
  48570. * - aspect ratio : 1.0
  48571. * - z-near and far equal to the active camera minZ and maxZ.
  48572. * Returns the PointLight.
  48573. */
  48574. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48575. protected _buildUniformLayout(): void;
  48576. /**
  48577. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48578. * @param effect The effect to update
  48579. * @param lightIndex The index of the light in the effect to update
  48580. * @returns The point light
  48581. */
  48582. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48583. /**
  48584. * Prepares the list of defines specific to the light type.
  48585. * @param defines the list of defines
  48586. * @param lightIndex defines the index of the light for the effect
  48587. */
  48588. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48589. }
  48590. }
  48591. declare module BABYLON {
  48592. /**
  48593. * Header information of HDR texture files.
  48594. */
  48595. export interface HDRInfo {
  48596. /**
  48597. * The height of the texture in pixels.
  48598. */
  48599. height: number;
  48600. /**
  48601. * The width of the texture in pixels.
  48602. */
  48603. width: number;
  48604. /**
  48605. * The index of the beginning of the data in the binary file.
  48606. */
  48607. dataPosition: number;
  48608. }
  48609. /**
  48610. * This groups tools to convert HDR texture to native colors array.
  48611. */
  48612. export class HDRTools {
  48613. private static Ldexp;
  48614. private static Rgbe2float;
  48615. private static readStringLine;
  48616. /**
  48617. * Reads header information from an RGBE texture stored in a native array.
  48618. * More information on this format are available here:
  48619. * https://en.wikipedia.org/wiki/RGBE_image_format
  48620. *
  48621. * @param uint8array The binary file stored in native array.
  48622. * @return The header information.
  48623. */
  48624. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48625. /**
  48626. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48627. * This RGBE texture needs to store the information as a panorama.
  48628. *
  48629. * More information on this format are available here:
  48630. * https://en.wikipedia.org/wiki/RGBE_image_format
  48631. *
  48632. * @param buffer The binary file stored in an array buffer.
  48633. * @param size The expected size of the extracted cubemap.
  48634. * @return The Cube Map information.
  48635. */
  48636. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48637. /**
  48638. * Returns the pixels data extracted from an RGBE texture.
  48639. * This pixels will be stored left to right up to down in the R G B order in one array.
  48640. *
  48641. * More information on this format are available here:
  48642. * https://en.wikipedia.org/wiki/RGBE_image_format
  48643. *
  48644. * @param uint8array The binary file stored in an array buffer.
  48645. * @param hdrInfo The header information of the file.
  48646. * @return The pixels data in RGB right to left up to down order.
  48647. */
  48648. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48649. private static RGBE_ReadPixels_RLE;
  48650. }
  48651. }
  48652. declare module BABYLON {
  48653. /**
  48654. * This represents a texture coming from an HDR input.
  48655. *
  48656. * The only supported format is currently panorama picture stored in RGBE format.
  48657. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48658. */
  48659. export class HDRCubeTexture extends BaseTexture {
  48660. private static _facesMapping;
  48661. private _generateHarmonics;
  48662. private _noMipmap;
  48663. private _textureMatrix;
  48664. private _size;
  48665. private _onLoad;
  48666. private _onError;
  48667. /**
  48668. * The texture URL.
  48669. */
  48670. url: string;
  48671. /**
  48672. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48673. */
  48674. coordinatesMode: number;
  48675. protected _isBlocking: boolean;
  48676. /**
  48677. * Sets wether or not the texture is blocking during loading.
  48678. */
  48679. /**
  48680. * Gets wether or not the texture is blocking during loading.
  48681. */
  48682. isBlocking: boolean;
  48683. protected _rotationY: number;
  48684. /**
  48685. * Sets texture matrix rotation angle around Y axis in radians.
  48686. */
  48687. /**
  48688. * Gets texture matrix rotation angle around Y axis radians.
  48689. */
  48690. rotationY: number;
  48691. /**
  48692. * Gets or sets the center of the bounding box associated with the cube texture
  48693. * It must define where the camera used to render the texture was set
  48694. */
  48695. boundingBoxPosition: Vector3;
  48696. private _boundingBoxSize;
  48697. /**
  48698. * Gets or sets the size of the bounding box associated with the cube texture
  48699. * When defined, the cubemap will switch to local mode
  48700. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48701. * @example https://www.babylonjs-playground.com/#RNASML
  48702. */
  48703. boundingBoxSize: Vector3;
  48704. /**
  48705. * Instantiates an HDRTexture from the following parameters.
  48706. *
  48707. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48708. * @param scene The scene the texture will be used in
  48709. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48710. * @param noMipmap Forces to not generate the mipmap if true
  48711. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48712. * @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)
  48713. * @param reserved Reserved flag for internal use.
  48714. */
  48715. 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>);
  48716. /**
  48717. * Get the current class name of the texture useful for serialization or dynamic coding.
  48718. * @returns "HDRCubeTexture"
  48719. */
  48720. getClassName(): string;
  48721. /**
  48722. * Occurs when the file is raw .hdr file.
  48723. */
  48724. private loadTexture;
  48725. clone(): HDRCubeTexture;
  48726. delayLoad(): void;
  48727. /**
  48728. * Get the texture reflection matrix used to rotate/transform the reflection.
  48729. * @returns the reflection matrix
  48730. */
  48731. getReflectionTextureMatrix(): Matrix;
  48732. /**
  48733. * Set the texture reflection matrix used to rotate/transform the reflection.
  48734. * @param value Define the reflection matrix to set
  48735. */
  48736. setReflectionTextureMatrix(value: Matrix): void;
  48737. /**
  48738. * Parses a JSON representation of an HDR Texture in order to create the texture
  48739. * @param parsedTexture Define the JSON representation
  48740. * @param scene Define the scene the texture should be created in
  48741. * @param rootUrl Define the root url in case we need to load relative dependencies
  48742. * @returns the newly created texture after parsing
  48743. */
  48744. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48745. serialize(): any;
  48746. }
  48747. }
  48748. declare module BABYLON {
  48749. /**
  48750. * Class used to control physics engine
  48751. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48752. */
  48753. export class PhysicsEngine implements IPhysicsEngine {
  48754. private _physicsPlugin;
  48755. /**
  48756. * Global value used to control the smallest number supported by the simulation
  48757. */
  48758. static Epsilon: number;
  48759. private _impostors;
  48760. private _joints;
  48761. /**
  48762. * Gets the gravity vector used by the simulation
  48763. */
  48764. gravity: Vector3;
  48765. /**
  48766. * Factory used to create the default physics plugin.
  48767. * @returns The default physics plugin
  48768. */
  48769. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48770. /**
  48771. * Creates a new Physics Engine
  48772. * @param gravity defines the gravity vector used by the simulation
  48773. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48774. */
  48775. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48776. /**
  48777. * Sets the gravity vector used by the simulation
  48778. * @param gravity defines the gravity vector to use
  48779. */
  48780. setGravity(gravity: Vector3): void;
  48781. /**
  48782. * Set the time step of the physics engine.
  48783. * Default is 1/60.
  48784. * To slow it down, enter 1/600 for example.
  48785. * To speed it up, 1/30
  48786. * @param newTimeStep defines the new timestep to apply to this world.
  48787. */
  48788. setTimeStep(newTimeStep?: number): void;
  48789. /**
  48790. * Get the time step of the physics engine.
  48791. * @returns the current time step
  48792. */
  48793. getTimeStep(): number;
  48794. /**
  48795. * Release all resources
  48796. */
  48797. dispose(): void;
  48798. /**
  48799. * Gets the name of the current physics plugin
  48800. * @returns the name of the plugin
  48801. */
  48802. getPhysicsPluginName(): string;
  48803. /**
  48804. * Adding a new impostor for the impostor tracking.
  48805. * This will be done by the impostor itself.
  48806. * @param impostor the impostor to add
  48807. */
  48808. addImpostor(impostor: PhysicsImpostor): void;
  48809. /**
  48810. * Remove an impostor from the engine.
  48811. * This impostor and its mesh will not longer be updated by the physics engine.
  48812. * @param impostor the impostor to remove
  48813. */
  48814. removeImpostor(impostor: PhysicsImpostor): void;
  48815. /**
  48816. * Add a joint to the physics engine
  48817. * @param mainImpostor defines the main impostor to which the joint is added.
  48818. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48819. * @param joint defines the joint that will connect both impostors.
  48820. */
  48821. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48822. /**
  48823. * Removes a joint from the simulation
  48824. * @param mainImpostor defines the impostor used with the joint
  48825. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48826. * @param joint defines the joint to remove
  48827. */
  48828. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48829. /**
  48830. * Called by the scene. No need to call it.
  48831. * @param delta defines the timespam between frames
  48832. */ private _step(delta: number): void;
  48833. /**
  48834. * Gets the current plugin used to run the simulation
  48835. * @returns current plugin
  48836. */
  48837. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48838. /**
  48839. * Gets the list of physic impostors
  48840. * @returns an array of PhysicsImpostor
  48841. */
  48842. getImpostors(): Array<PhysicsImpostor>;
  48843. /**
  48844. * Gets the impostor for a physics enabled object
  48845. * @param object defines the object impersonated by the impostor
  48846. * @returns the PhysicsImpostor or null if not found
  48847. */
  48848. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48849. /**
  48850. * Gets the impostor for a physics body object
  48851. * @param body defines physics body used by the impostor
  48852. * @returns the PhysicsImpostor or null if not found
  48853. */
  48854. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48855. /**
  48856. * Does a raycast in the physics world
  48857. * @param from when should the ray start?
  48858. * @param to when should the ray end?
  48859. * @returns PhysicsRaycastResult
  48860. */
  48861. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48862. }
  48863. }
  48864. declare module BABYLON {
  48865. /** @hidden */
  48866. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48867. private _useDeltaForWorldStep;
  48868. world: any;
  48869. name: string;
  48870. private _physicsMaterials;
  48871. private _fixedTimeStep;
  48872. private _cannonRaycastResult;
  48873. private _raycastResult;
  48874. private _physicsBodysToRemoveAfterStep;
  48875. BJSCANNON: any;
  48876. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48877. setGravity(gravity: Vector3): void;
  48878. setTimeStep(timeStep: number): void;
  48879. getTimeStep(): number;
  48880. executeStep(delta: number): void;
  48881. private _removeMarkedPhysicsBodiesFromWorld;
  48882. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48883. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48884. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48885. private _processChildMeshes;
  48886. removePhysicsBody(impostor: PhysicsImpostor): void;
  48887. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48888. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48889. private _addMaterial;
  48890. private _checkWithEpsilon;
  48891. private _createShape;
  48892. private _createHeightmap;
  48893. private _minus90X;
  48894. private _plus90X;
  48895. private _tmpPosition;
  48896. private _tmpDeltaPosition;
  48897. private _tmpUnityRotation;
  48898. private _updatePhysicsBodyTransformation;
  48899. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48900. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48901. isSupported(): boolean;
  48902. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48903. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48904. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48905. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48906. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48907. getBodyMass(impostor: PhysicsImpostor): number;
  48908. getBodyFriction(impostor: PhysicsImpostor): number;
  48909. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48910. getBodyRestitution(impostor: PhysicsImpostor): number;
  48911. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48912. sleepBody(impostor: PhysicsImpostor): void;
  48913. wakeUpBody(impostor: PhysicsImpostor): void;
  48914. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48915. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48918. getRadius(impostor: PhysicsImpostor): number;
  48919. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48920. dispose(): void;
  48921. private _extendNamespace;
  48922. /**
  48923. * Does a raycast in the physics world
  48924. * @param from when should the ray start?
  48925. * @param to when should the ray end?
  48926. * @returns PhysicsRaycastResult
  48927. */
  48928. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48929. }
  48930. }
  48931. declare module BABYLON {
  48932. /** @hidden */
  48933. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48934. world: any;
  48935. name: string;
  48936. BJSOIMO: any;
  48937. private _raycastResult;
  48938. constructor(iterations?: number, oimoInjection?: any);
  48939. setGravity(gravity: Vector3): void;
  48940. setTimeStep(timeStep: number): void;
  48941. getTimeStep(): number;
  48942. private _tmpImpostorsArray;
  48943. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48944. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48945. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48946. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48947. private _tmpPositionVector;
  48948. removePhysicsBody(impostor: PhysicsImpostor): void;
  48949. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48950. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48951. isSupported(): boolean;
  48952. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48953. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48954. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48955. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48956. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48957. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48958. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48959. getBodyMass(impostor: PhysicsImpostor): number;
  48960. getBodyFriction(impostor: PhysicsImpostor): number;
  48961. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48962. getBodyRestitution(impostor: PhysicsImpostor): number;
  48963. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48964. sleepBody(impostor: PhysicsImpostor): void;
  48965. wakeUpBody(impostor: PhysicsImpostor): void;
  48966. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48967. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48968. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48969. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48970. getRadius(impostor: PhysicsImpostor): number;
  48971. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48972. dispose(): void;
  48973. /**
  48974. * Does a raycast in the physics world
  48975. * @param from when should the ray start?
  48976. * @param to when should the ray end?
  48977. * @returns PhysicsRaycastResult
  48978. */
  48979. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48980. }
  48981. }
  48982. declare module BABYLON {
  48983. /**
  48984. * Class containing static functions to help procedurally build meshes
  48985. */
  48986. export class RibbonBuilder {
  48987. /**
  48988. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48989. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48990. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48991. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48992. * * 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
  48993. * * 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
  48994. * * 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
  48995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48996. * * 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
  48997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48998. * * 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
  48999. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49000. * * 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
  49001. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49003. * @param name defines the name of the mesh
  49004. * @param options defines the options used to create the mesh
  49005. * @param scene defines the hosting scene
  49006. * @returns the ribbon mesh
  49007. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49009. */
  49010. static CreateRibbon(name: string, options: {
  49011. pathArray: Vector3[][];
  49012. closeArray?: boolean;
  49013. closePath?: boolean;
  49014. offset?: number;
  49015. updatable?: boolean;
  49016. sideOrientation?: number;
  49017. frontUVs?: Vector4;
  49018. backUVs?: Vector4;
  49019. instance?: Mesh;
  49020. invertUV?: boolean;
  49021. uvs?: Vector2[];
  49022. colors?: Color4[];
  49023. }, scene?: Nullable<Scene>): Mesh;
  49024. }
  49025. }
  49026. declare module BABYLON {
  49027. /**
  49028. * Class containing static functions to help procedurally build meshes
  49029. */
  49030. export class ShapeBuilder {
  49031. /**
  49032. * 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.
  49033. * * 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.
  49034. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49035. * * 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.
  49036. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49037. * * 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
  49038. * * 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
  49039. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49041. * * 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
  49042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49044. * @param name defines the name of the mesh
  49045. * @param options defines the options used to create the mesh
  49046. * @param scene defines the hosting scene
  49047. * @returns the extruded shape mesh
  49048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49050. */
  49051. static ExtrudeShape(name: string, options: {
  49052. shape: Vector3[];
  49053. path: Vector3[];
  49054. scale?: number;
  49055. rotation?: number;
  49056. cap?: number;
  49057. updatable?: boolean;
  49058. sideOrientation?: number;
  49059. frontUVs?: Vector4;
  49060. backUVs?: Vector4;
  49061. instance?: Mesh;
  49062. invertUV?: boolean;
  49063. }, scene?: Nullable<Scene>): Mesh;
  49064. /**
  49065. * Creates an custom extruded shape mesh.
  49066. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49067. * * 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.
  49068. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49069. * * 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
  49070. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49071. * * 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
  49072. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49073. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49074. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49075. * * 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
  49076. * * 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
  49077. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49079. * * 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
  49080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49082. * @param name defines the name of the mesh
  49083. * @param options defines the options used to create the mesh
  49084. * @param scene defines the hosting scene
  49085. * @returns the custom extruded shape mesh
  49086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49089. */
  49090. static ExtrudeShapeCustom(name: string, options: {
  49091. shape: Vector3[];
  49092. path: Vector3[];
  49093. scaleFunction?: any;
  49094. rotationFunction?: any;
  49095. ribbonCloseArray?: boolean;
  49096. ribbonClosePath?: boolean;
  49097. cap?: number;
  49098. updatable?: boolean;
  49099. sideOrientation?: number;
  49100. frontUVs?: Vector4;
  49101. backUVs?: Vector4;
  49102. instance?: Mesh;
  49103. invertUV?: boolean;
  49104. }, scene?: Nullable<Scene>): Mesh;
  49105. private static _ExtrudeShapeGeneric;
  49106. }
  49107. }
  49108. declare module BABYLON {
  49109. /**
  49110. * AmmoJS Physics plugin
  49111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49112. * @see https://github.com/kripken/ammo.js/
  49113. */
  49114. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49115. private _useDeltaForWorldStep;
  49116. /**
  49117. * Reference to the Ammo library
  49118. */
  49119. bjsAMMO: any;
  49120. /**
  49121. * Created ammoJS world which physics bodies are added to
  49122. */
  49123. world: any;
  49124. /**
  49125. * Name of the plugin
  49126. */
  49127. name: string;
  49128. private _timeStep;
  49129. private _fixedTimeStep;
  49130. private _maxSteps;
  49131. private _tmpQuaternion;
  49132. private _tmpAmmoTransform;
  49133. private _tmpAmmoQuaternion;
  49134. private _tmpAmmoConcreteContactResultCallback;
  49135. private _collisionConfiguration;
  49136. private _dispatcher;
  49137. private _overlappingPairCache;
  49138. private _solver;
  49139. private _softBodySolver;
  49140. private _tmpAmmoVectorA;
  49141. private _tmpAmmoVectorB;
  49142. private _tmpAmmoVectorC;
  49143. private _tmpAmmoVectorD;
  49144. private _tmpContactCallbackResult;
  49145. private _tmpAmmoVectorRCA;
  49146. private _tmpAmmoVectorRCB;
  49147. private _raycastResult;
  49148. private static readonly DISABLE_COLLISION_FLAG;
  49149. private static readonly KINEMATIC_FLAG;
  49150. private static readonly DISABLE_DEACTIVATION_FLAG;
  49151. /**
  49152. * Initializes the ammoJS plugin
  49153. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49154. * @param ammoInjection can be used to inject your own ammo reference
  49155. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49156. */
  49157. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49158. /**
  49159. * Sets the gravity of the physics world (m/(s^2))
  49160. * @param gravity Gravity to set
  49161. */
  49162. setGravity(gravity: Vector3): void;
  49163. /**
  49164. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49165. * @param timeStep timestep to use in seconds
  49166. */
  49167. setTimeStep(timeStep: number): void;
  49168. /**
  49169. * 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)
  49170. * @param fixedTimeStep fixedTimeStep to use in seconds
  49171. */
  49172. setFixedTimeStep(fixedTimeStep: number): void;
  49173. /**
  49174. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49175. * @param maxSteps the maximum number of steps by the physics engine per frame
  49176. */
  49177. setMaxSteps(maxSteps: number): void;
  49178. /**
  49179. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49180. * @returns the current timestep in seconds
  49181. */
  49182. getTimeStep(): number;
  49183. private _isImpostorInContact;
  49184. private _isImpostorPairInContact;
  49185. private _stepSimulation;
  49186. /**
  49187. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49188. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49189. * After the step the babylon meshes are set to the position of the physics imposters
  49190. * @param delta amount of time to step forward
  49191. * @param impostors array of imposters to update before/after the step
  49192. */
  49193. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49194. /**
  49195. * Update babylon mesh to match physics world object
  49196. * @param impostor imposter to match
  49197. */
  49198. private _afterSoftStep;
  49199. /**
  49200. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49201. * @param impostor imposter to match
  49202. */
  49203. private _ropeStep;
  49204. /**
  49205. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49206. * @param impostor imposter to match
  49207. */
  49208. private _softbodyOrClothStep;
  49209. private _tmpVector;
  49210. private _tmpMatrix;
  49211. /**
  49212. * Applies an impulse on the imposter
  49213. * @param impostor imposter to apply impulse to
  49214. * @param force amount of force to be applied to the imposter
  49215. * @param contactPoint the location to apply the impulse on the imposter
  49216. */
  49217. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49218. /**
  49219. * Applies a force on the imposter
  49220. * @param impostor imposter to apply force
  49221. * @param force amount of force to be applied to the imposter
  49222. * @param contactPoint the location to apply the force on the imposter
  49223. */
  49224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49225. /**
  49226. * Creates a physics body using the plugin
  49227. * @param impostor the imposter to create the physics body on
  49228. */
  49229. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49230. /**
  49231. * Removes the physics body from the imposter and disposes of the body's memory
  49232. * @param impostor imposter to remove the physics body from
  49233. */
  49234. removePhysicsBody(impostor: PhysicsImpostor): void;
  49235. /**
  49236. * Generates a joint
  49237. * @param impostorJoint the imposter joint to create the joint with
  49238. */
  49239. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49240. /**
  49241. * Removes a joint
  49242. * @param impostorJoint the imposter joint to remove the joint from
  49243. */
  49244. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49245. private _addMeshVerts;
  49246. /**
  49247. * Initialise the soft body vertices to match its object's (mesh) vertices
  49248. * Softbody vertices (nodes) are in world space and to match this
  49249. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49250. * @param impostor to create the softbody for
  49251. */
  49252. private _softVertexData;
  49253. /**
  49254. * Create an impostor's soft body
  49255. * @param impostor to create the softbody for
  49256. */
  49257. private _createSoftbody;
  49258. /**
  49259. * Create cloth for an impostor
  49260. * @param impostor to create the softbody for
  49261. */
  49262. private _createCloth;
  49263. /**
  49264. * Create rope for an impostor
  49265. * @param impostor to create the softbody for
  49266. */
  49267. private _createRope;
  49268. private _addHullVerts;
  49269. private _createShape;
  49270. /**
  49271. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49272. * @param impostor imposter containing the physics body and babylon object
  49273. */
  49274. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49275. /**
  49276. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49277. * @param impostor imposter containing the physics body and babylon object
  49278. * @param newPosition new position
  49279. * @param newRotation new rotation
  49280. */
  49281. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49282. /**
  49283. * If this plugin is supported
  49284. * @returns true if its supported
  49285. */
  49286. isSupported(): boolean;
  49287. /**
  49288. * Sets the linear velocity of the physics body
  49289. * @param impostor imposter to set the velocity on
  49290. * @param velocity velocity to set
  49291. */
  49292. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49293. /**
  49294. * Sets the angular velocity of the physics body
  49295. * @param impostor imposter to set the velocity on
  49296. * @param velocity velocity to set
  49297. */
  49298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49299. /**
  49300. * gets the linear velocity
  49301. * @param impostor imposter to get linear velocity from
  49302. * @returns linear velocity
  49303. */
  49304. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49305. /**
  49306. * gets the angular velocity
  49307. * @param impostor imposter to get angular velocity from
  49308. * @returns angular velocity
  49309. */
  49310. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49311. /**
  49312. * Sets the mass of physics body
  49313. * @param impostor imposter to set the mass on
  49314. * @param mass mass to set
  49315. */
  49316. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49317. /**
  49318. * Gets the mass of the physics body
  49319. * @param impostor imposter to get the mass from
  49320. * @returns mass
  49321. */
  49322. getBodyMass(impostor: PhysicsImpostor): number;
  49323. /**
  49324. * Gets friction of the impostor
  49325. * @param impostor impostor to get friction from
  49326. * @returns friction value
  49327. */
  49328. getBodyFriction(impostor: PhysicsImpostor): number;
  49329. /**
  49330. * Sets friction of the impostor
  49331. * @param impostor impostor to set friction on
  49332. * @param friction friction value
  49333. */
  49334. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49335. /**
  49336. * Gets restitution of the impostor
  49337. * @param impostor impostor to get restitution from
  49338. * @returns restitution value
  49339. */
  49340. getBodyRestitution(impostor: PhysicsImpostor): number;
  49341. /**
  49342. * Sets resitution of the impostor
  49343. * @param impostor impostor to set resitution on
  49344. * @param restitution resitution value
  49345. */
  49346. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49347. /**
  49348. * Gets pressure inside the impostor
  49349. * @param impostor impostor to get pressure from
  49350. * @returns pressure value
  49351. */
  49352. getBodyPressure(impostor: PhysicsImpostor): number;
  49353. /**
  49354. * Sets pressure inside a soft body impostor
  49355. * Cloth and rope must remain 0 pressure
  49356. * @param impostor impostor to set pressure on
  49357. * @param pressure pressure value
  49358. */
  49359. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49360. /**
  49361. * Gets stiffness of the impostor
  49362. * @param impostor impostor to get stiffness from
  49363. * @returns pressure value
  49364. */
  49365. getBodyStiffness(impostor: PhysicsImpostor): number;
  49366. /**
  49367. * Sets stiffness of the impostor
  49368. * @param impostor impostor to set stiffness on
  49369. * @param stiffness stiffness value from 0 to 1
  49370. */
  49371. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49372. /**
  49373. * Gets velocityIterations of the impostor
  49374. * @param impostor impostor to get velocity iterations from
  49375. * @returns velocityIterations value
  49376. */
  49377. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49378. /**
  49379. * Sets velocityIterations of the impostor
  49380. * @param impostor impostor to set velocity iterations on
  49381. * @param velocityIterations velocityIterations value
  49382. */
  49383. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49384. /**
  49385. * Gets positionIterations of the impostor
  49386. * @param impostor impostor to get position iterations from
  49387. * @returns positionIterations value
  49388. */
  49389. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49390. /**
  49391. * Sets positionIterations of the impostor
  49392. * @param impostor impostor to set position on
  49393. * @param positionIterations positionIterations value
  49394. */
  49395. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49396. /**
  49397. * Append an anchor to a cloth object
  49398. * @param impostor is the cloth impostor to add anchor to
  49399. * @param otherImpostor is the rigid impostor to anchor to
  49400. * @param width ratio across width from 0 to 1
  49401. * @param height ratio up height from 0 to 1
  49402. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49403. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49404. */
  49405. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49406. /**
  49407. * Append an hook to a rope object
  49408. * @param impostor is the rope impostor to add hook to
  49409. * @param otherImpostor is the rigid impostor to hook to
  49410. * @param length ratio along the rope from 0 to 1
  49411. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49412. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49413. */
  49414. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49415. /**
  49416. * Sleeps the physics body and stops it from being active
  49417. * @param impostor impostor to sleep
  49418. */
  49419. sleepBody(impostor: PhysicsImpostor): void;
  49420. /**
  49421. * Activates the physics body
  49422. * @param impostor impostor to activate
  49423. */
  49424. wakeUpBody(impostor: PhysicsImpostor): void;
  49425. /**
  49426. * Updates the distance parameters of the joint
  49427. * @param joint joint to update
  49428. * @param maxDistance maximum distance of the joint
  49429. * @param minDistance minimum distance of the joint
  49430. */
  49431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49432. /**
  49433. * Sets a motor on the joint
  49434. * @param joint joint to set motor on
  49435. * @param speed speed of the motor
  49436. * @param maxForce maximum force of the motor
  49437. * @param motorIndex index of the motor
  49438. */
  49439. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49440. /**
  49441. * Sets the motors limit
  49442. * @param joint joint to set limit on
  49443. * @param upperLimit upper limit
  49444. * @param lowerLimit lower limit
  49445. */
  49446. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49447. /**
  49448. * Syncs the position and rotation of a mesh with the impostor
  49449. * @param mesh mesh to sync
  49450. * @param impostor impostor to update the mesh with
  49451. */
  49452. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49453. /**
  49454. * Gets the radius of the impostor
  49455. * @param impostor impostor to get radius from
  49456. * @returns the radius
  49457. */
  49458. getRadius(impostor: PhysicsImpostor): number;
  49459. /**
  49460. * Gets the box size of the impostor
  49461. * @param impostor impostor to get box size from
  49462. * @param result the resulting box size
  49463. */
  49464. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49465. /**
  49466. * Disposes of the impostor
  49467. */
  49468. dispose(): void;
  49469. /**
  49470. * Does a raycast in the physics world
  49471. * @param from when should the ray start?
  49472. * @param to when should the ray end?
  49473. * @returns PhysicsRaycastResult
  49474. */
  49475. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49476. }
  49477. }
  49478. declare module BABYLON {
  49479. interface AbstractScene {
  49480. /**
  49481. * The list of reflection probes added to the scene
  49482. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49483. */
  49484. reflectionProbes: Array<ReflectionProbe>;
  49485. /**
  49486. * Removes the given reflection probe from this scene.
  49487. * @param toRemove The reflection probe to remove
  49488. * @returns The index of the removed reflection probe
  49489. */
  49490. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49491. /**
  49492. * Adds the given reflection probe to this scene.
  49493. * @param newReflectionProbe The reflection probe to add
  49494. */
  49495. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49496. }
  49497. /**
  49498. * Class used to generate realtime reflection / refraction cube textures
  49499. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49500. */
  49501. export class ReflectionProbe {
  49502. /** defines the name of the probe */
  49503. name: string;
  49504. private _scene;
  49505. private _renderTargetTexture;
  49506. private _projectionMatrix;
  49507. private _viewMatrix;
  49508. private _target;
  49509. private _add;
  49510. private _attachedMesh;
  49511. private _invertYAxis;
  49512. /** Gets or sets probe position (center of the cube map) */
  49513. position: Vector3;
  49514. /**
  49515. * Creates a new reflection probe
  49516. * @param name defines the name of the probe
  49517. * @param size defines the texture resolution (for each face)
  49518. * @param scene defines the hosting scene
  49519. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49520. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49521. */
  49522. constructor(
  49523. /** defines the name of the probe */
  49524. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49525. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49526. samples: number;
  49527. /** Gets or sets the refresh rate to use (on every frame by default) */
  49528. refreshRate: number;
  49529. /**
  49530. * Gets the hosting scene
  49531. * @returns a Scene
  49532. */
  49533. getScene(): Scene;
  49534. /** Gets the internal CubeTexture used to render to */
  49535. readonly cubeTexture: RenderTargetTexture;
  49536. /** Gets the list of meshes to render */
  49537. readonly renderList: Nullable<AbstractMesh[]>;
  49538. /**
  49539. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49540. * @param mesh defines the mesh to attach to
  49541. */
  49542. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49543. /**
  49544. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49545. * @param renderingGroupId The rendering group id corresponding to its index
  49546. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49547. */
  49548. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49549. /**
  49550. * Clean all associated resources
  49551. */
  49552. dispose(): void;
  49553. /**
  49554. * Converts the reflection probe information to a readable string for debug purpose.
  49555. * @param fullDetails Supports for multiple levels of logging within scene loading
  49556. * @returns the human readable reflection probe info
  49557. */
  49558. toString(fullDetails?: boolean): string;
  49559. /**
  49560. * Get the class name of the relfection probe.
  49561. * @returns "ReflectionProbe"
  49562. */
  49563. getClassName(): string;
  49564. /**
  49565. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49566. * @returns The JSON representation of the texture
  49567. */
  49568. serialize(): any;
  49569. /**
  49570. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49571. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49572. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49573. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49574. * @returns The parsed reflection probe if successful
  49575. */
  49576. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49577. }
  49578. }
  49579. declare module BABYLON {
  49580. /** @hidden */
  49581. export var _BabylonLoaderRegistered: boolean;
  49582. }
  49583. declare module BABYLON {
  49584. /**
  49585. * The Physically based simple base material of BJS.
  49586. *
  49587. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49588. * It is used as the base class for both the specGloss and metalRough conventions.
  49589. */
  49590. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49591. /**
  49592. * Number of Simultaneous lights allowed on the material.
  49593. */
  49594. maxSimultaneousLights: number;
  49595. /**
  49596. * If sets to true, disables all the lights affecting the material.
  49597. */
  49598. disableLighting: boolean;
  49599. /**
  49600. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49601. */
  49602. environmentTexture: BaseTexture;
  49603. /**
  49604. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49605. */
  49606. invertNormalMapX: boolean;
  49607. /**
  49608. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49609. */
  49610. invertNormalMapY: boolean;
  49611. /**
  49612. * Normal map used in the model.
  49613. */
  49614. normalTexture: BaseTexture;
  49615. /**
  49616. * Emissivie color used to self-illuminate the model.
  49617. */
  49618. emissiveColor: Color3;
  49619. /**
  49620. * Emissivie texture used to self-illuminate the model.
  49621. */
  49622. emissiveTexture: BaseTexture;
  49623. /**
  49624. * Occlusion Channel Strenght.
  49625. */
  49626. occlusionStrength: number;
  49627. /**
  49628. * Occlusion Texture of the material (adding extra occlusion effects).
  49629. */
  49630. occlusionTexture: BaseTexture;
  49631. /**
  49632. * Defines the alpha limits in alpha test mode.
  49633. */
  49634. alphaCutOff: number;
  49635. /**
  49636. * Gets the current double sided mode.
  49637. */
  49638. /**
  49639. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49640. */
  49641. doubleSided: boolean;
  49642. /**
  49643. * Stores the pre-calculated light information of a mesh in a texture.
  49644. */
  49645. lightmapTexture: BaseTexture;
  49646. /**
  49647. * If true, the light map contains occlusion information instead of lighting info.
  49648. */
  49649. useLightmapAsShadowmap: boolean;
  49650. /**
  49651. * Instantiates a new PBRMaterial instance.
  49652. *
  49653. * @param name The material name
  49654. * @param scene The scene the material will be use in.
  49655. */
  49656. constructor(name: string, scene: Scene);
  49657. getClassName(): string;
  49658. }
  49659. }
  49660. declare module BABYLON {
  49661. /**
  49662. * The PBR material of BJS following the metal roughness convention.
  49663. *
  49664. * This fits to the PBR convention in the GLTF definition:
  49665. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49666. */
  49667. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49668. /**
  49669. * The base color has two different interpretations depending on the value of metalness.
  49670. * When the material is a metal, the base color is the specific measured reflectance value
  49671. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49672. * of the material.
  49673. */
  49674. baseColor: Color3;
  49675. /**
  49676. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49677. * well as opacity information in the alpha channel.
  49678. */
  49679. baseTexture: BaseTexture;
  49680. /**
  49681. * Specifies the metallic scalar value of the material.
  49682. * Can also be used to scale the metalness values of the metallic texture.
  49683. */
  49684. metallic: number;
  49685. /**
  49686. * Specifies the roughness scalar value of the material.
  49687. * Can also be used to scale the roughness values of the metallic texture.
  49688. */
  49689. roughness: number;
  49690. /**
  49691. * Texture containing both the metallic value in the B channel and the
  49692. * roughness value in the G channel to keep better precision.
  49693. */
  49694. metallicRoughnessTexture: BaseTexture;
  49695. /**
  49696. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49697. *
  49698. * @param name The material name
  49699. * @param scene The scene the material will be use in.
  49700. */
  49701. constructor(name: string, scene: Scene);
  49702. /**
  49703. * Return the currrent class name of the material.
  49704. */
  49705. getClassName(): string;
  49706. /**
  49707. * Makes a duplicate of the current material.
  49708. * @param name - name to use for the new material.
  49709. */
  49710. clone(name: string): PBRMetallicRoughnessMaterial;
  49711. /**
  49712. * Serialize the material to a parsable JSON object.
  49713. */
  49714. serialize(): any;
  49715. /**
  49716. * Parses a JSON object correponding to the serialize function.
  49717. */
  49718. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49719. }
  49720. }
  49721. declare module BABYLON {
  49722. /**
  49723. * The PBR material of BJS following the specular glossiness convention.
  49724. *
  49725. * This fits to the PBR convention in the GLTF definition:
  49726. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49727. */
  49728. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49729. /**
  49730. * Specifies the diffuse color of the material.
  49731. */
  49732. diffuseColor: Color3;
  49733. /**
  49734. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49735. * channel.
  49736. */
  49737. diffuseTexture: BaseTexture;
  49738. /**
  49739. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49740. */
  49741. specularColor: Color3;
  49742. /**
  49743. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49744. */
  49745. glossiness: number;
  49746. /**
  49747. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49748. */
  49749. specularGlossinessTexture: BaseTexture;
  49750. /**
  49751. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49752. *
  49753. * @param name The material name
  49754. * @param scene The scene the material will be use in.
  49755. */
  49756. constructor(name: string, scene: Scene);
  49757. /**
  49758. * Return the currrent class name of the material.
  49759. */
  49760. getClassName(): string;
  49761. /**
  49762. * Makes a duplicate of the current material.
  49763. * @param name - name to use for the new material.
  49764. */
  49765. clone(name: string): PBRSpecularGlossinessMaterial;
  49766. /**
  49767. * Serialize the material to a parsable JSON object.
  49768. */
  49769. serialize(): any;
  49770. /**
  49771. * Parses a JSON object correponding to the serialize function.
  49772. */
  49773. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49774. }
  49775. }
  49776. declare module BABYLON {
  49777. /**
  49778. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49779. * It can help converting any input color in a desired output one. This can then be used to create effects
  49780. * from sepia, black and white to sixties or futuristic rendering...
  49781. *
  49782. * The only supported format is currently 3dl.
  49783. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49784. */
  49785. export class ColorGradingTexture extends BaseTexture {
  49786. /**
  49787. * The current texture matrix. (will always be identity in color grading texture)
  49788. */
  49789. private _textureMatrix;
  49790. /**
  49791. * The texture URL.
  49792. */
  49793. url: string;
  49794. /**
  49795. * Empty line regex stored for GC.
  49796. */
  49797. private static _noneEmptyLineRegex;
  49798. private _engine;
  49799. /**
  49800. * Instantiates a ColorGradingTexture from the following parameters.
  49801. *
  49802. * @param url The location of the color gradind data (currently only supporting 3dl)
  49803. * @param scene The scene the texture will be used in
  49804. */
  49805. constructor(url: string, scene: Scene);
  49806. /**
  49807. * Returns the texture matrix used in most of the material.
  49808. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49809. */
  49810. getTextureMatrix(): Matrix;
  49811. /**
  49812. * Occurs when the file being loaded is a .3dl LUT file.
  49813. */
  49814. private load3dlTexture;
  49815. /**
  49816. * Starts the loading process of the texture.
  49817. */
  49818. private loadTexture;
  49819. /**
  49820. * Clones the color gradind texture.
  49821. */
  49822. clone(): ColorGradingTexture;
  49823. /**
  49824. * Called during delayed load for textures.
  49825. */
  49826. delayLoad(): void;
  49827. /**
  49828. * Parses a color grading texture serialized by Babylon.
  49829. * @param parsedTexture The texture information being parsedTexture
  49830. * @param scene The scene to load the texture in
  49831. * @param rootUrl The root url of the data assets to load
  49832. * @return A color gradind texture
  49833. */
  49834. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49835. /**
  49836. * Serializes the LUT texture to json format.
  49837. */
  49838. serialize(): any;
  49839. }
  49840. }
  49841. declare module BABYLON {
  49842. /**
  49843. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49844. */
  49845. export class EquiRectangularCubeTexture extends BaseTexture {
  49846. /** The six faces of the cube. */
  49847. private static _FacesMapping;
  49848. private _noMipmap;
  49849. private _onLoad;
  49850. private _onError;
  49851. /** The size of the cubemap. */
  49852. private _size;
  49853. /** The buffer of the image. */
  49854. private _buffer;
  49855. /** The width of the input image. */
  49856. private _width;
  49857. /** The height of the input image. */
  49858. private _height;
  49859. /** The URL to the image. */
  49860. url: string;
  49861. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49862. coordinatesMode: number;
  49863. /**
  49864. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49865. * @param url The location of the image
  49866. * @param scene The scene the texture will be used in
  49867. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49868. * @param noMipmap Forces to not generate the mipmap if true
  49869. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49870. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49871. * @param onLoad — defines a callback called when texture is loaded
  49872. * @param onError — defines a callback called if there is an error
  49873. */
  49874. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49875. /**
  49876. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49877. */
  49878. private loadImage;
  49879. /**
  49880. * Convert the image buffer into a cubemap and create a CubeTexture.
  49881. */
  49882. private loadTexture;
  49883. /**
  49884. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49885. * @param buffer The ArrayBuffer that should be converted.
  49886. * @returns The buffer as Float32Array.
  49887. */
  49888. private getFloat32ArrayFromArrayBuffer;
  49889. /**
  49890. * Get the current class name of the texture useful for serialization or dynamic coding.
  49891. * @returns "EquiRectangularCubeTexture"
  49892. */
  49893. getClassName(): string;
  49894. /**
  49895. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49896. * @returns A clone of the current EquiRectangularCubeTexture.
  49897. */
  49898. clone(): EquiRectangularCubeTexture;
  49899. }
  49900. }
  49901. declare module BABYLON {
  49902. /**
  49903. * Based on jsTGALoader - Javascript loader for TGA file
  49904. * By Vincent Thibault
  49905. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49906. */
  49907. export class TGATools {
  49908. private static _TYPE_INDEXED;
  49909. private static _TYPE_RGB;
  49910. private static _TYPE_GREY;
  49911. private static _TYPE_RLE_INDEXED;
  49912. private static _TYPE_RLE_RGB;
  49913. private static _TYPE_RLE_GREY;
  49914. private static _ORIGIN_MASK;
  49915. private static _ORIGIN_SHIFT;
  49916. private static _ORIGIN_BL;
  49917. private static _ORIGIN_BR;
  49918. private static _ORIGIN_UL;
  49919. private static _ORIGIN_UR;
  49920. /**
  49921. * Gets the header of a TGA file
  49922. * @param data defines the TGA data
  49923. * @returns the header
  49924. */
  49925. static GetTGAHeader(data: Uint8Array): any;
  49926. /**
  49927. * Uploads TGA content to a Babylon Texture
  49928. * @hidden
  49929. */
  49930. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49931. /** @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;
  49932. /** @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;
  49933. /** @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;
  49934. /** @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;
  49935. /** @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;
  49936. /** @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;
  49937. }
  49938. }
  49939. declare module BABYLON {
  49940. /**
  49941. * Implementation of the TGA Texture Loader.
  49942. * @hidden
  49943. */
  49944. export class _TGATextureLoader implements IInternalTextureLoader {
  49945. /**
  49946. * Defines wether the loader supports cascade loading the different faces.
  49947. */
  49948. readonly supportCascades: boolean;
  49949. /**
  49950. * This returns if the loader support the current file information.
  49951. * @param extension defines the file extension of the file being loaded
  49952. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49953. * @param fallback defines the fallback internal texture if any
  49954. * @param isBase64 defines whether the texture is encoded as a base64
  49955. * @param isBuffer defines whether the texture data are stored as a buffer
  49956. * @returns true if the loader can load the specified file
  49957. */
  49958. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49959. /**
  49960. * Transform the url before loading if required.
  49961. * @param rootUrl the url of the texture
  49962. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49963. * @returns the transformed texture
  49964. */
  49965. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49966. /**
  49967. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49968. * @param rootUrl the url of the texture
  49969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49970. * @returns the fallback texture
  49971. */
  49972. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49973. /**
  49974. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49975. * @param data contains the texture data
  49976. * @param texture defines the BabylonJS internal texture
  49977. * @param createPolynomials will be true if polynomials have been requested
  49978. * @param onLoad defines the callback to trigger once the texture is ready
  49979. * @param onError defines the callback to trigger in case of error
  49980. */
  49981. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49982. /**
  49983. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49984. * @param data contains the texture data
  49985. * @param texture defines the BabylonJS internal texture
  49986. * @param callback defines the method to call once ready to upload
  49987. */
  49988. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49989. }
  49990. }
  49991. declare module BABYLON {
  49992. /**
  49993. * Info about the .basis files
  49994. */
  49995. class BasisFileInfo {
  49996. /**
  49997. * If the file has alpha
  49998. */
  49999. hasAlpha: boolean;
  50000. /**
  50001. * Info about each image of the basis file
  50002. */
  50003. images: Array<{
  50004. levels: Array<{
  50005. width: number;
  50006. height: number;
  50007. transcodedPixels: ArrayBufferView;
  50008. }>;
  50009. }>;
  50010. }
  50011. /**
  50012. * Result of transcoding a basis file
  50013. */
  50014. class TranscodeResult {
  50015. /**
  50016. * Info about the .basis file
  50017. */
  50018. fileInfo: BasisFileInfo;
  50019. /**
  50020. * Format to use when loading the file
  50021. */
  50022. format: number;
  50023. }
  50024. /**
  50025. * Configuration options for the Basis transcoder
  50026. */
  50027. export class BasisTranscodeConfiguration {
  50028. /**
  50029. * Supported compression formats used to determine the supported output format of the transcoder
  50030. */
  50031. supportedCompressionFormats?: {
  50032. /**
  50033. * etc1 compression format
  50034. */
  50035. etc1?: boolean;
  50036. /**
  50037. * s3tc compression format
  50038. */
  50039. s3tc?: boolean;
  50040. /**
  50041. * pvrtc compression format
  50042. */
  50043. pvrtc?: boolean;
  50044. /**
  50045. * etc2 compression format
  50046. */
  50047. etc2?: boolean;
  50048. };
  50049. /**
  50050. * If mipmap levels should be loaded for transcoded images (Default: true)
  50051. */
  50052. loadMipmapLevels?: boolean;
  50053. /**
  50054. * Index of a single image to load (Default: all images)
  50055. */
  50056. loadSingleImage?: number;
  50057. }
  50058. /**
  50059. * Used to load .Basis files
  50060. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50061. */
  50062. export class BasisTools {
  50063. private static _IgnoreSupportedFormats;
  50064. /**
  50065. * URL to use when loading the basis transcoder
  50066. */
  50067. static JSModuleURL: string;
  50068. /**
  50069. * URL to use when loading the wasm module for the transcoder
  50070. */
  50071. static WasmModuleURL: string;
  50072. /**
  50073. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50074. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50075. * @returns internal format corresponding to the Basis format
  50076. */
  50077. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50078. private static _WorkerPromise;
  50079. private static _Worker;
  50080. private static _actionId;
  50081. private static _CreateWorkerAsync;
  50082. /**
  50083. * Transcodes a loaded image file to compressed pixel data
  50084. * @param imageData image data to transcode
  50085. * @param config configuration options for the transcoding
  50086. * @returns a promise resulting in the transcoded image
  50087. */
  50088. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50089. /**
  50090. * Loads a texture from the transcode result
  50091. * @param texture texture load to
  50092. * @param transcodeResult the result of transcoding the basis file to load from
  50093. */
  50094. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50095. }
  50096. }
  50097. declare module BABYLON {
  50098. /**
  50099. * Loader for .basis file format
  50100. */
  50101. export class _BasisTextureLoader implements IInternalTextureLoader {
  50102. /**
  50103. * Defines whether the loader supports cascade loading the different faces.
  50104. */
  50105. readonly supportCascades: boolean;
  50106. /**
  50107. * This returns if the loader support the current file information.
  50108. * @param extension defines the file extension of the file being loaded
  50109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50110. * @param fallback defines the fallback internal texture if any
  50111. * @param isBase64 defines whether the texture is encoded as a base64
  50112. * @param isBuffer defines whether the texture data are stored as a buffer
  50113. * @returns true if the loader can load the specified file
  50114. */
  50115. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50116. /**
  50117. * Transform the url before loading if required.
  50118. * @param rootUrl the url of the texture
  50119. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50120. * @returns the transformed texture
  50121. */
  50122. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50123. /**
  50124. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50125. * @param rootUrl the url of the texture
  50126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50127. * @returns the fallback texture
  50128. */
  50129. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50130. /**
  50131. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50132. * @param data contains the texture data
  50133. * @param texture defines the BabylonJS internal texture
  50134. * @param createPolynomials will be true if polynomials have been requested
  50135. * @param onLoad defines the callback to trigger once the texture is ready
  50136. * @param onError defines the callback to trigger in case of error
  50137. */
  50138. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50139. /**
  50140. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50141. * @param data contains the texture data
  50142. * @param texture defines the BabylonJS internal texture
  50143. * @param callback defines the method to call once ready to upload
  50144. */
  50145. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50146. }
  50147. }
  50148. declare module BABYLON {
  50149. /**
  50150. * 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.
  50151. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50152. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50153. */
  50154. export class CustomProceduralTexture extends ProceduralTexture {
  50155. private _animate;
  50156. private _time;
  50157. private _config;
  50158. private _texturePath;
  50159. /**
  50160. * Instantiates a new Custom Procedural Texture.
  50161. * 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.
  50162. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50163. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50164. * @param name Define the name of the texture
  50165. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50166. * @param size Define the size of the texture to create
  50167. * @param scene Define the scene the texture belongs to
  50168. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50169. * @param generateMipMaps Define if the texture should creates mip maps or not
  50170. */
  50171. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50172. private _loadJson;
  50173. /**
  50174. * Is the texture ready to be used ? (rendered at least once)
  50175. * @returns true if ready, otherwise, false.
  50176. */
  50177. isReady(): boolean;
  50178. /**
  50179. * Render the texture to its associated render target.
  50180. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50181. */
  50182. render(useCameraPostProcess?: boolean): void;
  50183. /**
  50184. * Update the list of dependant textures samplers in the shader.
  50185. */
  50186. updateTextures(): void;
  50187. /**
  50188. * Update the uniform values of the procedural texture in the shader.
  50189. */
  50190. updateShaderUniforms(): void;
  50191. /**
  50192. * Define if the texture animates or not.
  50193. */
  50194. animate: boolean;
  50195. }
  50196. }
  50197. declare module BABYLON {
  50198. /** @hidden */
  50199. export var noisePixelShader: {
  50200. name: string;
  50201. shader: string;
  50202. };
  50203. }
  50204. declare module BABYLON {
  50205. /**
  50206. * Class used to generate noise procedural textures
  50207. */
  50208. export class NoiseProceduralTexture extends ProceduralTexture {
  50209. private _time;
  50210. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50211. brightness: number;
  50212. /** Defines the number of octaves to process */
  50213. octaves: number;
  50214. /** Defines the level of persistence (0.8 by default) */
  50215. persistence: number;
  50216. /** Gets or sets animation speed factor (default is 1) */
  50217. animationSpeedFactor: number;
  50218. /**
  50219. * Creates a new NoiseProceduralTexture
  50220. * @param name defines the name fo the texture
  50221. * @param size defines the size of the texture (default is 256)
  50222. * @param scene defines the hosting scene
  50223. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50224. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50225. */
  50226. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50227. private _updateShaderUniforms;
  50228. protected _getDefines(): string;
  50229. /** Generate the current state of the procedural texture */
  50230. render(useCameraPostProcess?: boolean): void;
  50231. /**
  50232. * Serializes this noise procedural texture
  50233. * @returns a serialized noise procedural texture object
  50234. */
  50235. serialize(): any;
  50236. /**
  50237. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50238. * @param parsedTexture defines parsed texture data
  50239. * @param scene defines the current scene
  50240. * @param rootUrl defines the root URL containing noise procedural texture information
  50241. * @returns a parsed NoiseProceduralTexture
  50242. */
  50243. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50244. }
  50245. }
  50246. declare module BABYLON {
  50247. /**
  50248. * Raw cube texture where the raw buffers are passed in
  50249. */
  50250. export class RawCubeTexture extends CubeTexture {
  50251. /**
  50252. * Creates a cube texture where the raw buffers are passed in.
  50253. * @param scene defines the scene the texture is attached to
  50254. * @param data defines the array of data to use to create each face
  50255. * @param size defines the size of the textures
  50256. * @param format defines the format of the data
  50257. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50258. * @param generateMipMaps defines if the engine should generate the mip levels
  50259. * @param invertY defines if data must be stored with Y axis inverted
  50260. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50261. * @param compression defines the compression used (null by default)
  50262. */
  50263. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50264. /**
  50265. * Updates the raw cube texture.
  50266. * @param data defines the data to store
  50267. * @param format defines the data format
  50268. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50269. * @param invertY defines if data must be stored with Y axis inverted
  50270. * @param compression defines the compression used (null by default)
  50271. * @param level defines which level of the texture to update
  50272. */
  50273. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50274. /**
  50275. * Updates a raw cube texture with RGBD encoded data.
  50276. * @param data defines the array of data [mipmap][face] to use to create each face
  50277. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50280. * @returns a promsie that resolves when the operation is complete
  50281. */
  50282. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50283. /**
  50284. * Clones the raw cube texture.
  50285. * @return a new cube texture
  50286. */
  50287. clone(): CubeTexture;
  50288. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50289. }
  50290. }
  50291. declare module BABYLON {
  50292. /**
  50293. * Class used to store 3D textures containing user data
  50294. */
  50295. export class RawTexture3D extends Texture {
  50296. /** Gets or sets the texture format to use */
  50297. format: number;
  50298. private _engine;
  50299. /**
  50300. * Create a new RawTexture3D
  50301. * @param data defines the data of the texture
  50302. * @param width defines the width of the texture
  50303. * @param height defines the height of the texture
  50304. * @param depth defines the depth of the texture
  50305. * @param format defines the texture format to use
  50306. * @param scene defines the hosting scene
  50307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50308. * @param invertY defines if texture must be stored with Y axis inverted
  50309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50311. */
  50312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50313. /** Gets or sets the texture format to use */
  50314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50315. /**
  50316. * Update the texture with new data
  50317. * @param data defines the data to store in the texture
  50318. */
  50319. update(data: ArrayBufferView): void;
  50320. }
  50321. }
  50322. declare module BABYLON {
  50323. /**
  50324. * Creates a refraction texture used by refraction channel of the standard material.
  50325. * It is like a mirror but to see through a material.
  50326. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50327. */
  50328. export class RefractionTexture extends RenderTargetTexture {
  50329. /**
  50330. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50331. * 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.
  50332. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50333. */
  50334. refractionPlane: Plane;
  50335. /**
  50336. * Define how deep under the surface we should see.
  50337. */
  50338. depth: number;
  50339. /**
  50340. * Creates a refraction texture used by refraction channel of the standard material.
  50341. * It is like a mirror but to see through a material.
  50342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50343. * @param name Define the texture name
  50344. * @param size Define the size of the underlying texture
  50345. * @param scene Define the scene the refraction belongs to
  50346. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50347. */
  50348. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50349. /**
  50350. * Clone the refraction texture.
  50351. * @returns the cloned texture
  50352. */
  50353. clone(): RefractionTexture;
  50354. /**
  50355. * Serialize the texture to a JSON representation you could use in Parse later on
  50356. * @returns the serialized JSON representation
  50357. */
  50358. serialize(): any;
  50359. }
  50360. }
  50361. declare module BABYLON {
  50362. /**
  50363. * Defines the options related to the creation of an HtmlElementTexture
  50364. */
  50365. export interface IHtmlElementTextureOptions {
  50366. /**
  50367. * Defines wether mip maps should be created or not.
  50368. */
  50369. generateMipMaps?: boolean;
  50370. /**
  50371. * Defines the sampling mode of the texture.
  50372. */
  50373. samplingMode?: number;
  50374. /**
  50375. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50376. */
  50377. engine: Nullable<Engine>;
  50378. /**
  50379. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50380. */
  50381. scene: Nullable<Scene>;
  50382. }
  50383. /**
  50384. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50385. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50386. * is automatically managed.
  50387. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50388. * in your application.
  50389. *
  50390. * As the update is not automatic, you need to call them manually.
  50391. */
  50392. export class HtmlElementTexture extends BaseTexture {
  50393. /**
  50394. * The texture URL.
  50395. */
  50396. element: HTMLVideoElement | HTMLCanvasElement;
  50397. private static readonly DefaultOptions;
  50398. private _textureMatrix;
  50399. private _engine;
  50400. private _isVideo;
  50401. private _generateMipMaps;
  50402. private _samplingMode;
  50403. /**
  50404. * Instantiates a HtmlElementTexture from the following parameters.
  50405. *
  50406. * @param name Defines the name of the texture
  50407. * @param element Defines the video or canvas the texture is filled with
  50408. * @param options Defines the other none mandatory texture creation options
  50409. */
  50410. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50411. private _createInternalTexture;
  50412. /**
  50413. * Returns the texture matrix used in most of the material.
  50414. */
  50415. getTextureMatrix(): Matrix;
  50416. /**
  50417. * Updates the content of the texture.
  50418. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50419. */
  50420. update(invertY?: Nullable<boolean>): void;
  50421. }
  50422. }
  50423. declare module BABYLON {
  50424. /**
  50425. * Enum used to define the target of a block
  50426. */
  50427. export enum NodeMaterialBlockTargets {
  50428. /** Vertex shader */
  50429. Vertex = 1,
  50430. /** Fragment shader */
  50431. Fragment = 2,
  50432. /** Neutral */
  50433. Neutral = 4,
  50434. /** Vertex and Fragment */
  50435. VertexAndFragment = 3
  50436. }
  50437. }
  50438. declare module BABYLON {
  50439. /**
  50440. * Defines the kind of connection point for node based material
  50441. */
  50442. export enum NodeMaterialBlockConnectionPointTypes {
  50443. /** Float */
  50444. Float = 1,
  50445. /** Int */
  50446. Int = 2,
  50447. /** Vector2 */
  50448. Vector2 = 4,
  50449. /** Vector3 */
  50450. Vector3 = 8,
  50451. /** Vector4 */
  50452. Vector4 = 16,
  50453. /** Color3 */
  50454. Color3 = 32,
  50455. /** Color4 */
  50456. Color4 = 64,
  50457. /** Matrix */
  50458. Matrix = 128,
  50459. /** Detect type based on connection */
  50460. AutoDetect = 1024,
  50461. /** Output type that will be defined by input type */
  50462. BasedOnInput = 2048
  50463. }
  50464. }
  50465. declare module BABYLON {
  50466. /**
  50467. * Root class for all node material optimizers
  50468. */
  50469. export class NodeMaterialOptimizer {
  50470. /**
  50471. * Function used to optimize a NodeMaterial graph
  50472. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50473. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50474. */
  50475. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50476. }
  50477. }
  50478. declare module BABYLON {
  50479. /**
  50480. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  50481. */
  50482. export class TransformBlock extends NodeMaterialBlock {
  50483. /**
  50484. * Defines the value to use to complement W value to transform it to a Vector4
  50485. */
  50486. complementW: number;
  50487. /**
  50488. * Defines the value to use to complement z value to transform it to a Vector4
  50489. */
  50490. complementZ: number;
  50491. /**
  50492. * Creates a new TransformBlock
  50493. * @param name defines the block name
  50494. */
  50495. constructor(name: string);
  50496. /**
  50497. * Gets the current class name
  50498. * @returns the class name
  50499. */
  50500. getClassName(): string;
  50501. /**
  50502. * Gets the vector input
  50503. */
  50504. readonly vector: NodeMaterialConnectionPoint;
  50505. /**
  50506. * Gets the output component
  50507. */
  50508. readonly output: NodeMaterialConnectionPoint;
  50509. /**
  50510. * Gets the matrix transform input
  50511. */
  50512. readonly transform: NodeMaterialConnectionPoint;
  50513. protected _buildBlock(state: NodeMaterialBuildState): this;
  50514. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  50515. }
  50516. }
  50517. declare module BABYLON {
  50518. /**
  50519. * Block used to output the vertex position
  50520. */
  50521. export class VertexOutputBlock extends NodeMaterialBlock {
  50522. /**
  50523. * Creates a new VertexOutputBlock
  50524. * @param name defines the block name
  50525. */
  50526. constructor(name: string);
  50527. /**
  50528. * Gets the current class name
  50529. * @returns the class name
  50530. */
  50531. getClassName(): string;
  50532. /**
  50533. * Gets the vector input component
  50534. */
  50535. readonly vector: NodeMaterialConnectionPoint;
  50536. protected _buildBlock(state: NodeMaterialBuildState): this;
  50537. }
  50538. }
  50539. declare module BABYLON {
  50540. /**
  50541. * Block used to output the final color
  50542. */
  50543. export class FragmentOutputBlock extends NodeMaterialBlock {
  50544. /**
  50545. * Create a new FragmentOutputBlock
  50546. * @param name defines the block name
  50547. */
  50548. constructor(name: string);
  50549. /**
  50550. * Gets the current class name
  50551. * @returns the class name
  50552. */
  50553. getClassName(): string;
  50554. /**
  50555. * Gets the rgba input component
  50556. */
  50557. readonly rgba: NodeMaterialConnectionPoint;
  50558. /**
  50559. * Gets the rgb input component
  50560. */
  50561. readonly rgb: NodeMaterialConnectionPoint;
  50562. /**
  50563. * Gets the a input component
  50564. */
  50565. readonly a: NodeMaterialConnectionPoint;
  50566. protected _buildBlock(state: NodeMaterialBuildState): this;
  50567. }
  50568. }
  50569. declare module BABYLON {
  50570. /**
  50571. * Interface used to configure the node material editor
  50572. */
  50573. export interface INodeMaterialEditorOptions {
  50574. /** Define the URl to load node editor script */
  50575. editorURL?: string;
  50576. }
  50577. /** @hidden */
  50578. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50579. /** BONES */
  50580. NUM_BONE_INFLUENCERS: number;
  50581. BonesPerMesh: number;
  50582. BONETEXTURE: boolean;
  50583. /** MORPH TARGETS */
  50584. MORPHTARGETS: boolean;
  50585. MORPHTARGETS_NORMAL: boolean;
  50586. MORPHTARGETS_TANGENT: boolean;
  50587. MORPHTARGETS_UV: boolean;
  50588. NUM_MORPH_INFLUENCERS: number;
  50589. /** IMAGE PROCESSING */
  50590. IMAGEPROCESSING: boolean;
  50591. VIGNETTE: boolean;
  50592. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50593. VIGNETTEBLENDMODEOPAQUE: boolean;
  50594. TONEMAPPING: boolean;
  50595. TONEMAPPING_ACES: boolean;
  50596. CONTRAST: boolean;
  50597. EXPOSURE: boolean;
  50598. COLORCURVES: boolean;
  50599. COLORGRADING: boolean;
  50600. COLORGRADING3D: boolean;
  50601. SAMPLER3DGREENDEPTH: boolean;
  50602. SAMPLER3DBGRMAP: boolean;
  50603. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50604. constructor();
  50605. setValue(name: string, value: boolean): void;
  50606. }
  50607. /**
  50608. * Class used to configure NodeMaterial
  50609. */
  50610. export interface INodeMaterialOptions {
  50611. /**
  50612. * Defines if blocks should emit comments
  50613. */
  50614. emitComments: boolean;
  50615. }
  50616. /**
  50617. * Class used to create a node based material built by assembling shader blocks
  50618. */
  50619. export class NodeMaterial extends PushMaterial {
  50620. private static _BuildIdGenerator;
  50621. private _options;
  50622. private _vertexCompilationState;
  50623. private _fragmentCompilationState;
  50624. private _sharedData;
  50625. private _buildId;
  50626. private _buildWasSuccessful;
  50627. private _cachedWorldViewMatrix;
  50628. private _cachedWorldViewProjectionMatrix;
  50629. private _optimizers;
  50630. /** Define the URl to load node editor script */
  50631. static EditorURL: string;
  50632. private BJSNODEMATERIALEDITOR;
  50633. /** Get the inspector from bundle or global */
  50634. private _getGlobalNodeMaterialEditor;
  50635. /**
  50636. * 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)
  50637. */
  50638. ignoreAlpha: boolean;
  50639. /**
  50640. * Defines the maximum number of lights that can be used in the material
  50641. */
  50642. maxSimultaneousLights: number;
  50643. /**
  50644. * Observable raised when the material is built
  50645. */
  50646. onBuildObservable: Observable<NodeMaterial>;
  50647. /**
  50648. * Gets or sets the root nodes of the material vertex shader
  50649. */ private _vertexOutputNodes: NodeMaterialBlock[];
  50650. /**
  50651. * Gets or sets the root nodes of the material fragment (pixel) shader
  50652. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  50653. /** Gets or sets options to control the node material overall behavior */
  50654. options: INodeMaterialOptions;
  50655. /**
  50656. * Default configuration related to image processing available in the standard Material.
  50657. */
  50658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50659. /**
  50660. * Gets the image processing configuration used either in this material.
  50661. */
  50662. /**
  50663. * Sets the Default image processing configuration used either in the this material.
  50664. *
  50665. * If sets to null, the scene one is in use.
  50666. */
  50667. imageProcessingConfiguration: ImageProcessingConfiguration;
  50668. /**
  50669. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  50670. */
  50671. attachedBlocks: NodeMaterialBlock[];
  50672. /**
  50673. * Create a new node based material
  50674. * @param name defines the material name
  50675. * @param scene defines the hosting scene
  50676. * @param options defines creation option
  50677. */
  50678. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50679. /**
  50680. * Gets the current class name of the material e.g. "NodeMaterial"
  50681. * @returns the class name
  50682. */
  50683. getClassName(): string;
  50684. /**
  50685. * Keep track of the image processing observer to allow dispose and replace.
  50686. */
  50687. private _imageProcessingObserver;
  50688. /**
  50689. * Attaches a new image processing configuration to the Standard Material.
  50690. * @param configuration
  50691. */
  50692. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50693. /**
  50694. * Adds a new optimizer to the list of optimizers
  50695. * @param optimizer defines the optimizers to add
  50696. * @returns the current material
  50697. */
  50698. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50699. /**
  50700. * Remove an optimizer from the list of optimizers
  50701. * @param optimizer defines the optimizers to remove
  50702. * @returns the current material
  50703. */
  50704. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50705. /**
  50706. * Add a new block to the list of output nodes
  50707. * @param node defines the node to add
  50708. * @returns the current material
  50709. */
  50710. addOutputNode(node: NodeMaterialBlock): this;
  50711. /**
  50712. * Remove a block from the list of root nodes
  50713. * @param node defines the node to remove
  50714. * @returns the current material
  50715. */
  50716. removeOutputNode(node: NodeMaterialBlock): this;
  50717. private _addVertexOutputNode;
  50718. private _removeVertexOutputNode;
  50719. private _addFragmentOutputNode;
  50720. private _removeFragmentOutputNode;
  50721. /**
  50722. * Specifies if the material will require alpha blending
  50723. * @returns a boolean specifying if alpha blending is needed
  50724. */
  50725. needAlphaBlending(): boolean;
  50726. /**
  50727. * Specifies if this material should be rendered in alpha test mode
  50728. * @returns a boolean specifying if an alpha test is needed.
  50729. */
  50730. needAlphaTesting(): boolean;
  50731. private _initializeBlock;
  50732. private _resetDualBlocks;
  50733. /**
  50734. * Build the material and generates the inner effect
  50735. * @param verbose defines if the build should log activity
  50736. */
  50737. build(verbose?: boolean): void;
  50738. /**
  50739. * Runs an otpimization phase to try to improve the shader code
  50740. */
  50741. optimize(): void;
  50742. private _prepareDefinesForAttributes;
  50743. /**
  50744. * Get if the submesh is ready to be used and all its information available.
  50745. * Child classes can use it to update shaders
  50746. * @param mesh defines the mesh to check
  50747. * @param subMesh defines which submesh to check
  50748. * @param useInstances specifies that instances should be used
  50749. * @returns a boolean indicating that the submesh is ready or not
  50750. */
  50751. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50752. /**
  50753. * Get a string representing the shaders built by the current node graph
  50754. */
  50755. readonly compiledShaders: string;
  50756. /**
  50757. * Binds the world matrix to the material
  50758. * @param world defines the world transformation matrix
  50759. */
  50760. bindOnlyWorldMatrix(world: Matrix): void;
  50761. /**
  50762. * Binds the submesh to this material by preparing the effect and shader to draw
  50763. * @param world defines the world transformation matrix
  50764. * @param mesh defines the mesh containing the submesh
  50765. * @param subMesh defines the submesh to bind the material to
  50766. */
  50767. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50768. /**
  50769. * Gets the active textures from the material
  50770. * @returns an array of textures
  50771. */
  50772. getActiveTextures(): BaseTexture[];
  50773. /**
  50774. * Specifies if the material uses a texture
  50775. * @param texture defines the texture to check against the material
  50776. * @returns a boolean specifying if the material uses the texture
  50777. */
  50778. hasTexture(texture: BaseTexture): boolean;
  50779. /**
  50780. * Disposes the material
  50781. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50782. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50783. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50784. */
  50785. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50786. /** Creates the node editor window. */
  50787. private _createNodeEditor;
  50788. /**
  50789. * Launch the node material editor
  50790. * @param config Define the configuration of the editor
  50791. * @return a promise fulfilled when the node editor is visible
  50792. */
  50793. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50794. /**
  50795. * Clear the current material
  50796. */
  50797. clear(): void;
  50798. /**
  50799. * Clear the current material and set it to a default state
  50800. */
  50801. setToDefault(): void;
  50802. private _gatherBlocks;
  50803. /**
  50804. * Serializes this material in a JSON representation
  50805. * @returns the serialized material object
  50806. */
  50807. serialize(): any;
  50808. /**
  50809. * Clear the current graph and load a new one from a serialization object
  50810. * @param source defines the JSON representation of the material
  50811. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  50812. */
  50813. loadFromSerialization(source: any, rootUrl?: string): void;
  50814. /**
  50815. * Creates a node material from parsed material data
  50816. * @param source defines the JSON representation of the material
  50817. * @param scene defines the hosting scene
  50818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  50819. * @returns a new node material
  50820. */
  50821. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  50822. }
  50823. }
  50824. declare module BABYLON {
  50825. /**
  50826. * Block used to read a texture from a sampler
  50827. */
  50828. export class TextureBlock extends NodeMaterialBlock {
  50829. private _defineName;
  50830. private _samplerName;
  50831. private _transformedUVName;
  50832. private _textureTransformName;
  50833. private _textureInfoName;
  50834. private _mainUVName;
  50835. private _mainUVDefineName;
  50836. /**
  50837. * Gets or sets the texture associated with the node
  50838. */
  50839. texture: Nullable<BaseTexture>;
  50840. /**
  50841. * Create a new TextureBlock
  50842. * @param name defines the block name
  50843. */
  50844. constructor(name: string);
  50845. /**
  50846. * Gets the current class name
  50847. * @returns the class name
  50848. */
  50849. getClassName(): string;
  50850. /**
  50851. * Gets the uv input component
  50852. */
  50853. readonly uv: NodeMaterialConnectionPoint;
  50854. /**
  50855. * Gets the output component
  50856. */
  50857. readonly output: NodeMaterialConnectionPoint;
  50858. autoConfigure(): void;
  50859. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50861. isReady(): boolean;
  50862. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50863. private _injectVertexCode;
  50864. private _writeOutput;
  50865. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  50866. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  50867. }
  50868. }
  50869. declare module BABYLON {
  50870. /**
  50871. * Class used to store shared data between 2 NodeMaterialBuildState
  50872. */
  50873. export class NodeMaterialBuildStateSharedData {
  50874. /**
  50875. * Gets the list of emitted varyings
  50876. */
  50877. varyings: string[];
  50878. /**
  50879. * Gets the varying declaration string
  50880. */
  50881. varyingDeclaration: string;
  50882. /**
  50883. * Input blocks
  50884. */
  50885. inputBlocks: InputBlock[];
  50886. /**
  50887. * Input blocks
  50888. */
  50889. textureBlocks: TextureBlock[];
  50890. /**
  50891. * Bindable blocks (Blocks that need to set data to the effect)
  50892. */
  50893. bindableBlocks: NodeMaterialBlock[];
  50894. /**
  50895. * List of blocks that can provide a compilation fallback
  50896. */
  50897. blocksWithFallbacks: NodeMaterialBlock[];
  50898. /**
  50899. * List of blocks that can provide a define update
  50900. */
  50901. blocksWithDefines: NodeMaterialBlock[];
  50902. /**
  50903. * List of blocks that can provide a repeatable content
  50904. */
  50905. repeatableContentBlocks: NodeMaterialBlock[];
  50906. /**
  50907. * List of blocks that can provide a dynamic list of uniforms
  50908. */
  50909. dynamicUniformBlocks: NodeMaterialBlock[];
  50910. /**
  50911. * List of blocks that can block the isReady function for the material
  50912. */
  50913. blockingBlocks: NodeMaterialBlock[];
  50914. /**
  50915. * Build Id used to avoid multiple recompilations
  50916. */
  50917. buildId: number;
  50918. /** List of emitted variables */
  50919. variableNames: {
  50920. [key: string]: number;
  50921. };
  50922. /** List of emitted defines */
  50923. defineNames: {
  50924. [key: string]: number;
  50925. };
  50926. /** Should emit comments? */
  50927. emitComments: boolean;
  50928. /** Emit build activity */
  50929. verbose: boolean;
  50930. /**
  50931. * Gets the compilation hints emitted at compilation time
  50932. */
  50933. hints: {
  50934. needWorldViewMatrix: boolean;
  50935. needWorldViewProjectionMatrix: boolean;
  50936. needAlphaBlending: boolean;
  50937. needAlphaTesting: boolean;
  50938. };
  50939. /**
  50940. * List of compilation checks
  50941. */
  50942. checks: {
  50943. emitVertex: boolean;
  50944. emitFragment: boolean;
  50945. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50946. };
  50947. /** Creates a new shared data */
  50948. constructor();
  50949. /**
  50950. * Emits console errors and exceptions if there is a failing check
  50951. */
  50952. emitErrors(): void;
  50953. }
  50954. }
  50955. declare module BABYLON {
  50956. /**
  50957. * Class used to store node based material build state
  50958. */
  50959. export class NodeMaterialBuildState {
  50960. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50961. supportUniformBuffers: boolean;
  50962. /**
  50963. * Gets the list of emitted attributes
  50964. */
  50965. attributes: string[];
  50966. /**
  50967. * Gets the list of emitted uniforms
  50968. */
  50969. uniforms: string[];
  50970. /**
  50971. * Gets the list of emitted uniform buffers
  50972. */
  50973. uniformBuffers: string[];
  50974. /**
  50975. * Gets the list of emitted samplers
  50976. */
  50977. samplers: string[];
  50978. /**
  50979. * Gets the list of emitted functions
  50980. */
  50981. functions: {
  50982. [key: string]: string;
  50983. };
  50984. /**
  50985. * Gets the target of the compilation state
  50986. */
  50987. target: NodeMaterialBlockTargets;
  50988. /**
  50989. * Gets the list of emitted counters
  50990. */
  50991. counters: {
  50992. [key: string]: number;
  50993. };
  50994. /**
  50995. * Shared data between multiple NodeMaterialBuildState instances
  50996. */
  50997. sharedData: NodeMaterialBuildStateSharedData;
  50998. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  50999. /** @hidden */ private _attributeDeclaration: string;
  51000. /** @hidden */ private _uniformDeclaration: string;
  51001. /** @hidden */ private _samplerDeclaration: string;
  51002. /** @hidden */ private _varyingTransfer: string;
  51003. private _repeatableContentAnchorIndex;
  51004. /** @hidden */ private _builtCompilationString: string;
  51005. /**
  51006. * Gets the emitted compilation strings
  51007. */
  51008. compilationString: string;
  51009. /**
  51010. * Finalize the compilation strings
  51011. * @param state defines the current compilation state
  51012. */
  51013. finalize(state: NodeMaterialBuildState): void;
  51014. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  51015. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  51016. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  51017. /** @hidden */ private _excludeVariableName(name: string): void;
  51018. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51019. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  51020. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51021. replaceStrings?: {
  51022. search: RegExp;
  51023. replace: string;
  51024. }[];
  51025. repeatKey?: string;
  51026. }): string;
  51027. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51028. repeatKey?: string;
  51029. removeAttributes?: boolean;
  51030. removeUniforms?: boolean;
  51031. removeVaryings?: boolean;
  51032. removeIfDef?: boolean;
  51033. replaceStrings?: {
  51034. search: RegExp;
  51035. replace: string;
  51036. }[];
  51037. }, storeKey?: string): void;
  51038. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51039. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51040. }
  51041. }
  51042. declare module BABYLON {
  51043. /**
  51044. * Defines a block that can be used inside a node based material
  51045. */
  51046. export class NodeMaterialBlock {
  51047. private _buildId;
  51048. private _buildTarget;
  51049. private _target;
  51050. private _isFinalMerger;
  51051. private _isInput;
  51052. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  51053. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  51054. /**
  51055. * Gets or sets the name of the block
  51056. */
  51057. name: string;
  51058. /**
  51059. * Gets or sets the unique id of the node
  51060. */
  51061. uniqueId: number;
  51062. /**
  51063. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51064. */
  51065. readonly isFinalMerger: boolean;
  51066. /**
  51067. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51068. */
  51069. readonly isInput: boolean;
  51070. /**
  51071. * Gets or sets the build Id
  51072. */
  51073. buildId: number;
  51074. /**
  51075. * Gets or sets the target of the block
  51076. */
  51077. target: NodeMaterialBlockTargets;
  51078. /**
  51079. * Gets the list of input points
  51080. */
  51081. readonly inputs: NodeMaterialConnectionPoint[];
  51082. /** Gets the list of output points */
  51083. readonly outputs: NodeMaterialConnectionPoint[];
  51084. /**
  51085. * Find an input by its name
  51086. * @param name defines the name of the input to look for
  51087. * @returns the input or null if not found
  51088. */
  51089. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51090. /**
  51091. * Find an output by its name
  51092. * @param name defines the name of the outputto look for
  51093. * @returns the output or null if not found
  51094. */
  51095. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51096. /**
  51097. * Creates a new NodeMaterialBlock
  51098. * @param name defines the block name
  51099. * @param target defines the target of that block (Vertex by default)
  51100. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51101. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51102. */
  51103. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51104. /**
  51105. * Initialize the block and prepare the context for build
  51106. * @param state defines the state that will be used for the build
  51107. */
  51108. initialize(state: NodeMaterialBuildState): void;
  51109. /**
  51110. * Bind data to effect. Will only be called for blocks with isBindable === true
  51111. * @param effect defines the effect to bind data to
  51112. * @param nodeMaterial defines the hosting NodeMaterial
  51113. * @param mesh defines the mesh that will be rendered
  51114. */
  51115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51116. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51117. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51118. protected _writeFloat(value: number): string;
  51119. /**
  51120. * Gets the current class name e.g. "NodeMaterialBlock"
  51121. * @returns the class name
  51122. */
  51123. getClassName(): string;
  51124. /**
  51125. * Register a new input. Must be called inside a block constructor
  51126. * @param name defines the connection point name
  51127. * @param type defines the connection point type
  51128. * @param isOptional defines a boolean indicating that this input can be omitted
  51129. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51130. * @returns the current block
  51131. */
  51132. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51133. /**
  51134. * Register a new output. Must be called inside a block constructor
  51135. * @param name defines the connection point name
  51136. * @param type defines the connection point type
  51137. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51138. * @returns the current block
  51139. */
  51140. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51141. /**
  51142. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51143. * @param forOutput defines an optional connection point to check compatibility with
  51144. * @returns the first available input or null
  51145. */
  51146. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51147. /**
  51148. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51149. * @param forBlock defines an optional block to check compatibility with
  51150. * @returns the first available input or null
  51151. */
  51152. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51153. /**
  51154. * Connect current block with another block
  51155. * @param other defines the block to connect with
  51156. * @param options define the various options to help pick the right connections
  51157. * @returns the current block
  51158. */
  51159. connectTo(other: NodeMaterialBlock, options?: {
  51160. input?: string;
  51161. output?: string;
  51162. outputSwizzle?: string;
  51163. }): this | undefined;
  51164. protected _buildBlock(state: NodeMaterialBuildState): void;
  51165. /**
  51166. * Add uniforms, samplers and uniform buffers at compilation time
  51167. * @param state defines the state to update
  51168. * @param nodeMaterial defines the node material requesting the update
  51169. * @param defines defines the material defines to update
  51170. */
  51171. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51172. /**
  51173. * Add potential fallbacks if shader compilation fails
  51174. * @param mesh defines the mesh to be rendered
  51175. * @param fallbacks defines the current prioritized list of fallbacks
  51176. */
  51177. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51178. /**
  51179. * Update defines for shader compilation
  51180. * @param mesh defines the mesh to be rendered
  51181. * @param nodeMaterial defines the node material requesting the update
  51182. * @param defines defines the material defines to update
  51183. * @param useInstances specifies that instances should be used
  51184. */
  51185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51186. /**
  51187. * Initialize defines for shader compilation
  51188. * @param mesh defines the mesh to be rendered
  51189. * @param nodeMaterial defines the node material requesting the update
  51190. * @param defines defines the material defines to be prepared
  51191. * @param useInstances specifies that instances should be used
  51192. */
  51193. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51194. /**
  51195. * Lets the block try to connect some inputs automatically
  51196. */
  51197. autoConfigure(): void;
  51198. /**
  51199. * Function called when a block is declared as repeatable content generator
  51200. * @param vertexShaderState defines the current compilation state for the vertex shader
  51201. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51202. * @param mesh defines the mesh to be rendered
  51203. * @param defines defines the material defines to update
  51204. */
  51205. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51206. /**
  51207. * Checks if the block is ready
  51208. * @param mesh defines the mesh to be rendered
  51209. * @param nodeMaterial defines the node material requesting the update
  51210. * @param defines defines the material defines to update
  51211. * @param useInstances specifies that instances should be used
  51212. * @returns true if the block is ready
  51213. */
  51214. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51215. private _processBuild;
  51216. /**
  51217. * Compile the current node and generate the shader code
  51218. * @param state defines the current compilation state (uniforms, samplers, current string)
  51219. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51220. * @returns true if already built
  51221. */
  51222. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51223. /**
  51224. * Serializes this block in a JSON representation
  51225. * @returns the serialized block object
  51226. */
  51227. serialize(): any;
  51228. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51229. }
  51230. }
  51231. declare module BABYLON {
  51232. /**
  51233. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51234. */
  51235. export enum NodeMaterialBlockConnectionPointMode {
  51236. /** Value is an uniform */
  51237. Uniform = 0,
  51238. /** Value is a mesh attribute */
  51239. Attribute = 1,
  51240. /** Value is a varying between vertex and fragment shaders */
  51241. Varying = 2,
  51242. /** Mode is undefined */
  51243. Undefined = 3
  51244. }
  51245. }
  51246. declare module BABYLON {
  51247. /**
  51248. * Enum used to define well known values e.g. values automatically provided by the system
  51249. */
  51250. export enum NodeMaterialWellKnownValues {
  51251. /** World */
  51252. World = 1,
  51253. /** View */
  51254. View = 2,
  51255. /** Projection */
  51256. Projection = 3,
  51257. /** ViewProjection */
  51258. ViewProjection = 4,
  51259. /** WorldView */
  51260. WorldView = 5,
  51261. /** WorldViewProjection */
  51262. WorldViewProjection = 6,
  51263. /** CameraPosition */
  51264. CameraPosition = 7,
  51265. /** Fog Color */
  51266. FogColor = 8
  51267. }
  51268. }
  51269. declare module BABYLON {
  51270. /**
  51271. * Contains position and normal vectors for a vertex
  51272. */
  51273. export class PositionNormalVertex {
  51274. /** the position of the vertex (defaut: 0,0,0) */
  51275. position: Vector3;
  51276. /** the normal of the vertex (defaut: 0,1,0) */
  51277. normal: Vector3;
  51278. /**
  51279. * Creates a PositionNormalVertex
  51280. * @param position the position of the vertex (defaut: 0,0,0)
  51281. * @param normal the normal of the vertex (defaut: 0,1,0)
  51282. */
  51283. constructor(
  51284. /** the position of the vertex (defaut: 0,0,0) */
  51285. position?: Vector3,
  51286. /** the normal of the vertex (defaut: 0,1,0) */
  51287. normal?: Vector3);
  51288. /**
  51289. * Clones the PositionNormalVertex
  51290. * @returns the cloned PositionNormalVertex
  51291. */
  51292. clone(): PositionNormalVertex;
  51293. }
  51294. /**
  51295. * Contains position, normal and uv vectors for a vertex
  51296. */
  51297. export class PositionNormalTextureVertex {
  51298. /** the position of the vertex (defaut: 0,0,0) */
  51299. position: Vector3;
  51300. /** the normal of the vertex (defaut: 0,1,0) */
  51301. normal: Vector3;
  51302. /** the uv of the vertex (default: 0,0) */
  51303. uv: Vector2;
  51304. /**
  51305. * Creates a PositionNormalTextureVertex
  51306. * @param position the position of the vertex (defaut: 0,0,0)
  51307. * @param normal the normal of the vertex (defaut: 0,1,0)
  51308. * @param uv the uv of the vertex (default: 0,0)
  51309. */
  51310. constructor(
  51311. /** the position of the vertex (defaut: 0,0,0) */
  51312. position?: Vector3,
  51313. /** the normal of the vertex (defaut: 0,1,0) */
  51314. normal?: Vector3,
  51315. /** the uv of the vertex (default: 0,0) */
  51316. uv?: Vector2);
  51317. /**
  51318. * Clones the PositionNormalTextureVertex
  51319. * @returns the cloned PositionNormalTextureVertex
  51320. */
  51321. clone(): PositionNormalTextureVertex;
  51322. }
  51323. }
  51324. declare module BABYLON {
  51325. /**
  51326. * Block used to expose an input value
  51327. */
  51328. export class InputBlock extends NodeMaterialBlock {
  51329. private _mode;
  51330. private _associatedVariableName;
  51331. private _storedValue;
  51332. private _valueCallback;
  51333. private _type;
  51334. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51335. /**
  51336. * Gets or sets the connection point type (default is float)
  51337. */
  51338. readonly type: NodeMaterialBlockConnectionPointTypes;
  51339. /**
  51340. * Creates a new InputBlock
  51341. * @param name defines the block name
  51342. * @param target defines the target of that block (Vertex by default)
  51343. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  51344. */
  51345. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  51346. /**
  51347. * Gets the output component
  51348. */
  51349. readonly output: NodeMaterialConnectionPoint;
  51350. /**
  51351. * Set the source of this connection point to a vertex attribute
  51352. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51353. * @returns the current connection point
  51354. */
  51355. setAsAttribute(attributeName?: string): InputBlock;
  51356. /**
  51357. * Set the source of this connection point to a well known value
  51358. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51359. * @returns the current connection point
  51360. */
  51361. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  51362. /**
  51363. * Gets or sets the value of that point.
  51364. * Please note that this value will be ignored if valueCallback is defined
  51365. */
  51366. value: any;
  51367. /**
  51368. * Gets or sets a callback used to get the value of that point.
  51369. * Please note that setting this value will force the connection point to ignore the value property
  51370. */
  51371. valueCallback: () => any;
  51372. /**
  51373. * Gets or sets the associated variable name in the shader
  51374. */
  51375. associatedVariableName: string;
  51376. /**
  51377. * Gets a boolean indicating that this connection point not defined yet
  51378. */
  51379. readonly isUndefined: boolean;
  51380. /**
  51381. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51382. * In this case the connection point name must be the name of the uniform to use.
  51383. * Can only be set on inputs
  51384. */
  51385. isUniform: boolean;
  51386. /**
  51387. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51388. * In this case the connection point name must be the name of the attribute to use
  51389. * Can only be set on inputs
  51390. */
  51391. isAttribute: boolean;
  51392. /**
  51393. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51394. * Can only be set on exit points
  51395. */
  51396. isVarying: boolean;
  51397. /**
  51398. * Gets a boolean indicating that the current connection point is a well known value
  51399. */
  51400. readonly isWellKnownValue: boolean;
  51401. /**
  51402. * Gets or sets the current well known value or null if not defined as well know value
  51403. */
  51404. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51405. /**
  51406. * Gets the current class name
  51407. * @returns the class name
  51408. */
  51409. getClassName(): string;
  51410. private _emitDefine;
  51411. /**
  51412. * Set the input block to its default value (based on its type)
  51413. */
  51414. setDefaultValue(): void;
  51415. private _emit;
  51416. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51417. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  51418. protected _buildBlock(state: NodeMaterialBuildState): void;
  51419. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51420. }
  51421. }
  51422. declare module BABYLON {
  51423. /**
  51424. * Defines a connection point for a block
  51425. */
  51426. export class NodeMaterialConnectionPoint {
  51427. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  51428. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51429. private _endpoints;
  51430. private _associatedVariableName;
  51431. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51432. private _type;
  51433. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  51434. /**
  51435. * Gets or sets the additional types supported byt this connection point
  51436. */
  51437. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  51438. /**
  51439. * Gets or sets the associated variable name in the shader
  51440. */
  51441. associatedVariableName: string;
  51442. /**
  51443. * Gets or sets the connection point type (default is float)
  51444. */
  51445. type: NodeMaterialBlockConnectionPointTypes;
  51446. /**
  51447. * Gets or sets the connection point name
  51448. */
  51449. name: string;
  51450. /**
  51451. * Gets or sets a boolean indicating that this connection point can be omitted
  51452. */
  51453. isOptional: boolean;
  51454. /**
  51455. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51456. */
  51457. define: string;
  51458. /** Gets or sets the target of that connection point */
  51459. target: NodeMaterialBlockTargets;
  51460. /**
  51461. * Gets a boolean indicating that the current point is connected
  51462. */
  51463. readonly isConnected: boolean;
  51464. /**
  51465. * Gets a boolean indicating that the current point is connected to an input block
  51466. */
  51467. readonly isConnectedToInput: boolean;
  51468. /**
  51469. * Gets a the connected input block (if any)
  51470. */
  51471. readonly connectInputBlock: Nullable<InputBlock>;
  51472. /** Get the other side of the connection (if any) */
  51473. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51474. /** Get the block that owns this connection point */
  51475. readonly ownerBlock: NodeMaterialBlock;
  51476. /** Get the block connected on the other side of this connection (if any) */
  51477. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51478. /** Get the block connected on the endpoints of this connection (if any) */
  51479. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51480. /** Gets the list of connected endpoints */
  51481. readonly endpoints: NodeMaterialConnectionPoint[];
  51482. /**
  51483. * Creates a new connection point
  51484. * @param name defines the connection point name
  51485. * @param ownerBlock defines the block hosting this connection point
  51486. */
  51487. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51488. /**
  51489. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51490. * @returns the class name
  51491. */
  51492. getClassName(): string;
  51493. /**
  51494. * Gets an boolean indicating if the current point can be connected to another point
  51495. * @param connectionPoint defines the other connection point
  51496. * @returns true if the connection is possible
  51497. */
  51498. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  51499. /**
  51500. * Connect this point to another connection point
  51501. * @param connectionPoint defines the other connection point
  51502. * @returns the current connection point
  51503. */
  51504. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51505. /**
  51506. * Disconnect this point from one of his endpoint
  51507. * @param endpoint defines the other connection point
  51508. * @returns the current connection point
  51509. */
  51510. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51511. /**
  51512. * Serializes this point in a JSON representation
  51513. * @returns the serialized point object
  51514. */
  51515. serialize(): any;
  51516. }
  51517. }
  51518. declare module BABYLON {
  51519. /**
  51520. * Block used to add support for vertex skinning (bones)
  51521. */
  51522. export class BonesBlock extends NodeMaterialBlock {
  51523. /**
  51524. * Creates a new BonesBlock
  51525. * @param name defines the block name
  51526. */
  51527. constructor(name: string);
  51528. /**
  51529. * Initialize the block and prepare the context for build
  51530. * @param state defines the state that will be used for the build
  51531. */
  51532. initialize(state: NodeMaterialBuildState): void;
  51533. /**
  51534. * Gets the current class name
  51535. * @returns the class name
  51536. */
  51537. getClassName(): string;
  51538. /**
  51539. * Gets the matrix indices input component
  51540. */
  51541. readonly matricesIndices: NodeMaterialConnectionPoint;
  51542. /**
  51543. * Gets the matrix weights input component
  51544. */
  51545. readonly matricesWeights: NodeMaterialConnectionPoint;
  51546. /**
  51547. * Gets the extra matrix indices input component
  51548. */
  51549. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51550. /**
  51551. * Gets the extra matrix weights input component
  51552. */
  51553. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51554. /**
  51555. * Gets the world input component
  51556. */
  51557. readonly world: NodeMaterialConnectionPoint;
  51558. /**
  51559. * Gets the output component
  51560. */
  51561. readonly output: NodeMaterialConnectionPoint;
  51562. autoConfigure(): void;
  51563. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51566. protected _buildBlock(state: NodeMaterialBuildState): this;
  51567. }
  51568. }
  51569. declare module BABYLON {
  51570. /**
  51571. * Block used to add support for instances
  51572. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51573. */
  51574. export class InstancesBlock extends NodeMaterialBlock {
  51575. /**
  51576. * Creates a new InstancesBlock
  51577. * @param name defines the block name
  51578. */
  51579. constructor(name: string);
  51580. /**
  51581. * Gets the current class name
  51582. * @returns the class name
  51583. */
  51584. getClassName(): string;
  51585. /**
  51586. * Gets the first world row input component
  51587. */
  51588. readonly world0: NodeMaterialConnectionPoint;
  51589. /**
  51590. * Gets the second world row input component
  51591. */
  51592. readonly world1: NodeMaterialConnectionPoint;
  51593. /**
  51594. * Gets the third world row input component
  51595. */
  51596. readonly world2: NodeMaterialConnectionPoint;
  51597. /**
  51598. * Gets the forth world row input component
  51599. */
  51600. readonly world3: NodeMaterialConnectionPoint;
  51601. /**
  51602. * Gets the world input component
  51603. */
  51604. readonly world: NodeMaterialConnectionPoint;
  51605. /**
  51606. * Gets the output component
  51607. */
  51608. readonly output: NodeMaterialConnectionPoint;
  51609. autoConfigure(): void;
  51610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51611. protected _buildBlock(state: NodeMaterialBuildState): this;
  51612. }
  51613. }
  51614. declare module BABYLON {
  51615. /**
  51616. * Block used to add morph targets support to vertex shader
  51617. */
  51618. export class MorphTargetsBlock extends NodeMaterialBlock {
  51619. private _repeatableContentAnchor;
  51620. private _repeatebleContentGenerated;
  51621. /**
  51622. * Create a new MorphTargetsBlock
  51623. * @param name defines the block name
  51624. */
  51625. constructor(name: string);
  51626. /**
  51627. * Gets the current class name
  51628. * @returns the class name
  51629. */
  51630. getClassName(): string;
  51631. /**
  51632. * Gets the position input component
  51633. */
  51634. readonly position: NodeMaterialConnectionPoint;
  51635. /**
  51636. * Gets the normal input component
  51637. */
  51638. readonly normal: NodeMaterialConnectionPoint;
  51639. /**
  51640. * Gets the tangent input component
  51641. */
  51642. readonly tangent: NodeMaterialConnectionPoint;
  51643. /**
  51644. * Gets the tangent input component
  51645. */
  51646. readonly uv: NodeMaterialConnectionPoint;
  51647. /**
  51648. * Gets the position output component
  51649. */
  51650. readonly positionOutput: NodeMaterialConnectionPoint;
  51651. /**
  51652. * Gets the normal output component
  51653. */
  51654. readonly normalOutput: NodeMaterialConnectionPoint;
  51655. /**
  51656. * Gets the tangent output component
  51657. */
  51658. readonly tangentOutput: NodeMaterialConnectionPoint;
  51659. /**
  51660. * Gets the tangent output component
  51661. */
  51662. readonly uvOutput: NodeMaterialConnectionPoint;
  51663. initialize(state: NodeMaterialBuildState): void;
  51664. autoConfigure(): void;
  51665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51667. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51668. protected _buildBlock(state: NodeMaterialBuildState): this;
  51669. }
  51670. }
  51671. declare module BABYLON {
  51672. /**
  51673. * Block used to add an alpha test in the fragment shader
  51674. */
  51675. export class AlphaTestBlock extends NodeMaterialBlock {
  51676. /**
  51677. * Gets or sets the alpha value where alpha testing happens
  51678. */
  51679. alphaCutOff: number;
  51680. /**
  51681. * Create a new AlphaTestBlock
  51682. * @param name defines the block name
  51683. */
  51684. constructor(name: string);
  51685. /**
  51686. * Gets the current class name
  51687. * @returns the class name
  51688. */
  51689. getClassName(): string;
  51690. /**
  51691. * Gets the color input component
  51692. */
  51693. readonly color: NodeMaterialConnectionPoint;
  51694. /**
  51695. * Gets the alpha input component
  51696. */
  51697. readonly alpha: NodeMaterialConnectionPoint;
  51698. protected _buildBlock(state: NodeMaterialBuildState): this;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * Block used to create a Color3/4 out of individual inputs (one for each component)
  51704. */
  51705. export class ColorMergerBlock extends NodeMaterialBlock {
  51706. /**
  51707. * Create a new ColorMergerBlock
  51708. * @param name defines the block name
  51709. */
  51710. constructor(name: string);
  51711. /**
  51712. * Gets the current class name
  51713. * @returns the class name
  51714. */
  51715. getClassName(): string;
  51716. /**
  51717. * Gets the r component (input)
  51718. */
  51719. readonly r: NodeMaterialConnectionPoint;
  51720. /**
  51721. * Gets the g component (input)
  51722. */
  51723. readonly g: NodeMaterialConnectionPoint;
  51724. /**
  51725. * Gets the b component (input)
  51726. */
  51727. readonly b: NodeMaterialConnectionPoint;
  51728. /**
  51729. * Gets the a component (input)
  51730. */
  51731. readonly a: NodeMaterialConnectionPoint;
  51732. /**
  51733. * Gets the rgba component (output)
  51734. */
  51735. readonly rgba: NodeMaterialConnectionPoint;
  51736. /**
  51737. * Gets the rgb component (output)
  51738. */
  51739. readonly rgb: NodeMaterialConnectionPoint;
  51740. protected _buildBlock(state: NodeMaterialBuildState): this;
  51741. }
  51742. }
  51743. declare module BABYLON {
  51744. /**
  51745. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  51746. */
  51747. export class VectorMergerBlock extends NodeMaterialBlock {
  51748. /**
  51749. * Create a new VectorMergerBlock
  51750. * @param name defines the block name
  51751. */
  51752. constructor(name: string);
  51753. /**
  51754. * Gets the current class name
  51755. * @returns the class name
  51756. */
  51757. getClassName(): string;
  51758. /**
  51759. * Gets the x component (input)
  51760. */
  51761. readonly x: NodeMaterialConnectionPoint;
  51762. /**
  51763. * Gets the y component (input)
  51764. */
  51765. readonly y: NodeMaterialConnectionPoint;
  51766. /**
  51767. * Gets the z component (input)
  51768. */
  51769. readonly z: NodeMaterialConnectionPoint;
  51770. /**
  51771. * Gets the w component (input)
  51772. */
  51773. readonly w: NodeMaterialConnectionPoint;
  51774. /**
  51775. * Gets the xyzw component (output)
  51776. */
  51777. readonly xyzw: NodeMaterialConnectionPoint;
  51778. /**
  51779. * Gets the xyz component (output)
  51780. */
  51781. readonly xyz: NodeMaterialConnectionPoint;
  51782. /**
  51783. * Gets the xy component (output)
  51784. */
  51785. readonly xy: NodeMaterialConnectionPoint;
  51786. protected _buildBlock(state: NodeMaterialBuildState): this;
  51787. }
  51788. }
  51789. declare module BABYLON {
  51790. /**
  51791. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  51792. */
  51793. export class ColorSplitterBlock extends NodeMaterialBlock {
  51794. /**
  51795. * Create a new ColorSplitterBlock
  51796. * @param name defines the block name
  51797. */
  51798. constructor(name: string);
  51799. /**
  51800. * Gets the current class name
  51801. * @returns the class name
  51802. */
  51803. getClassName(): string;
  51804. /**
  51805. * Gets the rgba component (input)
  51806. */
  51807. readonly rgba: NodeMaterialConnectionPoint;
  51808. /**
  51809. * Gets the rgb component (input)
  51810. */
  51811. readonly rgbIn: NodeMaterialConnectionPoint;
  51812. /**
  51813. * Gets the rgb component (output)
  51814. */
  51815. readonly rgbOut: NodeMaterialConnectionPoint;
  51816. /**
  51817. * Gets the r component (output)
  51818. */
  51819. readonly r: NodeMaterialConnectionPoint;
  51820. /**
  51821. * Gets the g component (output)
  51822. */
  51823. readonly g: NodeMaterialConnectionPoint;
  51824. /**
  51825. * Gets the b component (output)
  51826. */
  51827. readonly b: NodeMaterialConnectionPoint;
  51828. /**
  51829. * Gets the a component (output)
  51830. */
  51831. readonly a: NodeMaterialConnectionPoint;
  51832. protected _buildBlock(state: NodeMaterialBuildState): this;
  51833. }
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  51838. */
  51839. export class VectorSplitterBlock extends NodeMaterialBlock {
  51840. /**
  51841. * Create a new VectorSplitterBlock
  51842. * @param name defines the block name
  51843. */
  51844. constructor(name: string);
  51845. /**
  51846. * Gets the current class name
  51847. * @returns the class name
  51848. */
  51849. getClassName(): string;
  51850. /**
  51851. * Gets the xyzw component (input)
  51852. */
  51853. readonly xyzw: NodeMaterialConnectionPoint;
  51854. /**
  51855. * Gets the xyz component (input)
  51856. */
  51857. readonly xyzIn: NodeMaterialConnectionPoint;
  51858. /**
  51859. * Gets the xyz component (output)
  51860. */
  51861. readonly xyzOut: NodeMaterialConnectionPoint;
  51862. /**
  51863. * Gets the xy component (output)
  51864. */
  51865. readonly xy: NodeMaterialConnectionPoint;
  51866. /**
  51867. * Gets the x component (output)
  51868. */
  51869. readonly x: NodeMaterialConnectionPoint;
  51870. /**
  51871. * Gets the y component (output)
  51872. */
  51873. readonly y: NodeMaterialConnectionPoint;
  51874. /**
  51875. * Gets the z component (output)
  51876. */
  51877. readonly z: NodeMaterialConnectionPoint;
  51878. /**
  51879. * Gets the w component (output)
  51880. */
  51881. readonly w: NodeMaterialConnectionPoint;
  51882. protected _buildBlock(state: NodeMaterialBuildState): this;
  51883. }
  51884. }
  51885. declare module BABYLON {
  51886. /**
  51887. * Block used to add image processing support to fragment shader
  51888. */
  51889. export class ImageProcessingBlock extends NodeMaterialBlock {
  51890. /**
  51891. * Create a new ImageProcessingBlock
  51892. * @param name defines the block name
  51893. */
  51894. constructor(name: string);
  51895. /**
  51896. * Gets the current class name
  51897. * @returns the class name
  51898. */
  51899. getClassName(): string;
  51900. /**
  51901. * Gets the color input component
  51902. */
  51903. readonly color: NodeMaterialConnectionPoint;
  51904. /**
  51905. * Gets the output component
  51906. */
  51907. readonly output: NodeMaterialConnectionPoint;
  51908. /**
  51909. * Initialize the block and prepare the context for build
  51910. * @param state defines the state that will be used for the build
  51911. */
  51912. initialize(state: NodeMaterialBuildState): void;
  51913. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51916. protected _buildBlock(state: NodeMaterialBuildState): this;
  51917. }
  51918. }
  51919. declare module BABYLON {
  51920. /**
  51921. * Block used to add support for scene fog
  51922. */
  51923. export class FogBlock extends NodeMaterialBlock {
  51924. private _fogDistanceName;
  51925. private _fogParameters;
  51926. /**
  51927. * Create a new FogBlock
  51928. * @param name defines the block name
  51929. */
  51930. constructor(name: string);
  51931. /**
  51932. * Gets the current class name
  51933. * @returns the class name
  51934. */
  51935. getClassName(): string;
  51936. /**
  51937. * Gets the world position input component
  51938. */
  51939. readonly worldPosition: NodeMaterialConnectionPoint;
  51940. /**
  51941. * Gets the view input component
  51942. */
  51943. readonly view: NodeMaterialConnectionPoint;
  51944. /**
  51945. * Gets the color input component
  51946. */
  51947. readonly color: NodeMaterialConnectionPoint;
  51948. /**
  51949. * Gets the fog color input component
  51950. */
  51951. readonly fogColor: NodeMaterialConnectionPoint;
  51952. /**
  51953. * Gets the output component
  51954. */
  51955. readonly output: NodeMaterialConnectionPoint;
  51956. autoConfigure(): void;
  51957. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51959. protected _buildBlock(state: NodeMaterialBuildState): this;
  51960. }
  51961. }
  51962. declare module BABYLON {
  51963. /**
  51964. * Block used to add light in the fragment shader
  51965. */
  51966. export class LightBlock extends NodeMaterialBlock {
  51967. private _lightId;
  51968. /**
  51969. * Gets or sets the light associated with this block
  51970. */
  51971. light: Nullable<Light>;
  51972. /**
  51973. * Create a new LightBlock
  51974. * @param name defines the block name
  51975. */
  51976. constructor(name: string);
  51977. /**
  51978. * Gets the current class name
  51979. * @returns the class name
  51980. */
  51981. getClassName(): string;
  51982. /**
  51983. * Gets the world position input component
  51984. */
  51985. readonly worldPosition: NodeMaterialConnectionPoint;
  51986. /**
  51987. * Gets the world normal input component
  51988. */
  51989. readonly worldNormal: NodeMaterialConnectionPoint;
  51990. /**
  51991. * Gets the camera (or eye) position component
  51992. */
  51993. readonly cameraPosition: NodeMaterialConnectionPoint;
  51994. /**
  51995. * Gets the diffuse output component
  51996. */
  51997. readonly diffuseOutput: NodeMaterialConnectionPoint;
  51998. /**
  51999. * Gets the specular output component
  52000. */
  52001. readonly specularOutput: NodeMaterialConnectionPoint;
  52002. autoConfigure(): void;
  52003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52004. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52005. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52006. private _injectVertexCode;
  52007. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52008. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52009. }
  52010. }
  52011. declare module BABYLON {
  52012. /**
  52013. * Block used to multiply 2 values
  52014. */
  52015. export class MultiplyBlock extends NodeMaterialBlock {
  52016. /**
  52017. * Creates a new MultiplyBlock
  52018. * @param name defines the block name
  52019. */
  52020. constructor(name: string);
  52021. /**
  52022. * Gets the current class name
  52023. * @returns the class name
  52024. */
  52025. getClassName(): string;
  52026. /**
  52027. * Gets the left operand input component
  52028. */
  52029. readonly left: NodeMaterialConnectionPoint;
  52030. /**
  52031. * Gets the right operand input component
  52032. */
  52033. readonly right: NodeMaterialConnectionPoint;
  52034. /**
  52035. * Gets the output component
  52036. */
  52037. readonly output: NodeMaterialConnectionPoint;
  52038. protected _buildBlock(state: NodeMaterialBuildState): this;
  52039. }
  52040. }
  52041. declare module BABYLON {
  52042. /**
  52043. * Block used to add 2 vectors
  52044. */
  52045. export class AddBlock extends NodeMaterialBlock {
  52046. /**
  52047. * Creates a new AddBlock
  52048. * @param name defines the block name
  52049. */
  52050. constructor(name: string);
  52051. /**
  52052. * Gets the current class name
  52053. * @returns the class name
  52054. */
  52055. getClassName(): string;
  52056. /**
  52057. * Gets the left operand input component
  52058. */
  52059. readonly left: NodeMaterialConnectionPoint;
  52060. /**
  52061. * Gets the right operand input component
  52062. */
  52063. readonly right: NodeMaterialConnectionPoint;
  52064. /**
  52065. * Gets the output component
  52066. */
  52067. readonly output: NodeMaterialConnectionPoint;
  52068. protected _buildBlock(state: NodeMaterialBuildState): this;
  52069. }
  52070. }
  52071. declare module BABYLON {
  52072. /**
  52073. * Block used to clamp a float
  52074. */
  52075. export class ClampBlock extends NodeMaterialBlock {
  52076. /** Gets or sets the minimum range */
  52077. minimum: number;
  52078. /** Gets or sets the maximum range */
  52079. maximum: number;
  52080. /**
  52081. * Creates a new ClampBlock
  52082. * @param name defines the block name
  52083. */
  52084. constructor(name: string);
  52085. /**
  52086. * Gets the current class name
  52087. * @returns the class name
  52088. */
  52089. getClassName(): string;
  52090. /**
  52091. * Gets the value input component
  52092. */
  52093. readonly value: NodeMaterialConnectionPoint;
  52094. /**
  52095. * Gets the output component
  52096. */
  52097. readonly output: NodeMaterialConnectionPoint;
  52098. protected _buildBlock(state: NodeMaterialBuildState): this;
  52099. }
  52100. }
  52101. declare module BABYLON {
  52102. /**
  52103. * Block used to apply a cross product between 2 vectors
  52104. */
  52105. export class CrossBlock extends NodeMaterialBlock {
  52106. /**
  52107. * Creates a new CrossBlock
  52108. * @param name defines the block name
  52109. */
  52110. constructor(name: string);
  52111. /**
  52112. * Gets the current class name
  52113. * @returns the class name
  52114. */
  52115. getClassName(): string;
  52116. /**
  52117. * Gets the left operand input component
  52118. */
  52119. readonly left: NodeMaterialConnectionPoint;
  52120. /**
  52121. * Gets the right operand input component
  52122. */
  52123. readonly right: NodeMaterialConnectionPoint;
  52124. /**
  52125. * Gets the output component
  52126. */
  52127. readonly output: NodeMaterialConnectionPoint;
  52128. protected _buildBlock(state: NodeMaterialBuildState): this;
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /**
  52133. * Block used to apply a dot product between 2 vectors
  52134. */
  52135. export class DotBlock extends NodeMaterialBlock {
  52136. /**
  52137. * Creates a new DotBlock
  52138. * @param name defines the block name
  52139. */
  52140. constructor(name: string);
  52141. /**
  52142. * Gets the current class name
  52143. * @returns the class name
  52144. */
  52145. getClassName(): string;
  52146. /**
  52147. * Gets the left operand input component
  52148. */
  52149. readonly left: NodeMaterialConnectionPoint;
  52150. /**
  52151. * Gets the right operand input component
  52152. */
  52153. readonly right: NodeMaterialConnectionPoint;
  52154. /**
  52155. * Gets the output component
  52156. */
  52157. readonly output: NodeMaterialConnectionPoint;
  52158. protected _buildBlock(state: NodeMaterialBuildState): this;
  52159. }
  52160. }
  52161. declare module BABYLON {
  52162. /**
  52163. * Block used to remap a float from a range to a new one
  52164. */
  52165. export class RemapBlock extends NodeMaterialBlock {
  52166. /**
  52167. * Gets or sets the source range
  52168. */
  52169. sourceRange: Vector2;
  52170. /**
  52171. * Gets or sets the target range
  52172. */
  52173. targetRange: Vector2;
  52174. /**
  52175. * Creates a new RemapBlock
  52176. * @param name defines the block name
  52177. */
  52178. constructor(name: string);
  52179. /**
  52180. * Gets the current class name
  52181. * @returns the class name
  52182. */
  52183. getClassName(): string;
  52184. /**
  52185. * Gets the input component
  52186. */
  52187. readonly input: NodeMaterialConnectionPoint;
  52188. /**
  52189. * Gets the output component
  52190. */
  52191. readonly output: NodeMaterialConnectionPoint;
  52192. protected _buildBlock(state: NodeMaterialBuildState): this;
  52193. }
  52194. }
  52195. declare module BABYLON {
  52196. /**
  52197. * Block used to normalize a vector
  52198. */
  52199. export class NormalizeBlock extends NodeMaterialBlock {
  52200. /**
  52201. * Creates a new NormalizeBlock
  52202. * @param name defines the block name
  52203. */
  52204. constructor(name: string);
  52205. /**
  52206. * Gets the current class name
  52207. * @returns the class name
  52208. */
  52209. getClassName(): string;
  52210. /**
  52211. * Gets the input component
  52212. */
  52213. readonly input: NodeMaterialConnectionPoint;
  52214. /**
  52215. * Gets the output component
  52216. */
  52217. readonly output: NodeMaterialConnectionPoint;
  52218. protected _buildBlock(state: NodeMaterialBuildState): this;
  52219. }
  52220. }
  52221. declare module BABYLON {
  52222. /**
  52223. * Effect Render Options
  52224. */
  52225. export interface IEffectRendererOptions {
  52226. /**
  52227. * Defines the vertices positions.
  52228. */
  52229. positions?: number[];
  52230. /**
  52231. * Defines the indices.
  52232. */
  52233. indices?: number[];
  52234. }
  52235. /**
  52236. * Helper class to render one or more effects
  52237. */
  52238. export class EffectRenderer {
  52239. private engine;
  52240. private static _DefaultOptions;
  52241. private _vertexBuffers;
  52242. private _indexBuffer;
  52243. private _ringBufferIndex;
  52244. private _ringScreenBuffer;
  52245. private _fullscreenViewport;
  52246. private _getNextFrameBuffer;
  52247. /**
  52248. * Creates an effect renderer
  52249. * @param engine the engine to use for rendering
  52250. * @param options defines the options of the effect renderer
  52251. */
  52252. constructor(engine: Engine, options?: IEffectRendererOptions);
  52253. /**
  52254. * Sets the current viewport in normalized coordinates 0-1
  52255. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  52256. */
  52257. setViewport(viewport?: Viewport): void;
  52258. /**
  52259. * Sets the current effect wrapper to use during draw.
  52260. * The effect needs to be ready before calling this api.
  52261. * This also sets the default full screen position attribute.
  52262. * @param effectWrapper Defines the effect to draw with
  52263. */
  52264. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  52265. /**
  52266. * Draws a full screen quad.
  52267. */
  52268. draw(): void;
  52269. /**
  52270. * renders one or more effects to a specified texture
  52271. * @param effectWrappers list of effects to renderer
  52272. * @param outputTexture texture to draw to, if null it will render to the screen
  52273. */
  52274. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52275. /**
  52276. * Disposes of the effect renderer
  52277. */
  52278. dispose(): void;
  52279. }
  52280. /**
  52281. * Options to create an EffectWrapper
  52282. */
  52283. interface EffectWrapperCreationOptions {
  52284. /**
  52285. * Engine to use to create the effect
  52286. */
  52287. engine: Engine;
  52288. /**
  52289. * Fragment shader for the effect
  52290. */
  52291. fragmentShader: string;
  52292. /**
  52293. * Vertex shader for the effect
  52294. */
  52295. vertexShader: string;
  52296. /**
  52297. * Attributes to use in the shader
  52298. */
  52299. attributeNames?: Array<string>;
  52300. /**
  52301. * Uniforms to use in the shader
  52302. */
  52303. uniformNames?: Array<string>;
  52304. /**
  52305. * Texture sampler names to use in the shader
  52306. */
  52307. samplerNames?: Array<string>;
  52308. /**
  52309. * The friendly name of the effect displayed in Spector.
  52310. */
  52311. name?: string;
  52312. }
  52313. /**
  52314. * Wraps an effect to be used for rendering
  52315. */
  52316. export class EffectWrapper {
  52317. /**
  52318. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52319. */
  52320. onApplyObservable: Observable<{}>;
  52321. /**
  52322. * The underlying effect
  52323. */
  52324. effect: Effect;
  52325. /**
  52326. * Creates an effect to be renderer
  52327. * @param creationOptions options to create the effect
  52328. */
  52329. constructor(creationOptions: EffectWrapperCreationOptions);
  52330. /**
  52331. * Disposes of the effect wrapper
  52332. */
  52333. dispose(): void;
  52334. }
  52335. }
  52336. declare module BABYLON {
  52337. /**
  52338. * Helper class to push actions to a pool of workers.
  52339. */
  52340. export class WorkerPool implements IDisposable {
  52341. private _workerInfos;
  52342. private _pendingActions;
  52343. /**
  52344. * Constructor
  52345. * @param workers Array of workers to use for actions
  52346. */
  52347. constructor(workers: Array<Worker>);
  52348. /**
  52349. * Terminates all workers and clears any pending actions.
  52350. */
  52351. dispose(): void;
  52352. /**
  52353. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52354. * pended until a worker has completed its action.
  52355. * @param action The action to perform. Call onComplete when the action is complete.
  52356. */
  52357. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52358. private _execute;
  52359. }
  52360. }
  52361. declare module BABYLON {
  52362. /**
  52363. * Configuration for Draco compression
  52364. */
  52365. export interface IDracoCompressionConfiguration {
  52366. /**
  52367. * Configuration for the decoder.
  52368. */
  52369. decoder: {
  52370. /**
  52371. * The url to the WebAssembly module.
  52372. */
  52373. wasmUrl?: string;
  52374. /**
  52375. * The url to the WebAssembly binary.
  52376. */
  52377. wasmBinaryUrl?: string;
  52378. /**
  52379. * The url to the fallback JavaScript module.
  52380. */
  52381. fallbackUrl?: string;
  52382. };
  52383. }
  52384. /**
  52385. * Draco compression (https://google.github.io/draco/)
  52386. *
  52387. * This class wraps the Draco module.
  52388. *
  52389. * **Encoder**
  52390. *
  52391. * The encoder is not currently implemented.
  52392. *
  52393. * **Decoder**
  52394. *
  52395. * 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.
  52396. *
  52397. * To update the configuration, use the following code:
  52398. * ```javascript
  52399. * DracoCompression.Configuration = {
  52400. * decoder: {
  52401. * wasmUrl: "<url to the WebAssembly library>",
  52402. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52403. * fallbackUrl: "<url to the fallback JavaScript library>",
  52404. * }
  52405. * };
  52406. * ```
  52407. *
  52408. * 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.
  52409. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52410. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52411. *
  52412. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52413. * ```javascript
  52414. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52415. * ```
  52416. *
  52417. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52418. */
  52419. export class DracoCompression implements IDisposable {
  52420. private _workerPoolPromise?;
  52421. private _decoderModulePromise?;
  52422. /**
  52423. * The configuration. Defaults to the following urls:
  52424. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52425. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52426. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52427. */
  52428. static Configuration: IDracoCompressionConfiguration;
  52429. /**
  52430. * Returns true if the decoder configuration is available.
  52431. */
  52432. static readonly DecoderAvailable: boolean;
  52433. /**
  52434. * Default number of workers to create when creating the draco compression object.
  52435. */
  52436. static DefaultNumWorkers: number;
  52437. private static GetDefaultNumWorkers;
  52438. private static _Default;
  52439. /**
  52440. * Default instance for the draco compression object.
  52441. */
  52442. static readonly Default: DracoCompression;
  52443. /**
  52444. * Constructor
  52445. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52446. */
  52447. constructor(numWorkers?: number);
  52448. /**
  52449. * Stop all async operations and release resources.
  52450. */
  52451. dispose(): void;
  52452. /**
  52453. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52454. * @returns a promise that resolves when ready
  52455. */
  52456. whenReadyAsync(): Promise<void>;
  52457. /**
  52458. * Decode Draco compressed mesh data to vertex data.
  52459. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52460. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52461. * @returns A promise that resolves with the decoded vertex data
  52462. */
  52463. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52464. [kind: string]: number;
  52465. }): Promise<VertexData>;
  52466. }
  52467. }
  52468. declare module BABYLON {
  52469. /**
  52470. * Class for building Constructive Solid Geometry
  52471. */
  52472. export class CSG {
  52473. private polygons;
  52474. /**
  52475. * The world matrix
  52476. */
  52477. matrix: Matrix;
  52478. /**
  52479. * Stores the position
  52480. */
  52481. position: Vector3;
  52482. /**
  52483. * Stores the rotation
  52484. */
  52485. rotation: Vector3;
  52486. /**
  52487. * Stores the rotation quaternion
  52488. */
  52489. rotationQuaternion: Nullable<Quaternion>;
  52490. /**
  52491. * Stores the scaling vector
  52492. */
  52493. scaling: Vector3;
  52494. /**
  52495. * Convert the Mesh to CSG
  52496. * @param mesh The Mesh to convert to CSG
  52497. * @returns A new CSG from the Mesh
  52498. */
  52499. static FromMesh(mesh: Mesh): CSG;
  52500. /**
  52501. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52502. * @param polygons Polygons used to construct a CSG solid
  52503. */
  52504. private static FromPolygons;
  52505. /**
  52506. * Clones, or makes a deep copy, of the CSG
  52507. * @returns A new CSG
  52508. */
  52509. clone(): CSG;
  52510. /**
  52511. * Unions this CSG with another CSG
  52512. * @param csg The CSG to union against this CSG
  52513. * @returns The unioned CSG
  52514. */
  52515. union(csg: CSG): CSG;
  52516. /**
  52517. * Unions this CSG with another CSG in place
  52518. * @param csg The CSG to union against this CSG
  52519. */
  52520. unionInPlace(csg: CSG): void;
  52521. /**
  52522. * Subtracts this CSG with another CSG
  52523. * @param csg The CSG to subtract against this CSG
  52524. * @returns A new CSG
  52525. */
  52526. subtract(csg: CSG): CSG;
  52527. /**
  52528. * Subtracts this CSG with another CSG in place
  52529. * @param csg The CSG to subtact against this CSG
  52530. */
  52531. subtractInPlace(csg: CSG): void;
  52532. /**
  52533. * Intersect this CSG with another CSG
  52534. * @param csg The CSG to intersect against this CSG
  52535. * @returns A new CSG
  52536. */
  52537. intersect(csg: CSG): CSG;
  52538. /**
  52539. * Intersects this CSG with another CSG in place
  52540. * @param csg The CSG to intersect against this CSG
  52541. */
  52542. intersectInPlace(csg: CSG): void;
  52543. /**
  52544. * Return a new CSG solid with solid and empty space switched. This solid is
  52545. * not modified.
  52546. * @returns A new CSG solid with solid and empty space switched
  52547. */
  52548. inverse(): CSG;
  52549. /**
  52550. * Inverses the CSG in place
  52551. */
  52552. inverseInPlace(): void;
  52553. /**
  52554. * This is used to keep meshes transformations so they can be restored
  52555. * when we build back a Babylon Mesh
  52556. * NB : All CSG operations are performed in world coordinates
  52557. * @param csg The CSG to copy the transform attributes from
  52558. * @returns This CSG
  52559. */
  52560. copyTransformAttributes(csg: CSG): CSG;
  52561. /**
  52562. * Build Raw mesh from CSG
  52563. * Coordinates here are in world space
  52564. * @param name The name of the mesh geometry
  52565. * @param scene The Scene
  52566. * @param keepSubMeshes Specifies if the submeshes should be kept
  52567. * @returns A new Mesh
  52568. */
  52569. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52570. /**
  52571. * Build Mesh from CSG taking material and transforms into account
  52572. * @param name The name of the Mesh
  52573. * @param material The material of the Mesh
  52574. * @param scene The Scene
  52575. * @param keepSubMeshes Specifies if submeshes should be kept
  52576. * @returns The new Mesh
  52577. */
  52578. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52579. }
  52580. }
  52581. declare module BABYLON {
  52582. /**
  52583. * Class used to create a trail following a mesh
  52584. */
  52585. export class TrailMesh extends Mesh {
  52586. private _generator;
  52587. private _autoStart;
  52588. private _running;
  52589. private _diameter;
  52590. private _length;
  52591. private _sectionPolygonPointsCount;
  52592. private _sectionVectors;
  52593. private _sectionNormalVectors;
  52594. private _beforeRenderObserver;
  52595. /**
  52596. * @constructor
  52597. * @param name The value used by scene.getMeshByName() to do a lookup.
  52598. * @param generator The mesh to generate a trail.
  52599. * @param scene The scene to add this mesh to.
  52600. * @param diameter Diameter of trailing mesh. Default is 1.
  52601. * @param length Length of trailing mesh. Default is 60.
  52602. * @param autoStart Automatically start trailing mesh. Default true.
  52603. */
  52604. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52605. /**
  52606. * "TrailMesh"
  52607. * @returns "TrailMesh"
  52608. */
  52609. getClassName(): string;
  52610. private _createMesh;
  52611. /**
  52612. * Start trailing mesh.
  52613. */
  52614. start(): void;
  52615. /**
  52616. * Stop trailing mesh.
  52617. */
  52618. stop(): void;
  52619. /**
  52620. * Update trailing mesh geometry.
  52621. */
  52622. update(): void;
  52623. /**
  52624. * Returns a new TrailMesh object.
  52625. * @param name is a string, the name given to the new mesh
  52626. * @param newGenerator use new generator object for cloned trail mesh
  52627. * @returns a new mesh
  52628. */
  52629. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52630. /**
  52631. * Serializes this trail mesh
  52632. * @param serializationObject object to write serialization to
  52633. */
  52634. serialize(serializationObject: any): void;
  52635. /**
  52636. * Parses a serialized trail mesh
  52637. * @param parsedMesh the serialized mesh
  52638. * @param scene the scene to create the trail mesh in
  52639. * @returns the created trail mesh
  52640. */
  52641. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52642. }
  52643. }
  52644. declare module BABYLON {
  52645. /**
  52646. * Class containing static functions to help procedurally build meshes
  52647. */
  52648. export class TiledBoxBuilder {
  52649. /**
  52650. * Creates a box mesh
  52651. * 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)
  52652. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52654. * * 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
  52655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52656. * @param name defines the name of the mesh
  52657. * @param options defines the options used to create the mesh
  52658. * @param scene defines the hosting scene
  52659. * @returns the box mesh
  52660. */
  52661. static CreateTiledBox(name: string, options: {
  52662. pattern?: number;
  52663. width?: number;
  52664. height?: number;
  52665. depth?: number;
  52666. tileSize?: number;
  52667. tileWidth?: number;
  52668. tileHeight?: number;
  52669. alignHorizontal?: number;
  52670. alignVertical?: number;
  52671. faceUV?: Vector4[];
  52672. faceColors?: Color4[];
  52673. sideOrientation?: number;
  52674. updatable?: boolean;
  52675. }, scene?: Nullable<Scene>): Mesh;
  52676. }
  52677. }
  52678. declare module BABYLON {
  52679. /**
  52680. * Class containing static functions to help procedurally build meshes
  52681. */
  52682. export class TorusKnotBuilder {
  52683. /**
  52684. * Creates a torus knot mesh
  52685. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52686. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52687. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52688. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52690. * * 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
  52691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52692. * @param name defines the name of the mesh
  52693. * @param options defines the options used to create the mesh
  52694. * @param scene defines the hosting scene
  52695. * @returns the torus knot mesh
  52696. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52697. */
  52698. static CreateTorusKnot(name: string, options: {
  52699. radius?: number;
  52700. tube?: number;
  52701. radialSegments?: number;
  52702. tubularSegments?: number;
  52703. p?: number;
  52704. q?: number;
  52705. updatable?: boolean;
  52706. sideOrientation?: number;
  52707. frontUVs?: Vector4;
  52708. backUVs?: Vector4;
  52709. }, scene: any): Mesh;
  52710. }
  52711. }
  52712. declare module BABYLON {
  52713. /**
  52714. * Polygon
  52715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52716. */
  52717. export class Polygon {
  52718. /**
  52719. * Creates a rectangle
  52720. * @param xmin bottom X coord
  52721. * @param ymin bottom Y coord
  52722. * @param xmax top X coord
  52723. * @param ymax top Y coord
  52724. * @returns points that make the resulting rectation
  52725. */
  52726. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52727. /**
  52728. * Creates a circle
  52729. * @param radius radius of circle
  52730. * @param cx scale in x
  52731. * @param cy scale in y
  52732. * @param numberOfSides number of sides that make up the circle
  52733. * @returns points that make the resulting circle
  52734. */
  52735. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52736. /**
  52737. * Creates a polygon from input string
  52738. * @param input Input polygon data
  52739. * @returns the parsed points
  52740. */
  52741. static Parse(input: string): Vector2[];
  52742. /**
  52743. * Starts building a polygon from x and y coordinates
  52744. * @param x x coordinate
  52745. * @param y y coordinate
  52746. * @returns the started path2
  52747. */
  52748. static StartingAt(x: number, y: number): Path2;
  52749. }
  52750. /**
  52751. * Builds a polygon
  52752. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52753. */
  52754. export class PolygonMeshBuilder {
  52755. private _points;
  52756. private _outlinepoints;
  52757. private _holes;
  52758. private _name;
  52759. private _scene;
  52760. private _epoints;
  52761. private _eholes;
  52762. private _addToepoint;
  52763. /**
  52764. * Babylon reference to the earcut plugin.
  52765. */
  52766. bjsEarcut: any;
  52767. /**
  52768. * Creates a PolygonMeshBuilder
  52769. * @param name name of the builder
  52770. * @param contours Path of the polygon
  52771. * @param scene scene to add to when creating the mesh
  52772. * @param earcutInjection can be used to inject your own earcut reference
  52773. */
  52774. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52775. /**
  52776. * Adds a whole within the polygon
  52777. * @param hole Array of points defining the hole
  52778. * @returns this
  52779. */
  52780. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52781. /**
  52782. * Creates the polygon
  52783. * @param updatable If the mesh should be updatable
  52784. * @param depth The depth of the mesh created
  52785. * @returns the created mesh
  52786. */
  52787. build(updatable?: boolean, depth?: number): Mesh;
  52788. /**
  52789. * Creates the polygon
  52790. * @param depth The depth of the mesh created
  52791. * @returns the created VertexData
  52792. */
  52793. buildVertexData(depth?: number): VertexData;
  52794. /**
  52795. * Adds a side to the polygon
  52796. * @param positions points that make the polygon
  52797. * @param normals normals of the polygon
  52798. * @param uvs uvs of the polygon
  52799. * @param indices indices of the polygon
  52800. * @param bounds bounds of the polygon
  52801. * @param points points of the polygon
  52802. * @param depth depth of the polygon
  52803. * @param flip flip of the polygon
  52804. */
  52805. private addSide;
  52806. }
  52807. }
  52808. declare module BABYLON {
  52809. /**
  52810. * Class containing static functions to help procedurally build meshes
  52811. */
  52812. export class PolygonBuilder {
  52813. /**
  52814. * Creates a polygon mesh
  52815. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52816. * * 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
  52817. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52819. * * 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)
  52820. * * Remember you can only change the shape positions, not their number when updating a polygon
  52821. * @param name defines the name of the mesh
  52822. * @param options defines the options used to create the mesh
  52823. * @param scene defines the hosting scene
  52824. * @param earcutInjection can be used to inject your own earcut reference
  52825. * @returns the polygon mesh
  52826. */
  52827. static CreatePolygon(name: string, options: {
  52828. shape: Vector3[];
  52829. holes?: Vector3[][];
  52830. depth?: number;
  52831. faceUV?: Vector4[];
  52832. faceColors?: Color4[];
  52833. updatable?: boolean;
  52834. sideOrientation?: number;
  52835. frontUVs?: Vector4;
  52836. backUVs?: Vector4;
  52837. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52838. /**
  52839. * Creates an extruded polygon mesh, with depth in the Y direction.
  52840. * * 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)
  52841. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52842. * @param name defines the name of the mesh
  52843. * @param options defines the options used to create the mesh
  52844. * @param scene defines the hosting scene
  52845. * @param earcutInjection can be used to inject your own earcut reference
  52846. * @returns the polygon mesh
  52847. */
  52848. static ExtrudePolygon(name: string, options: {
  52849. shape: Vector3[];
  52850. holes?: Vector3[][];
  52851. depth?: number;
  52852. faceUV?: Vector4[];
  52853. faceColors?: Color4[];
  52854. updatable?: boolean;
  52855. sideOrientation?: number;
  52856. frontUVs?: Vector4;
  52857. backUVs?: Vector4;
  52858. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52859. }
  52860. }
  52861. declare module BABYLON {
  52862. /**
  52863. * Class containing static functions to help procedurally build meshes
  52864. */
  52865. export class LatheBuilder {
  52866. /**
  52867. * Creates lathe mesh.
  52868. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52869. * * 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
  52870. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52871. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52872. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52873. * * 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
  52874. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52875. * * 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
  52876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52877. * * 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
  52878. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52880. * @param name defines the name of the mesh
  52881. * @param options defines the options used to create the mesh
  52882. * @param scene defines the hosting scene
  52883. * @returns the lathe mesh
  52884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52885. */
  52886. static CreateLathe(name: string, options: {
  52887. shape: Vector3[];
  52888. radius?: number;
  52889. tessellation?: number;
  52890. clip?: number;
  52891. arc?: number;
  52892. closed?: boolean;
  52893. updatable?: boolean;
  52894. sideOrientation?: number;
  52895. frontUVs?: Vector4;
  52896. backUVs?: Vector4;
  52897. cap?: number;
  52898. invertUV?: boolean;
  52899. }, scene?: Nullable<Scene>): Mesh;
  52900. }
  52901. }
  52902. declare module BABYLON {
  52903. /**
  52904. * Class containing static functions to help procedurally build meshes
  52905. */
  52906. export class TiledPlaneBuilder {
  52907. /**
  52908. * Creates a tiled plane mesh
  52909. * * The parameter `pattern` will, depending on value, do nothing or
  52910. * * * flip (reflect about central vertical) alternate tiles across and up
  52911. * * * flip every tile on alternate rows
  52912. * * * rotate (180 degs) alternate tiles across and up
  52913. * * * rotate every tile on alternate rows
  52914. * * * flip and rotate alternate tiles across and up
  52915. * * * flip and rotate every tile on alternate rows
  52916. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52917. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52918. * * 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
  52919. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52920. * * 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)
  52921. * * 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)
  52922. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52923. * @param name defines the name of the mesh
  52924. * @param options defines the options used to create the mesh
  52925. * @param scene defines the hosting scene
  52926. * @returns the box mesh
  52927. */
  52928. static CreateTiledPlane(name: string, options: {
  52929. pattern?: number;
  52930. tileSize?: number;
  52931. tileWidth?: number;
  52932. tileHeight?: number;
  52933. size?: number;
  52934. width?: number;
  52935. height?: number;
  52936. alignHorizontal?: number;
  52937. alignVertical?: number;
  52938. sideOrientation?: number;
  52939. frontUVs?: Vector4;
  52940. backUVs?: Vector4;
  52941. updatable?: boolean;
  52942. }, scene?: Nullable<Scene>): Mesh;
  52943. }
  52944. }
  52945. declare module BABYLON {
  52946. /**
  52947. * Class containing static functions to help procedurally build meshes
  52948. */
  52949. export class TubeBuilder {
  52950. /**
  52951. * Creates a tube mesh.
  52952. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52953. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52954. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52955. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52956. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52957. * * 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)
  52958. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52959. * * 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
  52960. * * 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
  52961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52962. * * 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
  52963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52965. * @param name defines the name of the mesh
  52966. * @param options defines the options used to create the mesh
  52967. * @param scene defines the hosting scene
  52968. * @returns the tube mesh
  52969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52970. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52971. */
  52972. static CreateTube(name: string, options: {
  52973. path: Vector3[];
  52974. radius?: number;
  52975. tessellation?: number;
  52976. radiusFunction?: {
  52977. (i: number, distance: number): number;
  52978. };
  52979. cap?: number;
  52980. arc?: number;
  52981. updatable?: boolean;
  52982. sideOrientation?: number;
  52983. frontUVs?: Vector4;
  52984. backUVs?: Vector4;
  52985. instance?: Mesh;
  52986. invertUV?: boolean;
  52987. }, scene?: Nullable<Scene>): Mesh;
  52988. }
  52989. }
  52990. declare module BABYLON {
  52991. /**
  52992. * Class containing static functions to help procedurally build meshes
  52993. */
  52994. export class IcoSphereBuilder {
  52995. /**
  52996. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52997. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52998. * * 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`)
  52999. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53000. * * 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
  53001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53002. * * 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
  53003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53004. * @param name defines the name of the mesh
  53005. * @param options defines the options used to create the mesh
  53006. * @param scene defines the hosting scene
  53007. * @returns the icosahedron mesh
  53008. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53009. */
  53010. static CreateIcoSphere(name: string, options: {
  53011. radius?: number;
  53012. radiusX?: number;
  53013. radiusY?: number;
  53014. radiusZ?: number;
  53015. flat?: boolean;
  53016. subdivisions?: number;
  53017. sideOrientation?: number;
  53018. frontUVs?: Vector4;
  53019. backUVs?: Vector4;
  53020. updatable?: boolean;
  53021. }, scene?: Nullable<Scene>): Mesh;
  53022. }
  53023. }
  53024. declare module BABYLON {
  53025. /**
  53026. * Class containing static functions to help procedurally build meshes
  53027. */
  53028. export class DecalBuilder {
  53029. /**
  53030. * Creates a decal mesh.
  53031. * 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
  53032. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53033. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53034. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53035. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53036. * @param name defines the name of the mesh
  53037. * @param sourceMesh defines the mesh where the decal must be applied
  53038. * @param options defines the options used to create the mesh
  53039. * @param scene defines the hosting scene
  53040. * @returns the decal mesh
  53041. * @see https://doc.babylonjs.com/how_to/decals
  53042. */
  53043. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53044. position?: Vector3;
  53045. normal?: Vector3;
  53046. size?: Vector3;
  53047. angle?: number;
  53048. }): Mesh;
  53049. }
  53050. }
  53051. declare module BABYLON {
  53052. /**
  53053. * Class containing static functions to help procedurally build meshes
  53054. */
  53055. export class MeshBuilder {
  53056. /**
  53057. * Creates a box mesh
  53058. * * The parameter `size` sets the size (float) of each box side (default 1)
  53059. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53060. * * 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)
  53061. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53063. * * 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
  53064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53065. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53066. * @param name defines the name of the mesh
  53067. * @param options defines the options used to create the mesh
  53068. * @param scene defines the hosting scene
  53069. * @returns the box mesh
  53070. */
  53071. static CreateBox(name: string, options: {
  53072. size?: number;
  53073. width?: number;
  53074. height?: number;
  53075. depth?: number;
  53076. faceUV?: Vector4[];
  53077. faceColors?: Color4[];
  53078. sideOrientation?: number;
  53079. frontUVs?: Vector4;
  53080. backUVs?: Vector4;
  53081. updatable?: boolean;
  53082. }, scene?: Nullable<Scene>): Mesh;
  53083. /**
  53084. * Creates a tiled box mesh
  53085. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53087. * @param name defines the name of the mesh
  53088. * @param options defines the options used to create the mesh
  53089. * @param scene defines the hosting scene
  53090. * @returns the tiled box mesh
  53091. */
  53092. static CreateTiledBox(name: string, options: {
  53093. pattern?: number;
  53094. size?: number;
  53095. width?: number;
  53096. height?: number;
  53097. depth: number;
  53098. tileSize?: number;
  53099. tileWidth?: number;
  53100. tileHeight?: number;
  53101. faceUV?: Vector4[];
  53102. faceColors?: Color4[];
  53103. alignHorizontal?: number;
  53104. alignVertical?: number;
  53105. sideOrientation?: number;
  53106. updatable?: boolean;
  53107. }, scene?: Nullable<Scene>): Mesh;
  53108. /**
  53109. * Creates a sphere mesh
  53110. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53111. * * 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`)
  53112. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53113. * * 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
  53114. * * 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)
  53115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53116. * * 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
  53117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53118. * @param name defines the name of the mesh
  53119. * @param options defines the options used to create the mesh
  53120. * @param scene defines the hosting scene
  53121. * @returns the sphere mesh
  53122. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53123. */
  53124. static CreateSphere(name: string, options: {
  53125. segments?: number;
  53126. diameter?: number;
  53127. diameterX?: number;
  53128. diameterY?: number;
  53129. diameterZ?: number;
  53130. arc?: number;
  53131. slice?: number;
  53132. sideOrientation?: number;
  53133. frontUVs?: Vector4;
  53134. backUVs?: Vector4;
  53135. updatable?: boolean;
  53136. }, scene?: Nullable<Scene>): Mesh;
  53137. /**
  53138. * Creates a plane polygonal mesh. By default, this is a disc
  53139. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53140. * * 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
  53141. * * 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
  53142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53143. * * 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
  53144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53145. * @param name defines the name of the mesh
  53146. * @param options defines the options used to create the mesh
  53147. * @param scene defines the hosting scene
  53148. * @returns the plane polygonal mesh
  53149. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53150. */
  53151. static CreateDisc(name: string, options: {
  53152. radius?: number;
  53153. tessellation?: number;
  53154. arc?: number;
  53155. updatable?: boolean;
  53156. sideOrientation?: number;
  53157. frontUVs?: Vector4;
  53158. backUVs?: Vector4;
  53159. }, scene?: Nullable<Scene>): Mesh;
  53160. /**
  53161. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53162. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53163. * * 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`)
  53164. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53165. * * 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
  53166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53167. * * 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
  53168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53169. * @param name defines the name of the mesh
  53170. * @param options defines the options used to create the mesh
  53171. * @param scene defines the hosting scene
  53172. * @returns the icosahedron mesh
  53173. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53174. */
  53175. static CreateIcoSphere(name: string, options: {
  53176. radius?: number;
  53177. radiusX?: number;
  53178. radiusY?: number;
  53179. radiusZ?: number;
  53180. flat?: boolean;
  53181. subdivisions?: number;
  53182. sideOrientation?: number;
  53183. frontUVs?: Vector4;
  53184. backUVs?: Vector4;
  53185. updatable?: boolean;
  53186. }, scene?: Nullable<Scene>): Mesh;
  53187. /**
  53188. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53189. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53190. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53191. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53192. * * 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
  53193. * * 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
  53194. * * 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
  53195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53196. * * 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
  53197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53198. * * 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
  53199. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53200. * * 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
  53201. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53203. * @param name defines the name of the mesh
  53204. * @param options defines the options used to create the mesh
  53205. * @param scene defines the hosting scene
  53206. * @returns the ribbon mesh
  53207. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53208. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53209. */
  53210. static CreateRibbon(name: string, options: {
  53211. pathArray: Vector3[][];
  53212. closeArray?: boolean;
  53213. closePath?: boolean;
  53214. offset?: number;
  53215. updatable?: boolean;
  53216. sideOrientation?: number;
  53217. frontUVs?: Vector4;
  53218. backUVs?: Vector4;
  53219. instance?: Mesh;
  53220. invertUV?: boolean;
  53221. uvs?: Vector2[];
  53222. colors?: Color4[];
  53223. }, scene?: Nullable<Scene>): Mesh;
  53224. /**
  53225. * Creates a cylinder or a cone mesh
  53226. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53227. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53228. * * 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.
  53229. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53230. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53231. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53232. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53233. * * 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).
  53234. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53235. * * 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).
  53236. * * 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
  53237. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53238. * * 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
  53239. * * 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.
  53240. * * If `enclose` is false, a ring surface is one element.
  53241. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53242. * * 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
  53243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53244. * * 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
  53245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53246. * @param name defines the name of the mesh
  53247. * @param options defines the options used to create the mesh
  53248. * @param scene defines the hosting scene
  53249. * @returns the cylinder mesh
  53250. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53251. */
  53252. static CreateCylinder(name: string, options: {
  53253. height?: number;
  53254. diameterTop?: number;
  53255. diameterBottom?: number;
  53256. diameter?: number;
  53257. tessellation?: number;
  53258. subdivisions?: number;
  53259. arc?: number;
  53260. faceColors?: Color4[];
  53261. faceUV?: Vector4[];
  53262. updatable?: boolean;
  53263. hasRings?: boolean;
  53264. enclose?: boolean;
  53265. cap?: number;
  53266. sideOrientation?: number;
  53267. frontUVs?: Vector4;
  53268. backUVs?: Vector4;
  53269. }, scene?: Nullable<Scene>): Mesh;
  53270. /**
  53271. * Creates a torus mesh
  53272. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53273. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53274. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53276. * * 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
  53277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53278. * @param name defines the name of the mesh
  53279. * @param options defines the options used to create the mesh
  53280. * @param scene defines the hosting scene
  53281. * @returns the torus mesh
  53282. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53283. */
  53284. static CreateTorus(name: string, options: {
  53285. diameter?: number;
  53286. thickness?: number;
  53287. tessellation?: number;
  53288. updatable?: boolean;
  53289. sideOrientation?: number;
  53290. frontUVs?: Vector4;
  53291. backUVs?: Vector4;
  53292. }, scene?: Nullable<Scene>): Mesh;
  53293. /**
  53294. * Creates a torus knot mesh
  53295. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53296. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53297. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53298. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53300. * * 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
  53301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53302. * @param name defines the name of the mesh
  53303. * @param options defines the options used to create the mesh
  53304. * @param scene defines the hosting scene
  53305. * @returns the torus knot mesh
  53306. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53307. */
  53308. static CreateTorusKnot(name: string, options: {
  53309. radius?: number;
  53310. tube?: number;
  53311. radialSegments?: number;
  53312. tubularSegments?: number;
  53313. p?: number;
  53314. q?: number;
  53315. updatable?: boolean;
  53316. sideOrientation?: number;
  53317. frontUVs?: Vector4;
  53318. backUVs?: Vector4;
  53319. }, scene?: Nullable<Scene>): Mesh;
  53320. /**
  53321. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53322. * * 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
  53323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53324. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53325. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53326. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53327. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53328. * * 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
  53329. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53332. * @param name defines the name of the new line system
  53333. * @param options defines the options used to create the line system
  53334. * @param scene defines the hosting scene
  53335. * @returns a new line system mesh
  53336. */
  53337. static CreateLineSystem(name: string, options: {
  53338. lines: Vector3[][];
  53339. updatable?: boolean;
  53340. instance?: Nullable<LinesMesh>;
  53341. colors?: Nullable<Color4[][]>;
  53342. useVertexAlpha?: boolean;
  53343. }, scene: Nullable<Scene>): LinesMesh;
  53344. /**
  53345. * Creates a line mesh
  53346. * 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
  53347. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53348. * * The parameter `points` is an array successive Vector3
  53349. * * 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
  53350. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53351. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53352. * * When updating an instance, remember that only point positions can change, not the number of points
  53353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53355. * @param name defines the name of the new line system
  53356. * @param options defines the options used to create the line system
  53357. * @param scene defines the hosting scene
  53358. * @returns a new line mesh
  53359. */
  53360. static CreateLines(name: string, options: {
  53361. points: Vector3[];
  53362. updatable?: boolean;
  53363. instance?: Nullable<LinesMesh>;
  53364. colors?: Color4[];
  53365. useVertexAlpha?: boolean;
  53366. }, scene?: Nullable<Scene>): LinesMesh;
  53367. /**
  53368. * Creates a dashed line mesh
  53369. * * 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
  53370. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53371. * * The parameter `points` is an array successive Vector3
  53372. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53373. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53374. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53375. * * 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
  53376. * * When updating an instance, remember that only point positions can change, not the number of points
  53377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53378. * @param name defines the name of the mesh
  53379. * @param options defines the options used to create the mesh
  53380. * @param scene defines the hosting scene
  53381. * @returns the dashed line mesh
  53382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53383. */
  53384. static CreateDashedLines(name: string, options: {
  53385. points: Vector3[];
  53386. dashSize?: number;
  53387. gapSize?: number;
  53388. dashNb?: number;
  53389. updatable?: boolean;
  53390. instance?: LinesMesh;
  53391. }, scene?: Nullable<Scene>): LinesMesh;
  53392. /**
  53393. * 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.
  53394. * * 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.
  53395. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53396. * * 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.
  53397. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53398. * * 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
  53399. * * 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
  53400. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53402. * * 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
  53403. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53405. * @param name defines the name of the mesh
  53406. * @param options defines the options used to create the mesh
  53407. * @param scene defines the hosting scene
  53408. * @returns the extruded shape mesh
  53409. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53411. */
  53412. static ExtrudeShape(name: string, options: {
  53413. shape: Vector3[];
  53414. path: Vector3[];
  53415. scale?: number;
  53416. rotation?: number;
  53417. cap?: number;
  53418. updatable?: boolean;
  53419. sideOrientation?: number;
  53420. frontUVs?: Vector4;
  53421. backUVs?: Vector4;
  53422. instance?: Mesh;
  53423. invertUV?: boolean;
  53424. }, scene?: Nullable<Scene>): Mesh;
  53425. /**
  53426. * Creates an custom extruded shape mesh.
  53427. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53428. * * 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.
  53429. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53430. * * 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
  53431. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53432. * * 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
  53433. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53434. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53435. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53436. * * 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
  53437. * * 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
  53438. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53440. * * 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
  53441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53443. * @param name defines the name of the mesh
  53444. * @param options defines the options used to create the mesh
  53445. * @param scene defines the hosting scene
  53446. * @returns the custom extruded shape mesh
  53447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53450. */
  53451. static ExtrudeShapeCustom(name: string, options: {
  53452. shape: Vector3[];
  53453. path: Vector3[];
  53454. scaleFunction?: any;
  53455. rotationFunction?: any;
  53456. ribbonCloseArray?: boolean;
  53457. ribbonClosePath?: boolean;
  53458. cap?: number;
  53459. updatable?: boolean;
  53460. sideOrientation?: number;
  53461. frontUVs?: Vector4;
  53462. backUVs?: Vector4;
  53463. instance?: Mesh;
  53464. invertUV?: boolean;
  53465. }, scene?: Nullable<Scene>): Mesh;
  53466. /**
  53467. * Creates lathe mesh.
  53468. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53469. * * 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
  53470. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53471. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53472. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53473. * * 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
  53474. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53475. * * 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
  53476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53477. * * 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
  53478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53480. * @param name defines the name of the mesh
  53481. * @param options defines the options used to create the mesh
  53482. * @param scene defines the hosting scene
  53483. * @returns the lathe mesh
  53484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53485. */
  53486. static CreateLathe(name: string, options: {
  53487. shape: Vector3[];
  53488. radius?: number;
  53489. tessellation?: number;
  53490. clip?: number;
  53491. arc?: number;
  53492. closed?: boolean;
  53493. updatable?: boolean;
  53494. sideOrientation?: number;
  53495. frontUVs?: Vector4;
  53496. backUVs?: Vector4;
  53497. cap?: number;
  53498. invertUV?: boolean;
  53499. }, scene?: Nullable<Scene>): Mesh;
  53500. /**
  53501. * Creates a tiled plane mesh
  53502. * * You can set a limited pattern arrangement with the tiles
  53503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53506. * @param name defines the name of the mesh
  53507. * @param options defines the options used to create the mesh
  53508. * @param scene defines the hosting scene
  53509. * @returns the plane mesh
  53510. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53511. */
  53512. static CreateTiledPlane(name: string, options: {
  53513. pattern?: number;
  53514. tileSize?: number;
  53515. tileWidth?: number;
  53516. tileHeight?: number;
  53517. size?: number;
  53518. width?: number;
  53519. height?: number;
  53520. alignHorizontal?: number;
  53521. alignVertical?: number;
  53522. sideOrientation?: number;
  53523. frontUVs?: Vector4;
  53524. backUVs?: Vector4;
  53525. updatable?: boolean;
  53526. }, scene?: Nullable<Scene>): Mesh;
  53527. /**
  53528. * Creates a plane mesh
  53529. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53530. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53531. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53533. * * 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
  53534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53535. * @param name defines the name of the mesh
  53536. * @param options defines the options used to create the mesh
  53537. * @param scene defines the hosting scene
  53538. * @returns the plane mesh
  53539. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53540. */
  53541. static CreatePlane(name: string, options: {
  53542. size?: number;
  53543. width?: number;
  53544. height?: number;
  53545. sideOrientation?: number;
  53546. frontUVs?: Vector4;
  53547. backUVs?: Vector4;
  53548. updatable?: boolean;
  53549. sourcePlane?: Plane;
  53550. }, scene?: Nullable<Scene>): Mesh;
  53551. /**
  53552. * Creates a ground mesh
  53553. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53554. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53556. * @param name defines the name of the mesh
  53557. * @param options defines the options used to create the mesh
  53558. * @param scene defines the hosting scene
  53559. * @returns the ground mesh
  53560. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53561. */
  53562. static CreateGround(name: string, options: {
  53563. width?: number;
  53564. height?: number;
  53565. subdivisions?: number;
  53566. subdivisionsX?: number;
  53567. subdivisionsY?: number;
  53568. updatable?: boolean;
  53569. }, scene?: Nullable<Scene>): Mesh;
  53570. /**
  53571. * Creates a tiled ground mesh
  53572. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53573. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53574. * * 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
  53575. * * 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
  53576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53577. * @param name defines the name of the mesh
  53578. * @param options defines the options used to create the mesh
  53579. * @param scene defines the hosting scene
  53580. * @returns the tiled ground mesh
  53581. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53582. */
  53583. static CreateTiledGround(name: string, options: {
  53584. xmin: number;
  53585. zmin: number;
  53586. xmax: number;
  53587. zmax: number;
  53588. subdivisions?: {
  53589. w: number;
  53590. h: number;
  53591. };
  53592. precision?: {
  53593. w: number;
  53594. h: number;
  53595. };
  53596. updatable?: boolean;
  53597. }, scene?: Nullable<Scene>): Mesh;
  53598. /**
  53599. * Creates a ground mesh from a height map
  53600. * * The parameter `url` sets the URL of the height map image resource.
  53601. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53602. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53603. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53604. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53605. * * 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.
  53606. * * 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).
  53607. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53609. * @param name defines the name of the mesh
  53610. * @param url defines the url to the height map
  53611. * @param options defines the options used to create the mesh
  53612. * @param scene defines the hosting scene
  53613. * @returns the ground mesh
  53614. * @see https://doc.babylonjs.com/babylon101/height_map
  53615. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53616. */
  53617. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53618. width?: number;
  53619. height?: number;
  53620. subdivisions?: number;
  53621. minHeight?: number;
  53622. maxHeight?: number;
  53623. colorFilter?: Color3;
  53624. alphaFilter?: number;
  53625. updatable?: boolean;
  53626. onReady?: (mesh: GroundMesh) => void;
  53627. }, scene?: Nullable<Scene>): GroundMesh;
  53628. /**
  53629. * Creates a polygon mesh
  53630. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53631. * * 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
  53632. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53634. * * 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)
  53635. * * Remember you can only change the shape positions, not their number when updating a polygon
  53636. * @param name defines the name of the mesh
  53637. * @param options defines the options used to create the mesh
  53638. * @param scene defines the hosting scene
  53639. * @param earcutInjection can be used to inject your own earcut reference
  53640. * @returns the polygon mesh
  53641. */
  53642. static CreatePolygon(name: string, options: {
  53643. shape: Vector3[];
  53644. holes?: Vector3[][];
  53645. depth?: number;
  53646. faceUV?: Vector4[];
  53647. faceColors?: Color4[];
  53648. updatable?: boolean;
  53649. sideOrientation?: number;
  53650. frontUVs?: Vector4;
  53651. backUVs?: Vector4;
  53652. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53653. /**
  53654. * Creates an extruded polygon mesh, with depth in the Y direction.
  53655. * * 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)
  53656. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53657. * @param name defines the name of the mesh
  53658. * @param options defines the options used to create the mesh
  53659. * @param scene defines the hosting scene
  53660. * @param earcutInjection can be used to inject your own earcut reference
  53661. * @returns the polygon mesh
  53662. */
  53663. static ExtrudePolygon(name: string, options: {
  53664. shape: Vector3[];
  53665. holes?: Vector3[][];
  53666. depth?: number;
  53667. faceUV?: Vector4[];
  53668. faceColors?: Color4[];
  53669. updatable?: boolean;
  53670. sideOrientation?: number;
  53671. frontUVs?: Vector4;
  53672. backUVs?: Vector4;
  53673. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53674. /**
  53675. * Creates a tube mesh.
  53676. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53677. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53678. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53679. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53680. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53681. * * 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)
  53682. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53683. * * 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
  53684. * * 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
  53685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53686. * * 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
  53687. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53689. * @param name defines the name of the mesh
  53690. * @param options defines the options used to create the mesh
  53691. * @param scene defines the hosting scene
  53692. * @returns the tube mesh
  53693. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53694. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53695. */
  53696. static CreateTube(name: string, options: {
  53697. path: Vector3[];
  53698. radius?: number;
  53699. tessellation?: number;
  53700. radiusFunction?: {
  53701. (i: number, distance: number): number;
  53702. };
  53703. cap?: number;
  53704. arc?: number;
  53705. updatable?: boolean;
  53706. sideOrientation?: number;
  53707. frontUVs?: Vector4;
  53708. backUVs?: Vector4;
  53709. instance?: Mesh;
  53710. invertUV?: boolean;
  53711. }, scene?: Nullable<Scene>): Mesh;
  53712. /**
  53713. * Creates a polyhedron mesh
  53714. * * 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
  53715. * * The parameter `size` (positive float, default 1) sets the polygon size
  53716. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53717. * * 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`
  53718. * * 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
  53719. * * 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)`)
  53720. * * 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
  53721. * * 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
  53722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53723. * * 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
  53724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53725. * @param name defines the name of the mesh
  53726. * @param options defines the options used to create the mesh
  53727. * @param scene defines the hosting scene
  53728. * @returns the polyhedron mesh
  53729. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53730. */
  53731. static CreatePolyhedron(name: string, options: {
  53732. type?: number;
  53733. size?: number;
  53734. sizeX?: number;
  53735. sizeY?: number;
  53736. sizeZ?: number;
  53737. custom?: any;
  53738. faceUV?: Vector4[];
  53739. faceColors?: Color4[];
  53740. flat?: boolean;
  53741. updatable?: boolean;
  53742. sideOrientation?: number;
  53743. frontUVs?: Vector4;
  53744. backUVs?: Vector4;
  53745. }, scene?: Nullable<Scene>): Mesh;
  53746. /**
  53747. * Creates a decal mesh.
  53748. * 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
  53749. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53750. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53751. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53752. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53753. * @param name defines the name of the mesh
  53754. * @param sourceMesh defines the mesh where the decal must be applied
  53755. * @param options defines the options used to create the mesh
  53756. * @param scene defines the hosting scene
  53757. * @returns the decal mesh
  53758. * @see https://doc.babylonjs.com/how_to/decals
  53759. */
  53760. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53761. position?: Vector3;
  53762. normal?: Vector3;
  53763. size?: Vector3;
  53764. angle?: number;
  53765. }): Mesh;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /**
  53770. * A simplifier interface for future simplification implementations
  53771. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53772. */
  53773. export interface ISimplifier {
  53774. /**
  53775. * Simplification of a given mesh according to the given settings.
  53776. * Since this requires computation, it is assumed that the function runs async.
  53777. * @param settings The settings of the simplification, including quality and distance
  53778. * @param successCallback A callback that will be called after the mesh was simplified.
  53779. * @param errorCallback in case of an error, this callback will be called. optional.
  53780. */
  53781. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53782. }
  53783. /**
  53784. * Expected simplification settings.
  53785. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53786. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53787. */
  53788. export interface ISimplificationSettings {
  53789. /**
  53790. * Gets or sets the expected quality
  53791. */
  53792. quality: number;
  53793. /**
  53794. * Gets or sets the distance when this optimized version should be used
  53795. */
  53796. distance: number;
  53797. /**
  53798. * Gets an already optimized mesh
  53799. */
  53800. optimizeMesh?: boolean;
  53801. }
  53802. /**
  53803. * Class used to specify simplification options
  53804. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53805. */
  53806. export class SimplificationSettings implements ISimplificationSettings {
  53807. /** expected quality */
  53808. quality: number;
  53809. /** distance when this optimized version should be used */
  53810. distance: number;
  53811. /** already optimized mesh */
  53812. optimizeMesh?: boolean | undefined;
  53813. /**
  53814. * Creates a SimplificationSettings
  53815. * @param quality expected quality
  53816. * @param distance distance when this optimized version should be used
  53817. * @param optimizeMesh already optimized mesh
  53818. */
  53819. constructor(
  53820. /** expected quality */
  53821. quality: number,
  53822. /** distance when this optimized version should be used */
  53823. distance: number,
  53824. /** already optimized mesh */
  53825. optimizeMesh?: boolean | undefined);
  53826. }
  53827. /**
  53828. * Interface used to define a simplification task
  53829. */
  53830. export interface ISimplificationTask {
  53831. /**
  53832. * Array of settings
  53833. */
  53834. settings: Array<ISimplificationSettings>;
  53835. /**
  53836. * Simplification type
  53837. */
  53838. simplificationType: SimplificationType;
  53839. /**
  53840. * Mesh to simplify
  53841. */
  53842. mesh: Mesh;
  53843. /**
  53844. * Callback called on success
  53845. */
  53846. successCallback?: () => void;
  53847. /**
  53848. * Defines if parallel processing can be used
  53849. */
  53850. parallelProcessing: boolean;
  53851. }
  53852. /**
  53853. * Queue used to order the simplification tasks
  53854. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53855. */
  53856. export class SimplificationQueue {
  53857. private _simplificationArray;
  53858. /**
  53859. * Gets a boolean indicating that the process is still running
  53860. */
  53861. running: boolean;
  53862. /**
  53863. * Creates a new queue
  53864. */
  53865. constructor();
  53866. /**
  53867. * Adds a new simplification task
  53868. * @param task defines a task to add
  53869. */
  53870. addTask(task: ISimplificationTask): void;
  53871. /**
  53872. * Execute next task
  53873. */
  53874. executeNext(): void;
  53875. /**
  53876. * Execute a simplification task
  53877. * @param task defines the task to run
  53878. */
  53879. runSimplification(task: ISimplificationTask): void;
  53880. private getSimplifier;
  53881. }
  53882. /**
  53883. * The implemented types of simplification
  53884. * At the moment only Quadratic Error Decimation is implemented
  53885. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53886. */
  53887. export enum SimplificationType {
  53888. /** Quadratic error decimation */
  53889. QUADRATIC = 0
  53890. }
  53891. }
  53892. declare module BABYLON {
  53893. interface Scene {
  53894. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  53895. /**
  53896. * Gets or sets the simplification queue attached to the scene
  53897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53898. */
  53899. simplificationQueue: SimplificationQueue;
  53900. }
  53901. interface Mesh {
  53902. /**
  53903. * Simplify the mesh according to the given array of settings.
  53904. * Function will return immediately and will simplify async
  53905. * @param settings a collection of simplification settings
  53906. * @param parallelProcessing should all levels calculate parallel or one after the other
  53907. * @param simplificationType the type of simplification to run
  53908. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53909. * @returns the current mesh
  53910. */
  53911. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53912. }
  53913. /**
  53914. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53915. * created in a scene
  53916. */
  53917. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53918. /**
  53919. * The component name helpfull to identify the component in the list of scene components.
  53920. */
  53921. readonly name: string;
  53922. /**
  53923. * The scene the component belongs to.
  53924. */
  53925. scene: Scene;
  53926. /**
  53927. * Creates a new instance of the component for the given scene
  53928. * @param scene Defines the scene to register the component in
  53929. */
  53930. constructor(scene: Scene);
  53931. /**
  53932. * Registers the component in a given scene
  53933. */
  53934. register(): void;
  53935. /**
  53936. * Rebuilds the elements related to this component in case of
  53937. * context lost for instance.
  53938. */
  53939. rebuild(): void;
  53940. /**
  53941. * Disposes the component and the associated ressources
  53942. */
  53943. dispose(): void;
  53944. private _beforeCameraUpdate;
  53945. }
  53946. }
  53947. declare module BABYLON {
  53948. /**
  53949. * Navigation plugin interface to add navigation constrained by a navigation mesh
  53950. */
  53951. export interface INavigationEnginePlugin {
  53952. /**
  53953. * plugin name
  53954. */
  53955. name: string;
  53956. /**
  53957. * Creates a navigation mesh
  53958. * @param meshes array of all the geometry used to compute the navigatio mesh
  53959. * @param parameters bunch of parameters used to filter geometry
  53960. */
  53961. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  53962. /**
  53963. * Create a navigation mesh debug mesh
  53964. * @param scene is where the mesh will be added
  53965. * @returns debug display mesh
  53966. */
  53967. createDebugNavMesh(scene: Scene): Mesh;
  53968. /**
  53969. * Get a navigation mesh constrained position, closest to the parameter position
  53970. * @param position world position
  53971. * @returns the closest point to position constrained by the navigation mesh
  53972. */
  53973. getClosestPoint(position: Vector3): Vector3;
  53974. /**
  53975. * Get a navigation mesh constrained position, within a particular radius
  53976. * @param position world position
  53977. * @param maxRadius the maximum distance to the constrained world position
  53978. * @returns the closest point to position constrained by the navigation mesh
  53979. */
  53980. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  53981. /**
  53982. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  53983. * @param start world position
  53984. * @param end world position
  53985. * @returns array containing world position composing the path
  53986. */
  53987. computePath(start: Vector3, end: Vector3): Vector3[];
  53988. /**
  53989. * If this plugin is supported
  53990. * @returns true if plugin is supported
  53991. */
  53992. isSupported(): boolean;
  53993. /**
  53994. * Create a new Crowd so you can add agents
  53995. * @param maxAgents the maximum agent count in the crowd
  53996. * @param maxAgentRadius the maximum radius an agent can have
  53997. * @param scene to attach the crowd to
  53998. * @returns the crowd you can add agents to
  53999. */
  54000. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54001. /**
  54002. * Release all resources
  54003. */
  54004. dispose(): void;
  54005. }
  54006. /**
  54007. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  54008. */
  54009. export interface ICrowd {
  54010. /**
  54011. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54012. * You can attach anything to that node. The node position is updated in the scene update tick.
  54013. * @param pos world position that will be constrained by the navigation mesh
  54014. * @param parameters agent parameters
  54015. * @param transform hooked to the agent that will be update by the scene
  54016. * @returns agent index
  54017. */
  54018. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54019. /**
  54020. * Returns the agent position in world space
  54021. * @param index agent index returned by addAgent
  54022. * @returns world space position
  54023. */
  54024. getAgentPosition(index: number): Vector3;
  54025. /**
  54026. * Gets the agent velocity in world space
  54027. * @param index agent index returned by addAgent
  54028. * @returns world space velocity
  54029. */
  54030. getAgentVelocity(index: number): Vector3;
  54031. /**
  54032. * remove a particular agent previously created
  54033. * @param index agent index returned by addAgent
  54034. */
  54035. removeAgent(index: number): void;
  54036. /**
  54037. * get the list of all agents attached to this crowd
  54038. * @returns list of agent indices
  54039. */
  54040. getAgents(): number[];
  54041. /**
  54042. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54043. * @param deltaTime in seconds
  54044. */
  54045. update(deltaTime: number): void;
  54046. /**
  54047. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54048. * @param index agent index returned by addAgent
  54049. * @param destination targeted world position
  54050. */
  54051. agentGoto(index: number, destination: Vector3): void;
  54052. /**
  54053. * Release all resources
  54054. */
  54055. dispose(): void;
  54056. }
  54057. /**
  54058. * Configures an agent
  54059. */
  54060. export interface IAgentParameters {
  54061. /**
  54062. * Agent radius. [Limit: >= 0]
  54063. */
  54064. radius: number;
  54065. /**
  54066. * Agent height. [Limit: > 0]
  54067. */
  54068. height: number;
  54069. /**
  54070. * Maximum allowed acceleration. [Limit: >= 0]
  54071. */
  54072. maxAcceleration: number;
  54073. /**
  54074. * Maximum allowed speed. [Limit: >= 0]
  54075. */
  54076. maxSpeed: number;
  54077. /**
  54078. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  54079. */
  54080. collisionQueryRange: number;
  54081. /**
  54082. * The path visibility optimization range. [Limit: > 0]
  54083. */
  54084. pathOptimizationRange: number;
  54085. /**
  54086. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  54087. */
  54088. separationWeight: number;
  54089. }
  54090. /**
  54091. * Configures the navigation mesh creation
  54092. */
  54093. export interface INavMeshParameters {
  54094. /**
  54095. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  54096. */
  54097. cs: number;
  54098. /**
  54099. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  54100. */
  54101. ch: number;
  54102. /**
  54103. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  54104. */
  54105. walkableSlopeAngle: number;
  54106. /**
  54107. * Minimum floor to 'ceiling' height that will still allow the floor area to
  54108. * be considered walkable. [Limit: >= 3] [Units: vx]
  54109. */
  54110. walkableHeight: number;
  54111. /**
  54112. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  54113. */
  54114. walkableClimb: number;
  54115. /**
  54116. * The distance to erode/shrink the walkable area of the heightfield away from
  54117. * obstructions. [Limit: >=0] [Units: vx]
  54118. */
  54119. walkableRadius: number;
  54120. /**
  54121. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  54122. */
  54123. maxEdgeLen: number;
  54124. /**
  54125. * The maximum distance a simplfied contour's border edges should deviate
  54126. * the original raw contour. [Limit: >=0] [Units: vx]
  54127. */
  54128. maxSimplificationError: number;
  54129. /**
  54130. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  54131. */
  54132. minRegionArea: number;
  54133. /**
  54134. * Any regions with a span count smaller than this value will, if possible,
  54135. * be merged with larger regions. [Limit: >=0] [Units: vx]
  54136. */
  54137. mergeRegionArea: number;
  54138. /**
  54139. * The maximum number of vertices allowed for polygons generated during the
  54140. * contour to polygon conversion process. [Limit: >= 3]
  54141. */
  54142. maxVertsPerPoly: number;
  54143. /**
  54144. * Sets the sampling distance to use when generating the detail mesh.
  54145. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  54146. */
  54147. detailSampleDist: number;
  54148. /**
  54149. * The maximum distance the detail mesh surface should deviate from heightfield
  54150. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  54151. */
  54152. detailSampleMaxError: number;
  54153. }
  54154. }
  54155. declare module BABYLON {
  54156. /**
  54157. * RecastJS navigation plugin
  54158. */
  54159. export class RecastJSPlugin implements INavigationEnginePlugin {
  54160. /**
  54161. * Reference to the Recast library
  54162. */
  54163. bjsRECAST: any;
  54164. /**
  54165. * plugin name
  54166. */
  54167. name: string;
  54168. /**
  54169. * the first navmesh created. We might extend this to support multiple navmeshes
  54170. */
  54171. navMesh: any;
  54172. /**
  54173. * Initializes the recastJS plugin
  54174. * @param recastInjection can be used to inject your own recast reference
  54175. */
  54176. constructor(recastInjection?: any);
  54177. /**
  54178. * Creates a navigation mesh
  54179. * @param meshes array of all the geometry used to compute the navigatio mesh
  54180. * @param parameters bunch of parameters used to filter geometry
  54181. */
  54182. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54183. /**
  54184. * Create a navigation mesh debug mesh
  54185. * @param scene is where the mesh will be added
  54186. * @returns debug display mesh
  54187. */
  54188. createDebugNavMesh(scene: Scene): Mesh;
  54189. /**
  54190. * Get a navigation mesh constrained position, closest to the parameter position
  54191. * @param position world position
  54192. * @returns the closest point to position constrained by the navigation mesh
  54193. */
  54194. getClosestPoint(position: Vector3): Vector3;
  54195. /**
  54196. * Get a navigation mesh constrained position, within a particular radius
  54197. * @param position world position
  54198. * @param maxRadius the maximum distance to the constrained world position
  54199. * @returns the closest point to position constrained by the navigation mesh
  54200. */
  54201. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54202. /**
  54203. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54204. * @param start world position
  54205. * @param end world position
  54206. * @returns array containing world position composing the path
  54207. */
  54208. computePath(start: Vector3, end: Vector3): Vector3[];
  54209. /**
  54210. * Create a new Crowd so you can add agents
  54211. * @param maxAgents the maximum agent count in the crowd
  54212. * @param maxAgentRadius the maximum radius an agent can have
  54213. * @param scene to attach the crowd to
  54214. * @returns the crowd you can add agents to
  54215. */
  54216. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54217. /**
  54218. * Disposes
  54219. */
  54220. dispose(): void;
  54221. /**
  54222. * If this plugin is supported
  54223. * @returns true if plugin is supported
  54224. */
  54225. isSupported(): boolean;
  54226. }
  54227. /**
  54228. * Recast detour crowd implementation
  54229. */
  54230. export class RecastJSCrowd implements ICrowd {
  54231. /**
  54232. * Recast/detour plugin
  54233. */
  54234. bjsRECASTPlugin: RecastJSPlugin;
  54235. /**
  54236. * Link to the detour crowd
  54237. */
  54238. recastCrowd: any;
  54239. /**
  54240. * One transform per agent
  54241. */
  54242. transforms: TransformNode[];
  54243. /**
  54244. * All agents created
  54245. */
  54246. agents: number[];
  54247. /**
  54248. * Link to the scene is kept to unregister the crowd from the scene
  54249. */
  54250. private _scene;
  54251. /**
  54252. * Observer for crowd updates
  54253. */
  54254. private _onBeforeAnimationsObserver;
  54255. /**
  54256. * Constructor
  54257. * @param plugin recastJS plugin
  54258. * @param maxAgents the maximum agent count in the crowd
  54259. * @param maxAgentRadius the maximum radius an agent can have
  54260. * @param scene to attach the crowd to
  54261. * @returns the crowd you can add agents to
  54262. */
  54263. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  54264. /**
  54265. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54266. * You can attach anything to that node. The node position is updated in the scene update tick.
  54267. * @param pos world position that will be constrained by the navigation mesh
  54268. * @param parameters agent parameters
  54269. * @param transform hooked to the agent that will be update by the scene
  54270. * @returns agent index
  54271. */
  54272. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54273. /**
  54274. * Returns the agent position in world space
  54275. * @param index agent index returned by addAgent
  54276. * @returns world space position
  54277. */
  54278. getAgentPosition(index: number): Vector3;
  54279. /**
  54280. * Returns the agent velocity in world space
  54281. * @param index agent index returned by addAgent
  54282. * @returns world space velocity
  54283. */
  54284. getAgentVelocity(index: number): Vector3;
  54285. /**
  54286. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54287. * @param index agent index returned by addAgent
  54288. * @param destination targeted world position
  54289. */
  54290. agentGoto(index: number, destination: Vector3): void;
  54291. /**
  54292. * remove a particular agent previously created
  54293. * @param index agent index returned by addAgent
  54294. */
  54295. removeAgent(index: number): void;
  54296. /**
  54297. * get the list of all agents attached to this crowd
  54298. * @returns list of agent indices
  54299. */
  54300. getAgents(): number[];
  54301. /**
  54302. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54303. * @param deltaTime in seconds
  54304. */
  54305. update(deltaTime: number): void;
  54306. /**
  54307. * Release all resources
  54308. */
  54309. dispose(): void;
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. /**
  54314. * Class used to enable access to IndexedDB
  54315. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54316. */
  54317. export class Database implements IOfflineProvider {
  54318. private _callbackManifestChecked;
  54319. private _currentSceneUrl;
  54320. private _db;
  54321. private _enableSceneOffline;
  54322. private _enableTexturesOffline;
  54323. private _manifestVersionFound;
  54324. private _mustUpdateRessources;
  54325. private _hasReachedQuota;
  54326. private _isSupported;
  54327. private _idbFactory;
  54328. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54329. private static IsUASupportingBlobStorage;
  54330. /**
  54331. * Gets a boolean indicating if Database storate is enabled (off by default)
  54332. */
  54333. static IDBStorageEnabled: boolean;
  54334. /**
  54335. * Gets a boolean indicating if scene must be saved in the database
  54336. */
  54337. readonly enableSceneOffline: boolean;
  54338. /**
  54339. * Gets a boolean indicating if textures must be saved in the database
  54340. */
  54341. readonly enableTexturesOffline: boolean;
  54342. /**
  54343. * Creates a new Database
  54344. * @param urlToScene defines the url to load the scene
  54345. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54346. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54347. */
  54348. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54349. private static _ParseURL;
  54350. private static _ReturnFullUrlLocation;
  54351. private _checkManifestFile;
  54352. /**
  54353. * Open the database and make it available
  54354. * @param successCallback defines the callback to call on success
  54355. * @param errorCallback defines the callback to call on error
  54356. */
  54357. open(successCallback: () => void, errorCallback: () => void): void;
  54358. /**
  54359. * Loads an image from the database
  54360. * @param url defines the url to load from
  54361. * @param image defines the target DOM image
  54362. */
  54363. loadImage(url: string, image: HTMLImageElement): void;
  54364. private _loadImageFromDBAsync;
  54365. private _saveImageIntoDBAsync;
  54366. private _checkVersionFromDB;
  54367. private _loadVersionFromDBAsync;
  54368. private _saveVersionIntoDBAsync;
  54369. /**
  54370. * Loads a file from database
  54371. * @param url defines the URL to load from
  54372. * @param sceneLoaded defines a callback to call on success
  54373. * @param progressCallBack defines a callback to call when progress changed
  54374. * @param errorCallback defines a callback to call on error
  54375. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  54376. */
  54377. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54378. private _loadFileAsync;
  54379. private _saveFileAsync;
  54380. /**
  54381. * Validates if xhr data is correct
  54382. * @param xhr defines the request to validate
  54383. * @param dataType defines the expected data type
  54384. * @returns true if data is correct
  54385. */
  54386. private static _ValidateXHRData;
  54387. }
  54388. }
  54389. declare module BABYLON {
  54390. /** @hidden */
  54391. export var gpuUpdateParticlesPixelShader: {
  54392. name: string;
  54393. shader: string;
  54394. };
  54395. }
  54396. declare module BABYLON {
  54397. /** @hidden */
  54398. export var gpuUpdateParticlesVertexShader: {
  54399. name: string;
  54400. shader: string;
  54401. };
  54402. }
  54403. declare module BABYLON {
  54404. /** @hidden */
  54405. export var clipPlaneFragmentDeclaration2: {
  54406. name: string;
  54407. shader: string;
  54408. };
  54409. }
  54410. declare module BABYLON {
  54411. /** @hidden */
  54412. export var gpuRenderParticlesPixelShader: {
  54413. name: string;
  54414. shader: string;
  54415. };
  54416. }
  54417. declare module BABYLON {
  54418. /** @hidden */
  54419. export var clipPlaneVertexDeclaration2: {
  54420. name: string;
  54421. shader: string;
  54422. };
  54423. }
  54424. declare module BABYLON {
  54425. /** @hidden */
  54426. export var gpuRenderParticlesVertexShader: {
  54427. name: string;
  54428. shader: string;
  54429. };
  54430. }
  54431. declare module BABYLON {
  54432. /**
  54433. * This represents a GPU particle system in Babylon
  54434. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54435. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54436. */
  54437. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54438. /**
  54439. * The layer mask we are rendering the particles through.
  54440. */
  54441. layerMask: number;
  54442. private _capacity;
  54443. private _activeCount;
  54444. private _currentActiveCount;
  54445. private _accumulatedCount;
  54446. private _renderEffect;
  54447. private _updateEffect;
  54448. private _buffer0;
  54449. private _buffer1;
  54450. private _spriteBuffer;
  54451. private _updateVAO;
  54452. private _renderVAO;
  54453. private _targetIndex;
  54454. private _sourceBuffer;
  54455. private _targetBuffer;
  54456. private _engine;
  54457. private _currentRenderId;
  54458. private _started;
  54459. private _stopped;
  54460. private _timeDelta;
  54461. private _randomTexture;
  54462. private _randomTexture2;
  54463. private _attributesStrideSize;
  54464. private _updateEffectOptions;
  54465. private _randomTextureSize;
  54466. private _actualFrame;
  54467. private readonly _rawTextureWidth;
  54468. /**
  54469. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54470. */
  54471. static readonly IsSupported: boolean;
  54472. /**
  54473. * An event triggered when the system is disposed.
  54474. */
  54475. onDisposeObservable: Observable<GPUParticleSystem>;
  54476. /**
  54477. * Gets the maximum number of particles active at the same time.
  54478. * @returns The max number of active particles.
  54479. */
  54480. getCapacity(): number;
  54481. /**
  54482. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54483. * to override the particles.
  54484. */
  54485. forceDepthWrite: boolean;
  54486. /**
  54487. * Gets or set the number of active particles
  54488. */
  54489. activeParticleCount: number;
  54490. private _preWarmDone;
  54491. /**
  54492. * Is this system ready to be used/rendered
  54493. * @return true if the system is ready
  54494. */
  54495. isReady(): boolean;
  54496. /**
  54497. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54498. * @returns True if it has been started, otherwise false.
  54499. */
  54500. isStarted(): boolean;
  54501. /**
  54502. * Starts the particle system and begins to emit
  54503. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54504. */
  54505. start(delay?: number): void;
  54506. /**
  54507. * Stops the particle system.
  54508. */
  54509. stop(): void;
  54510. /**
  54511. * Remove all active particles
  54512. */
  54513. reset(): void;
  54514. /**
  54515. * Returns the string "GPUParticleSystem"
  54516. * @returns a string containing the class name
  54517. */
  54518. getClassName(): string;
  54519. private _colorGradientsTexture;
  54520. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54521. /**
  54522. * Adds a new color gradient
  54523. * @param gradient defines the gradient to use (between 0 and 1)
  54524. * @param color1 defines the color to affect to the specified gradient
  54525. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54526. * @returns the current particle system
  54527. */
  54528. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54529. /**
  54530. * Remove a specific color gradient
  54531. * @param gradient defines the gradient to remove
  54532. * @returns the current particle system
  54533. */
  54534. removeColorGradient(gradient: number): GPUParticleSystem;
  54535. private _angularSpeedGradientsTexture;
  54536. private _sizeGradientsTexture;
  54537. private _velocityGradientsTexture;
  54538. private _limitVelocityGradientsTexture;
  54539. private _dragGradientsTexture;
  54540. private _addFactorGradient;
  54541. /**
  54542. * Adds a new size gradient
  54543. * @param gradient defines the gradient to use (between 0 and 1)
  54544. * @param factor defines the size factor to affect to the specified gradient
  54545. * @returns the current particle system
  54546. */
  54547. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54548. /**
  54549. * Remove a specific size gradient
  54550. * @param gradient defines the gradient to remove
  54551. * @returns the current particle system
  54552. */
  54553. removeSizeGradient(gradient: number): GPUParticleSystem;
  54554. /**
  54555. * Adds a new angular speed gradient
  54556. * @param gradient defines the gradient to use (between 0 and 1)
  54557. * @param factor defines the angular speed to affect to the specified gradient
  54558. * @returns the current particle system
  54559. */
  54560. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54561. /**
  54562. * Remove a specific angular speed gradient
  54563. * @param gradient defines the gradient to remove
  54564. * @returns the current particle system
  54565. */
  54566. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54567. /**
  54568. * Adds a new velocity gradient
  54569. * @param gradient defines the gradient to use (between 0 and 1)
  54570. * @param factor defines the velocity to affect to the specified gradient
  54571. * @returns the current particle system
  54572. */
  54573. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54574. /**
  54575. * Remove a specific velocity gradient
  54576. * @param gradient defines the gradient to remove
  54577. * @returns the current particle system
  54578. */
  54579. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54580. /**
  54581. * Adds a new limit velocity gradient
  54582. * @param gradient defines the gradient to use (between 0 and 1)
  54583. * @param factor defines the limit velocity value to affect to the specified gradient
  54584. * @returns the current particle system
  54585. */
  54586. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54587. /**
  54588. * Remove a specific limit velocity gradient
  54589. * @param gradient defines the gradient to remove
  54590. * @returns the current particle system
  54591. */
  54592. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54593. /**
  54594. * Adds a new drag gradient
  54595. * @param gradient defines the gradient to use (between 0 and 1)
  54596. * @param factor defines the drag value to affect to the specified gradient
  54597. * @returns the current particle system
  54598. */
  54599. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54600. /**
  54601. * Remove a specific drag gradient
  54602. * @param gradient defines the gradient to remove
  54603. * @returns the current particle system
  54604. */
  54605. removeDragGradient(gradient: number): GPUParticleSystem;
  54606. /**
  54607. * Not supported by GPUParticleSystem
  54608. * @param gradient defines the gradient to use (between 0 and 1)
  54609. * @param factor defines the emit rate value to affect to the specified gradient
  54610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54611. * @returns the current particle system
  54612. */
  54613. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54614. /**
  54615. * Not supported by GPUParticleSystem
  54616. * @param gradient defines the gradient to remove
  54617. * @returns the current particle system
  54618. */
  54619. removeEmitRateGradient(gradient: number): IParticleSystem;
  54620. /**
  54621. * Not supported by GPUParticleSystem
  54622. * @param gradient defines the gradient to use (between 0 and 1)
  54623. * @param factor defines the start size value to affect to the specified gradient
  54624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54625. * @returns the current particle system
  54626. */
  54627. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54628. /**
  54629. * Not supported by GPUParticleSystem
  54630. * @param gradient defines the gradient to remove
  54631. * @returns the current particle system
  54632. */
  54633. removeStartSizeGradient(gradient: number): IParticleSystem;
  54634. /**
  54635. * Not supported by GPUParticleSystem
  54636. * @param gradient defines the gradient to use (between 0 and 1)
  54637. * @param min defines the color remap minimal range
  54638. * @param max defines the color remap maximal range
  54639. * @returns the current particle system
  54640. */
  54641. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54642. /**
  54643. * Not supported by GPUParticleSystem
  54644. * @param gradient defines the gradient to remove
  54645. * @returns the current particle system
  54646. */
  54647. removeColorRemapGradient(): IParticleSystem;
  54648. /**
  54649. * Not supported by GPUParticleSystem
  54650. * @param gradient defines the gradient to use (between 0 and 1)
  54651. * @param min defines the alpha remap minimal range
  54652. * @param max defines the alpha remap maximal range
  54653. * @returns the current particle system
  54654. */
  54655. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54656. /**
  54657. * Not supported by GPUParticleSystem
  54658. * @param gradient defines the gradient to remove
  54659. * @returns the current particle system
  54660. */
  54661. removeAlphaRemapGradient(): IParticleSystem;
  54662. /**
  54663. * Not supported by GPUParticleSystem
  54664. * @param gradient defines the gradient to use (between 0 and 1)
  54665. * @param color defines the color to affect to the specified gradient
  54666. * @returns the current particle system
  54667. */
  54668. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54669. /**
  54670. * Not supported by GPUParticleSystem
  54671. * @param gradient defines the gradient to remove
  54672. * @returns the current particle system
  54673. */
  54674. removeRampGradient(): IParticleSystem;
  54675. /**
  54676. * Not supported by GPUParticleSystem
  54677. * @returns the list of ramp gradients
  54678. */
  54679. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54680. /**
  54681. * Not supported by GPUParticleSystem
  54682. * Gets or sets a boolean indicating that ramp gradients must be used
  54683. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54684. */
  54685. useRampGradients: boolean;
  54686. /**
  54687. * Not supported by GPUParticleSystem
  54688. * @param gradient defines the gradient to use (between 0 and 1)
  54689. * @param factor defines the life time factor to affect to the specified gradient
  54690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54691. * @returns the current particle system
  54692. */
  54693. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54694. /**
  54695. * Not supported by GPUParticleSystem
  54696. * @param gradient defines the gradient to remove
  54697. * @returns the current particle system
  54698. */
  54699. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54700. /**
  54701. * Instantiates a GPU particle system.
  54702. * 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.
  54703. * @param name The name of the particle system
  54704. * @param options The options used to create the system
  54705. * @param scene The scene the particle system belongs to
  54706. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54707. */
  54708. constructor(name: string, options: Partial<{
  54709. capacity: number;
  54710. randomTextureSize: number;
  54711. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54712. protected _reset(): void;
  54713. private _createUpdateVAO;
  54714. private _createRenderVAO;
  54715. private _initialize;
  54716. /** @hidden */ private _recreateUpdateEffect(): void;
  54717. /** @hidden */ private _recreateRenderEffect(): void;
  54718. /**
  54719. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54720. * @param preWarm defines if we are in the pre-warmimg phase
  54721. */
  54722. animate(preWarm?: boolean): void;
  54723. private _createFactorGradientTexture;
  54724. private _createSizeGradientTexture;
  54725. private _createAngularSpeedGradientTexture;
  54726. private _createVelocityGradientTexture;
  54727. private _createLimitVelocityGradientTexture;
  54728. private _createDragGradientTexture;
  54729. private _createColorGradientTexture;
  54730. /**
  54731. * Renders the particle system in its current state
  54732. * @param preWarm defines if the system should only update the particles but not render them
  54733. * @returns the current number of particles
  54734. */
  54735. render(preWarm?: boolean): number;
  54736. /**
  54737. * Rebuilds the particle system
  54738. */
  54739. rebuild(): void;
  54740. private _releaseBuffers;
  54741. private _releaseVAOs;
  54742. /**
  54743. * Disposes the particle system and free the associated resources
  54744. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54745. */
  54746. dispose(disposeTexture?: boolean): void;
  54747. /**
  54748. * Clones the particle system.
  54749. * @param name The name of the cloned object
  54750. * @param newEmitter The new emitter to use
  54751. * @returns the cloned particle system
  54752. */
  54753. clone(name: string, newEmitter: any): GPUParticleSystem;
  54754. /**
  54755. * Serializes the particle system to a JSON object.
  54756. * @returns the JSON object
  54757. */
  54758. serialize(): any;
  54759. /**
  54760. * Parses a JSON object to create a GPU particle system.
  54761. * @param parsedParticleSystem The JSON object to parse
  54762. * @param scene The scene to create the particle system in
  54763. * @param rootUrl The root url to use to load external dependencies like texture
  54764. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54765. * @returns the parsed GPU particle system
  54766. */
  54767. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54768. }
  54769. }
  54770. declare module BABYLON {
  54771. /**
  54772. * Represents a set of particle systems working together to create a specific effect
  54773. */
  54774. export class ParticleSystemSet implements IDisposable {
  54775. private _emitterCreationOptions;
  54776. private _emitterNode;
  54777. /**
  54778. * Gets the particle system list
  54779. */
  54780. systems: IParticleSystem[];
  54781. /**
  54782. * Gets the emitter node used with this set
  54783. */
  54784. readonly emitterNode: Nullable<TransformNode>;
  54785. /**
  54786. * Creates a new emitter mesh as a sphere
  54787. * @param options defines the options used to create the sphere
  54788. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54789. * @param scene defines the hosting scene
  54790. */
  54791. setEmitterAsSphere(options: {
  54792. diameter: number;
  54793. segments: number;
  54794. color: Color3;
  54795. }, renderingGroupId: number, scene: Scene): void;
  54796. /**
  54797. * Starts all particle systems of the set
  54798. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54799. */
  54800. start(emitter?: AbstractMesh): void;
  54801. /**
  54802. * Release all associated resources
  54803. */
  54804. dispose(): void;
  54805. /**
  54806. * Serialize the set into a JSON compatible object
  54807. * @returns a JSON compatible representation of the set
  54808. */
  54809. serialize(): any;
  54810. /**
  54811. * Parse a new ParticleSystemSet from a serialized source
  54812. * @param data defines a JSON compatible representation of the set
  54813. * @param scene defines the hosting scene
  54814. * @param gpu defines if we want GPU particles or CPU particles
  54815. * @returns a new ParticleSystemSet
  54816. */
  54817. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54818. }
  54819. }
  54820. declare module BABYLON {
  54821. /**
  54822. * This class is made for on one-liner static method to help creating particle system set.
  54823. */
  54824. export class ParticleHelper {
  54825. /**
  54826. * Gets or sets base Assets URL
  54827. */
  54828. static BaseAssetsUrl: string;
  54829. /**
  54830. * Create a default particle system that you can tweak
  54831. * @param emitter defines the emitter to use
  54832. * @param capacity defines the system capacity (default is 500 particles)
  54833. * @param scene defines the hosting scene
  54834. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54835. * @returns the new Particle system
  54836. */
  54837. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54838. /**
  54839. * This is the main static method (one-liner) of this helper to create different particle systems
  54840. * @param type This string represents the type to the particle system to create
  54841. * @param scene The scene where the particle system should live
  54842. * @param gpu If the system will use gpu
  54843. * @returns the ParticleSystemSet created
  54844. */
  54845. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54846. /**
  54847. * Static function used to export a particle system to a ParticleSystemSet variable.
  54848. * Please note that the emitter shape is not exported
  54849. * @param systems defines the particle systems to export
  54850. * @returns the created particle system set
  54851. */
  54852. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54853. }
  54854. }
  54855. declare module BABYLON {
  54856. interface Engine {
  54857. /**
  54858. * Create an effect to use with particle systems.
  54859. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54860. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54861. * @param uniformsNames defines a list of attribute names
  54862. * @param samplers defines an array of string used to represent textures
  54863. * @param defines defines the string containing the defines to use to compile the shaders
  54864. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54865. * @param onCompiled defines a function to call when the effect creation is successful
  54866. * @param onError defines a function to call when the effect creation has failed
  54867. * @returns the new Effect
  54868. */
  54869. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54870. }
  54871. interface Mesh {
  54872. /**
  54873. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54874. * @returns an array of IParticleSystem
  54875. */
  54876. getEmittedParticleSystems(): IParticleSystem[];
  54877. /**
  54878. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54879. * @returns an array of IParticleSystem
  54880. */
  54881. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54882. }
  54883. /**
  54884. * @hidden
  54885. */
  54886. export var _IDoNeedToBeInTheBuild: number;
  54887. }
  54888. declare module BABYLON {
  54889. interface Scene {
  54890. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  54891. /**
  54892. * Gets the current physics engine
  54893. * @returns a IPhysicsEngine or null if none attached
  54894. */
  54895. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54896. /**
  54897. * Enables physics to the current scene
  54898. * @param gravity defines the scene's gravity for the physics engine
  54899. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54900. * @return a boolean indicating if the physics engine was initialized
  54901. */
  54902. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54903. /**
  54904. * Disables and disposes the physics engine associated with the scene
  54905. */
  54906. disablePhysicsEngine(): void;
  54907. /**
  54908. * Gets a boolean indicating if there is an active physics engine
  54909. * @returns a boolean indicating if there is an active physics engine
  54910. */
  54911. isPhysicsEnabled(): boolean;
  54912. /**
  54913. * Deletes a physics compound impostor
  54914. * @param compound defines the compound to delete
  54915. */
  54916. deleteCompoundImpostor(compound: any): void;
  54917. /**
  54918. * An event triggered when physic simulation is about to be run
  54919. */
  54920. onBeforePhysicsObservable: Observable<Scene>;
  54921. /**
  54922. * An event triggered when physic simulation has been done
  54923. */
  54924. onAfterPhysicsObservable: Observable<Scene>;
  54925. }
  54926. interface AbstractMesh {
  54927. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  54928. /**
  54929. * Gets or sets impostor used for physic simulation
  54930. * @see http://doc.babylonjs.com/features/physics_engine
  54931. */
  54932. physicsImpostor: Nullable<PhysicsImpostor>;
  54933. /**
  54934. * Gets the current physics impostor
  54935. * @see http://doc.babylonjs.com/features/physics_engine
  54936. * @returns a physics impostor or null
  54937. */
  54938. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54939. /** Apply a physic impulse to the mesh
  54940. * @param force defines the force to apply
  54941. * @param contactPoint defines where to apply the force
  54942. * @returns the current mesh
  54943. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54944. */
  54945. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54946. /**
  54947. * Creates a physic joint between two meshes
  54948. * @param otherMesh defines the other mesh to use
  54949. * @param pivot1 defines the pivot to use on this mesh
  54950. * @param pivot2 defines the pivot to use on the other mesh
  54951. * @param options defines additional options (can be plugin dependent)
  54952. * @returns the current mesh
  54953. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54954. */
  54955. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54956. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  54957. }
  54958. /**
  54959. * Defines the physics engine scene component responsible to manage a physics engine
  54960. */
  54961. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54962. /**
  54963. * The component name helpful to identify the component in the list of scene components.
  54964. */
  54965. readonly name: string;
  54966. /**
  54967. * The scene the component belongs to.
  54968. */
  54969. scene: Scene;
  54970. /**
  54971. * Creates a new instance of the component for the given scene
  54972. * @param scene Defines the scene to register the component in
  54973. */
  54974. constructor(scene: Scene);
  54975. /**
  54976. * Registers the component in a given scene
  54977. */
  54978. register(): void;
  54979. /**
  54980. * Rebuilds the elements related to this component in case of
  54981. * context lost for instance.
  54982. */
  54983. rebuild(): void;
  54984. /**
  54985. * Disposes the component and the associated ressources
  54986. */
  54987. dispose(): void;
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * A helper for physics simulations
  54993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54994. */
  54995. export class PhysicsHelper {
  54996. private _scene;
  54997. private _physicsEngine;
  54998. /**
  54999. * Initializes the Physics helper
  55000. * @param scene Babylon.js scene
  55001. */
  55002. constructor(scene: Scene);
  55003. /**
  55004. * Applies a radial explosion impulse
  55005. * @param origin the origin of the explosion
  55006. * @param radiusOrEventOptions the radius or the options of radial explosion
  55007. * @param strength the explosion strength
  55008. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55009. * @returns A physics radial explosion event, or null
  55010. */
  55011. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55012. /**
  55013. * Applies a radial explosion force
  55014. * @param origin the origin of the explosion
  55015. * @param radiusOrEventOptions the radius or the options of radial explosion
  55016. * @param strength the explosion strength
  55017. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55018. * @returns A physics radial explosion event, or null
  55019. */
  55020. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55021. /**
  55022. * Creates a gravitational field
  55023. * @param origin the origin of the explosion
  55024. * @param radiusOrEventOptions the radius or the options of radial explosion
  55025. * @param strength the explosion strength
  55026. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55027. * @returns A physics gravitational field event, or null
  55028. */
  55029. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55030. /**
  55031. * Creates a physics updraft event
  55032. * @param origin the origin of the updraft
  55033. * @param radiusOrEventOptions the radius or the options of the updraft
  55034. * @param strength the strength of the updraft
  55035. * @param height the height of the updraft
  55036. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55037. * @returns A physics updraft event, or null
  55038. */
  55039. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55040. /**
  55041. * Creates a physics vortex event
  55042. * @param origin the of the vortex
  55043. * @param radiusOrEventOptions the radius or the options of the vortex
  55044. * @param strength the strength of the vortex
  55045. * @param height the height of the vortex
  55046. * @returns a Physics vortex event, or null
  55047. * A physics vortex event or null
  55048. */
  55049. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55050. }
  55051. /**
  55052. * Represents a physics radial explosion event
  55053. */
  55054. class PhysicsRadialExplosionEvent {
  55055. private _scene;
  55056. private _options;
  55057. private _sphere;
  55058. private _dataFetched;
  55059. /**
  55060. * Initializes a radial explosioin event
  55061. * @param _scene BabylonJS scene
  55062. * @param _options The options for the vortex event
  55063. */
  55064. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55065. /**
  55066. * Returns the data related to the radial explosion event (sphere).
  55067. * @returns The radial explosion event data
  55068. */
  55069. getData(): PhysicsRadialExplosionEventData;
  55070. /**
  55071. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55072. * @param impostor A physics imposter
  55073. * @param origin the origin of the explosion
  55074. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55075. */
  55076. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55077. /**
  55078. * Triggers affecterd impostors callbacks
  55079. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55080. */
  55081. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55082. /**
  55083. * Disposes the sphere.
  55084. * @param force Specifies if the sphere should be disposed by force
  55085. */
  55086. dispose(force?: boolean): void;
  55087. /*** Helpers ***/
  55088. private _prepareSphere;
  55089. private _intersectsWithSphere;
  55090. }
  55091. /**
  55092. * Represents a gravitational field event
  55093. */
  55094. class PhysicsGravitationalFieldEvent {
  55095. private _physicsHelper;
  55096. private _scene;
  55097. private _origin;
  55098. private _options;
  55099. private _tickCallback;
  55100. private _sphere;
  55101. private _dataFetched;
  55102. /**
  55103. * Initializes the physics gravitational field event
  55104. * @param _physicsHelper A physics helper
  55105. * @param _scene BabylonJS scene
  55106. * @param _origin The origin position of the gravitational field event
  55107. * @param _options The options for the vortex event
  55108. */
  55109. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55110. /**
  55111. * Returns the data related to the gravitational field event (sphere).
  55112. * @returns A gravitational field event
  55113. */
  55114. getData(): PhysicsGravitationalFieldEventData;
  55115. /**
  55116. * Enables the gravitational field.
  55117. */
  55118. enable(): void;
  55119. /**
  55120. * Disables the gravitational field.
  55121. */
  55122. disable(): void;
  55123. /**
  55124. * Disposes the sphere.
  55125. * @param force The force to dispose from the gravitational field event
  55126. */
  55127. dispose(force?: boolean): void;
  55128. private _tick;
  55129. }
  55130. /**
  55131. * Represents a physics updraft event
  55132. */
  55133. class PhysicsUpdraftEvent {
  55134. private _scene;
  55135. private _origin;
  55136. private _options;
  55137. private _physicsEngine;
  55138. private _originTop;
  55139. private _originDirection;
  55140. private _tickCallback;
  55141. private _cylinder;
  55142. private _cylinderPosition;
  55143. private _dataFetched;
  55144. /**
  55145. * Initializes the physics updraft event
  55146. * @param _scene BabylonJS scene
  55147. * @param _origin The origin position of the updraft
  55148. * @param _options The options for the updraft event
  55149. */
  55150. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55151. /**
  55152. * Returns the data related to the updraft event (cylinder).
  55153. * @returns A physics updraft event
  55154. */
  55155. getData(): PhysicsUpdraftEventData;
  55156. /**
  55157. * Enables the updraft.
  55158. */
  55159. enable(): void;
  55160. /**
  55161. * Disables the updraft.
  55162. */
  55163. disable(): void;
  55164. /**
  55165. * Disposes the cylinder.
  55166. * @param force Specifies if the updraft should be disposed by force
  55167. */
  55168. dispose(force?: boolean): void;
  55169. private getImpostorHitData;
  55170. private _tick;
  55171. /*** Helpers ***/
  55172. private _prepareCylinder;
  55173. private _intersectsWithCylinder;
  55174. }
  55175. /**
  55176. * Represents a physics vortex event
  55177. */
  55178. class PhysicsVortexEvent {
  55179. private _scene;
  55180. private _origin;
  55181. private _options;
  55182. private _physicsEngine;
  55183. private _originTop;
  55184. private _tickCallback;
  55185. private _cylinder;
  55186. private _cylinderPosition;
  55187. private _dataFetched;
  55188. /**
  55189. * Initializes the physics vortex event
  55190. * @param _scene The BabylonJS scene
  55191. * @param _origin The origin position of the vortex
  55192. * @param _options The options for the vortex event
  55193. */
  55194. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55195. /**
  55196. * Returns the data related to the vortex event (cylinder).
  55197. * @returns The physics vortex event data
  55198. */
  55199. getData(): PhysicsVortexEventData;
  55200. /**
  55201. * Enables the vortex.
  55202. */
  55203. enable(): void;
  55204. /**
  55205. * Disables the cortex.
  55206. */
  55207. disable(): void;
  55208. /**
  55209. * Disposes the sphere.
  55210. * @param force
  55211. */
  55212. dispose(force?: boolean): void;
  55213. private getImpostorHitData;
  55214. private _tick;
  55215. /*** Helpers ***/
  55216. private _prepareCylinder;
  55217. private _intersectsWithCylinder;
  55218. }
  55219. /**
  55220. * Options fot the radial explosion event
  55221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55222. */
  55223. export class PhysicsRadialExplosionEventOptions {
  55224. /**
  55225. * The radius of the sphere for the radial explosion.
  55226. */
  55227. radius: number;
  55228. /**
  55229. * The strenth of the explosion.
  55230. */
  55231. strength: number;
  55232. /**
  55233. * The strenght of the force in correspondence to the distance of the affected object
  55234. */
  55235. falloff: PhysicsRadialImpulseFalloff;
  55236. /**
  55237. * Sphere options for the radial explosion.
  55238. */
  55239. sphere: {
  55240. segments: number;
  55241. diameter: number;
  55242. };
  55243. /**
  55244. * Sphere options for the radial explosion.
  55245. */
  55246. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55247. }
  55248. /**
  55249. * Options fot the updraft event
  55250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55251. */
  55252. export class PhysicsUpdraftEventOptions {
  55253. /**
  55254. * The radius of the cylinder for the vortex
  55255. */
  55256. radius: number;
  55257. /**
  55258. * The strenth of the updraft.
  55259. */
  55260. strength: number;
  55261. /**
  55262. * The height of the cylinder for the updraft.
  55263. */
  55264. height: number;
  55265. /**
  55266. * The mode for the the updraft.
  55267. */
  55268. updraftMode: PhysicsUpdraftMode;
  55269. }
  55270. /**
  55271. * Options fot the vortex event
  55272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55273. */
  55274. export class PhysicsVortexEventOptions {
  55275. /**
  55276. * The radius of the cylinder for the vortex
  55277. */
  55278. radius: number;
  55279. /**
  55280. * The strenth of the vortex.
  55281. */
  55282. strength: number;
  55283. /**
  55284. * The height of the cylinder for the vortex.
  55285. */
  55286. height: number;
  55287. /**
  55288. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55289. */
  55290. centripetalForceThreshold: number;
  55291. /**
  55292. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55293. */
  55294. centripetalForceMultiplier: number;
  55295. /**
  55296. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55297. */
  55298. centrifugalForceMultiplier: number;
  55299. /**
  55300. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55301. */
  55302. updraftForceMultiplier: number;
  55303. }
  55304. /**
  55305. * The strenght of the force in correspondence to the distance of the affected object
  55306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55307. */
  55308. export enum PhysicsRadialImpulseFalloff {
  55309. /** Defines that impulse is constant in strength across it's whole radius */
  55310. Constant = 0,
  55311. /** Defines that impulse gets weaker if it's further from the origin */
  55312. Linear = 1
  55313. }
  55314. /**
  55315. * The strength of the force in correspondence to the distance of the affected object
  55316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55317. */
  55318. export enum PhysicsUpdraftMode {
  55319. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55320. Center = 0,
  55321. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55322. Perpendicular = 1
  55323. }
  55324. /**
  55325. * Interface for a physics hit data
  55326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55327. */
  55328. export interface PhysicsHitData {
  55329. /**
  55330. * The force applied at the contact point
  55331. */
  55332. force: Vector3;
  55333. /**
  55334. * The contact point
  55335. */
  55336. contactPoint: Vector3;
  55337. /**
  55338. * The distance from the origin to the contact point
  55339. */
  55340. distanceFromOrigin: number;
  55341. }
  55342. /**
  55343. * Interface for radial explosion event data
  55344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55345. */
  55346. export interface PhysicsRadialExplosionEventData {
  55347. /**
  55348. * A sphere used for the radial explosion event
  55349. */
  55350. sphere: Mesh;
  55351. }
  55352. /**
  55353. * Interface for gravitational field event data
  55354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55355. */
  55356. export interface PhysicsGravitationalFieldEventData {
  55357. /**
  55358. * A sphere mesh used for the gravitational field event
  55359. */
  55360. sphere: Mesh;
  55361. }
  55362. /**
  55363. * Interface for updraft event data
  55364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55365. */
  55366. export interface PhysicsUpdraftEventData {
  55367. /**
  55368. * A cylinder used for the updraft event
  55369. */
  55370. cylinder: Mesh;
  55371. }
  55372. /**
  55373. * Interface for vortex event data
  55374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55375. */
  55376. export interface PhysicsVortexEventData {
  55377. /**
  55378. * A cylinder used for the vortex event
  55379. */
  55380. cylinder: Mesh;
  55381. }
  55382. /**
  55383. * Interface for an affected physics impostor
  55384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55385. */
  55386. export interface PhysicsAffectedImpostorWithData {
  55387. /**
  55388. * The impostor affected by the effect
  55389. */
  55390. impostor: PhysicsImpostor;
  55391. /**
  55392. * The data about the hit/horce from the explosion
  55393. */
  55394. hitData: PhysicsHitData;
  55395. }
  55396. }
  55397. declare module BABYLON {
  55398. /** @hidden */
  55399. export var blackAndWhitePixelShader: {
  55400. name: string;
  55401. shader: string;
  55402. };
  55403. }
  55404. declare module BABYLON {
  55405. /**
  55406. * Post process used to render in black and white
  55407. */
  55408. export class BlackAndWhitePostProcess extends PostProcess {
  55409. /**
  55410. * Linear about to convert he result to black and white (default: 1)
  55411. */
  55412. degree: number;
  55413. /**
  55414. * Creates a black and white post process
  55415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55416. * @param name The name of the effect.
  55417. * @param options The required width/height ratio to downsize to before computing the render pass.
  55418. * @param camera The camera to apply the render pass to.
  55419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55420. * @param engine The engine which the post process will be applied. (default: current engine)
  55421. * @param reusable If the post process can be reused on the same frame. (default: false)
  55422. */
  55423. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * This represents a set of one or more post processes in Babylon.
  55429. * A post process can be used to apply a shader to a texture after it is rendered.
  55430. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55431. */
  55432. export class PostProcessRenderEffect {
  55433. private _postProcesses;
  55434. private _getPostProcesses;
  55435. private _singleInstance;
  55436. private _cameras;
  55437. private _indicesForCamera;
  55438. /**
  55439. * Name of the effect
  55440. * @hidden
  55441. */ private _name: string;
  55442. /**
  55443. * Instantiates a post process render effect.
  55444. * A post process can be used to apply a shader to a texture after it is rendered.
  55445. * @param engine The engine the effect is tied to
  55446. * @param name The name of the effect
  55447. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55448. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55449. */
  55450. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55451. /**
  55452. * Checks if all the post processes in the effect are supported.
  55453. */
  55454. readonly isSupported: boolean;
  55455. /**
  55456. * Updates the current state of the effect
  55457. * @hidden
  55458. */ private _update(): void;
  55459. /**
  55460. * Attaches the effect on cameras
  55461. * @param cameras The camera to attach to.
  55462. * @hidden
  55463. */ private _attachCameras(cameras: Camera): void;
  55464. /**
  55465. * Attaches the effect on cameras
  55466. * @param cameras The camera to attach to.
  55467. * @hidden
  55468. */ private _attachCameras(cameras: Camera[]): void;
  55469. /**
  55470. * Detaches the effect on cameras
  55471. * @param cameras The camera to detatch from.
  55472. * @hidden
  55473. */ private _detachCameras(cameras: Camera): void;
  55474. /**
  55475. * Detatches the effect on cameras
  55476. * @param cameras The camera to detatch from.
  55477. * @hidden
  55478. */ private _detachCameras(cameras: Camera[]): void;
  55479. /**
  55480. * Enables the effect on given cameras
  55481. * @param cameras The camera to enable.
  55482. * @hidden
  55483. */ private _enable(cameras: Camera): void;
  55484. /**
  55485. * Enables the effect on given cameras
  55486. * @param cameras The camera to enable.
  55487. * @hidden
  55488. */ private _enable(cameras: Nullable<Camera[]>): void;
  55489. /**
  55490. * Disables the effect on the given cameras
  55491. * @param cameras The camera to disable.
  55492. * @hidden
  55493. */ private _disable(cameras: Camera): void;
  55494. /**
  55495. * Disables the effect on the given cameras
  55496. * @param cameras The camera to disable.
  55497. * @hidden
  55498. */ private _disable(cameras: Nullable<Camera[]>): void;
  55499. /**
  55500. * Gets a list of the post processes contained in the effect.
  55501. * @param camera The camera to get the post processes on.
  55502. * @returns The list of the post processes in the effect.
  55503. */
  55504. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55505. }
  55506. }
  55507. declare module BABYLON {
  55508. /** @hidden */
  55509. export var extractHighlightsPixelShader: {
  55510. name: string;
  55511. shader: string;
  55512. };
  55513. }
  55514. declare module BABYLON {
  55515. /**
  55516. * 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.
  55517. */
  55518. export class ExtractHighlightsPostProcess extends PostProcess {
  55519. /**
  55520. * The luminance threshold, pixels below this value will be set to black.
  55521. */
  55522. threshold: number;
  55523. /** @hidden */ private _exposure: number;
  55524. /**
  55525. * Post process which has the input texture to be used when performing highlight extraction
  55526. * @hidden
  55527. */ private _inputPostProcess: Nullable<PostProcess>;
  55528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55529. }
  55530. }
  55531. declare module BABYLON {
  55532. /** @hidden */
  55533. export var bloomMergePixelShader: {
  55534. name: string;
  55535. shader: string;
  55536. };
  55537. }
  55538. declare module BABYLON {
  55539. /**
  55540. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55541. */
  55542. export class BloomMergePostProcess extends PostProcess {
  55543. /** Weight of the bloom to be added to the original input. */
  55544. weight: number;
  55545. /**
  55546. * Creates a new instance of @see BloomMergePostProcess
  55547. * @param name The name of the effect.
  55548. * @param originalFromInput Post process which's input will be used for the merge.
  55549. * @param blurred Blurred highlights post process which's output will be used.
  55550. * @param weight Weight of the bloom to be added to the original input.
  55551. * @param options The required width/height ratio to downsize to before computing the render pass.
  55552. * @param camera The camera to apply the render pass to.
  55553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55554. * @param engine The engine which the post process will be applied. (default: current engine)
  55555. * @param reusable If the post process can be reused on the same frame. (default: false)
  55556. * @param textureType Type of textures used when performing the post process. (default: 0)
  55557. * @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)
  55558. */
  55559. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55560. /** Weight of the bloom to be added to the original input. */
  55561. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55562. }
  55563. }
  55564. declare module BABYLON {
  55565. /**
  55566. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55567. */
  55568. export class BloomEffect extends PostProcessRenderEffect {
  55569. private bloomScale;
  55570. /**
  55571. * @hidden Internal
  55572. */ private _effects: Array<PostProcess>;
  55573. /**
  55574. * @hidden Internal
  55575. */ private _downscale: ExtractHighlightsPostProcess;
  55576. private _blurX;
  55577. private _blurY;
  55578. private _merge;
  55579. /**
  55580. * The luminance threshold to find bright areas of the image to bloom.
  55581. */
  55582. threshold: number;
  55583. /**
  55584. * The strength of the bloom.
  55585. */
  55586. weight: number;
  55587. /**
  55588. * Specifies the size of the bloom blur kernel, relative to the final output size
  55589. */
  55590. kernel: number;
  55591. /**
  55592. * Creates a new instance of @see BloomEffect
  55593. * @param scene The scene the effect belongs to.
  55594. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55595. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55596. * @param bloomWeight The the strength of bloom.
  55597. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55598. * @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)
  55599. */
  55600. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55601. /**
  55602. * Disposes each of the internal effects for a given camera.
  55603. * @param camera The camera to dispose the effect on.
  55604. */
  55605. disposeEffects(camera: Camera): void;
  55606. /**
  55607. * @hidden Internal
  55608. */ private _updateEffects(): void;
  55609. /**
  55610. * Internal
  55611. * @returns if all the contained post processes are ready.
  55612. * @hidden
  55613. */ private _isReady(): boolean;
  55614. }
  55615. }
  55616. declare module BABYLON {
  55617. /** @hidden */
  55618. export var chromaticAberrationPixelShader: {
  55619. name: string;
  55620. shader: string;
  55621. };
  55622. }
  55623. declare module BABYLON {
  55624. /**
  55625. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55626. */
  55627. export class ChromaticAberrationPostProcess extends PostProcess {
  55628. /**
  55629. * The amount of seperation of rgb channels (default: 30)
  55630. */
  55631. aberrationAmount: number;
  55632. /**
  55633. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55634. */
  55635. radialIntensity: number;
  55636. /**
  55637. * 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))
  55638. */
  55639. direction: Vector2;
  55640. /**
  55641. * 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))
  55642. */
  55643. centerPosition: Vector2;
  55644. /**
  55645. * Creates a new instance ChromaticAberrationPostProcess
  55646. * @param name The name of the effect.
  55647. * @param screenWidth The width of the screen to apply the effect on.
  55648. * @param screenHeight The height of the screen to apply the effect on.
  55649. * @param options The required width/height ratio to downsize to before computing the render pass.
  55650. * @param camera The camera to apply the render pass to.
  55651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55652. * @param engine The engine which the post process will be applied. (default: current engine)
  55653. * @param reusable If the post process can be reused on the same frame. (default: false)
  55654. * @param textureType Type of textures used when performing the post process. (default: 0)
  55655. * @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)
  55656. */
  55657. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55658. }
  55659. }
  55660. declare module BABYLON {
  55661. /** @hidden */
  55662. export var circleOfConfusionPixelShader: {
  55663. name: string;
  55664. shader: string;
  55665. };
  55666. }
  55667. declare module BABYLON {
  55668. /**
  55669. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55670. */
  55671. export class CircleOfConfusionPostProcess extends PostProcess {
  55672. /**
  55673. * 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.
  55674. */
  55675. lensSize: number;
  55676. /**
  55677. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55678. */
  55679. fStop: number;
  55680. /**
  55681. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55682. */
  55683. focusDistance: number;
  55684. /**
  55685. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55686. */
  55687. focalLength: number;
  55688. private _depthTexture;
  55689. /**
  55690. * Creates a new instance CircleOfConfusionPostProcess
  55691. * @param name The name of the effect.
  55692. * @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.
  55693. * @param options The required width/height ratio to downsize to before computing the render pass.
  55694. * @param camera The camera to apply the render pass to.
  55695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55696. * @param engine The engine which the post process will be applied. (default: current engine)
  55697. * @param reusable If the post process can be reused on the same frame. (default: false)
  55698. * @param textureType Type of textures used when performing the post process. (default: 0)
  55699. * @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)
  55700. */
  55701. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55702. /**
  55703. * 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.
  55704. */
  55705. depthTexture: RenderTargetTexture;
  55706. }
  55707. }
  55708. declare module BABYLON {
  55709. /** @hidden */
  55710. export var colorCorrectionPixelShader: {
  55711. name: string;
  55712. shader: string;
  55713. };
  55714. }
  55715. declare module BABYLON {
  55716. /**
  55717. *
  55718. * This post-process allows the modification of rendered colors by using
  55719. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55720. *
  55721. * The object needs to be provided an url to a texture containing the color
  55722. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55723. * Use an image editing software to tweak the LUT to match your needs.
  55724. *
  55725. * For an example of a color LUT, see here:
  55726. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55727. * For explanations on color grading, see here:
  55728. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55729. *
  55730. */
  55731. export class ColorCorrectionPostProcess extends PostProcess {
  55732. private _colorTableTexture;
  55733. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55734. }
  55735. }
  55736. declare module BABYLON {
  55737. /** @hidden */
  55738. export var convolutionPixelShader: {
  55739. name: string;
  55740. shader: string;
  55741. };
  55742. }
  55743. declare module BABYLON {
  55744. /**
  55745. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55746. * input texture to perform effects such as edge detection or sharpening
  55747. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55748. */
  55749. export class ConvolutionPostProcess extends PostProcess {
  55750. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55751. kernel: number[];
  55752. /**
  55753. * Creates a new instance ConvolutionPostProcess
  55754. * @param name The name of the effect.
  55755. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55756. * @param options The required width/height ratio to downsize to before computing the render pass.
  55757. * @param camera The camera to apply the render pass to.
  55758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55759. * @param engine The engine which the post process will be applied. (default: current engine)
  55760. * @param reusable If the post process can be reused on the same frame. (default: false)
  55761. * @param textureType Type of textures used when performing the post process. (default: 0)
  55762. */
  55763. constructor(name: string,
  55764. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55765. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55766. /**
  55767. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55768. */
  55769. static EdgeDetect0Kernel: number[];
  55770. /**
  55771. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55772. */
  55773. static EdgeDetect1Kernel: number[];
  55774. /**
  55775. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55776. */
  55777. static EdgeDetect2Kernel: number[];
  55778. /**
  55779. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55780. */
  55781. static SharpenKernel: number[];
  55782. /**
  55783. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55784. */
  55785. static EmbossKernel: number[];
  55786. /**
  55787. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55788. */
  55789. static GaussianKernel: number[];
  55790. }
  55791. }
  55792. declare module BABYLON {
  55793. /**
  55794. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55795. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55796. * based on samples that have a large difference in distance than the center pixel.
  55797. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55798. */
  55799. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55800. direction: Vector2;
  55801. /**
  55802. * Creates a new instance CircleOfConfusionPostProcess
  55803. * @param name The name of the effect.
  55804. * @param scene The scene the effect belongs to.
  55805. * @param direction The direction the blur should be applied.
  55806. * @param kernel The size of the kernel used to blur.
  55807. * @param options The required width/height ratio to downsize to before computing the render pass.
  55808. * @param camera The camera to apply the render pass to.
  55809. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55810. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55812. * @param engine The engine which the post process will be applied. (default: current engine)
  55813. * @param reusable If the post process can be reused on the same frame. (default: false)
  55814. * @param textureType Type of textures used when performing the post process. (default: 0)
  55815. * @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)
  55816. */
  55817. 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);
  55818. }
  55819. }
  55820. declare module BABYLON {
  55821. /** @hidden */
  55822. export var depthOfFieldMergePixelShader: {
  55823. name: string;
  55824. shader: string;
  55825. };
  55826. }
  55827. declare module BABYLON {
  55828. /**
  55829. * Options to be set when merging outputs from the default pipeline.
  55830. */
  55831. export class DepthOfFieldMergePostProcessOptions {
  55832. /**
  55833. * The original image to merge on top of
  55834. */
  55835. originalFromInput: PostProcess;
  55836. /**
  55837. * Parameters to perform the merge of the depth of field effect
  55838. */
  55839. depthOfField?: {
  55840. circleOfConfusion: PostProcess;
  55841. blurSteps: Array<PostProcess>;
  55842. };
  55843. /**
  55844. * Parameters to perform the merge of bloom effect
  55845. */
  55846. bloom?: {
  55847. blurred: PostProcess;
  55848. weight: number;
  55849. };
  55850. }
  55851. /**
  55852. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55853. */
  55854. export class DepthOfFieldMergePostProcess extends PostProcess {
  55855. private blurSteps;
  55856. /**
  55857. * Creates a new instance of DepthOfFieldMergePostProcess
  55858. * @param name The name of the effect.
  55859. * @param originalFromInput Post process which's input will be used for the merge.
  55860. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55861. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55862. * @param options The required width/height ratio to downsize to before computing the render pass.
  55863. * @param camera The camera to apply the render pass to.
  55864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55865. * @param engine The engine which the post process will be applied. (default: current engine)
  55866. * @param reusable If the post process can be reused on the same frame. (default: false)
  55867. * @param textureType Type of textures used when performing the post process. (default: 0)
  55868. * @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)
  55869. */
  55870. 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);
  55871. /**
  55872. * Updates the effect with the current post process compile time values and recompiles the shader.
  55873. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55874. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55875. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55876. * @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
  55877. * @param onCompiled Called when the shader has been compiled.
  55878. * @param onError Called if there is an error when compiling a shader.
  55879. */
  55880. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55881. }
  55882. }
  55883. declare module BABYLON {
  55884. /**
  55885. * Specifies the level of max blur that should be applied when using the depth of field effect
  55886. */
  55887. export enum DepthOfFieldEffectBlurLevel {
  55888. /**
  55889. * Subtle blur
  55890. */
  55891. Low = 0,
  55892. /**
  55893. * Medium blur
  55894. */
  55895. Medium = 1,
  55896. /**
  55897. * Large blur
  55898. */
  55899. High = 2
  55900. }
  55901. /**
  55902. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55903. */
  55904. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55905. private _circleOfConfusion;
  55906. /**
  55907. * @hidden Internal, blurs from high to low
  55908. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55909. private _depthOfFieldBlurY;
  55910. private _dofMerge;
  55911. /**
  55912. * @hidden Internal post processes in depth of field effect
  55913. */ private _effects: Array<PostProcess>;
  55914. /**
  55915. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55916. */
  55917. focalLength: number;
  55918. /**
  55919. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55920. */
  55921. fStop: number;
  55922. /**
  55923. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55924. */
  55925. focusDistance: number;
  55926. /**
  55927. * 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.
  55928. */
  55929. lensSize: number;
  55930. /**
  55931. * Creates a new instance DepthOfFieldEffect
  55932. * @param scene The scene the effect belongs to.
  55933. * @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.
  55934. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55935. * @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)
  55936. */
  55937. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55938. /**
  55939. * Get the current class name of the current effet
  55940. * @returns "DepthOfFieldEffect"
  55941. */
  55942. getClassName(): string;
  55943. /**
  55944. * 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.
  55945. */
  55946. depthTexture: RenderTargetTexture;
  55947. /**
  55948. * Disposes each of the internal effects for a given camera.
  55949. * @param camera The camera to dispose the effect on.
  55950. */
  55951. disposeEffects(camera: Camera): void;
  55952. /**
  55953. * @hidden Internal
  55954. */ private _updateEffects(): void;
  55955. /**
  55956. * Internal
  55957. * @returns if all the contained post processes are ready.
  55958. * @hidden
  55959. */ private _isReady(): boolean;
  55960. }
  55961. }
  55962. declare module BABYLON {
  55963. /** @hidden */
  55964. export var displayPassPixelShader: {
  55965. name: string;
  55966. shader: string;
  55967. };
  55968. }
  55969. declare module BABYLON {
  55970. /**
  55971. * DisplayPassPostProcess which produces an output the same as it's input
  55972. */
  55973. export class DisplayPassPostProcess extends PostProcess {
  55974. /**
  55975. * Creates the DisplayPassPostProcess
  55976. * @param name The name of the effect.
  55977. * @param options The required width/height ratio to downsize to before computing the render pass.
  55978. * @param camera The camera to apply the render pass to.
  55979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55980. * @param engine The engine which the post process will be applied. (default: current engine)
  55981. * @param reusable If the post process can be reused on the same frame. (default: false)
  55982. */
  55983. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55984. }
  55985. }
  55986. declare module BABYLON {
  55987. /** @hidden */
  55988. export var filterPixelShader: {
  55989. name: string;
  55990. shader: string;
  55991. };
  55992. }
  55993. declare module BABYLON {
  55994. /**
  55995. * Applies a kernel filter to the image
  55996. */
  55997. export class FilterPostProcess extends PostProcess {
  55998. /** The matrix to be applied to the image */
  55999. kernelMatrix: Matrix;
  56000. /**
  56001. *
  56002. * @param name The name of the effect.
  56003. * @param kernelMatrix The matrix to be applied to the image
  56004. * @param options The required width/height ratio to downsize to before computing the render pass.
  56005. * @param camera The camera to apply the render pass to.
  56006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56007. * @param engine The engine which the post process will be applied. (default: current engine)
  56008. * @param reusable If the post process can be reused on the same frame. (default: false)
  56009. */
  56010. constructor(name: string,
  56011. /** The matrix to be applied to the image */
  56012. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56013. }
  56014. }
  56015. declare module BABYLON {
  56016. /** @hidden */
  56017. export var fxaaPixelShader: {
  56018. name: string;
  56019. shader: string;
  56020. };
  56021. }
  56022. declare module BABYLON {
  56023. /** @hidden */
  56024. export var fxaaVertexShader: {
  56025. name: string;
  56026. shader: string;
  56027. };
  56028. }
  56029. declare module BABYLON {
  56030. /**
  56031. * Fxaa post process
  56032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56033. */
  56034. export class FxaaPostProcess extends PostProcess {
  56035. /** @hidden */
  56036. texelWidth: number;
  56037. /** @hidden */
  56038. texelHeight: number;
  56039. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56040. private _getDefines;
  56041. }
  56042. }
  56043. declare module BABYLON {
  56044. /** @hidden */
  56045. export var grainPixelShader: {
  56046. name: string;
  56047. shader: string;
  56048. };
  56049. }
  56050. declare module BABYLON {
  56051. /**
  56052. * The GrainPostProcess adds noise to the image at mid luminance levels
  56053. */
  56054. export class GrainPostProcess extends PostProcess {
  56055. /**
  56056. * The intensity of the grain added (default: 30)
  56057. */
  56058. intensity: number;
  56059. /**
  56060. * If the grain should be randomized on every frame
  56061. */
  56062. animated: boolean;
  56063. /**
  56064. * Creates a new instance of @see GrainPostProcess
  56065. * @param name The name of the effect.
  56066. * @param options The required width/height ratio to downsize to before computing the render pass.
  56067. * @param camera The camera to apply the render pass to.
  56068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56069. * @param engine The engine which the post process will be applied. (default: current engine)
  56070. * @param reusable If the post process can be reused on the same frame. (default: false)
  56071. * @param textureType Type of textures used when performing the post process. (default: 0)
  56072. * @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)
  56073. */
  56074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56075. }
  56076. }
  56077. declare module BABYLON {
  56078. /** @hidden */
  56079. export var highlightsPixelShader: {
  56080. name: string;
  56081. shader: string;
  56082. };
  56083. }
  56084. declare module BABYLON {
  56085. /**
  56086. * Extracts highlights from the image
  56087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56088. */
  56089. export class HighlightsPostProcess extends PostProcess {
  56090. /**
  56091. * Extracts highlights from the image
  56092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56093. * @param name The name of the effect.
  56094. * @param options The required width/height ratio to downsize to before computing the render pass.
  56095. * @param camera The camera to apply the render pass to.
  56096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56097. * @param engine The engine which the post process will be applied. (default: current engine)
  56098. * @param reusable If the post process can be reused on the same frame. (default: false)
  56099. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56100. */
  56101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56102. }
  56103. }
  56104. declare module BABYLON {
  56105. /** @hidden */
  56106. export var mrtFragmentDeclaration: {
  56107. name: string;
  56108. shader: string;
  56109. };
  56110. }
  56111. declare module BABYLON {
  56112. /** @hidden */
  56113. export var geometryPixelShader: {
  56114. name: string;
  56115. shader: string;
  56116. };
  56117. }
  56118. declare module BABYLON {
  56119. /** @hidden */
  56120. export var geometryVertexShader: {
  56121. name: string;
  56122. shader: string;
  56123. };
  56124. }
  56125. declare module BABYLON {
  56126. /** @hidden */
  56127. interface ISavedTransformationMatrix {
  56128. world: Matrix;
  56129. viewProjection: Matrix;
  56130. }
  56131. /**
  56132. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56133. */
  56134. export class GeometryBufferRenderer {
  56135. /**
  56136. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56137. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56138. */
  56139. static readonly POSITION_TEXTURE_TYPE: number;
  56140. /**
  56141. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56142. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56143. */
  56144. static readonly VELOCITY_TEXTURE_TYPE: number;
  56145. /**
  56146. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56147. * in order to compute objects velocities when enableVelocity is set to "true"
  56148. * @hidden
  56149. */ private _previousTransformationMatrices: {
  56150. [index: number]: ISavedTransformationMatrix;
  56151. };
  56152. /**
  56153. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56154. * in order to compute objects velocities when enableVelocity is set to "true"
  56155. * @hidden
  56156. */ private _previousBonesTransformationMatrices: {
  56157. [index: number]: Float32Array;
  56158. };
  56159. /**
  56160. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56161. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56162. */
  56163. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56164. private _scene;
  56165. private _multiRenderTarget;
  56166. private _ratio;
  56167. private _enablePosition;
  56168. private _enableVelocity;
  56169. private _positionIndex;
  56170. private _velocityIndex;
  56171. protected _effect: Effect;
  56172. protected _cachedDefines: string;
  56173. /**
  56174. * Set the render list (meshes to be rendered) used in the G buffer.
  56175. */
  56176. renderList: Mesh[];
  56177. /**
  56178. * Gets wether or not G buffer are supported by the running hardware.
  56179. * This requires draw buffer supports
  56180. */
  56181. readonly isSupported: boolean;
  56182. /**
  56183. * Returns the index of the given texture type in the G-Buffer textures array
  56184. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56185. * @returns the index of the given texture type in the G-Buffer textures array
  56186. */
  56187. getTextureIndex(textureType: number): number;
  56188. /**
  56189. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56190. */
  56191. /**
  56192. * Sets whether or not objects positions are enabled for the G buffer.
  56193. */
  56194. enablePosition: boolean;
  56195. /**
  56196. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56197. */
  56198. /**
  56199. * Sets wether or not objects velocities are enabled for the G buffer.
  56200. */
  56201. enableVelocity: boolean;
  56202. /**
  56203. * Gets the scene associated with the buffer.
  56204. */
  56205. readonly scene: Scene;
  56206. /**
  56207. * Gets the ratio used by the buffer during its creation.
  56208. * How big is the buffer related to the main canvas.
  56209. */
  56210. readonly ratio: number;
  56211. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  56212. /**
  56213. * Creates a new G Buffer for the scene
  56214. * @param scene The scene the buffer belongs to
  56215. * @param ratio How big is the buffer related to the main canvas.
  56216. */
  56217. constructor(scene: Scene, ratio?: number);
  56218. /**
  56219. * Checks wether everything is ready to render a submesh to the G buffer.
  56220. * @param subMesh the submesh to check readiness for
  56221. * @param useInstances is the mesh drawn using instance or not
  56222. * @returns true if ready otherwise false
  56223. */
  56224. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56225. /**
  56226. * Gets the current underlying G Buffer.
  56227. * @returns the buffer
  56228. */
  56229. getGBuffer(): MultiRenderTarget;
  56230. /**
  56231. * Gets the number of samples used to render the buffer (anti aliasing).
  56232. */
  56233. /**
  56234. * Sets the number of samples used to render the buffer (anti aliasing).
  56235. */
  56236. samples: number;
  56237. /**
  56238. * Disposes the renderer and frees up associated resources.
  56239. */
  56240. dispose(): void;
  56241. protected _createRenderTargets(): void;
  56242. private _copyBonesTransformationMatrices;
  56243. }
  56244. }
  56245. declare module BABYLON {
  56246. interface Scene {
  56247. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56248. /**
  56249. * Gets or Sets the current geometry buffer associated to the scene.
  56250. */
  56251. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56252. /**
  56253. * Enables a GeometryBufferRender and associates it with the scene
  56254. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56255. * @returns the GeometryBufferRenderer
  56256. */
  56257. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56258. /**
  56259. * Disables the GeometryBufferRender associated with the scene
  56260. */
  56261. disableGeometryBufferRenderer(): void;
  56262. }
  56263. /**
  56264. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56265. * in several rendering techniques.
  56266. */
  56267. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56268. /**
  56269. * The component name helpful to identify the component in the list of scene components.
  56270. */
  56271. readonly name: string;
  56272. /**
  56273. * The scene the component belongs to.
  56274. */
  56275. scene: Scene;
  56276. /**
  56277. * Creates a new instance of the component for the given scene
  56278. * @param scene Defines the scene to register the component in
  56279. */
  56280. constructor(scene: Scene);
  56281. /**
  56282. * Registers the component in a given scene
  56283. */
  56284. register(): void;
  56285. /**
  56286. * Rebuilds the elements related to this component in case of
  56287. * context lost for instance.
  56288. */
  56289. rebuild(): void;
  56290. /**
  56291. * Disposes the component and the associated ressources
  56292. */
  56293. dispose(): void;
  56294. private _gatherRenderTargets;
  56295. }
  56296. }
  56297. declare module BABYLON {
  56298. /** @hidden */
  56299. export var motionBlurPixelShader: {
  56300. name: string;
  56301. shader: string;
  56302. };
  56303. }
  56304. declare module BABYLON {
  56305. /**
  56306. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56307. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56308. * As an example, all you have to do is to create the post-process:
  56309. * var mb = new BABYLON.MotionBlurPostProcess(
  56310. * 'mb', // The name of the effect.
  56311. * scene, // The scene containing the objects to blur according to their velocity.
  56312. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56313. * camera // The camera to apply the render pass to.
  56314. * );
  56315. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56316. */
  56317. export class MotionBlurPostProcess extends PostProcess {
  56318. /**
  56319. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56320. */
  56321. motionStrength: number;
  56322. /**
  56323. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56324. */
  56325. /**
  56326. * Sets the number of iterations to be used for motion blur quality
  56327. */
  56328. motionBlurSamples: number;
  56329. private _motionBlurSamples;
  56330. private _geometryBufferRenderer;
  56331. /**
  56332. * Creates a new instance MotionBlurPostProcess
  56333. * @param name The name of the effect.
  56334. * @param scene The scene containing the objects to blur according to their velocity.
  56335. * @param options The required width/height ratio to downsize to before computing the render pass.
  56336. * @param camera The camera to apply the render pass to.
  56337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56338. * @param engine The engine which the post process will be applied. (default: current engine)
  56339. * @param reusable If the post process can be reused on the same frame. (default: false)
  56340. * @param textureType Type of textures used when performing the post process. (default: 0)
  56341. * @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)
  56342. */
  56343. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56344. /**
  56345. * Excludes the given skinned mesh from computing bones velocities.
  56346. * 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.
  56347. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56348. */
  56349. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56350. /**
  56351. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56352. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56353. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56354. */
  56355. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56356. /**
  56357. * Disposes the post process.
  56358. * @param camera The camera to dispose the post process on.
  56359. */
  56360. dispose(camera?: Camera): void;
  56361. }
  56362. }
  56363. declare module BABYLON {
  56364. /** @hidden */
  56365. export var refractionPixelShader: {
  56366. name: string;
  56367. shader: string;
  56368. };
  56369. }
  56370. declare module BABYLON {
  56371. /**
  56372. * Post process which applies a refractin texture
  56373. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56374. */
  56375. export class RefractionPostProcess extends PostProcess {
  56376. /** the base color of the refraction (used to taint the rendering) */
  56377. color: Color3;
  56378. /** simulated refraction depth */
  56379. depth: number;
  56380. /** the coefficient of the base color (0 to remove base color tainting) */
  56381. colorLevel: number;
  56382. private _refTexture;
  56383. private _ownRefractionTexture;
  56384. /**
  56385. * Gets or sets the refraction texture
  56386. * Please note that you are responsible for disposing the texture if you set it manually
  56387. */
  56388. refractionTexture: Texture;
  56389. /**
  56390. * Initializes the RefractionPostProcess
  56391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56392. * @param name The name of the effect.
  56393. * @param refractionTextureUrl Url of the refraction texture to use
  56394. * @param color the base color of the refraction (used to taint the rendering)
  56395. * @param depth simulated refraction depth
  56396. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56397. * @param camera The camera to apply the render pass to.
  56398. * @param options The required width/height ratio to downsize to before computing the render pass.
  56399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56400. * @param engine The engine which the post process will be applied. (default: current engine)
  56401. * @param reusable If the post process can be reused on the same frame. (default: false)
  56402. */
  56403. constructor(name: string, refractionTextureUrl: string,
  56404. /** the base color of the refraction (used to taint the rendering) */
  56405. color: Color3,
  56406. /** simulated refraction depth */
  56407. depth: number,
  56408. /** the coefficient of the base color (0 to remove base color tainting) */
  56409. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56410. /**
  56411. * Disposes of the post process
  56412. * @param camera Camera to dispose post process on
  56413. */
  56414. dispose(camera: Camera): void;
  56415. }
  56416. }
  56417. declare module BABYLON {
  56418. /** @hidden */
  56419. export var sharpenPixelShader: {
  56420. name: string;
  56421. shader: string;
  56422. };
  56423. }
  56424. declare module BABYLON {
  56425. /**
  56426. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56427. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56428. */
  56429. export class SharpenPostProcess extends PostProcess {
  56430. /**
  56431. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56432. */
  56433. colorAmount: number;
  56434. /**
  56435. * How much sharpness should be applied (default: 0.3)
  56436. */
  56437. edgeAmount: number;
  56438. /**
  56439. * Creates a new instance ConvolutionPostProcess
  56440. * @param name The name of the effect.
  56441. * @param options The required width/height ratio to downsize to before computing the render pass.
  56442. * @param camera The camera to apply the render pass to.
  56443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56444. * @param engine The engine which the post process will be applied. (default: current engine)
  56445. * @param reusable If the post process can be reused on the same frame. (default: false)
  56446. * @param textureType Type of textures used when performing the post process. (default: 0)
  56447. * @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)
  56448. */
  56449. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56450. }
  56451. }
  56452. declare module BABYLON {
  56453. /**
  56454. * PostProcessRenderPipeline
  56455. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56456. */
  56457. export class PostProcessRenderPipeline {
  56458. private engine;
  56459. private _renderEffects;
  56460. private _renderEffectsForIsolatedPass;
  56461. /**
  56462. * List of inspectable custom properties (used by the Inspector)
  56463. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56464. */
  56465. inspectableCustomProperties: IInspectable[];
  56466. /**
  56467. * @hidden
  56468. */
  56469. protected _cameras: Camera[];
  56470. /** @hidden */ private _name: string;
  56471. /**
  56472. * Gets pipeline name
  56473. */
  56474. readonly name: string;
  56475. /**
  56476. * Initializes a PostProcessRenderPipeline
  56477. * @param engine engine to add the pipeline to
  56478. * @param name name of the pipeline
  56479. */
  56480. constructor(engine: Engine, name: string);
  56481. /**
  56482. * Gets the class name
  56483. * @returns "PostProcessRenderPipeline"
  56484. */
  56485. getClassName(): string;
  56486. /**
  56487. * If all the render effects in the pipeline are supported
  56488. */
  56489. readonly isSupported: boolean;
  56490. /**
  56491. * Adds an effect to the pipeline
  56492. * @param renderEffect the effect to add
  56493. */
  56494. addEffect(renderEffect: PostProcessRenderEffect): void;
  56495. /** @hidden */ private _rebuild(): void;
  56496. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  56497. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56498. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56499. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56500. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  56501. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  56502. /** @hidden */ private _detachCameras(cameras: Camera): void;
  56503. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  56504. /** @hidden */ private _update(): void;
  56505. /** @hidden */ private _reset(): void;
  56506. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56507. /**
  56508. * Disposes of the pipeline
  56509. */
  56510. dispose(): void;
  56511. }
  56512. }
  56513. declare module BABYLON {
  56514. /**
  56515. * PostProcessRenderPipelineManager class
  56516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56517. */
  56518. export class PostProcessRenderPipelineManager {
  56519. private _renderPipelines;
  56520. /**
  56521. * Initializes a PostProcessRenderPipelineManager
  56522. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56523. */
  56524. constructor();
  56525. /**
  56526. * Gets the list of supported render pipelines
  56527. */
  56528. readonly supportedPipelines: PostProcessRenderPipeline[];
  56529. /**
  56530. * Adds a pipeline to the manager
  56531. * @param renderPipeline The pipeline to add
  56532. */
  56533. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56534. /**
  56535. * Attaches a camera to the pipeline
  56536. * @param renderPipelineName The name of the pipeline to attach to
  56537. * @param cameras the camera to attach
  56538. * @param unique if the camera can be attached multiple times to the pipeline
  56539. */
  56540. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56541. /**
  56542. * Detaches a camera from the pipeline
  56543. * @param renderPipelineName The name of the pipeline to detach from
  56544. * @param cameras the camera to detach
  56545. */
  56546. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56547. /**
  56548. * Enables an effect by name on a pipeline
  56549. * @param renderPipelineName the name of the pipeline to enable the effect in
  56550. * @param renderEffectName the name of the effect to enable
  56551. * @param cameras the cameras that the effect should be enabled on
  56552. */
  56553. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56554. /**
  56555. * Disables an effect by name on a pipeline
  56556. * @param renderPipelineName the name of the pipeline to disable the effect in
  56557. * @param renderEffectName the name of the effect to disable
  56558. * @param cameras the cameras that the effect should be disabled on
  56559. */
  56560. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56561. /**
  56562. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56563. */
  56564. update(): void;
  56565. /** @hidden */ private _rebuild(): void;
  56566. /**
  56567. * Disposes of the manager and pipelines
  56568. */
  56569. dispose(): void;
  56570. }
  56571. }
  56572. declare module BABYLON {
  56573. interface Scene {
  56574. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56575. /**
  56576. * Gets the postprocess render pipeline manager
  56577. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56578. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56579. */
  56580. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56581. }
  56582. /**
  56583. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56584. */
  56585. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56586. /**
  56587. * The component name helpfull to identify the component in the list of scene components.
  56588. */
  56589. readonly name: string;
  56590. /**
  56591. * The scene the component belongs to.
  56592. */
  56593. scene: Scene;
  56594. /**
  56595. * Creates a new instance of the component for the given scene
  56596. * @param scene Defines the scene to register the component in
  56597. */
  56598. constructor(scene: Scene);
  56599. /**
  56600. * Registers the component in a given scene
  56601. */
  56602. register(): void;
  56603. /**
  56604. * Rebuilds the elements related to this component in case of
  56605. * context lost for instance.
  56606. */
  56607. rebuild(): void;
  56608. /**
  56609. * Disposes the component and the associated ressources
  56610. */
  56611. dispose(): void;
  56612. private _gatherRenderTargets;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /**
  56617. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56618. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56619. */
  56620. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56621. private _scene;
  56622. private _camerasToBeAttached;
  56623. /**
  56624. * ID of the sharpen post process,
  56625. */
  56626. private readonly SharpenPostProcessId;
  56627. /**
  56628. * @ignore
  56629. * ID of the image processing post process;
  56630. */
  56631. readonly ImageProcessingPostProcessId: string;
  56632. /**
  56633. * @ignore
  56634. * ID of the Fast Approximate Anti-Aliasing post process;
  56635. */
  56636. readonly FxaaPostProcessId: string;
  56637. /**
  56638. * ID of the chromatic aberration post process,
  56639. */
  56640. private readonly ChromaticAberrationPostProcessId;
  56641. /**
  56642. * ID of the grain post process
  56643. */
  56644. private readonly GrainPostProcessId;
  56645. /**
  56646. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56647. */
  56648. sharpen: SharpenPostProcess;
  56649. private _sharpenEffect;
  56650. private bloom;
  56651. /**
  56652. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56653. */
  56654. depthOfField: DepthOfFieldEffect;
  56655. /**
  56656. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56657. */
  56658. fxaa: FxaaPostProcess;
  56659. /**
  56660. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56661. */
  56662. imageProcessing: ImageProcessingPostProcess;
  56663. /**
  56664. * Chromatic aberration post process which will shift rgb colors in the image
  56665. */
  56666. chromaticAberration: ChromaticAberrationPostProcess;
  56667. private _chromaticAberrationEffect;
  56668. /**
  56669. * Grain post process which add noise to the image
  56670. */
  56671. grain: GrainPostProcess;
  56672. private _grainEffect;
  56673. /**
  56674. * Glow post process which adds a glow to emissive areas of the image
  56675. */
  56676. private _glowLayer;
  56677. /**
  56678. * Animations which can be used to tweak settings over a period of time
  56679. */
  56680. animations: Animation[];
  56681. private _imageProcessingConfigurationObserver;
  56682. private _sharpenEnabled;
  56683. private _bloomEnabled;
  56684. private _depthOfFieldEnabled;
  56685. private _depthOfFieldBlurLevel;
  56686. private _fxaaEnabled;
  56687. private _imageProcessingEnabled;
  56688. private _defaultPipelineTextureType;
  56689. private _bloomScale;
  56690. private _chromaticAberrationEnabled;
  56691. private _grainEnabled;
  56692. private _buildAllowed;
  56693. /**
  56694. * Gets active scene
  56695. */
  56696. readonly scene: Scene;
  56697. /**
  56698. * Enable or disable the sharpen process from the pipeline
  56699. */
  56700. sharpenEnabled: boolean;
  56701. private _resizeObserver;
  56702. private _hardwareScaleLevel;
  56703. private _bloomKernel;
  56704. /**
  56705. * Specifies the size of the bloom blur kernel, relative to the final output size
  56706. */
  56707. bloomKernel: number;
  56708. /**
  56709. * Specifies the weight of the bloom in the final rendering
  56710. */
  56711. private _bloomWeight;
  56712. /**
  56713. * Specifies the luma threshold for the area that will be blurred by the bloom
  56714. */
  56715. private _bloomThreshold;
  56716. private _hdr;
  56717. /**
  56718. * The strength of the bloom.
  56719. */
  56720. bloomWeight: number;
  56721. /**
  56722. * The strength of the bloom.
  56723. */
  56724. bloomThreshold: number;
  56725. /**
  56726. * The scale of the bloom, lower value will provide better performance.
  56727. */
  56728. bloomScale: number;
  56729. /**
  56730. * Enable or disable the bloom from the pipeline
  56731. */
  56732. bloomEnabled: boolean;
  56733. private _rebuildBloom;
  56734. /**
  56735. * If the depth of field is enabled.
  56736. */
  56737. depthOfFieldEnabled: boolean;
  56738. /**
  56739. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56740. */
  56741. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56742. /**
  56743. * If the anti aliasing is enabled.
  56744. */
  56745. fxaaEnabled: boolean;
  56746. private _samples;
  56747. /**
  56748. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56749. */
  56750. samples: number;
  56751. /**
  56752. * If image processing is enabled.
  56753. */
  56754. imageProcessingEnabled: boolean;
  56755. /**
  56756. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56757. */
  56758. glowLayerEnabled: boolean;
  56759. /**
  56760. * Gets the glow layer (or null if not defined)
  56761. */
  56762. readonly glowLayer: Nullable<GlowLayer>;
  56763. /**
  56764. * Enable or disable the chromaticAberration process from the pipeline
  56765. */
  56766. chromaticAberrationEnabled: boolean;
  56767. /**
  56768. * Enable or disable the grain process from the pipeline
  56769. */
  56770. grainEnabled: boolean;
  56771. /**
  56772. * @constructor
  56773. * @param name - The rendering pipeline name (default: "")
  56774. * @param hdr - If high dynamic range textures should be used (default: true)
  56775. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56776. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56777. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56778. */
  56779. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56780. /**
  56781. * Get the class name
  56782. * @returns "DefaultRenderingPipeline"
  56783. */
  56784. getClassName(): string;
  56785. /**
  56786. * Force the compilation of the entire pipeline.
  56787. */
  56788. prepare(): void;
  56789. private _hasCleared;
  56790. private _prevPostProcess;
  56791. private _prevPrevPostProcess;
  56792. private _setAutoClearAndTextureSharing;
  56793. private _depthOfFieldSceneObserver;
  56794. private _buildPipeline;
  56795. private _disposePostProcesses;
  56796. /**
  56797. * Adds a camera to the pipeline
  56798. * @param camera the camera to be added
  56799. */
  56800. addCamera(camera: Camera): void;
  56801. /**
  56802. * Removes a camera from the pipeline
  56803. * @param camera the camera to remove
  56804. */
  56805. removeCamera(camera: Camera): void;
  56806. /**
  56807. * Dispose of the pipeline and stop all post processes
  56808. */
  56809. dispose(): void;
  56810. /**
  56811. * Serialize the rendering pipeline (Used when exporting)
  56812. * @returns the serialized object
  56813. */
  56814. serialize(): any;
  56815. /**
  56816. * Parse the serialized pipeline
  56817. * @param source Source pipeline.
  56818. * @param scene The scene to load the pipeline to.
  56819. * @param rootUrl The URL of the serialized pipeline.
  56820. * @returns An instantiated pipeline from the serialized object.
  56821. */
  56822. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56823. }
  56824. }
  56825. declare module BABYLON {
  56826. /** @hidden */
  56827. export var lensHighlightsPixelShader: {
  56828. name: string;
  56829. shader: string;
  56830. };
  56831. }
  56832. declare module BABYLON {
  56833. /** @hidden */
  56834. export var depthOfFieldPixelShader: {
  56835. name: string;
  56836. shader: string;
  56837. };
  56838. }
  56839. declare module BABYLON {
  56840. /**
  56841. * BABYLON.JS Chromatic Aberration GLSL Shader
  56842. * Author: Olivier Guyot
  56843. * Separates very slightly R, G and B colors on the edges of the screen
  56844. * Inspired by Francois Tarlier & Martins Upitis
  56845. */
  56846. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56847. /**
  56848. * @ignore
  56849. * The chromatic aberration PostProcess id in the pipeline
  56850. */
  56851. LensChromaticAberrationEffect: string;
  56852. /**
  56853. * @ignore
  56854. * The highlights enhancing PostProcess id in the pipeline
  56855. */
  56856. HighlightsEnhancingEffect: string;
  56857. /**
  56858. * @ignore
  56859. * The depth-of-field PostProcess id in the pipeline
  56860. */
  56861. LensDepthOfFieldEffect: string;
  56862. private _scene;
  56863. private _depthTexture;
  56864. private _grainTexture;
  56865. private _chromaticAberrationPostProcess;
  56866. private _highlightsPostProcess;
  56867. private _depthOfFieldPostProcess;
  56868. private _edgeBlur;
  56869. private _grainAmount;
  56870. private _chromaticAberration;
  56871. private _distortion;
  56872. private _highlightsGain;
  56873. private _highlightsThreshold;
  56874. private _dofDistance;
  56875. private _dofAperture;
  56876. private _dofDarken;
  56877. private _dofPentagon;
  56878. private _blurNoise;
  56879. /**
  56880. * @constructor
  56881. *
  56882. * Effect parameters are as follow:
  56883. * {
  56884. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56885. * edge_blur: number; // from 0 to x (1 for realism)
  56886. * distortion: number; // from 0 to x (1 for realism)
  56887. * grain_amount: number; // from 0 to 1
  56888. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56889. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56890. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56891. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56892. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56893. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56894. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56895. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56896. * }
  56897. * Note: if an effect parameter is unset, effect is disabled
  56898. *
  56899. * @param name The rendering pipeline name
  56900. * @param parameters - An object containing all parameters (see above)
  56901. * @param scene The scene linked to this pipeline
  56902. * @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)
  56903. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56904. */
  56905. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56906. /**
  56907. * Get the class name
  56908. * @returns "LensRenderingPipeline"
  56909. */
  56910. getClassName(): string;
  56911. /**
  56912. * Gets associated scene
  56913. */
  56914. readonly scene: Scene;
  56915. /**
  56916. * Gets or sets the edge blur
  56917. */
  56918. edgeBlur: number;
  56919. /**
  56920. * Gets or sets the grain amount
  56921. */
  56922. grainAmount: number;
  56923. /**
  56924. * Gets or sets the chromatic aberration amount
  56925. */
  56926. chromaticAberration: number;
  56927. /**
  56928. * Gets or sets the depth of field aperture
  56929. */
  56930. dofAperture: number;
  56931. /**
  56932. * Gets or sets the edge distortion
  56933. */
  56934. edgeDistortion: number;
  56935. /**
  56936. * Gets or sets the depth of field distortion
  56937. */
  56938. dofDistortion: number;
  56939. /**
  56940. * Gets or sets the darken out of focus amount
  56941. */
  56942. darkenOutOfFocus: number;
  56943. /**
  56944. * Gets or sets a boolean indicating if blur noise is enabled
  56945. */
  56946. blurNoise: boolean;
  56947. /**
  56948. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56949. */
  56950. pentagonBokeh: boolean;
  56951. /**
  56952. * Gets or sets the highlight grain amount
  56953. */
  56954. highlightsGain: number;
  56955. /**
  56956. * Gets or sets the highlight threshold
  56957. */
  56958. highlightsThreshold: number;
  56959. /**
  56960. * Sets the amount of blur at the edges
  56961. * @param amount blur amount
  56962. */
  56963. setEdgeBlur(amount: number): void;
  56964. /**
  56965. * Sets edge blur to 0
  56966. */
  56967. disableEdgeBlur(): void;
  56968. /**
  56969. * Sets the amout of grain
  56970. * @param amount Amount of grain
  56971. */
  56972. setGrainAmount(amount: number): void;
  56973. /**
  56974. * Set grain amount to 0
  56975. */
  56976. disableGrain(): void;
  56977. /**
  56978. * Sets the chromatic aberration amount
  56979. * @param amount amount of chromatic aberration
  56980. */
  56981. setChromaticAberration(amount: number): void;
  56982. /**
  56983. * Sets chromatic aberration amount to 0
  56984. */
  56985. disableChromaticAberration(): void;
  56986. /**
  56987. * Sets the EdgeDistortion amount
  56988. * @param amount amount of EdgeDistortion
  56989. */
  56990. setEdgeDistortion(amount: number): void;
  56991. /**
  56992. * Sets edge distortion to 0
  56993. */
  56994. disableEdgeDistortion(): void;
  56995. /**
  56996. * Sets the FocusDistance amount
  56997. * @param amount amount of FocusDistance
  56998. */
  56999. setFocusDistance(amount: number): void;
  57000. /**
  57001. * Disables depth of field
  57002. */
  57003. disableDepthOfField(): void;
  57004. /**
  57005. * Sets the Aperture amount
  57006. * @param amount amount of Aperture
  57007. */
  57008. setAperture(amount: number): void;
  57009. /**
  57010. * Sets the DarkenOutOfFocus amount
  57011. * @param amount amount of DarkenOutOfFocus
  57012. */
  57013. setDarkenOutOfFocus(amount: number): void;
  57014. private _pentagonBokehIsEnabled;
  57015. /**
  57016. * Creates a pentagon bokeh effect
  57017. */
  57018. enablePentagonBokeh(): void;
  57019. /**
  57020. * Disables the pentagon bokeh effect
  57021. */
  57022. disablePentagonBokeh(): void;
  57023. /**
  57024. * Enables noise blur
  57025. */
  57026. enableNoiseBlur(): void;
  57027. /**
  57028. * Disables noise blur
  57029. */
  57030. disableNoiseBlur(): void;
  57031. /**
  57032. * Sets the HighlightsGain amount
  57033. * @param amount amount of HighlightsGain
  57034. */
  57035. setHighlightsGain(amount: number): void;
  57036. /**
  57037. * Sets the HighlightsThreshold amount
  57038. * @param amount amount of HighlightsThreshold
  57039. */
  57040. setHighlightsThreshold(amount: number): void;
  57041. /**
  57042. * Disables highlights
  57043. */
  57044. disableHighlights(): void;
  57045. /**
  57046. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57047. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57048. */
  57049. dispose(disableDepthRender?: boolean): void;
  57050. private _createChromaticAberrationPostProcess;
  57051. private _createHighlightsPostProcess;
  57052. private _createDepthOfFieldPostProcess;
  57053. private _createGrainTexture;
  57054. }
  57055. }
  57056. declare module BABYLON {
  57057. /** @hidden */
  57058. export var ssao2PixelShader: {
  57059. name: string;
  57060. shader: string;
  57061. };
  57062. }
  57063. declare module BABYLON {
  57064. /** @hidden */
  57065. export var ssaoCombinePixelShader: {
  57066. name: string;
  57067. shader: string;
  57068. };
  57069. }
  57070. declare module BABYLON {
  57071. /**
  57072. * Render pipeline to produce ssao effect
  57073. */
  57074. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57075. /**
  57076. * @ignore
  57077. * The PassPostProcess id in the pipeline that contains the original scene color
  57078. */
  57079. SSAOOriginalSceneColorEffect: string;
  57080. /**
  57081. * @ignore
  57082. * The SSAO PostProcess id in the pipeline
  57083. */
  57084. SSAORenderEffect: string;
  57085. /**
  57086. * @ignore
  57087. * The horizontal blur PostProcess id in the pipeline
  57088. */
  57089. SSAOBlurHRenderEffect: string;
  57090. /**
  57091. * @ignore
  57092. * The vertical blur PostProcess id in the pipeline
  57093. */
  57094. SSAOBlurVRenderEffect: string;
  57095. /**
  57096. * @ignore
  57097. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57098. */
  57099. SSAOCombineRenderEffect: string;
  57100. /**
  57101. * The output strength of the SSAO post-process. Default value is 1.0.
  57102. */
  57103. totalStrength: number;
  57104. /**
  57105. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57106. */
  57107. maxZ: number;
  57108. /**
  57109. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57110. */
  57111. minZAspect: number;
  57112. private _samples;
  57113. /**
  57114. * Number of samples used for the SSAO calculations. Default value is 8
  57115. */
  57116. samples: number;
  57117. private _textureSamples;
  57118. /**
  57119. * Number of samples to use for antialiasing
  57120. */
  57121. textureSamples: number;
  57122. /**
  57123. * Ratio object used for SSAO ratio and blur ratio
  57124. */
  57125. private _ratio;
  57126. /**
  57127. * Dynamically generated sphere sampler.
  57128. */
  57129. private _sampleSphere;
  57130. /**
  57131. * Blur filter offsets
  57132. */
  57133. private _samplerOffsets;
  57134. private _expensiveBlur;
  57135. /**
  57136. * If bilateral blur should be used
  57137. */
  57138. expensiveBlur: boolean;
  57139. /**
  57140. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57141. */
  57142. radius: number;
  57143. /**
  57144. * The base color of the SSAO post-process
  57145. * The final result is "base + ssao" between [0, 1]
  57146. */
  57147. base: number;
  57148. /**
  57149. * Support test.
  57150. */
  57151. static readonly IsSupported: boolean;
  57152. private _scene;
  57153. private _depthTexture;
  57154. private _normalTexture;
  57155. private _randomTexture;
  57156. private _originalColorPostProcess;
  57157. private _ssaoPostProcess;
  57158. private _blurHPostProcess;
  57159. private _blurVPostProcess;
  57160. private _ssaoCombinePostProcess;
  57161. private _firstUpdate;
  57162. /**
  57163. * Gets active scene
  57164. */
  57165. readonly scene: Scene;
  57166. /**
  57167. * @constructor
  57168. * @param name The rendering pipeline name
  57169. * @param scene The scene linked to this pipeline
  57170. * @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 }
  57171. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57172. */
  57173. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57174. /**
  57175. * Get the class name
  57176. * @returns "SSAO2RenderingPipeline"
  57177. */
  57178. getClassName(): string;
  57179. /**
  57180. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57181. */
  57182. dispose(disableGeometryBufferRenderer?: boolean): void;
  57183. private _createBlurPostProcess;
  57184. /** @hidden */ private _rebuild(): void;
  57185. private _bits;
  57186. private _radicalInverse_VdC;
  57187. private _hammersley;
  57188. private _hemisphereSample_uniform;
  57189. private _generateHemisphere;
  57190. private _createSSAOPostProcess;
  57191. private _createSSAOCombinePostProcess;
  57192. private _createRandomTexture;
  57193. /**
  57194. * Serialize the rendering pipeline (Used when exporting)
  57195. * @returns the serialized object
  57196. */
  57197. serialize(): any;
  57198. /**
  57199. * Parse the serialized pipeline
  57200. * @param source Source pipeline.
  57201. * @param scene The scene to load the pipeline to.
  57202. * @param rootUrl The URL of the serialized pipeline.
  57203. * @returns An instantiated pipeline from the serialized object.
  57204. */
  57205. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57206. }
  57207. }
  57208. declare module BABYLON {
  57209. /** @hidden */
  57210. export var ssaoPixelShader: {
  57211. name: string;
  57212. shader: string;
  57213. };
  57214. }
  57215. declare module BABYLON {
  57216. /**
  57217. * Render pipeline to produce ssao effect
  57218. */
  57219. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57220. /**
  57221. * @ignore
  57222. * The PassPostProcess id in the pipeline that contains the original scene color
  57223. */
  57224. SSAOOriginalSceneColorEffect: string;
  57225. /**
  57226. * @ignore
  57227. * The SSAO PostProcess id in the pipeline
  57228. */
  57229. SSAORenderEffect: string;
  57230. /**
  57231. * @ignore
  57232. * The horizontal blur PostProcess id in the pipeline
  57233. */
  57234. SSAOBlurHRenderEffect: string;
  57235. /**
  57236. * @ignore
  57237. * The vertical blur PostProcess id in the pipeline
  57238. */
  57239. SSAOBlurVRenderEffect: string;
  57240. /**
  57241. * @ignore
  57242. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57243. */
  57244. SSAOCombineRenderEffect: string;
  57245. /**
  57246. * The output strength of the SSAO post-process. Default value is 1.0.
  57247. */
  57248. totalStrength: number;
  57249. /**
  57250. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57251. */
  57252. radius: number;
  57253. /**
  57254. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57255. * Must not be equal to fallOff and superior to fallOff.
  57256. * Default value is 0.0075
  57257. */
  57258. area: number;
  57259. /**
  57260. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57261. * Must not be equal to area and inferior to area.
  57262. * Default value is 0.000001
  57263. */
  57264. fallOff: number;
  57265. /**
  57266. * The base color of the SSAO post-process
  57267. * The final result is "base + ssao" between [0, 1]
  57268. */
  57269. base: number;
  57270. private _scene;
  57271. private _depthTexture;
  57272. private _randomTexture;
  57273. private _originalColorPostProcess;
  57274. private _ssaoPostProcess;
  57275. private _blurHPostProcess;
  57276. private _blurVPostProcess;
  57277. private _ssaoCombinePostProcess;
  57278. private _firstUpdate;
  57279. /**
  57280. * Gets active scene
  57281. */
  57282. readonly scene: Scene;
  57283. /**
  57284. * @constructor
  57285. * @param name - The rendering pipeline name
  57286. * @param scene - The scene linked to this pipeline
  57287. * @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 }
  57288. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57289. */
  57290. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57291. /**
  57292. * Get the class name
  57293. * @returns "SSAORenderingPipeline"
  57294. */
  57295. getClassName(): string;
  57296. /**
  57297. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57298. */
  57299. dispose(disableDepthRender?: boolean): void;
  57300. private _createBlurPostProcess;
  57301. /** @hidden */ private _rebuild(): void;
  57302. private _createSSAOPostProcess;
  57303. private _createSSAOCombinePostProcess;
  57304. private _createRandomTexture;
  57305. }
  57306. }
  57307. declare module BABYLON {
  57308. /** @hidden */
  57309. export var standardPixelShader: {
  57310. name: string;
  57311. shader: string;
  57312. };
  57313. }
  57314. declare module BABYLON {
  57315. /**
  57316. * Standard rendering pipeline
  57317. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57318. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57319. */
  57320. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57321. /**
  57322. * Public members
  57323. */
  57324. /**
  57325. * Post-process which contains the original scene color before the pipeline applies all the effects
  57326. */
  57327. originalPostProcess: Nullable<PostProcess>;
  57328. /**
  57329. * Post-process used to down scale an image x4
  57330. */
  57331. downSampleX4PostProcess: Nullable<PostProcess>;
  57332. /**
  57333. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57334. */
  57335. brightPassPostProcess: Nullable<PostProcess>;
  57336. /**
  57337. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57338. */
  57339. blurHPostProcesses: PostProcess[];
  57340. /**
  57341. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57342. */
  57343. blurVPostProcesses: PostProcess[];
  57344. /**
  57345. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57346. */
  57347. textureAdderPostProcess: Nullable<PostProcess>;
  57348. /**
  57349. * Post-process used to create volumetric lighting effect
  57350. */
  57351. volumetricLightPostProcess: Nullable<PostProcess>;
  57352. /**
  57353. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57354. */
  57355. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57356. /**
  57357. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57358. */
  57359. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57360. /**
  57361. * Post-process used to merge the volumetric light effect and the real scene color
  57362. */
  57363. volumetricLightMergePostProces: Nullable<PostProcess>;
  57364. /**
  57365. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57366. */
  57367. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57368. /**
  57369. * Base post-process used to calculate the average luminance of the final image for HDR
  57370. */
  57371. luminancePostProcess: Nullable<PostProcess>;
  57372. /**
  57373. * Post-processes used to create down sample post-processes in order to get
  57374. * the average luminance of the final image for HDR
  57375. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57376. */
  57377. luminanceDownSamplePostProcesses: PostProcess[];
  57378. /**
  57379. * Post-process used to create a HDR effect (light adaptation)
  57380. */
  57381. hdrPostProcess: Nullable<PostProcess>;
  57382. /**
  57383. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57384. */
  57385. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57386. /**
  57387. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57388. */
  57389. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57390. /**
  57391. * Post-process used to merge the final HDR post-process and the real scene color
  57392. */
  57393. hdrFinalPostProcess: Nullable<PostProcess>;
  57394. /**
  57395. * Post-process used to create a lens flare effect
  57396. */
  57397. lensFlarePostProcess: Nullable<PostProcess>;
  57398. /**
  57399. * Post-process that merges the result of the lens flare post-process and the real scene color
  57400. */
  57401. lensFlareComposePostProcess: Nullable<PostProcess>;
  57402. /**
  57403. * Post-process used to create a motion blur effect
  57404. */
  57405. motionBlurPostProcess: Nullable<PostProcess>;
  57406. /**
  57407. * Post-process used to create a depth of field effect
  57408. */
  57409. depthOfFieldPostProcess: Nullable<PostProcess>;
  57410. /**
  57411. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57412. */
  57413. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57414. /**
  57415. * Represents the brightness threshold in order to configure the illuminated surfaces
  57416. */
  57417. brightThreshold: number;
  57418. /**
  57419. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57420. */
  57421. blurWidth: number;
  57422. /**
  57423. * Sets if the blur for highlighted surfaces must be only horizontal
  57424. */
  57425. horizontalBlur: boolean;
  57426. /**
  57427. * Gets the overall exposure used by the pipeline
  57428. */
  57429. /**
  57430. * Sets the overall exposure used by the pipeline
  57431. */
  57432. exposure: number;
  57433. /**
  57434. * Texture used typically to simulate "dirty" on camera lens
  57435. */
  57436. lensTexture: Nullable<Texture>;
  57437. /**
  57438. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57439. */
  57440. volumetricLightCoefficient: number;
  57441. /**
  57442. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57443. */
  57444. volumetricLightPower: number;
  57445. /**
  57446. * Used the set the blur intensity to smooth the volumetric lights
  57447. */
  57448. volumetricLightBlurScale: number;
  57449. /**
  57450. * Light (spot or directional) used to generate the volumetric lights rays
  57451. * The source light must have a shadow generate so the pipeline can get its
  57452. * depth map
  57453. */
  57454. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57455. /**
  57456. * For eye adaptation, represents the minimum luminance the eye can see
  57457. */
  57458. hdrMinimumLuminance: number;
  57459. /**
  57460. * For eye adaptation, represents the decrease luminance speed
  57461. */
  57462. hdrDecreaseRate: number;
  57463. /**
  57464. * For eye adaptation, represents the increase luminance speed
  57465. */
  57466. hdrIncreaseRate: number;
  57467. /**
  57468. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57469. */
  57470. /**
  57471. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57472. */
  57473. hdrAutoExposure: boolean;
  57474. /**
  57475. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57476. */
  57477. lensColorTexture: Nullable<Texture>;
  57478. /**
  57479. * The overall strengh for the lens flare effect
  57480. */
  57481. lensFlareStrength: number;
  57482. /**
  57483. * Dispersion coefficient for lens flare ghosts
  57484. */
  57485. lensFlareGhostDispersal: number;
  57486. /**
  57487. * Main lens flare halo width
  57488. */
  57489. lensFlareHaloWidth: number;
  57490. /**
  57491. * Based on the lens distortion effect, defines how much the lens flare result
  57492. * is distorted
  57493. */
  57494. lensFlareDistortionStrength: number;
  57495. /**
  57496. * Lens star texture must be used to simulate rays on the flares and is available
  57497. * in the documentation
  57498. */
  57499. lensStarTexture: Nullable<Texture>;
  57500. /**
  57501. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57502. * flare effect by taking account of the dirt texture
  57503. */
  57504. lensFlareDirtTexture: Nullable<Texture>;
  57505. /**
  57506. * Represents the focal length for the depth of field effect
  57507. */
  57508. depthOfFieldDistance: number;
  57509. /**
  57510. * Represents the blur intensity for the blurred part of the depth of field effect
  57511. */
  57512. depthOfFieldBlurWidth: number;
  57513. /**
  57514. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57515. */
  57516. /**
  57517. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57518. */
  57519. motionStrength: number;
  57520. /**
  57521. * Gets wether or not the motion blur post-process is object based or screen based.
  57522. */
  57523. /**
  57524. * Sets wether or not the motion blur post-process should be object based or screen based
  57525. */
  57526. objectBasedMotionBlur: boolean;
  57527. /**
  57528. * List of animations for the pipeline (IAnimatable implementation)
  57529. */
  57530. animations: Animation[];
  57531. /**
  57532. * Private members
  57533. */
  57534. private _scene;
  57535. private _currentDepthOfFieldSource;
  57536. private _basePostProcess;
  57537. private _fixedExposure;
  57538. private _currentExposure;
  57539. private _hdrAutoExposure;
  57540. private _hdrCurrentLuminance;
  57541. private _motionStrength;
  57542. private _isObjectBasedMotionBlur;
  57543. private _floatTextureType;
  57544. private _ratio;
  57545. private _bloomEnabled;
  57546. private _depthOfFieldEnabled;
  57547. private _vlsEnabled;
  57548. private _lensFlareEnabled;
  57549. private _hdrEnabled;
  57550. private _motionBlurEnabled;
  57551. private _fxaaEnabled;
  57552. private _motionBlurSamples;
  57553. private _volumetricLightStepsCount;
  57554. private _samples;
  57555. /**
  57556. * @ignore
  57557. * Specifies if the bloom pipeline is enabled
  57558. */
  57559. BloomEnabled: boolean;
  57560. /**
  57561. * @ignore
  57562. * Specifies if the depth of field pipeline is enabed
  57563. */
  57564. DepthOfFieldEnabled: boolean;
  57565. /**
  57566. * @ignore
  57567. * Specifies if the lens flare pipeline is enabed
  57568. */
  57569. LensFlareEnabled: boolean;
  57570. /**
  57571. * @ignore
  57572. * Specifies if the HDR pipeline is enabled
  57573. */
  57574. HDREnabled: boolean;
  57575. /**
  57576. * @ignore
  57577. * Specifies if the volumetric lights scattering effect is enabled
  57578. */
  57579. VLSEnabled: boolean;
  57580. /**
  57581. * @ignore
  57582. * Specifies if the motion blur effect is enabled
  57583. */
  57584. MotionBlurEnabled: boolean;
  57585. /**
  57586. * Specifies if anti-aliasing is enabled
  57587. */
  57588. fxaaEnabled: boolean;
  57589. /**
  57590. * Specifies the number of steps used to calculate the volumetric lights
  57591. * Typically in interval [50, 200]
  57592. */
  57593. volumetricLightStepsCount: number;
  57594. /**
  57595. * Specifies the number of samples used for the motion blur effect
  57596. * Typically in interval [16, 64]
  57597. */
  57598. motionBlurSamples: number;
  57599. /**
  57600. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57601. */
  57602. samples: number;
  57603. /**
  57604. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57605. * @constructor
  57606. * @param name The rendering pipeline name
  57607. * @param scene The scene linked to this pipeline
  57608. * @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)
  57609. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57610. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57611. */
  57612. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57613. private _buildPipeline;
  57614. private _createDownSampleX4PostProcess;
  57615. private _createBrightPassPostProcess;
  57616. private _createBlurPostProcesses;
  57617. private _createTextureAdderPostProcess;
  57618. private _createVolumetricLightPostProcess;
  57619. private _createLuminancePostProcesses;
  57620. private _createHdrPostProcess;
  57621. private _createLensFlarePostProcess;
  57622. private _createDepthOfFieldPostProcess;
  57623. private _createMotionBlurPostProcess;
  57624. private _getDepthTexture;
  57625. private _disposePostProcesses;
  57626. /**
  57627. * Dispose of the pipeline and stop all post processes
  57628. */
  57629. dispose(): void;
  57630. /**
  57631. * Serialize the rendering pipeline (Used when exporting)
  57632. * @returns the serialized object
  57633. */
  57634. serialize(): any;
  57635. /**
  57636. * Parse the serialized pipeline
  57637. * @param source Source pipeline.
  57638. * @param scene The scene to load the pipeline to.
  57639. * @param rootUrl The URL of the serialized pipeline.
  57640. * @returns An instantiated pipeline from the serialized object.
  57641. */
  57642. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57643. /**
  57644. * Luminance steps
  57645. */
  57646. static LuminanceSteps: number;
  57647. }
  57648. }
  57649. declare module BABYLON {
  57650. /** @hidden */
  57651. export var tonemapPixelShader: {
  57652. name: string;
  57653. shader: string;
  57654. };
  57655. }
  57656. declare module BABYLON {
  57657. /** Defines operator used for tonemapping */
  57658. export enum TonemappingOperator {
  57659. /** Hable */
  57660. Hable = 0,
  57661. /** Reinhard */
  57662. Reinhard = 1,
  57663. /** HejiDawson */
  57664. HejiDawson = 2,
  57665. /** Photographic */
  57666. Photographic = 3
  57667. }
  57668. /**
  57669. * Defines a post process to apply tone mapping
  57670. */
  57671. export class TonemapPostProcess extends PostProcess {
  57672. private _operator;
  57673. /** Defines the required exposure adjustement */
  57674. exposureAdjustment: number;
  57675. /**
  57676. * Creates a new TonemapPostProcess
  57677. * @param name defines the name of the postprocess
  57678. * @param _operator defines the operator to use
  57679. * @param exposureAdjustment defines the required exposure adjustement
  57680. * @param camera defines the camera to use (can be null)
  57681. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57682. * @param engine defines the hosting engine (can be ignore if camera is set)
  57683. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57684. */
  57685. constructor(name: string, _operator: TonemappingOperator,
  57686. /** Defines the required exposure adjustement */
  57687. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57688. }
  57689. }
  57690. declare module BABYLON {
  57691. /** @hidden */
  57692. export var depthVertexShader: {
  57693. name: string;
  57694. shader: string;
  57695. };
  57696. }
  57697. declare module BABYLON {
  57698. /** @hidden */
  57699. export var volumetricLightScatteringPixelShader: {
  57700. name: string;
  57701. shader: string;
  57702. };
  57703. }
  57704. declare module BABYLON {
  57705. /** @hidden */
  57706. export var volumetricLightScatteringPassPixelShader: {
  57707. name: string;
  57708. shader: string;
  57709. };
  57710. }
  57711. declare module BABYLON {
  57712. /**
  57713. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57714. */
  57715. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57716. private _volumetricLightScatteringPass;
  57717. private _volumetricLightScatteringRTT;
  57718. private _viewPort;
  57719. private _screenCoordinates;
  57720. private _cachedDefines;
  57721. /**
  57722. * If not undefined, the mesh position is computed from the attached node position
  57723. */
  57724. attachedNode: {
  57725. position: Vector3;
  57726. };
  57727. /**
  57728. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57729. */
  57730. customMeshPosition: Vector3;
  57731. /**
  57732. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57733. */
  57734. useCustomMeshPosition: boolean;
  57735. /**
  57736. * If the post-process should inverse the light scattering direction
  57737. */
  57738. invert: boolean;
  57739. /**
  57740. * The internal mesh used by the post-process
  57741. */
  57742. mesh: Mesh;
  57743. /**
  57744. * @hidden
  57745. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57746. */
  57747. useDiffuseColor: boolean;
  57748. /**
  57749. * Array containing the excluded meshes not rendered in the internal pass
  57750. */
  57751. excludedMeshes: AbstractMesh[];
  57752. /**
  57753. * Controls the overall intensity of the post-process
  57754. */
  57755. exposure: number;
  57756. /**
  57757. * Dissipates each sample's contribution in range [0, 1]
  57758. */
  57759. decay: number;
  57760. /**
  57761. * Controls the overall intensity of each sample
  57762. */
  57763. weight: number;
  57764. /**
  57765. * Controls the density of each sample
  57766. */
  57767. density: number;
  57768. /**
  57769. * @constructor
  57770. * @param name The post-process name
  57771. * @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)
  57772. * @param camera The camera that the post-process will be attached to
  57773. * @param mesh The mesh used to create the light scattering
  57774. * @param samples The post-process quality, default 100
  57775. * @param samplingModeThe post-process filtering mode
  57776. * @param engine The babylon engine
  57777. * @param reusable If the post-process is reusable
  57778. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57779. */
  57780. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57781. /**
  57782. * Returns the string "VolumetricLightScatteringPostProcess"
  57783. * @returns "VolumetricLightScatteringPostProcess"
  57784. */
  57785. getClassName(): string;
  57786. private _isReady;
  57787. /**
  57788. * Sets the new light position for light scattering effect
  57789. * @param position The new custom light position
  57790. */
  57791. setCustomMeshPosition(position: Vector3): void;
  57792. /**
  57793. * Returns the light position for light scattering effect
  57794. * @return Vector3 The custom light position
  57795. */
  57796. getCustomMeshPosition(): Vector3;
  57797. /**
  57798. * Disposes the internal assets and detaches the post-process from the camera
  57799. */
  57800. dispose(camera: Camera): void;
  57801. /**
  57802. * Returns the render target texture used by the post-process
  57803. * @return the render target texture used by the post-process
  57804. */
  57805. getPass(): RenderTargetTexture;
  57806. private _meshExcluded;
  57807. private _createPass;
  57808. private _updateMeshScreenCoordinates;
  57809. /**
  57810. * Creates a default mesh for the Volumeric Light Scattering post-process
  57811. * @param name The mesh name
  57812. * @param scene The scene where to create the mesh
  57813. * @return the default mesh
  57814. */
  57815. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. interface Scene {
  57820. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  57821. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  57822. /**
  57823. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57824. */
  57825. forceShowBoundingBoxes: boolean;
  57826. /**
  57827. * Gets the bounding box renderer associated with the scene
  57828. * @returns a BoundingBoxRenderer
  57829. */
  57830. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57831. }
  57832. interface AbstractMesh {
  57833. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  57834. /**
  57835. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57836. */
  57837. showBoundingBox: boolean;
  57838. }
  57839. /**
  57840. * Component responsible of rendering the bounding box of the meshes in a scene.
  57841. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57842. */
  57843. export class BoundingBoxRenderer implements ISceneComponent {
  57844. /**
  57845. * The component name helpfull to identify the component in the list of scene components.
  57846. */
  57847. readonly name: string;
  57848. /**
  57849. * The scene the component belongs to.
  57850. */
  57851. scene: Scene;
  57852. /**
  57853. * Color of the bounding box lines placed in front of an object
  57854. */
  57855. frontColor: Color3;
  57856. /**
  57857. * Color of the bounding box lines placed behind an object
  57858. */
  57859. backColor: Color3;
  57860. /**
  57861. * Defines if the renderer should show the back lines or not
  57862. */
  57863. showBackLines: boolean;
  57864. /**
  57865. * @hidden
  57866. */
  57867. renderList: SmartArray<BoundingBox>;
  57868. private _colorShader;
  57869. private _vertexBuffers;
  57870. private _indexBuffer;
  57871. private _fillIndexBuffer;
  57872. private _fillIndexData;
  57873. /**
  57874. * Instantiates a new bounding box renderer in a scene.
  57875. * @param scene the scene the renderer renders in
  57876. */
  57877. constructor(scene: Scene);
  57878. /**
  57879. * Registers the component in a given scene
  57880. */
  57881. register(): void;
  57882. private _evaluateSubMesh;
  57883. private _activeMesh;
  57884. private _prepareRessources;
  57885. private _createIndexBuffer;
  57886. /**
  57887. * Rebuilds the elements related to this component in case of
  57888. * context lost for instance.
  57889. */
  57890. rebuild(): void;
  57891. /**
  57892. * @hidden
  57893. */
  57894. reset(): void;
  57895. /**
  57896. * Render the bounding boxes of a specific rendering group
  57897. * @param renderingGroupId defines the rendering group to render
  57898. */
  57899. render(renderingGroupId: number): void;
  57900. /**
  57901. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57902. * @param mesh Define the mesh to render the occlusion bounding box for
  57903. */
  57904. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57905. /**
  57906. * Dispose and release the resources attached to this renderer.
  57907. */
  57908. dispose(): void;
  57909. }
  57910. }
  57911. declare module BABYLON {
  57912. /** @hidden */
  57913. export var depthPixelShader: {
  57914. name: string;
  57915. shader: string;
  57916. };
  57917. }
  57918. declare module BABYLON {
  57919. /**
  57920. * This represents a depth renderer in Babylon.
  57921. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57922. */
  57923. export class DepthRenderer {
  57924. private _scene;
  57925. private _depthMap;
  57926. private _effect;
  57927. private readonly _storeNonLinearDepth;
  57928. private readonly _clearColor;
  57929. /** Get if the depth renderer is using packed depth or not */
  57930. readonly isPacked: boolean;
  57931. private _cachedDefines;
  57932. private _camera;
  57933. /**
  57934. * Specifiess that the depth renderer will only be used within
  57935. * the camera it is created for.
  57936. * This can help forcing its rendering during the camera processing.
  57937. */
  57938. useOnlyInActiveCamera: boolean;
  57939. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  57940. /**
  57941. * Instantiates a depth renderer
  57942. * @param scene The scene the renderer belongs to
  57943. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57944. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57945. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57946. */
  57947. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57948. /**
  57949. * Creates the depth rendering effect and checks if the effect is ready.
  57950. * @param subMesh The submesh to be used to render the depth map of
  57951. * @param useInstances If multiple world instances should be used
  57952. * @returns if the depth renderer is ready to render the depth map
  57953. */
  57954. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57955. /**
  57956. * Gets the texture which the depth map will be written to.
  57957. * @returns The depth map texture
  57958. */
  57959. getDepthMap(): RenderTargetTexture;
  57960. /**
  57961. * Disposes of the depth renderer.
  57962. */
  57963. dispose(): void;
  57964. }
  57965. }
  57966. declare module BABYLON {
  57967. interface Scene {
  57968. /** @hidden (Backing field) */ private _depthRenderer: {
  57969. [id: string]: DepthRenderer;
  57970. };
  57971. /**
  57972. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57973. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57974. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57975. * @returns the created depth renderer
  57976. */
  57977. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  57978. /**
  57979. * Disables a depth renderer for a given camera
  57980. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57981. */
  57982. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57983. }
  57984. /**
  57985. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57986. * in several rendering techniques.
  57987. */
  57988. export class DepthRendererSceneComponent implements ISceneComponent {
  57989. /**
  57990. * The component name helpfull to identify the component in the list of scene components.
  57991. */
  57992. readonly name: string;
  57993. /**
  57994. * The scene the component belongs to.
  57995. */
  57996. scene: Scene;
  57997. /**
  57998. * Creates a new instance of the component for the given scene
  57999. * @param scene Defines the scene to register the component in
  58000. */
  58001. constructor(scene: Scene);
  58002. /**
  58003. * Registers the component in a given scene
  58004. */
  58005. register(): void;
  58006. /**
  58007. * Rebuilds the elements related to this component in case of
  58008. * context lost for instance.
  58009. */
  58010. rebuild(): void;
  58011. /**
  58012. * Disposes the component and the associated ressources
  58013. */
  58014. dispose(): void;
  58015. private _gatherRenderTargets;
  58016. private _gatherActiveCameraRenderTargets;
  58017. }
  58018. }
  58019. declare module BABYLON {
  58020. /** @hidden */
  58021. export var outlinePixelShader: {
  58022. name: string;
  58023. shader: string;
  58024. };
  58025. }
  58026. declare module BABYLON {
  58027. /** @hidden */
  58028. export var outlineVertexShader: {
  58029. name: string;
  58030. shader: string;
  58031. };
  58032. }
  58033. declare module BABYLON {
  58034. interface Scene {
  58035. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  58036. /**
  58037. * Gets the outline renderer associated with the scene
  58038. * @returns a OutlineRenderer
  58039. */
  58040. getOutlineRenderer(): OutlineRenderer;
  58041. }
  58042. interface AbstractMesh {
  58043. /** @hidden (Backing field) */ private _renderOutline: boolean;
  58044. /**
  58045. * Gets or sets a boolean indicating if the outline must be rendered as well
  58046. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58047. */
  58048. renderOutline: boolean;
  58049. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  58050. /**
  58051. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58052. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58053. */
  58054. renderOverlay: boolean;
  58055. }
  58056. /**
  58057. * This class is responsible to draw bothe outline/overlay of meshes.
  58058. * It should not be used directly but through the available method on mesh.
  58059. */
  58060. export class OutlineRenderer implements ISceneComponent {
  58061. /**
  58062. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58063. */
  58064. private static _StencilReference;
  58065. /**
  58066. * The name of the component. Each component must have a unique name.
  58067. */
  58068. name: string;
  58069. /**
  58070. * The scene the component belongs to.
  58071. */
  58072. scene: Scene;
  58073. /**
  58074. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58075. */
  58076. zOffset: number;
  58077. private _engine;
  58078. private _effect;
  58079. private _cachedDefines;
  58080. private _savedDepthWrite;
  58081. /**
  58082. * Instantiates a new outline renderer. (There could be only one per scene).
  58083. * @param scene Defines the scene it belongs to
  58084. */
  58085. constructor(scene: Scene);
  58086. /**
  58087. * Register the component to one instance of a scene.
  58088. */
  58089. register(): void;
  58090. /**
  58091. * Rebuilds the elements related to this component in case of
  58092. * context lost for instance.
  58093. */
  58094. rebuild(): void;
  58095. /**
  58096. * Disposes the component and the associated ressources.
  58097. */
  58098. dispose(): void;
  58099. /**
  58100. * Renders the outline in the canvas.
  58101. * @param subMesh Defines the sumesh to render
  58102. * @param batch Defines the batch of meshes in case of instances
  58103. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58104. */
  58105. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58106. /**
  58107. * Returns whether or not the outline renderer is ready for a given submesh.
  58108. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58109. * @param subMesh Defines the submesh to check readyness for
  58110. * @param useInstances Defines wheter wee are trying to render instances or not
  58111. * @returns true if ready otherwise false
  58112. */
  58113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58114. private _beforeRenderingMesh;
  58115. private _afterRenderingMesh;
  58116. }
  58117. }
  58118. declare module BABYLON {
  58119. /**
  58120. * Defines the list of states available for a task inside a AssetsManager
  58121. */
  58122. export enum AssetTaskState {
  58123. /**
  58124. * Initialization
  58125. */
  58126. INIT = 0,
  58127. /**
  58128. * Running
  58129. */
  58130. RUNNING = 1,
  58131. /**
  58132. * Done
  58133. */
  58134. DONE = 2,
  58135. /**
  58136. * Error
  58137. */
  58138. ERROR = 3
  58139. }
  58140. /**
  58141. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58142. */
  58143. export abstract class AbstractAssetTask {
  58144. /**
  58145. * Task name
  58146. */ name: string;
  58147. /**
  58148. * Callback called when the task is successful
  58149. */
  58150. onSuccess: (task: any) => void;
  58151. /**
  58152. * Callback called when the task is not successful
  58153. */
  58154. onError: (task: any, message?: string, exception?: any) => void;
  58155. /**
  58156. * Creates a new AssetsManager
  58157. * @param name defines the name of the task
  58158. */
  58159. constructor(
  58160. /**
  58161. * Task name
  58162. */ name: string);
  58163. private _isCompleted;
  58164. private _taskState;
  58165. private _errorObject;
  58166. /**
  58167. * Get if the task is completed
  58168. */
  58169. readonly isCompleted: boolean;
  58170. /**
  58171. * Gets the current state of the task
  58172. */
  58173. readonly taskState: AssetTaskState;
  58174. /**
  58175. * Gets the current error object (if task is in error)
  58176. */
  58177. readonly errorObject: {
  58178. message?: string;
  58179. exception?: any;
  58180. };
  58181. /**
  58182. * Internal only
  58183. * @hidden
  58184. */ private _setErrorObject(message?: string, exception?: any): void;
  58185. /**
  58186. * Execute the current task
  58187. * @param scene defines the scene where you want your assets to be loaded
  58188. * @param onSuccess is a callback called when the task is successfully executed
  58189. * @param onError is a callback called if an error occurs
  58190. */
  58191. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58192. /**
  58193. * Execute the current task
  58194. * @param scene defines the scene where you want your assets to be loaded
  58195. * @param onSuccess is a callback called when the task is successfully executed
  58196. * @param onError is a callback called if an error occurs
  58197. */
  58198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58199. /**
  58200. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58201. * This can be used with failed tasks that have the reason for failure fixed.
  58202. */
  58203. reset(): void;
  58204. private onErrorCallback;
  58205. private onDoneCallback;
  58206. }
  58207. /**
  58208. * Define the interface used by progress events raised during assets loading
  58209. */
  58210. export interface IAssetsProgressEvent {
  58211. /**
  58212. * Defines the number of remaining tasks to process
  58213. */
  58214. remainingCount: number;
  58215. /**
  58216. * Defines the total number of tasks
  58217. */
  58218. totalCount: number;
  58219. /**
  58220. * Defines the task that was just processed
  58221. */
  58222. task: AbstractAssetTask;
  58223. }
  58224. /**
  58225. * Class used to share progress information about assets loading
  58226. */
  58227. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58228. /**
  58229. * Defines the number of remaining tasks to process
  58230. */
  58231. remainingCount: number;
  58232. /**
  58233. * Defines the total number of tasks
  58234. */
  58235. totalCount: number;
  58236. /**
  58237. * Defines the task that was just processed
  58238. */
  58239. task: AbstractAssetTask;
  58240. /**
  58241. * Creates a AssetsProgressEvent
  58242. * @param remainingCount defines the number of remaining tasks to process
  58243. * @param totalCount defines the total number of tasks
  58244. * @param task defines the task that was just processed
  58245. */
  58246. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58247. }
  58248. /**
  58249. * Define a task used by AssetsManager to load meshes
  58250. */
  58251. export class MeshAssetTask extends AbstractAssetTask {
  58252. /**
  58253. * Defines the name of the task
  58254. */
  58255. name: string;
  58256. /**
  58257. * Defines the list of mesh's names you want to load
  58258. */
  58259. meshesNames: any;
  58260. /**
  58261. * Defines the root url to use as a base to load your meshes and associated resources
  58262. */
  58263. rootUrl: string;
  58264. /**
  58265. * Defines the filename of the scene to load from
  58266. */
  58267. sceneFilename: string;
  58268. /**
  58269. * Gets the list of loaded meshes
  58270. */
  58271. loadedMeshes: Array<AbstractMesh>;
  58272. /**
  58273. * Gets the list of loaded particle systems
  58274. */
  58275. loadedParticleSystems: Array<IParticleSystem>;
  58276. /**
  58277. * Gets the list of loaded skeletons
  58278. */
  58279. loadedSkeletons: Array<Skeleton>;
  58280. /**
  58281. * Gets the list of loaded animation groups
  58282. */
  58283. loadedAnimationGroups: Array<AnimationGroup>;
  58284. /**
  58285. * Callback called when the task is successful
  58286. */
  58287. onSuccess: (task: MeshAssetTask) => void;
  58288. /**
  58289. * Callback called when the task is successful
  58290. */
  58291. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58292. /**
  58293. * Creates a new MeshAssetTask
  58294. * @param name defines the name of the task
  58295. * @param meshesNames defines the list of mesh's names you want to load
  58296. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58297. * @param sceneFilename defines the filename of the scene to load from
  58298. */
  58299. constructor(
  58300. /**
  58301. * Defines the name of the task
  58302. */
  58303. name: string,
  58304. /**
  58305. * Defines the list of mesh's names you want to load
  58306. */
  58307. meshesNames: any,
  58308. /**
  58309. * Defines the root url to use as a base to load your meshes and associated resources
  58310. */
  58311. rootUrl: string,
  58312. /**
  58313. * Defines the filename of the scene to load from
  58314. */
  58315. sceneFilename: string);
  58316. /**
  58317. * Execute the current task
  58318. * @param scene defines the scene where you want your assets to be loaded
  58319. * @param onSuccess is a callback called when the task is successfully executed
  58320. * @param onError is a callback called if an error occurs
  58321. */
  58322. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58323. }
  58324. /**
  58325. * Define a task used by AssetsManager to load text content
  58326. */
  58327. export class TextFileAssetTask extends AbstractAssetTask {
  58328. /**
  58329. * Defines the name of the task
  58330. */
  58331. name: string;
  58332. /**
  58333. * Defines the location of the file to load
  58334. */
  58335. url: string;
  58336. /**
  58337. * Gets the loaded text string
  58338. */
  58339. text: string;
  58340. /**
  58341. * Callback called when the task is successful
  58342. */
  58343. onSuccess: (task: TextFileAssetTask) => void;
  58344. /**
  58345. * Callback called when the task is successful
  58346. */
  58347. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58348. /**
  58349. * Creates a new TextFileAssetTask object
  58350. * @param name defines the name of the task
  58351. * @param url defines the location of the file to load
  58352. */
  58353. constructor(
  58354. /**
  58355. * Defines the name of the task
  58356. */
  58357. name: string,
  58358. /**
  58359. * Defines the location of the file to load
  58360. */
  58361. url: string);
  58362. /**
  58363. * Execute the current task
  58364. * @param scene defines the scene where you want your assets to be loaded
  58365. * @param onSuccess is a callback called when the task is successfully executed
  58366. * @param onError is a callback called if an error occurs
  58367. */
  58368. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58369. }
  58370. /**
  58371. * Define a task used by AssetsManager to load binary data
  58372. */
  58373. export class BinaryFileAssetTask extends AbstractAssetTask {
  58374. /**
  58375. * Defines the name of the task
  58376. */
  58377. name: string;
  58378. /**
  58379. * Defines the location of the file to load
  58380. */
  58381. url: string;
  58382. /**
  58383. * Gets the lodaded data (as an array buffer)
  58384. */
  58385. data: ArrayBuffer;
  58386. /**
  58387. * Callback called when the task is successful
  58388. */
  58389. onSuccess: (task: BinaryFileAssetTask) => void;
  58390. /**
  58391. * Callback called when the task is successful
  58392. */
  58393. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58394. /**
  58395. * Creates a new BinaryFileAssetTask object
  58396. * @param name defines the name of the new task
  58397. * @param url defines the location of the file to load
  58398. */
  58399. constructor(
  58400. /**
  58401. * Defines the name of the task
  58402. */
  58403. name: string,
  58404. /**
  58405. * Defines the location of the file to load
  58406. */
  58407. url: string);
  58408. /**
  58409. * Execute the current task
  58410. * @param scene defines the scene where you want your assets to be loaded
  58411. * @param onSuccess is a callback called when the task is successfully executed
  58412. * @param onError is a callback called if an error occurs
  58413. */
  58414. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58415. }
  58416. /**
  58417. * Define a task used by AssetsManager to load images
  58418. */
  58419. export class ImageAssetTask extends AbstractAssetTask {
  58420. /**
  58421. * Defines the name of the task
  58422. */
  58423. name: string;
  58424. /**
  58425. * Defines the location of the image to load
  58426. */
  58427. url: string;
  58428. /**
  58429. * Gets the loaded images
  58430. */
  58431. image: HTMLImageElement;
  58432. /**
  58433. * Callback called when the task is successful
  58434. */
  58435. onSuccess: (task: ImageAssetTask) => void;
  58436. /**
  58437. * Callback called when the task is successful
  58438. */
  58439. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58440. /**
  58441. * Creates a new ImageAssetTask
  58442. * @param name defines the name of the task
  58443. * @param url defines the location of the image to load
  58444. */
  58445. constructor(
  58446. /**
  58447. * Defines the name of the task
  58448. */
  58449. name: string,
  58450. /**
  58451. * Defines the location of the image to load
  58452. */
  58453. url: string);
  58454. /**
  58455. * Execute the current task
  58456. * @param scene defines the scene where you want your assets to be loaded
  58457. * @param onSuccess is a callback called when the task is successfully executed
  58458. * @param onError is a callback called if an error occurs
  58459. */
  58460. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58461. }
  58462. /**
  58463. * Defines the interface used by texture loading tasks
  58464. */
  58465. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58466. /**
  58467. * Gets the loaded texture
  58468. */
  58469. texture: TEX;
  58470. }
  58471. /**
  58472. * Define a task used by AssetsManager to load 2D textures
  58473. */
  58474. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58475. /**
  58476. * Defines the name of the task
  58477. */
  58478. name: string;
  58479. /**
  58480. * Defines the location of the file to load
  58481. */
  58482. url: string;
  58483. /**
  58484. * Defines if mipmap should not be generated (default is false)
  58485. */
  58486. noMipmap?: boolean | undefined;
  58487. /**
  58488. * Defines if texture must be inverted on Y axis (default is false)
  58489. */
  58490. invertY?: boolean | undefined;
  58491. /**
  58492. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58493. */
  58494. samplingMode: number;
  58495. /**
  58496. * Gets the loaded texture
  58497. */
  58498. texture: Texture;
  58499. /**
  58500. * Callback called when the task is successful
  58501. */
  58502. onSuccess: (task: TextureAssetTask) => void;
  58503. /**
  58504. * Callback called when the task is successful
  58505. */
  58506. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58507. /**
  58508. * Creates a new TextureAssetTask object
  58509. * @param name defines the name of the task
  58510. * @param url defines the location of the file to load
  58511. * @param noMipmap defines if mipmap should not be generated (default is false)
  58512. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58513. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58514. */
  58515. constructor(
  58516. /**
  58517. * Defines the name of the task
  58518. */
  58519. name: string,
  58520. /**
  58521. * Defines the location of the file to load
  58522. */
  58523. url: string,
  58524. /**
  58525. * Defines if mipmap should not be generated (default is false)
  58526. */
  58527. noMipmap?: boolean | undefined,
  58528. /**
  58529. * Defines if texture must be inverted on Y axis (default is false)
  58530. */
  58531. invertY?: boolean | undefined,
  58532. /**
  58533. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58534. */
  58535. samplingMode?: number);
  58536. /**
  58537. * Execute the current task
  58538. * @param scene defines the scene where you want your assets to be loaded
  58539. * @param onSuccess is a callback called when the task is successfully executed
  58540. * @param onError is a callback called if an error occurs
  58541. */
  58542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58543. }
  58544. /**
  58545. * Define a task used by AssetsManager to load cube textures
  58546. */
  58547. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58548. /**
  58549. * Defines the name of the task
  58550. */
  58551. name: string;
  58552. /**
  58553. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58554. */
  58555. url: string;
  58556. /**
  58557. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58558. */
  58559. extensions?: string[] | undefined;
  58560. /**
  58561. * Defines if mipmaps should not be generated (default is false)
  58562. */
  58563. noMipmap?: boolean | undefined;
  58564. /**
  58565. * Defines the explicit list of files (undefined by default)
  58566. */
  58567. files?: string[] | undefined;
  58568. /**
  58569. * Gets the loaded texture
  58570. */
  58571. texture: CubeTexture;
  58572. /**
  58573. * Callback called when the task is successful
  58574. */
  58575. onSuccess: (task: CubeTextureAssetTask) => void;
  58576. /**
  58577. * Callback called when the task is successful
  58578. */
  58579. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58580. /**
  58581. * Creates a new CubeTextureAssetTask
  58582. * @param name defines the name of the task
  58583. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58584. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58585. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58586. * @param files defines the explicit list of files (undefined by default)
  58587. */
  58588. constructor(
  58589. /**
  58590. * Defines the name of the task
  58591. */
  58592. name: string,
  58593. /**
  58594. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58595. */
  58596. url: string,
  58597. /**
  58598. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58599. */
  58600. extensions?: string[] | undefined,
  58601. /**
  58602. * Defines if mipmaps should not be generated (default is false)
  58603. */
  58604. noMipmap?: boolean | undefined,
  58605. /**
  58606. * Defines the explicit list of files (undefined by default)
  58607. */
  58608. files?: string[] | undefined);
  58609. /**
  58610. * Execute the current task
  58611. * @param scene defines the scene where you want your assets to be loaded
  58612. * @param onSuccess is a callback called when the task is successfully executed
  58613. * @param onError is a callback called if an error occurs
  58614. */
  58615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58616. }
  58617. /**
  58618. * Define a task used by AssetsManager to load HDR cube textures
  58619. */
  58620. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58621. /**
  58622. * Defines the name of the task
  58623. */
  58624. name: string;
  58625. /**
  58626. * Defines the location of the file to load
  58627. */
  58628. url: string;
  58629. /**
  58630. * Defines the desired size (the more it increases the longer the generation will be)
  58631. */
  58632. size: number;
  58633. /**
  58634. * Defines if mipmaps should not be generated (default is false)
  58635. */
  58636. noMipmap: boolean;
  58637. /**
  58638. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58639. */
  58640. generateHarmonics: boolean;
  58641. /**
  58642. * 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)
  58643. */
  58644. gammaSpace: boolean;
  58645. /**
  58646. * Internal Use Only
  58647. */
  58648. reserved: boolean;
  58649. /**
  58650. * Gets the loaded texture
  58651. */
  58652. texture: HDRCubeTexture;
  58653. /**
  58654. * Callback called when the task is successful
  58655. */
  58656. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58657. /**
  58658. * Callback called when the task is successful
  58659. */
  58660. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58661. /**
  58662. * Creates a new HDRCubeTextureAssetTask object
  58663. * @param name defines the name of the task
  58664. * @param url defines the location of the file to load
  58665. * @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.
  58666. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58667. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58668. * @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)
  58669. * @param reserved Internal use only
  58670. */
  58671. constructor(
  58672. /**
  58673. * Defines the name of the task
  58674. */
  58675. name: string,
  58676. /**
  58677. * Defines the location of the file to load
  58678. */
  58679. url: string,
  58680. /**
  58681. * Defines the desired size (the more it increases the longer the generation will be)
  58682. */
  58683. size: number,
  58684. /**
  58685. * Defines if mipmaps should not be generated (default is false)
  58686. */
  58687. noMipmap?: boolean,
  58688. /**
  58689. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58690. */
  58691. generateHarmonics?: boolean,
  58692. /**
  58693. * 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)
  58694. */
  58695. gammaSpace?: boolean,
  58696. /**
  58697. * Internal Use Only
  58698. */
  58699. reserved?: boolean);
  58700. /**
  58701. * Execute the current task
  58702. * @param scene defines the scene where you want your assets to be loaded
  58703. * @param onSuccess is a callback called when the task is successfully executed
  58704. * @param onError is a callback called if an error occurs
  58705. */
  58706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58707. }
  58708. /**
  58709. * Define a task used by AssetsManager to load Equirectangular cube textures
  58710. */
  58711. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58712. /**
  58713. * Defines the name of the task
  58714. */
  58715. name: string;
  58716. /**
  58717. * Defines the location of the file to load
  58718. */
  58719. url: string;
  58720. /**
  58721. * Defines the desired size (the more it increases the longer the generation will be)
  58722. */
  58723. size: number;
  58724. /**
  58725. * Defines if mipmaps should not be generated (default is false)
  58726. */
  58727. noMipmap: boolean;
  58728. /**
  58729. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58730. * but the standard material would require them in Gamma space) (default is true)
  58731. */
  58732. gammaSpace: boolean;
  58733. /**
  58734. * Gets the loaded texture
  58735. */
  58736. texture: EquiRectangularCubeTexture;
  58737. /**
  58738. * Callback called when the task is successful
  58739. */
  58740. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58741. /**
  58742. * Callback called when the task is successful
  58743. */
  58744. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58745. /**
  58746. * Creates a new EquiRectangularCubeTextureAssetTask object
  58747. * @param name defines the name of the task
  58748. * @param url defines the location of the file to load
  58749. * @param size defines the desired size (the more it increases the longer the generation will be)
  58750. * If the size is omitted this implies you are using a preprocessed cubemap.
  58751. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58752. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58753. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58754. * (default is true)
  58755. */
  58756. constructor(
  58757. /**
  58758. * Defines the name of the task
  58759. */
  58760. name: string,
  58761. /**
  58762. * Defines the location of the file to load
  58763. */
  58764. url: string,
  58765. /**
  58766. * Defines the desired size (the more it increases the longer the generation will be)
  58767. */
  58768. size: number,
  58769. /**
  58770. * Defines if mipmaps should not be generated (default is false)
  58771. */
  58772. noMipmap?: boolean,
  58773. /**
  58774. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58775. * but the standard material would require them in Gamma space) (default is true)
  58776. */
  58777. gammaSpace?: boolean);
  58778. /**
  58779. * Execute the current task
  58780. * @param scene defines the scene where you want your assets to be loaded
  58781. * @param onSuccess is a callback called when the task is successfully executed
  58782. * @param onError is a callback called if an error occurs
  58783. */
  58784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58785. }
  58786. /**
  58787. * This class can be used to easily import assets into a scene
  58788. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58789. */
  58790. export class AssetsManager {
  58791. private _scene;
  58792. private _isLoading;
  58793. protected _tasks: AbstractAssetTask[];
  58794. protected _waitingTasksCount: number;
  58795. protected _totalTasksCount: number;
  58796. /**
  58797. * Callback called when all tasks are processed
  58798. */
  58799. onFinish: (tasks: AbstractAssetTask[]) => void;
  58800. /**
  58801. * Callback called when a task is successful
  58802. */
  58803. onTaskSuccess: (task: AbstractAssetTask) => void;
  58804. /**
  58805. * Callback called when a task had an error
  58806. */
  58807. onTaskError: (task: AbstractAssetTask) => void;
  58808. /**
  58809. * Callback called when a task is done (whatever the result is)
  58810. */
  58811. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58812. /**
  58813. * Observable called when all tasks are processed
  58814. */
  58815. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58816. /**
  58817. * Observable called when a task had an error
  58818. */
  58819. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58820. /**
  58821. * Observable called when all tasks were executed
  58822. */
  58823. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58824. /**
  58825. * Observable called when a task is done (whatever the result is)
  58826. */
  58827. onProgressObservable: Observable<IAssetsProgressEvent>;
  58828. /**
  58829. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58830. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58831. */
  58832. useDefaultLoadingScreen: boolean;
  58833. /**
  58834. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  58835. * when all assets have been downloaded.
  58836. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  58837. */
  58838. autoHideLoadingUI: boolean;
  58839. /**
  58840. * Creates a new AssetsManager
  58841. * @param scene defines the scene to work on
  58842. */
  58843. constructor(scene: Scene);
  58844. /**
  58845. * Add a MeshAssetTask to the list of active tasks
  58846. * @param taskName defines the name of the new task
  58847. * @param meshesNames defines the name of meshes to load
  58848. * @param rootUrl defines the root url to use to locate files
  58849. * @param sceneFilename defines the filename of the scene file
  58850. * @returns a new MeshAssetTask object
  58851. */
  58852. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58853. /**
  58854. * Add a TextFileAssetTask to the list of active tasks
  58855. * @param taskName defines the name of the new task
  58856. * @param url defines the url of the file to load
  58857. * @returns a new TextFileAssetTask object
  58858. */
  58859. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58860. /**
  58861. * Add a BinaryFileAssetTask to the list of active tasks
  58862. * @param taskName defines the name of the new task
  58863. * @param url defines the url of the file to load
  58864. * @returns a new BinaryFileAssetTask object
  58865. */
  58866. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58867. /**
  58868. * Add a ImageAssetTask to the list of active tasks
  58869. * @param taskName defines the name of the new task
  58870. * @param url defines the url of the file to load
  58871. * @returns a new ImageAssetTask object
  58872. */
  58873. addImageTask(taskName: string, url: string): ImageAssetTask;
  58874. /**
  58875. * Add a TextureAssetTask to the list of active tasks
  58876. * @param taskName defines the name of the new task
  58877. * @param url defines the url of the file to load
  58878. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58879. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58880. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58881. * @returns a new TextureAssetTask object
  58882. */
  58883. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58884. /**
  58885. * Add a CubeTextureAssetTask to the list of active tasks
  58886. * @param taskName defines the name of the new task
  58887. * @param url defines the url of the file to load
  58888. * @param extensions defines the extension to use to load the cube map (can be null)
  58889. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58890. * @param files defines the list of files to load (can be null)
  58891. * @returns a new CubeTextureAssetTask object
  58892. */
  58893. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58894. /**
  58895. *
  58896. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58897. * @param taskName defines the name of the new task
  58898. * @param url defines the url of the file to load
  58899. * @param size defines the size you want for the cubemap (can be null)
  58900. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58901. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58902. * @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)
  58903. * @param reserved Internal use only
  58904. * @returns a new HDRCubeTextureAssetTask object
  58905. */
  58906. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58907. /**
  58908. *
  58909. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58910. * @param taskName defines the name of the new task
  58911. * @param url defines the url of the file to load
  58912. * @param size defines the size you want for the cubemap (can be null)
  58913. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58914. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58915. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58916. * @returns a new EquiRectangularCubeTextureAssetTask object
  58917. */
  58918. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58919. /**
  58920. * Remove a task from the assets manager.
  58921. * @param task the task to remove
  58922. */
  58923. removeTask(task: AbstractAssetTask): void;
  58924. private _decreaseWaitingTasksCount;
  58925. private _runTask;
  58926. /**
  58927. * Reset the AssetsManager and remove all tasks
  58928. * @return the current instance of the AssetsManager
  58929. */
  58930. reset(): AssetsManager;
  58931. /**
  58932. * Start the loading process
  58933. * @return the current instance of the AssetsManager
  58934. */
  58935. load(): AssetsManager;
  58936. /**
  58937. * Start the loading process as an async operation
  58938. * @return a promise returning the list of failed tasks
  58939. */
  58940. loadAsync(): Promise<void>;
  58941. }
  58942. }
  58943. declare module BABYLON {
  58944. /**
  58945. * Wrapper class for promise with external resolve and reject.
  58946. */
  58947. export class Deferred<T> {
  58948. /**
  58949. * The promise associated with this deferred object.
  58950. */
  58951. readonly promise: Promise<T>;
  58952. private _resolve;
  58953. private _reject;
  58954. /**
  58955. * The resolve method of the promise associated with this deferred object.
  58956. */
  58957. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58958. /**
  58959. * The reject method of the promise associated with this deferred object.
  58960. */
  58961. readonly reject: (reason?: any) => void;
  58962. /**
  58963. * Constructor for this deferred object.
  58964. */
  58965. constructor();
  58966. }
  58967. }
  58968. declare module BABYLON {
  58969. /**
  58970. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58971. */
  58972. export class MeshExploder {
  58973. private _centerMesh;
  58974. private _meshes;
  58975. private _meshesOrigins;
  58976. private _toCenterVectors;
  58977. private _scaledDirection;
  58978. private _newPosition;
  58979. private _centerPosition;
  58980. /**
  58981. * Explodes meshes from a center mesh.
  58982. * @param meshes The meshes to explode.
  58983. * @param centerMesh The mesh to be center of explosion.
  58984. */
  58985. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58986. private _setCenterMesh;
  58987. /**
  58988. * Get class name
  58989. * @returns "MeshExploder"
  58990. */
  58991. getClassName(): string;
  58992. /**
  58993. * "Exploded meshes"
  58994. * @returns Array of meshes with the centerMesh at index 0.
  58995. */
  58996. getMeshes(): Array<Mesh>;
  58997. /**
  58998. * Explodes meshes giving a specific direction
  58999. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59000. */
  59001. explode(direction?: number): void;
  59002. }
  59003. }
  59004. declare module BABYLON {
  59005. /**
  59006. * Class used to help managing file picking and drag'n'drop
  59007. */
  59008. export class FilesInput {
  59009. /**
  59010. * List of files ready to be loaded
  59011. */
  59012. static readonly FilesToLoad: {
  59013. [key: string]: File;
  59014. };
  59015. /**
  59016. * Callback called when a file is processed
  59017. */
  59018. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59019. private _engine;
  59020. private _currentScene;
  59021. private _sceneLoadedCallback;
  59022. private _progressCallback;
  59023. private _additionalRenderLoopLogicCallback;
  59024. private _textureLoadingCallback;
  59025. private _startingProcessingFilesCallback;
  59026. private _onReloadCallback;
  59027. private _errorCallback;
  59028. private _elementToMonitor;
  59029. private _sceneFileToLoad;
  59030. private _filesToLoad;
  59031. /**
  59032. * Creates a new FilesInput
  59033. * @param engine defines the rendering engine
  59034. * @param scene defines the hosting scene
  59035. * @param sceneLoadedCallback callback called when scene is loaded
  59036. * @param progressCallback callback called to track progress
  59037. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59038. * @param textureLoadingCallback callback called when a texture is loading
  59039. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59040. * @param onReloadCallback callback called when a reload is requested
  59041. * @param errorCallback callback call if an error occurs
  59042. */
  59043. 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);
  59044. private _dragEnterHandler;
  59045. private _dragOverHandler;
  59046. private _dropHandler;
  59047. /**
  59048. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59049. * @param elementToMonitor defines the DOM element to track
  59050. */
  59051. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59052. /**
  59053. * Release all associated resources
  59054. */
  59055. dispose(): void;
  59056. private renderFunction;
  59057. private drag;
  59058. private drop;
  59059. private _traverseFolder;
  59060. private _processFiles;
  59061. /**
  59062. * Load files from a drop event
  59063. * @param event defines the drop event to use as source
  59064. */
  59065. loadFiles(event: any): void;
  59066. private _processReload;
  59067. /**
  59068. * Reload the current scene from the loaded files
  59069. */
  59070. reload(): void;
  59071. }
  59072. }
  59073. declare module BABYLON {
  59074. /**
  59075. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59077. */
  59078. export class SceneOptimization {
  59079. /**
  59080. * Defines the priority of this optimization (0 by default which means first in the list)
  59081. */
  59082. priority: number;
  59083. /**
  59084. * Gets a string describing the action executed by the current optimization
  59085. * @returns description string
  59086. */
  59087. getDescription(): string;
  59088. /**
  59089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59090. * @param scene defines the current scene where to apply this optimization
  59091. * @param optimizer defines the current optimizer
  59092. * @returns true if everything that can be done was applied
  59093. */
  59094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59095. /**
  59096. * Creates the SceneOptimization object
  59097. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59098. * @param desc defines the description associated with the optimization
  59099. */
  59100. constructor(
  59101. /**
  59102. * Defines the priority of this optimization (0 by default which means first in the list)
  59103. */
  59104. priority?: number);
  59105. }
  59106. /**
  59107. * Defines an optimization used to reduce the size of render target textures
  59108. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59109. */
  59110. export class TextureOptimization extends SceneOptimization {
  59111. /**
  59112. * Defines the priority of this optimization (0 by default which means first in the list)
  59113. */
  59114. priority: number;
  59115. /**
  59116. * 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
  59117. */
  59118. maximumSize: number;
  59119. /**
  59120. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59121. */
  59122. step: number;
  59123. /**
  59124. * Gets a string describing the action executed by the current optimization
  59125. * @returns description string
  59126. */
  59127. getDescription(): string;
  59128. /**
  59129. * Creates the TextureOptimization object
  59130. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59131. * @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
  59132. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59133. */
  59134. constructor(
  59135. /**
  59136. * Defines the priority of this optimization (0 by default which means first in the list)
  59137. */
  59138. priority?: number,
  59139. /**
  59140. * 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
  59141. */
  59142. maximumSize?: number,
  59143. /**
  59144. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59145. */
  59146. step?: number);
  59147. /**
  59148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59149. * @param scene defines the current scene where to apply this optimization
  59150. * @param optimizer defines the current optimizer
  59151. * @returns true if everything that can be done was applied
  59152. */
  59153. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59154. }
  59155. /**
  59156. * Defines an optimization used to increase or decrease the rendering resolution
  59157. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59158. */
  59159. export class HardwareScalingOptimization extends SceneOptimization {
  59160. /**
  59161. * Defines the priority of this optimization (0 by default which means first in the list)
  59162. */
  59163. priority: number;
  59164. /**
  59165. * Defines the maximum scale to use (2 by default)
  59166. */
  59167. maximumScale: number;
  59168. /**
  59169. * Defines the step to use between two passes (0.5 by default)
  59170. */
  59171. step: number;
  59172. private _currentScale;
  59173. private _directionOffset;
  59174. /**
  59175. * Gets a string describing the action executed by the current optimization
  59176. * @return description string
  59177. */
  59178. getDescription(): string;
  59179. /**
  59180. * Creates the HardwareScalingOptimization object
  59181. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59182. * @param maximumScale defines the maximum scale to use (2 by default)
  59183. * @param step defines the step to use between two passes (0.5 by default)
  59184. */
  59185. constructor(
  59186. /**
  59187. * Defines the priority of this optimization (0 by default which means first in the list)
  59188. */
  59189. priority?: number,
  59190. /**
  59191. * Defines the maximum scale to use (2 by default)
  59192. */
  59193. maximumScale?: number,
  59194. /**
  59195. * Defines the step to use between two passes (0.5 by default)
  59196. */
  59197. step?: number);
  59198. /**
  59199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59200. * @param scene defines the current scene where to apply this optimization
  59201. * @param optimizer defines the current optimizer
  59202. * @returns true if everything that can be done was applied
  59203. */
  59204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59205. }
  59206. /**
  59207. * Defines an optimization used to remove shadows
  59208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59209. */
  59210. export class ShadowsOptimization extends SceneOptimization {
  59211. /**
  59212. * Gets a string describing the action executed by the current optimization
  59213. * @return description string
  59214. */
  59215. getDescription(): string;
  59216. /**
  59217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59218. * @param scene defines the current scene where to apply this optimization
  59219. * @param optimizer defines the current optimizer
  59220. * @returns true if everything that can be done was applied
  59221. */
  59222. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59223. }
  59224. /**
  59225. * Defines an optimization used to turn post-processes off
  59226. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59227. */
  59228. export class PostProcessesOptimization extends SceneOptimization {
  59229. /**
  59230. * Gets a string describing the action executed by the current optimization
  59231. * @return description string
  59232. */
  59233. getDescription(): string;
  59234. /**
  59235. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59236. * @param scene defines the current scene where to apply this optimization
  59237. * @param optimizer defines the current optimizer
  59238. * @returns true if everything that can be done was applied
  59239. */
  59240. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59241. }
  59242. /**
  59243. * Defines an optimization used to turn lens flares off
  59244. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59245. */
  59246. export class LensFlaresOptimization extends SceneOptimization {
  59247. /**
  59248. * Gets a string describing the action executed by the current optimization
  59249. * @return description string
  59250. */
  59251. getDescription(): string;
  59252. /**
  59253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59254. * @param scene defines the current scene where to apply this optimization
  59255. * @param optimizer defines the current optimizer
  59256. * @returns true if everything that can be done was applied
  59257. */
  59258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59259. }
  59260. /**
  59261. * Defines an optimization based on user defined callback.
  59262. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59263. */
  59264. export class CustomOptimization extends SceneOptimization {
  59265. /**
  59266. * Callback called to apply the custom optimization.
  59267. */
  59268. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59269. /**
  59270. * Callback called to get custom description
  59271. */
  59272. onGetDescription: () => string;
  59273. /**
  59274. * Gets a string describing the action executed by the current optimization
  59275. * @returns description string
  59276. */
  59277. getDescription(): string;
  59278. /**
  59279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59280. * @param scene defines the current scene where to apply this optimization
  59281. * @param optimizer defines the current optimizer
  59282. * @returns true if everything that can be done was applied
  59283. */
  59284. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59285. }
  59286. /**
  59287. * Defines an optimization used to turn particles off
  59288. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59289. */
  59290. export class ParticlesOptimization extends SceneOptimization {
  59291. /**
  59292. * Gets a string describing the action executed by the current optimization
  59293. * @return description string
  59294. */
  59295. getDescription(): string;
  59296. /**
  59297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59298. * @param scene defines the current scene where to apply this optimization
  59299. * @param optimizer defines the current optimizer
  59300. * @returns true if everything that can be done was applied
  59301. */
  59302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59303. }
  59304. /**
  59305. * Defines an optimization used to turn render targets off
  59306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59307. */
  59308. export class RenderTargetsOptimization extends SceneOptimization {
  59309. /**
  59310. * Gets a string describing the action executed by the current optimization
  59311. * @return description string
  59312. */
  59313. getDescription(): string;
  59314. /**
  59315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59316. * @param scene defines the current scene where to apply this optimization
  59317. * @param optimizer defines the current optimizer
  59318. * @returns true if everything that can be done was applied
  59319. */
  59320. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59321. }
  59322. /**
  59323. * Defines an optimization used to merge meshes with compatible materials
  59324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59325. */
  59326. export class MergeMeshesOptimization extends SceneOptimization {
  59327. private static _UpdateSelectionTree;
  59328. /**
  59329. * Gets or sets a boolean which defines if optimization octree has to be updated
  59330. */
  59331. /**
  59332. * Gets or sets a boolean which defines if optimization octree has to be updated
  59333. */
  59334. static UpdateSelectionTree: boolean;
  59335. /**
  59336. * Gets a string describing the action executed by the current optimization
  59337. * @return description string
  59338. */
  59339. getDescription(): string;
  59340. private _canBeMerged;
  59341. /**
  59342. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59343. * @param scene defines the current scene where to apply this optimization
  59344. * @param optimizer defines the current optimizer
  59345. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59346. * @returns true if everything that can be done was applied
  59347. */
  59348. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59349. }
  59350. /**
  59351. * Defines a list of options used by SceneOptimizer
  59352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59353. */
  59354. export class SceneOptimizerOptions {
  59355. /**
  59356. * Defines the target frame rate to reach (60 by default)
  59357. */
  59358. targetFrameRate: number;
  59359. /**
  59360. * Defines the interval between two checkes (2000ms by default)
  59361. */
  59362. trackerDuration: number;
  59363. /**
  59364. * Gets the list of optimizations to apply
  59365. */
  59366. optimizations: SceneOptimization[];
  59367. /**
  59368. * Creates a new list of options used by SceneOptimizer
  59369. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59370. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59371. */
  59372. constructor(
  59373. /**
  59374. * Defines the target frame rate to reach (60 by default)
  59375. */
  59376. targetFrameRate?: number,
  59377. /**
  59378. * Defines the interval between two checkes (2000ms by default)
  59379. */
  59380. trackerDuration?: number);
  59381. /**
  59382. * Add a new optimization
  59383. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59384. * @returns the current SceneOptimizerOptions
  59385. */
  59386. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59387. /**
  59388. * Add a new custom optimization
  59389. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59390. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59391. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59392. * @returns the current SceneOptimizerOptions
  59393. */
  59394. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59395. /**
  59396. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59397. * @param targetFrameRate defines the target frame rate (60 by default)
  59398. * @returns a SceneOptimizerOptions object
  59399. */
  59400. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59401. /**
  59402. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59403. * @param targetFrameRate defines the target frame rate (60 by default)
  59404. * @returns a SceneOptimizerOptions object
  59405. */
  59406. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59407. /**
  59408. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59409. * @param targetFrameRate defines the target frame rate (60 by default)
  59410. * @returns a SceneOptimizerOptions object
  59411. */
  59412. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59413. }
  59414. /**
  59415. * Class used to run optimizations in order to reach a target frame rate
  59416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59417. */
  59418. export class SceneOptimizer implements IDisposable {
  59419. private _isRunning;
  59420. private _options;
  59421. private _scene;
  59422. private _currentPriorityLevel;
  59423. private _targetFrameRate;
  59424. private _trackerDuration;
  59425. private _currentFrameRate;
  59426. private _sceneDisposeObserver;
  59427. private _improvementMode;
  59428. /**
  59429. * Defines an observable called when the optimizer reaches the target frame rate
  59430. */
  59431. onSuccessObservable: Observable<SceneOptimizer>;
  59432. /**
  59433. * Defines an observable called when the optimizer enables an optimization
  59434. */
  59435. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59436. /**
  59437. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59438. */
  59439. onFailureObservable: Observable<SceneOptimizer>;
  59440. /**
  59441. * Gets a boolean indicating if the optimizer is in improvement mode
  59442. */
  59443. readonly isInImprovementMode: boolean;
  59444. /**
  59445. * Gets the current priority level (0 at start)
  59446. */
  59447. readonly currentPriorityLevel: number;
  59448. /**
  59449. * Gets the current frame rate checked by the SceneOptimizer
  59450. */
  59451. readonly currentFrameRate: number;
  59452. /**
  59453. * Gets or sets the current target frame rate (60 by default)
  59454. */
  59455. /**
  59456. * Gets or sets the current target frame rate (60 by default)
  59457. */
  59458. targetFrameRate: number;
  59459. /**
  59460. * Gets or sets the current interval between two checks (every 2000ms by default)
  59461. */
  59462. /**
  59463. * Gets or sets the current interval between two checks (every 2000ms by default)
  59464. */
  59465. trackerDuration: number;
  59466. /**
  59467. * Gets the list of active optimizations
  59468. */
  59469. readonly optimizations: SceneOptimization[];
  59470. /**
  59471. * Creates a new SceneOptimizer
  59472. * @param scene defines the scene to work on
  59473. * @param options defines the options to use with the SceneOptimizer
  59474. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59475. * @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)
  59476. */
  59477. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59478. /**
  59479. * Stops the current optimizer
  59480. */
  59481. stop(): void;
  59482. /**
  59483. * Reset the optimizer to initial step (current priority level = 0)
  59484. */
  59485. reset(): void;
  59486. /**
  59487. * Start the optimizer. By default it will try to reach a specific framerate
  59488. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59489. */
  59490. start(): void;
  59491. private _checkCurrentState;
  59492. /**
  59493. * Release all resources
  59494. */
  59495. dispose(): void;
  59496. /**
  59497. * Helper function to create a SceneOptimizer with one single line of code
  59498. * @param scene defines the scene to work on
  59499. * @param options defines the options to use with the SceneOptimizer
  59500. * @param onSuccess defines a callback to call on success
  59501. * @param onFailure defines a callback to call on failure
  59502. * @returns the new SceneOptimizer object
  59503. */
  59504. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59505. }
  59506. }
  59507. declare module BABYLON {
  59508. /**
  59509. * Class used to serialize a scene into a string
  59510. */
  59511. export class SceneSerializer {
  59512. /**
  59513. * Clear cache used by a previous serialization
  59514. */
  59515. static ClearCache(): void;
  59516. /**
  59517. * Serialize a scene into a JSON compatible object
  59518. * @param scene defines the scene to serialize
  59519. * @returns a JSON compatible object
  59520. */
  59521. static Serialize(scene: Scene): any;
  59522. /**
  59523. * Serialize a mesh into a JSON compatible object
  59524. * @param toSerialize defines the mesh to serialize
  59525. * @param withParents defines if parents must be serialized as well
  59526. * @param withChildren defines if children must be serialized as well
  59527. * @returns a JSON compatible object
  59528. */
  59529. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59530. }
  59531. }
  59532. declare module BABYLON {
  59533. /**
  59534. * Class used to host texture specific utilities
  59535. */
  59536. export class TextureTools {
  59537. /**
  59538. * Uses the GPU to create a copy texture rescaled at a given size
  59539. * @param texture Texture to copy from
  59540. * @param width defines the desired width
  59541. * @param height defines the desired height
  59542. * @param useBilinearMode defines if bilinear mode has to be used
  59543. * @return the generated texture
  59544. */
  59545. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. /**
  59550. * This represents the different options available for the video capture.
  59551. */
  59552. export interface VideoRecorderOptions {
  59553. /** Defines the mime type of the video. */
  59554. mimeType: string;
  59555. /** Defines the FPS the video should be recorded at. */
  59556. fps: number;
  59557. /** Defines the chunk size for the recording data. */
  59558. recordChunckSize: number;
  59559. /** The audio tracks to attach to the recording. */
  59560. audioTracks?: MediaStreamTrack[];
  59561. }
  59562. /**
  59563. * This can help with recording videos from BabylonJS.
  59564. * This is based on the available WebRTC functionalities of the browser.
  59565. *
  59566. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59567. */
  59568. export class VideoRecorder {
  59569. private static readonly _defaultOptions;
  59570. /**
  59571. * Returns whether or not the VideoRecorder is available in your browser.
  59572. * @param engine Defines the Babylon Engine.
  59573. * @returns true if supported otherwise false.
  59574. */
  59575. static IsSupported(engine: Engine): boolean;
  59576. private readonly _options;
  59577. private _canvas;
  59578. private _mediaRecorder;
  59579. private _recordedChunks;
  59580. private _fileName;
  59581. private _resolve;
  59582. private _reject;
  59583. /**
  59584. * True when a recording is already in progress.
  59585. */
  59586. readonly isRecording: boolean;
  59587. /**
  59588. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59589. * @param engine Defines the BabylonJS Engine you wish to record.
  59590. * @param options Defines options that can be used to customize the capture.
  59591. */
  59592. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59593. /**
  59594. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59595. */
  59596. stopRecording(): void;
  59597. /**
  59598. * Starts recording the canvas for a max duration specified in parameters.
  59599. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59600. * If null no automatic download will start and you can rely on the promise to get the data back.
  59601. * @param maxDuration Defines the maximum recording time in seconds.
  59602. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59603. * @return A promise callback at the end of the recording with the video data in Blob.
  59604. */
  59605. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59606. /**
  59607. * Releases internal resources used during the recording.
  59608. */
  59609. dispose(): void;
  59610. private _handleDataAvailable;
  59611. private _handleError;
  59612. private _handleStop;
  59613. }
  59614. }
  59615. declare module BABYLON {
  59616. /**
  59617. * Class containing a set of static utilities functions for screenshots
  59618. */
  59619. export class ScreenshotTools {
  59620. /**
  59621. * Captures a screenshot of the current rendering
  59622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59623. * @param engine defines the rendering engine
  59624. * @param camera defines the source camera
  59625. * @param size This parameter can be set to a single number or to an object with the
  59626. * following (optional) properties: precision, width, height. If a single number is passed,
  59627. * it will be used for both width and height. If an object is passed, the screenshot size
  59628. * will be derived from the parameters. The precision property is a multiplier allowing
  59629. * rendering at a higher or lower resolution
  59630. * @param successCallback defines the callback receives a single parameter which contains the
  59631. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59632. * src parameter of an <img> to display it
  59633. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59634. * Check your browser for supported MIME types
  59635. */
  59636. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  59637. /**
  59638. * Captures a screenshot of the current rendering
  59639. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59640. * @param engine defines the rendering engine
  59641. * @param camera defines the source camera
  59642. * @param size This parameter can be set to a single number or to an object with the
  59643. * following (optional) properties: precision, width, height. If a single number is passed,
  59644. * it will be used for both width and height. If an object is passed, the screenshot size
  59645. * will be derived from the parameters. The precision property is a multiplier allowing
  59646. * rendering at a higher or lower resolution
  59647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59648. * Check your browser for supported MIME types
  59649. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  59650. * to the src parameter of an <img> to display it
  59651. */
  59652. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  59653. /**
  59654. * Generates an image screenshot from the specified camera.
  59655. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59656. * @param engine The engine to use for rendering
  59657. * @param camera The camera to use for rendering
  59658. * @param size This parameter can be set to a single number or to an object with the
  59659. * following (optional) properties: precision, width, height. If a single number is passed,
  59660. * it will be used for both width and height. If an object is passed, the screenshot size
  59661. * will be derived from the parameters. The precision property is a multiplier allowing
  59662. * rendering at a higher or lower resolution
  59663. * @param successCallback The callback receives a single parameter which contains the
  59664. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59665. * src parameter of an <img> to display it
  59666. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59667. * Check your browser for supported MIME types
  59668. * @param samples Texture samples (default: 1)
  59669. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59670. * @param fileName A name for for the downloaded file.
  59671. */
  59672. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59673. /**
  59674. * Generates an image screenshot from the specified camera.
  59675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59676. * @param engine The engine to use for rendering
  59677. * @param camera The camera to use for rendering
  59678. * @param size This parameter can be set to a single number or to an object with the
  59679. * following (optional) properties: precision, width, height. If a single number is passed,
  59680. * it will be used for both width and height. If an object is passed, the screenshot size
  59681. * will be derived from the parameters. The precision property is a multiplier allowing
  59682. * rendering at a higher or lower resolution
  59683. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59684. * Check your browser for supported MIME types
  59685. * @param samples Texture samples (default: 1)
  59686. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59687. * @param fileName A name for for the downloaded file.
  59688. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  59689. * to the src parameter of an <img> to display it
  59690. */
  59691. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  59692. }
  59693. }
  59694. declare module BABYLON {
  59695. /**
  59696. * A cursor which tracks a point on a path
  59697. */
  59698. export class PathCursor {
  59699. private path;
  59700. /**
  59701. * Stores path cursor callbacks for when an onchange event is triggered
  59702. */
  59703. private _onchange;
  59704. /**
  59705. * The value of the path cursor
  59706. */
  59707. value: number;
  59708. /**
  59709. * The animation array of the path cursor
  59710. */
  59711. animations: Animation[];
  59712. /**
  59713. * Initializes the path cursor
  59714. * @param path The path to track
  59715. */
  59716. constructor(path: Path2);
  59717. /**
  59718. * Gets the cursor point on the path
  59719. * @returns A point on the path cursor at the cursor location
  59720. */
  59721. getPoint(): Vector3;
  59722. /**
  59723. * Moves the cursor ahead by the step amount
  59724. * @param step The amount to move the cursor forward
  59725. * @returns This path cursor
  59726. */
  59727. moveAhead(step?: number): PathCursor;
  59728. /**
  59729. * Moves the cursor behind by the step amount
  59730. * @param step The amount to move the cursor back
  59731. * @returns This path cursor
  59732. */
  59733. moveBack(step?: number): PathCursor;
  59734. /**
  59735. * Moves the cursor by the step amount
  59736. * If the step amount is greater than one, an exception is thrown
  59737. * @param step The amount to move the cursor
  59738. * @returns This path cursor
  59739. */
  59740. move(step: number): PathCursor;
  59741. /**
  59742. * Ensures that the value is limited between zero and one
  59743. * @returns This path cursor
  59744. */
  59745. private ensureLimits;
  59746. /**
  59747. * Runs onchange callbacks on change (used by the animation engine)
  59748. * @returns This path cursor
  59749. */
  59750. private raiseOnChange;
  59751. /**
  59752. * Executes a function on change
  59753. * @param f A path cursor onchange callback
  59754. * @returns This path cursor
  59755. */
  59756. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59757. }
  59758. }
  59759. declare module BABYLON {
  59760. /** @hidden */
  59761. export var blurPixelShader: {
  59762. name: string;
  59763. shader: string;
  59764. };
  59765. }
  59766. declare module BABYLON {
  59767. /** @hidden */
  59768. export var pointCloudVertexDeclaration: {
  59769. name: string;
  59770. shader: string;
  59771. };
  59772. }
  59773. // Mixins
  59774. interface Window {
  59775. mozIndexedDB: IDBFactory;
  59776. webkitIndexedDB: IDBFactory;
  59777. msIndexedDB: IDBFactory;
  59778. webkitURL: typeof URL;
  59779. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59780. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59781. WebGLRenderingContext: WebGLRenderingContext;
  59782. MSGesture: MSGesture;
  59783. CANNON: any;
  59784. AudioContext: AudioContext;
  59785. webkitAudioContext: AudioContext;
  59786. PointerEvent: any;
  59787. Math: Math;
  59788. Uint8Array: Uint8ArrayConstructor;
  59789. Float32Array: Float32ArrayConstructor;
  59790. mozURL: typeof URL;
  59791. msURL: typeof URL;
  59792. VRFrameData: any; // WebVR, from specs 1.1
  59793. DracoDecoderModule: any;
  59794. setImmediate(handler: (...args: any[]) => void): number;
  59795. }
  59796. interface HTMLCanvasElement {
  59797. requestPointerLock(): void;
  59798. msRequestPointerLock?(): void;
  59799. mozRequestPointerLock?(): void;
  59800. webkitRequestPointerLock?(): void;
  59801. /** Track wether a record is in progress */
  59802. isRecording: boolean;
  59803. /** Capture Stream method defined by some browsers */
  59804. captureStream(fps?: number): MediaStream;
  59805. }
  59806. interface CanvasRenderingContext2D {
  59807. msImageSmoothingEnabled: boolean;
  59808. }
  59809. interface MouseEvent {
  59810. mozMovementX: number;
  59811. mozMovementY: number;
  59812. webkitMovementX: number;
  59813. webkitMovementY: number;
  59814. msMovementX: number;
  59815. msMovementY: number;
  59816. }
  59817. interface Navigator {
  59818. mozGetVRDevices: (any: any) => any;
  59819. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59820. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59821. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59822. webkitGetGamepads(): Gamepad[];
  59823. msGetGamepads(): Gamepad[];
  59824. webkitGamepads(): Gamepad[];
  59825. }
  59826. interface HTMLVideoElement {
  59827. mozSrcObject: any;
  59828. }
  59829. interface Math {
  59830. fround(x: number): number;
  59831. imul(a: number, b: number): number;
  59832. }
  59833. interface WebGLRenderingContext {
  59834. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59835. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59836. vertexAttribDivisor(index: number, divisor: number): void;
  59837. createVertexArray(): any;
  59838. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59839. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59840. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59841. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59842. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59843. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59844. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59845. // Queries
  59846. createQuery(): WebGLQuery;
  59847. deleteQuery(query: WebGLQuery): void;
  59848. beginQuery(target: number, query: WebGLQuery): void;
  59849. endQuery(target: number): void;
  59850. getQueryParameter(query: WebGLQuery, pname: number): any;
  59851. getQuery(target: number, pname: number): any;
  59852. MAX_SAMPLES: number;
  59853. RGBA8: number;
  59854. READ_FRAMEBUFFER: number;
  59855. DRAW_FRAMEBUFFER: number;
  59856. UNIFORM_BUFFER: number;
  59857. HALF_FLOAT_OES: number;
  59858. RGBA16F: number;
  59859. RGBA32F: number;
  59860. R32F: number;
  59861. RG32F: number;
  59862. RGB32F: number;
  59863. R16F: number;
  59864. RG16F: number;
  59865. RGB16F: number;
  59866. RED: number;
  59867. RG: number;
  59868. R8: number;
  59869. RG8: number;
  59870. UNSIGNED_INT_24_8: number;
  59871. DEPTH24_STENCIL8: number;
  59872. /* Multiple Render Targets */
  59873. drawBuffers(buffers: number[]): void;
  59874. readBuffer(src: number): void;
  59875. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59876. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59877. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59878. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59879. // Occlusion Query
  59880. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59881. ANY_SAMPLES_PASSED: number;
  59882. QUERY_RESULT_AVAILABLE: number;
  59883. QUERY_RESULT: number;
  59884. }
  59885. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59886. }
  59887. interface EXT_disjoint_timer_query {
  59888. QUERY_COUNTER_BITS_EXT: number;
  59889. TIME_ELAPSED_EXT: number;
  59890. TIMESTAMP_EXT: number;
  59891. GPU_DISJOINT_EXT: number;
  59892. QUERY_RESULT_EXT: number;
  59893. QUERY_RESULT_AVAILABLE_EXT: number;
  59894. queryCounterEXT(query: WebGLQuery, target: number): void;
  59895. createQueryEXT(): WebGLQuery;
  59896. beginQueryEXT(target: number, query: WebGLQuery): void;
  59897. endQueryEXT(target: number): void;
  59898. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59899. deleteQueryEXT(query: WebGLQuery): void;
  59900. }
  59901. interface WebGLUniformLocation { private _currentState: any;
  59902. }
  59903. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59904. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59905. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59906. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59907. interface WebGLRenderingContext {
  59908. readonly RASTERIZER_DISCARD: number;
  59909. readonly DEPTH_COMPONENT24: number;
  59910. readonly TEXTURE_3D: number;
  59911. readonly TEXTURE_2D_ARRAY: number;
  59912. readonly TEXTURE_COMPARE_FUNC: number;
  59913. readonly TEXTURE_COMPARE_MODE: number;
  59914. readonly COMPARE_REF_TO_TEXTURE: number;
  59915. readonly TEXTURE_WRAP_R: number;
  59916. readonly HALF_FLOAT: number;
  59917. readonly RGB8: number;
  59918. readonly RED_INTEGER: number;
  59919. readonly RG_INTEGER: number;
  59920. readonly RGB_INTEGER: number;
  59921. readonly RGBA_INTEGER: number;
  59922. readonly R8_SNORM: number;
  59923. readonly RG8_SNORM: number;
  59924. readonly RGB8_SNORM: number;
  59925. readonly RGBA8_SNORM: number;
  59926. readonly R8I: number;
  59927. readonly RG8I: number;
  59928. readonly RGB8I: number;
  59929. readonly RGBA8I: number;
  59930. readonly R8UI: number;
  59931. readonly RG8UI: number;
  59932. readonly RGB8UI: number;
  59933. readonly RGBA8UI: number;
  59934. readonly R16I: number;
  59935. readonly RG16I: number;
  59936. readonly RGB16I: number;
  59937. readonly RGBA16I: number;
  59938. readonly R16UI: number;
  59939. readonly RG16UI: number;
  59940. readonly RGB16UI: number;
  59941. readonly RGBA16UI: number;
  59942. readonly R32I: number;
  59943. readonly RG32I: number;
  59944. readonly RGB32I: number;
  59945. readonly RGBA32I: number;
  59946. readonly R32UI: number;
  59947. readonly RG32UI: number;
  59948. readonly RGB32UI: number;
  59949. readonly RGBA32UI: number;
  59950. readonly RGB10_A2UI: number;
  59951. readonly R11F_G11F_B10F: number;
  59952. readonly RGB9_E5: number;
  59953. readonly RGB10_A2: number;
  59954. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59955. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59956. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59957. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59958. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59959. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59960. 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;
  59961. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59962. readonly TRANSFORM_FEEDBACK: number;
  59963. readonly INTERLEAVED_ATTRIBS: number;
  59964. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59965. createTransformFeedback(): WebGLTransformFeedback;
  59966. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59967. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59968. beginTransformFeedback(primitiveMode: number): void;
  59969. endTransformFeedback(): void;
  59970. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59971. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59972. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59973. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59974. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59975. }
  59976. interface ImageBitmap {
  59977. readonly width: number;
  59978. readonly height: number;
  59979. close(): void;
  59980. }
  59981. interface WebGLQuery extends WebGLObject {
  59982. }
  59983. declare var WebGLQuery: {
  59984. prototype: WebGLQuery;
  59985. new(): WebGLQuery;
  59986. };
  59987. interface WebGLSampler extends WebGLObject {
  59988. }
  59989. declare var WebGLSampler: {
  59990. prototype: WebGLSampler;
  59991. new(): WebGLSampler;
  59992. };
  59993. interface WebGLSync extends WebGLObject {
  59994. }
  59995. declare var WebGLSync: {
  59996. prototype: WebGLSync;
  59997. new(): WebGLSync;
  59998. };
  59999. interface WebGLTransformFeedback extends WebGLObject {
  60000. }
  60001. declare var WebGLTransformFeedback: {
  60002. prototype: WebGLTransformFeedback;
  60003. new(): WebGLTransformFeedback;
  60004. };
  60005. interface WebGLVertexArrayObject extends WebGLObject {
  60006. }
  60007. declare var WebGLVertexArrayObject: {
  60008. prototype: WebGLVertexArrayObject;
  60009. new(): WebGLVertexArrayObject;
  60010. };
  60011. // Type definitions for WebVR API
  60012. // Project: https://w3c.github.io/webvr/
  60013. // Definitions by: six a <https://github.com/lostfictions>
  60014. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60015. interface VRDisplay extends EventTarget {
  60016. /**
  60017. * Dictionary of capabilities describing the VRDisplay.
  60018. */
  60019. readonly capabilities: VRDisplayCapabilities;
  60020. /**
  60021. * z-depth defining the far plane of the eye view frustum
  60022. * enables mapping of values in the render target depth
  60023. * attachment to scene coordinates. Initially set to 10000.0.
  60024. */
  60025. depthFar: number;
  60026. /**
  60027. * z-depth defining the near plane of the eye view frustum
  60028. * enables mapping of values in the render target depth
  60029. * attachment to scene coordinates. Initially set to 0.01.
  60030. */
  60031. depthNear: number;
  60032. /**
  60033. * An identifier for this distinct VRDisplay. Used as an
  60034. * association point in the Gamepad API.
  60035. */
  60036. readonly displayId: number;
  60037. /**
  60038. * A display name, a user-readable name identifying it.
  60039. */
  60040. readonly displayName: string;
  60041. readonly isConnected: boolean;
  60042. readonly isPresenting: boolean;
  60043. /**
  60044. * If this VRDisplay supports room-scale experiences, the optional
  60045. * stage attribute contains details on the room-scale parameters.
  60046. */
  60047. readonly stageParameters: VRStageParameters | null;
  60048. /**
  60049. * Passing the value returned by `requestAnimationFrame` to
  60050. * `cancelAnimationFrame` will unregister the callback.
  60051. * @param handle Define the hanle of the request to cancel
  60052. */
  60053. cancelAnimationFrame(handle: number): void;
  60054. /**
  60055. * Stops presenting to the VRDisplay.
  60056. * @returns a promise to know when it stopped
  60057. */
  60058. exitPresent(): Promise<void>;
  60059. /**
  60060. * Return the current VREyeParameters for the given eye.
  60061. * @param whichEye Define the eye we want the parameter for
  60062. * @returns the eye parameters
  60063. */
  60064. getEyeParameters(whichEye: string): VREyeParameters;
  60065. /**
  60066. * Populates the passed VRFrameData with the information required to render
  60067. * the current frame.
  60068. * @param frameData Define the data structure to populate
  60069. * @returns true if ok otherwise false
  60070. */
  60071. getFrameData(frameData: VRFrameData): boolean;
  60072. /**
  60073. * Get the layers currently being presented.
  60074. * @returns the list of VR layers
  60075. */
  60076. getLayers(): VRLayer[];
  60077. /**
  60078. * Return a VRPose containing the future predicted pose of the VRDisplay
  60079. * when the current frame will be presented. The value returned will not
  60080. * change until JavaScript has returned control to the browser.
  60081. *
  60082. * The VRPose will contain the position, orientation, velocity,
  60083. * and acceleration of each of these properties.
  60084. * @returns the pose object
  60085. */
  60086. getPose(): VRPose;
  60087. /**
  60088. * Return the current instantaneous pose of the VRDisplay, with no
  60089. * prediction applied.
  60090. * @returns the current instantaneous pose
  60091. */
  60092. getImmediatePose(): VRPose;
  60093. /**
  60094. * The callback passed to `requestAnimationFrame` will be called
  60095. * any time a new frame should be rendered. When the VRDisplay is
  60096. * presenting the callback will be called at the native refresh
  60097. * rate of the HMD. When not presenting this function acts
  60098. * identically to how window.requestAnimationFrame acts. Content should
  60099. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60100. * asynchronously from other displays and at differing refresh rates.
  60101. * @param callback Define the eaction to run next frame
  60102. * @returns the request handle it
  60103. */
  60104. requestAnimationFrame(callback: FrameRequestCallback): number;
  60105. /**
  60106. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60107. * Repeat calls while already presenting will update the VRLayers being displayed.
  60108. * @param layers Define the list of layer to present
  60109. * @returns a promise to know when the request has been fulfilled
  60110. */
  60111. requestPresent(layers: VRLayer[]): Promise<void>;
  60112. /**
  60113. * Reset the pose for this display, treating its current position and
  60114. * orientation as the "origin/zero" values. VRPose.position,
  60115. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60116. * updated when calling resetPose(). This should be called in only
  60117. * sitting-space experiences.
  60118. */
  60119. resetPose(): void;
  60120. /**
  60121. * The VRLayer provided to the VRDisplay will be captured and presented
  60122. * in the HMD. Calling this function has the same effect on the source
  60123. * canvas as any other operation that uses its source image, and canvases
  60124. * created without preserveDrawingBuffer set to true will be cleared.
  60125. * @param pose Define the pose to submit
  60126. */
  60127. submitFrame(pose?: VRPose): void;
  60128. }
  60129. declare var VRDisplay: {
  60130. prototype: VRDisplay;
  60131. new(): VRDisplay;
  60132. };
  60133. interface VRLayer {
  60134. leftBounds?: number[] | Float32Array | null;
  60135. rightBounds?: number[] | Float32Array | null;
  60136. source?: HTMLCanvasElement | null;
  60137. }
  60138. interface VRDisplayCapabilities {
  60139. readonly canPresent: boolean;
  60140. readonly hasExternalDisplay: boolean;
  60141. readonly hasOrientation: boolean;
  60142. readonly hasPosition: boolean;
  60143. readonly maxLayers: number;
  60144. }
  60145. interface VREyeParameters {
  60146. /** @deprecated */
  60147. readonly fieldOfView: VRFieldOfView;
  60148. readonly offset: Float32Array;
  60149. readonly renderHeight: number;
  60150. readonly renderWidth: number;
  60151. }
  60152. interface VRFieldOfView {
  60153. readonly downDegrees: number;
  60154. readonly leftDegrees: number;
  60155. readonly rightDegrees: number;
  60156. readonly upDegrees: number;
  60157. }
  60158. interface VRFrameData {
  60159. readonly leftProjectionMatrix: Float32Array;
  60160. readonly leftViewMatrix: Float32Array;
  60161. readonly pose: VRPose;
  60162. readonly rightProjectionMatrix: Float32Array;
  60163. readonly rightViewMatrix: Float32Array;
  60164. readonly timestamp: number;
  60165. }
  60166. interface VRPose {
  60167. readonly angularAcceleration: Float32Array | null;
  60168. readonly angularVelocity: Float32Array | null;
  60169. readonly linearAcceleration: Float32Array | null;
  60170. readonly linearVelocity: Float32Array | null;
  60171. readonly orientation: Float32Array | null;
  60172. readonly position: Float32Array | null;
  60173. readonly timestamp: number;
  60174. }
  60175. interface VRStageParameters {
  60176. sittingToStandingTransform?: Float32Array;
  60177. sizeX?: number;
  60178. sizeY?: number;
  60179. }
  60180. interface Navigator {
  60181. getVRDisplays(): Promise<VRDisplay[]>;
  60182. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60183. }
  60184. interface Window {
  60185. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60186. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60187. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60188. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60189. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60190. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60191. }
  60192. interface Gamepad {
  60193. readonly displayId: number;
  60194. }
  60195. type XRSessionMode =
  60196. | "inline"
  60197. | "immersive-vr"
  60198. | "immersive-ar";
  60199. type XRReferenceSpaceType =
  60200. | "viewer"
  60201. | "local"
  60202. | "local-floor"
  60203. | "bounded-floor"
  60204. | "unbounded";
  60205. type XREnvironmentBlendMode =
  60206. | "opaque"
  60207. | "additive"
  60208. | "alpha-blend";
  60209. type XRVisibilityState =
  60210. | "visible"
  60211. | "visible-blurred"
  60212. | "hidden";
  60213. type XRHandedness =
  60214. | "none"
  60215. | "left"
  60216. | "right";
  60217. type XRTargetRayMode =
  60218. | "gaze"
  60219. | "tracked-pointer"
  60220. | "screen";
  60221. type XREye =
  60222. | "none"
  60223. | "left"
  60224. | "right";
  60225. interface XRSpace extends EventTarget {
  60226. }
  60227. interface XRRenderState {
  60228. depthNear?: number;
  60229. depthFar?: number;
  60230. inlineVerticalFieldOfView?: number;
  60231. baseLayer?: XRWebGLLayer;
  60232. }
  60233. interface XRInputSource {
  60234. handedness: XRHandedness;
  60235. targetRayMode: XRTargetRayMode;
  60236. targetRaySpace: XRSpace;
  60237. gripSpace: XRSpace | undefined;
  60238. gamepad: Gamepad | undefined;
  60239. profiles: Array<string>;
  60240. }
  60241. interface XRSession {
  60242. addEventListener: Function;
  60243. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60244. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  60245. requestAnimationFrame: Function;
  60246. end(): Promise<void>;
  60247. renderState: XRRenderState;
  60248. inputSources: Array<XRInputSource>;
  60249. }
  60250. interface XRReferenceSpace extends XRSpace {
  60251. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60252. onreset: any;
  60253. }
  60254. interface XRFrame {
  60255. session: XRSession;
  60256. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60257. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60258. }
  60259. interface XRViewerPose extends XRPose {
  60260. views: Array<XRView>;
  60261. }
  60262. interface XRPose {
  60263. transform: XRRigidTransform;
  60264. emulatedPosition: boolean;
  60265. }
  60266. declare var XRWebGLLayer: {
  60267. prototype: XRWebGLLayer;
  60268. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60269. };
  60270. interface XRWebGLLayer {
  60271. framebuffer: WebGLFramebuffer;
  60272. framebufferWidth: number;
  60273. framebufferHeight: number;
  60274. getViewport: Function;
  60275. }
  60276. interface XRRigidTransform {
  60277. position: DOMPointReadOnly;
  60278. orientation: DOMPointReadOnly;
  60279. matrix: Float32Array;
  60280. inverse: XRRigidTransform;
  60281. }
  60282. interface XRView {
  60283. eye: XREye;
  60284. projectionMatrix: Float32Array;
  60285. transform: XRRigidTransform;
  60286. }
  60287. interface XRInputSourceChangeEvent {
  60288. session: XRSession;
  60289. removed: Array<XRInputSource>;
  60290. added: Array<XRInputSource>;
  60291. }
  60292. declare module BABYLON.GUI {
  60293. /**
  60294. * Class used to specific a value and its associated unit
  60295. */
  60296. export class ValueAndUnit {
  60297. /** defines the unit to store */
  60298. unit: number;
  60299. /** defines a boolean indicating if the value can be negative */
  60300. negativeValueAllowed: boolean;
  60301. private _value;
  60302. private _originalUnit;
  60303. /**
  60304. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60305. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60306. */
  60307. ignoreAdaptiveScaling: boolean;
  60308. /**
  60309. * Creates a new ValueAndUnit
  60310. * @param value defines the value to store
  60311. * @param unit defines the unit to store
  60312. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60313. */
  60314. constructor(value: number,
  60315. /** defines the unit to store */
  60316. unit?: number,
  60317. /** defines a boolean indicating if the value can be negative */
  60318. negativeValueAllowed?: boolean);
  60319. /** Gets a boolean indicating if the value is a percentage */
  60320. readonly isPercentage: boolean;
  60321. /** Gets a boolean indicating if the value is store as pixel */
  60322. readonly isPixel: boolean;
  60323. /** Gets direct internal value */
  60324. readonly internalValue: number;
  60325. /**
  60326. * Gets value as pixel
  60327. * @param host defines the root host
  60328. * @param refValue defines the reference value for percentages
  60329. * @returns the value as pixel
  60330. */
  60331. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  60332. /**
  60333. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  60334. * @param value defines the value to store
  60335. * @param unit defines the unit to store
  60336. * @returns the current ValueAndUnit
  60337. */
  60338. updateInPlace(value: number, unit?: number): ValueAndUnit;
  60339. /**
  60340. * Gets the value accordingly to its unit
  60341. * @param host defines the root host
  60342. * @returns the value
  60343. */
  60344. getValue(host: AdvancedDynamicTexture): number;
  60345. /**
  60346. * Gets a string representation of the value
  60347. * @param host defines the root host
  60348. * @param decimals defines an optional number of decimals to display
  60349. * @returns a string
  60350. */
  60351. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  60352. /**
  60353. * Store a value parsed from a string
  60354. * @param source defines the source string
  60355. * @returns true if the value was successfully parsed
  60356. */
  60357. fromString(source: string | number): boolean;
  60358. private static _Regex;
  60359. private static _UNITMODE_PERCENTAGE;
  60360. private static _UNITMODE_PIXEL;
  60361. /** UNITMODE_PERCENTAGE */
  60362. static readonly UNITMODE_PERCENTAGE: number;
  60363. /** UNITMODE_PIXEL */
  60364. static readonly UNITMODE_PIXEL: number;
  60365. }
  60366. }
  60367. declare module BABYLON.GUI {
  60368. /**
  60369. * Define a style used by control to automatically setup properties based on a template.
  60370. * Only support font related properties so far
  60371. */
  60372. export class Style implements BABYLON.IDisposable {
  60373. private _fontFamily;
  60374. private _fontStyle;
  60375. private _fontWeight;
  60376. /** @hidden */ private _host: AdvancedDynamicTexture;
  60377. /** @hidden */ private _fontSize: ValueAndUnit;
  60378. /**
  60379. * BABYLON.Observable raised when the style values are changed
  60380. */
  60381. onChangedObservable: BABYLON.Observable<Style>;
  60382. /**
  60383. * Creates a new style object
  60384. * @param host defines the AdvancedDynamicTexture which hosts this style
  60385. */
  60386. constructor(host: AdvancedDynamicTexture);
  60387. /**
  60388. * Gets or sets the font size
  60389. */
  60390. fontSize: string | number;
  60391. /**
  60392. * Gets or sets the font family
  60393. */
  60394. fontFamily: string;
  60395. /**
  60396. * Gets or sets the font style
  60397. */
  60398. fontStyle: string;
  60399. /** Gets or sets font weight */
  60400. fontWeight: string;
  60401. /** Dispose all associated resources */
  60402. dispose(): void;
  60403. }
  60404. }
  60405. declare module BABYLON.GUI {
  60406. /**
  60407. * Class used to transport BABYLON.Vector2 information for pointer events
  60408. */
  60409. export class Vector2WithInfo extends BABYLON.Vector2 {
  60410. /** defines the current mouse button index */
  60411. buttonIndex: number;
  60412. /**
  60413. * Creates a new Vector2WithInfo
  60414. * @param source defines the vector2 data to transport
  60415. * @param buttonIndex defines the current mouse button index
  60416. */
  60417. constructor(source: BABYLON.Vector2,
  60418. /** defines the current mouse button index */
  60419. buttonIndex?: number);
  60420. }
  60421. /** Class used to provide 2D matrix features */
  60422. export class Matrix2D {
  60423. /** Gets the internal array of 6 floats used to store matrix data */
  60424. m: Float32Array;
  60425. /**
  60426. * Creates a new matrix
  60427. * @param m00 defines value for (0, 0)
  60428. * @param m01 defines value for (0, 1)
  60429. * @param m10 defines value for (1, 0)
  60430. * @param m11 defines value for (1, 1)
  60431. * @param m20 defines value for (2, 0)
  60432. * @param m21 defines value for (2, 1)
  60433. */
  60434. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  60435. /**
  60436. * Fills the matrix from direct values
  60437. * @param m00 defines value for (0, 0)
  60438. * @param m01 defines value for (0, 1)
  60439. * @param m10 defines value for (1, 0)
  60440. * @param m11 defines value for (1, 1)
  60441. * @param m20 defines value for (2, 0)
  60442. * @param m21 defines value for (2, 1)
  60443. * @returns the current modified matrix
  60444. */
  60445. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  60446. /**
  60447. * Gets matrix determinant
  60448. * @returns the determinant
  60449. */
  60450. determinant(): number;
  60451. /**
  60452. * Inverses the matrix and stores it in a target matrix
  60453. * @param result defines the target matrix
  60454. * @returns the current matrix
  60455. */
  60456. invertToRef(result: Matrix2D): Matrix2D;
  60457. /**
  60458. * Multiplies the current matrix with another one
  60459. * @param other defines the second operand
  60460. * @param result defines the target matrix
  60461. * @returns the current matrix
  60462. */
  60463. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  60464. /**
  60465. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  60466. * @param x defines the x coordinate to transform
  60467. * @param y defines the x coordinate to transform
  60468. * @param result defines the target vector2
  60469. * @returns the current matrix
  60470. */
  60471. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60472. /**
  60473. * Creates an identity matrix
  60474. * @returns a new matrix
  60475. */
  60476. static Identity(): Matrix2D;
  60477. /**
  60478. * Creates a translation matrix and stores it in a target matrix
  60479. * @param x defines the x coordinate of the translation
  60480. * @param y defines the y coordinate of the translation
  60481. * @param result defines the target matrix
  60482. */
  60483. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60484. /**
  60485. * Creates a scaling matrix and stores it in a target matrix
  60486. * @param x defines the x coordinate of the scaling
  60487. * @param y defines the y coordinate of the scaling
  60488. * @param result defines the target matrix
  60489. */
  60490. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60491. /**
  60492. * Creates a rotation matrix and stores it in a target matrix
  60493. * @param angle defines the rotation angle
  60494. * @param result defines the target matrix
  60495. */
  60496. static RotationToRef(angle: number, result: Matrix2D): void;
  60497. private static _TempPreTranslationMatrix;
  60498. private static _TempPostTranslationMatrix;
  60499. private static _TempRotationMatrix;
  60500. private static _TempScalingMatrix;
  60501. private static _TempCompose0;
  60502. private static _TempCompose1;
  60503. private static _TempCompose2;
  60504. /**
  60505. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60506. * @param tx defines the x coordinate of the translation
  60507. * @param ty defines the y coordinate of the translation
  60508. * @param angle defines the rotation angle
  60509. * @param scaleX defines the x coordinate of the scaling
  60510. * @param scaleY defines the y coordinate of the scaling
  60511. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60512. * @param result defines the target matrix
  60513. */
  60514. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60515. }
  60516. }
  60517. declare module BABYLON.GUI {
  60518. /**
  60519. * Class used to store 2D control sizes
  60520. */
  60521. export class Measure {
  60522. /** defines left coordinate */
  60523. left: number;
  60524. /** defines top coordinate */
  60525. top: number;
  60526. /** defines width dimension */
  60527. width: number;
  60528. /** defines height dimension */
  60529. height: number;
  60530. /**
  60531. * Creates a new measure
  60532. * @param left defines left coordinate
  60533. * @param top defines top coordinate
  60534. * @param width defines width dimension
  60535. * @param height defines height dimension
  60536. */
  60537. constructor(
  60538. /** defines left coordinate */
  60539. left: number,
  60540. /** defines top coordinate */
  60541. top: number,
  60542. /** defines width dimension */
  60543. width: number,
  60544. /** defines height dimension */
  60545. height: number);
  60546. /**
  60547. * Copy from another measure
  60548. * @param other defines the other measure to copy from
  60549. */
  60550. copyFrom(other: Measure): void;
  60551. /**
  60552. * Copy from a group of 4 floats
  60553. * @param left defines left coordinate
  60554. * @param top defines top coordinate
  60555. * @param width defines width dimension
  60556. * @param height defines height dimension
  60557. */
  60558. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60559. /**
  60560. * Computes the axis aligned bounding box measure for two given measures
  60561. * @param a Input measure
  60562. * @param b Input measure
  60563. * @param result the resulting bounding measure
  60564. */
  60565. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60566. /**
  60567. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60568. * @param transform the matrix to transform the measure before computing the AABB
  60569. * @param result the resulting AABB
  60570. */
  60571. transformToRef(transform: Matrix2D, result: Measure): void;
  60572. /**
  60573. * Check equality between this measure and another one
  60574. * @param other defines the other measures
  60575. * @returns true if both measures are equals
  60576. */
  60577. isEqualsTo(other: Measure): boolean;
  60578. /**
  60579. * Creates an empty measure
  60580. * @returns a new measure
  60581. */
  60582. static Empty(): Measure;
  60583. }
  60584. }
  60585. declare module BABYLON.GUI {
  60586. /**
  60587. * Interface used to define a control that can receive focus
  60588. */
  60589. export interface IFocusableControl {
  60590. /**
  60591. * Function called when the control receives the focus
  60592. */
  60593. onFocus(): void;
  60594. /**
  60595. * Function called when the control loses the focus
  60596. */
  60597. onBlur(): void;
  60598. /**
  60599. * Function called to let the control handle keyboard events
  60600. * @param evt defines the current keyboard event
  60601. */
  60602. processKeyboard(evt: KeyboardEvent): void;
  60603. /**
  60604. * Function called to get the list of controls that should not steal the focus from this control
  60605. * @returns an array of controls
  60606. */
  60607. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60608. }
  60609. /**
  60610. * Class used to create texture to support 2D GUI elements
  60611. * @see http://doc.babylonjs.com/how_to/gui
  60612. */
  60613. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60614. private _isDirty;
  60615. private _renderObserver;
  60616. private _resizeObserver;
  60617. private _preKeyboardObserver;
  60618. private _pointerMoveObserver;
  60619. private _pointerObserver;
  60620. private _canvasPointerOutObserver;
  60621. private _background;
  60622. /** @hidden */ private _rootContainer: Container;
  60623. /** @hidden */ private _lastPickedControl: Control;
  60624. /** @hidden */ private _lastControlOver: {
  60625. [pointerId: number]: Control;
  60626. };
  60627. /** @hidden */ private _lastControlDown: {
  60628. [pointerId: number]: Control;
  60629. };
  60630. /** @hidden */ private _capturingControl: {
  60631. [pointerId: number]: Control;
  60632. };
  60633. /** @hidden */ private _shouldBlockPointer: boolean;
  60634. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60635. /** @hidden */ private _linkedControls: Control[];
  60636. private _isFullscreen;
  60637. private _fullscreenViewport;
  60638. private _idealWidth;
  60639. private _idealHeight;
  60640. private _useSmallestIdeal;
  60641. private _renderAtIdealSize;
  60642. private _focusedControl;
  60643. private _blockNextFocusCheck;
  60644. private _renderScale;
  60645. private _rootCanvas;
  60646. private _cursorChanged;
  60647. /**
  60648. * Define type to string to ensure compatibility across browsers
  60649. * Safari doesn't support DataTransfer constructor
  60650. */
  60651. private _clipboardData;
  60652. /**
  60653. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60654. */
  60655. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60656. /**
  60657. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60658. */
  60659. onControlPickedObservable: BABYLON.Observable<Control>;
  60660. /**
  60661. * BABYLON.Observable event triggered before layout is evaluated
  60662. */
  60663. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60664. /**
  60665. * BABYLON.Observable event triggered after the layout was evaluated
  60666. */
  60667. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60668. /**
  60669. * BABYLON.Observable event triggered before the texture is rendered
  60670. */
  60671. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60672. /**
  60673. * BABYLON.Observable event triggered after the texture was rendered
  60674. */
  60675. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60676. /**
  60677. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60678. */
  60679. premulAlpha: boolean;
  60680. /**
  60681. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60682. * Useful when you want more antialiasing
  60683. */
  60684. renderScale: number;
  60685. /** Gets or sets the background color */
  60686. background: string;
  60687. /**
  60688. * Gets or sets the ideal width used to design controls.
  60689. * The GUI will then rescale everything accordingly
  60690. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60691. */
  60692. idealWidth: number;
  60693. /**
  60694. * Gets or sets the ideal height used to design controls.
  60695. * The GUI will then rescale everything accordingly
  60696. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60697. */
  60698. idealHeight: number;
  60699. /**
  60700. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60701. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60702. */
  60703. useSmallestIdeal: boolean;
  60704. /**
  60705. * Gets or sets a boolean indicating if adaptive scaling must be used
  60706. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60707. */
  60708. renderAtIdealSize: boolean;
  60709. /**
  60710. * Gets the underlying layer used to render the texture when in fullscreen mode
  60711. */
  60712. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60713. /**
  60714. * Gets the root container control
  60715. */
  60716. readonly rootContainer: Container;
  60717. /**
  60718. * Returns an array containing the root container.
  60719. * This is mostly used to let the Inspector introspects the ADT
  60720. * @returns an array containing the rootContainer
  60721. */
  60722. getChildren(): Array<Container>;
  60723. /**
  60724. * Will return all controls that are inside this texture
  60725. * @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
  60726. * @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
  60727. * @return all child controls
  60728. */
  60729. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60730. /**
  60731. * Gets or sets the current focused control
  60732. */
  60733. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60734. /**
  60735. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60736. */
  60737. isForeground: boolean;
  60738. /**
  60739. * Gets or set information about clipboardData
  60740. */
  60741. clipboardData: string;
  60742. /**
  60743. * Creates a new AdvancedDynamicTexture
  60744. * @param name defines the name of the texture
  60745. * @param width defines the width of the texture
  60746. * @param height defines the height of the texture
  60747. * @param scene defines the hosting scene
  60748. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60749. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60750. */
  60751. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60752. /**
  60753. * Get the current class name of the texture useful for serialization or dynamic coding.
  60754. * @returns "AdvancedDynamicTexture"
  60755. */
  60756. getClassName(): string;
  60757. /**
  60758. * Function used to execute a function on all controls
  60759. * @param func defines the function to execute
  60760. * @param container defines the container where controls belong. If null the root container will be used
  60761. */
  60762. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60763. private _useInvalidateRectOptimization;
  60764. /**
  60765. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60766. */
  60767. useInvalidateRectOptimization: boolean;
  60768. private _invalidatedRectangle;
  60769. /**
  60770. * Invalidates a rectangle area on the gui texture
  60771. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60772. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60773. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60774. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60775. */
  60776. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60777. /**
  60778. * Marks the texture as dirty forcing a complete update
  60779. */
  60780. markAsDirty(): void;
  60781. /**
  60782. * Helper function used to create a new style
  60783. * @returns a new style
  60784. * @see http://doc.babylonjs.com/how_to/gui#styles
  60785. */
  60786. createStyle(): Style;
  60787. /**
  60788. * Adds a new control to the root container
  60789. * @param control defines the control to add
  60790. * @returns the current texture
  60791. */
  60792. addControl(control: Control): AdvancedDynamicTexture;
  60793. /**
  60794. * Removes a control from the root container
  60795. * @param control defines the control to remove
  60796. * @returns the current texture
  60797. */
  60798. removeControl(control: Control): AdvancedDynamicTexture;
  60799. /**
  60800. * Release all resources
  60801. */
  60802. dispose(): void;
  60803. private _onResize;
  60804. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60805. /**
  60806. * Get screen coordinates for a vector3
  60807. * @param position defines the position to project
  60808. * @param worldMatrix defines the world matrix to use
  60809. * @returns the projected position
  60810. */
  60811. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60812. private _checkUpdate;
  60813. private _clearMeasure;
  60814. private _render;
  60815. /** @hidden */ private _changeCursor(cursor: string): void;
  60816. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  60817. private _doPicking;
  60818. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  60819. [pointerId: number]: Control;
  60820. }, control: Control): void;
  60821. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  60822. /** Attach to all scene events required to support pointer events */
  60823. attach(): void;
  60824. /** @hidden */
  60825. private onClipboardCopy;
  60826. /** @hidden */
  60827. private onClipboardCut;
  60828. /** @hidden */
  60829. private onClipboardPaste;
  60830. /**
  60831. * Register the clipboard Events onto the canvas
  60832. */
  60833. registerClipboardEvents(): void;
  60834. /**
  60835. * Unregister the clipboard Events from the canvas
  60836. */
  60837. unRegisterClipboardEvents(): void;
  60838. /**
  60839. * Connect the texture to a hosting mesh to enable interactions
  60840. * @param mesh defines the mesh to attach to
  60841. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60842. */
  60843. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60844. /**
  60845. * Move the focus to a specific control
  60846. * @param control defines the control which will receive the focus
  60847. */
  60848. moveFocusToControl(control: IFocusableControl): void;
  60849. private _manageFocus;
  60850. private _attachToOnPointerOut;
  60851. /**
  60852. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60853. * @param mesh defines the mesh which will receive the texture
  60854. * @param width defines the texture width (1024 by default)
  60855. * @param height defines the texture height (1024 by default)
  60856. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60857. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60858. * @returns a new AdvancedDynamicTexture
  60859. */
  60860. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60861. /**
  60862. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60863. * In this mode the texture will rely on a layer for its rendering.
  60864. * This allows it to be treated like any other layer.
  60865. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60866. * LayerMask is set through advancedTexture.layer.layerMask
  60867. * @param name defines name for the texture
  60868. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60869. * @param scene defines the hsoting scene
  60870. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60871. * @returns a new AdvancedDynamicTexture
  60872. */
  60873. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60874. }
  60875. }
  60876. declare module BABYLON.GUI {
  60877. /**
  60878. * Root class used for all 2D controls
  60879. * @see http://doc.babylonjs.com/how_to/gui#controls
  60880. */
  60881. export class Control {
  60882. /** defines the name of the control */
  60883. name?: string | undefined;
  60884. /**
  60885. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60886. */
  60887. static AllowAlphaInheritance: boolean;
  60888. private _alpha;
  60889. private _alphaSet;
  60890. private _zIndex;
  60891. /** @hidden */ private _host: AdvancedDynamicTexture;
  60892. /** Gets or sets the control parent */
  60893. parent: BABYLON.Nullable<Container>;
  60894. /** @hidden */ private _currentMeasure: Measure;
  60895. private _fontFamily;
  60896. private _fontStyle;
  60897. private _fontWeight;
  60898. private _fontSize;
  60899. private _font;
  60900. /** @hidden */ private _width: ValueAndUnit;
  60901. /** @hidden */ private _height: ValueAndUnit;
  60902. /** @hidden */
  60903. protected _fontOffset: {
  60904. ascent: number;
  60905. height: number;
  60906. descent: number;
  60907. };
  60908. private _color;
  60909. private _style;
  60910. private _styleObserver;
  60911. /** @hidden */
  60912. protected _horizontalAlignment: number;
  60913. /** @hidden */
  60914. protected _verticalAlignment: number;
  60915. /** @hidden */
  60916. protected _isDirty: boolean;
  60917. /** @hidden */
  60918. protected _wasDirty: boolean;
  60919. /** @hidden */ private _tempParentMeasure: Measure;
  60920. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60921. /** @hidden */
  60922. protected _cachedParentMeasure: Measure;
  60923. private _paddingLeft;
  60924. private _paddingRight;
  60925. private _paddingTop;
  60926. private _paddingBottom;
  60927. /** @hidden */ private _left: ValueAndUnit;
  60928. /** @hidden */ private _top: ValueAndUnit;
  60929. private _scaleX;
  60930. private _scaleY;
  60931. private _rotation;
  60932. private _transformCenterX;
  60933. private _transformCenterY;
  60934. /** @hidden */ private _transformMatrix: Matrix2D;
  60935. /** @hidden */
  60936. protected _invertTransformMatrix: Matrix2D;
  60937. /** @hidden */
  60938. protected _transformedPosition: BABYLON.Vector2;
  60939. private _isMatrixDirty;
  60940. private _cachedOffsetX;
  60941. private _cachedOffsetY;
  60942. private _isVisible;
  60943. private _isHighlighted;
  60944. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60945. private _fontSet;
  60946. private _dummyVector2;
  60947. private _downCount;
  60948. private _enterCount;
  60949. private _doNotRender;
  60950. private _downPointerIds;
  60951. protected _isEnabled: boolean;
  60952. protected _disabledColor: string;
  60953. /** @hidden */
  60954. protected _rebuildLayout: boolean;
  60955. /** @hidden */ private _isClipped: boolean;
  60956. /** @hidden */ private _tag: any;
  60957. /**
  60958. * 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
  60959. */
  60960. uniqueId: number;
  60961. /**
  60962. * Gets or sets an object used to store user defined information for the node
  60963. */
  60964. metadata: any;
  60965. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60966. isHitTestVisible: boolean;
  60967. /** Gets or sets a boolean indicating if the control can block pointer events */
  60968. isPointerBlocker: boolean;
  60969. /** Gets or sets a boolean indicating if the control can be focusable */
  60970. isFocusInvisible: boolean;
  60971. /**
  60972. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60973. * 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
  60974. */
  60975. clipChildren: boolean;
  60976. /**
  60977. * Gets or sets a boolean indicating that control content must be clipped
  60978. * 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
  60979. */
  60980. clipContent: boolean;
  60981. /**
  60982. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60983. */
  60984. useBitmapCache: boolean;
  60985. private _cacheData;
  60986. private _shadowOffsetX;
  60987. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60988. shadowOffsetX: number;
  60989. private _shadowOffsetY;
  60990. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60991. shadowOffsetY: number;
  60992. private _shadowBlur;
  60993. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60994. shadowBlur: number;
  60995. private _shadowColor;
  60996. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60997. shadowColor: string;
  60998. /** Gets or sets the cursor to use when the control is hovered */
  60999. hoverCursor: string;
  61000. /** @hidden */
  61001. protected _linkOffsetX: ValueAndUnit;
  61002. /** @hidden */
  61003. protected _linkOffsetY: ValueAndUnit;
  61004. /** Gets the control type name */
  61005. readonly typeName: string;
  61006. /**
  61007. * Get the current class name of the control.
  61008. * @returns current class name
  61009. */
  61010. getClassName(): string;
  61011. /**
  61012. * An event triggered when the pointer move over the control.
  61013. */
  61014. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61015. /**
  61016. * An event triggered when the pointer move out of the control.
  61017. */
  61018. onPointerOutObservable: BABYLON.Observable<Control>;
  61019. /**
  61020. * An event triggered when the pointer taps the control
  61021. */
  61022. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61023. /**
  61024. * An event triggered when pointer up
  61025. */
  61026. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61027. /**
  61028. * An event triggered when a control is clicked on
  61029. */
  61030. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61031. /**
  61032. * An event triggered when pointer enters the control
  61033. */
  61034. onPointerEnterObservable: BABYLON.Observable<Control>;
  61035. /**
  61036. * An event triggered when the control is marked as dirty
  61037. */
  61038. onDirtyObservable: BABYLON.Observable<Control>;
  61039. /**
  61040. * An event triggered before drawing the control
  61041. */
  61042. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61043. /**
  61044. * An event triggered after the control was drawn
  61045. */
  61046. onAfterDrawObservable: BABYLON.Observable<Control>;
  61047. /**
  61048. * Get the hosting AdvancedDynamicTexture
  61049. */
  61050. readonly host: AdvancedDynamicTexture;
  61051. /** Gets or set information about font offsets (used to render and align text) */
  61052. fontOffset: {
  61053. ascent: number;
  61054. height: number;
  61055. descent: number;
  61056. };
  61057. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61058. alpha: number;
  61059. /**
  61060. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61061. */
  61062. isHighlighted: boolean;
  61063. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61064. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61065. */
  61066. scaleX: number;
  61067. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61068. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61069. */
  61070. scaleY: number;
  61071. /** Gets or sets the rotation angle (0 by default)
  61072. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61073. */
  61074. rotation: number;
  61075. /** Gets or sets the transformation center on Y axis (0 by default)
  61076. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61077. */
  61078. transformCenterY: number;
  61079. /** Gets or sets the transformation center on X axis (0 by default)
  61080. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61081. */
  61082. transformCenterX: number;
  61083. /**
  61084. * Gets or sets the horizontal alignment
  61085. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61086. */
  61087. horizontalAlignment: number;
  61088. /**
  61089. * Gets or sets the vertical alignment
  61090. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61091. */
  61092. verticalAlignment: number;
  61093. /**
  61094. * Gets or sets control width
  61095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61096. */
  61097. width: string | number;
  61098. /**
  61099. * Gets or sets the control width in pixel
  61100. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61101. */
  61102. widthInPixels: number;
  61103. /**
  61104. * Gets or sets control height
  61105. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61106. */
  61107. height: string | number;
  61108. /**
  61109. * Gets or sets control height in pixel
  61110. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61111. */
  61112. heightInPixels: number;
  61113. /** Gets or set font family */
  61114. fontFamily: string;
  61115. /** Gets or sets font style */
  61116. fontStyle: string;
  61117. /** Gets or sets font weight */
  61118. fontWeight: string;
  61119. /**
  61120. * Gets or sets style
  61121. * @see http://doc.babylonjs.com/how_to/gui#styles
  61122. */
  61123. style: BABYLON.Nullable<Style>;
  61124. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  61125. /** Gets or sets font size in pixels */
  61126. fontSizeInPixels: number;
  61127. /** Gets or sets font size */
  61128. fontSize: string | number;
  61129. /** Gets or sets foreground color */
  61130. color: string;
  61131. /** Gets or sets z index which is used to reorder controls on the z axis */
  61132. zIndex: number;
  61133. /** Gets or sets a boolean indicating if the control can be rendered */
  61134. notRenderable: boolean;
  61135. /** Gets or sets a boolean indicating if the control is visible */
  61136. isVisible: boolean;
  61137. /** Gets a boolean indicating that the control needs to update its rendering */
  61138. readonly isDirty: boolean;
  61139. /**
  61140. * Gets the current linked mesh (or null if none)
  61141. */
  61142. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61143. /**
  61144. * Gets or sets a value indicating the padding to use on the left of the control
  61145. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61146. */
  61147. paddingLeft: string | number;
  61148. /**
  61149. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61150. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61151. */
  61152. paddingLeftInPixels: number;
  61153. /**
  61154. * Gets or sets a value indicating the padding to use on the right of the control
  61155. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61156. */
  61157. paddingRight: string | number;
  61158. /**
  61159. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61161. */
  61162. paddingRightInPixels: number;
  61163. /**
  61164. * Gets or sets a value indicating the padding to use on the top of the control
  61165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61166. */
  61167. paddingTop: string | number;
  61168. /**
  61169. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61170. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61171. */
  61172. paddingTopInPixels: number;
  61173. /**
  61174. * Gets or sets a value indicating the padding to use on the bottom of the control
  61175. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61176. */
  61177. paddingBottom: string | number;
  61178. /**
  61179. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61180. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61181. */
  61182. paddingBottomInPixels: number;
  61183. /**
  61184. * Gets or sets a value indicating the left coordinate of the control
  61185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61186. */
  61187. left: string | number;
  61188. /**
  61189. * Gets or sets a value indicating the left coordinate in pixels of the control
  61190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61191. */
  61192. leftInPixels: number;
  61193. /**
  61194. * Gets or sets a value indicating the top coordinate of the control
  61195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61196. */
  61197. top: string | number;
  61198. /**
  61199. * Gets or sets a value indicating the top coordinate in pixels of the control
  61200. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61201. */
  61202. topInPixels: number;
  61203. /**
  61204. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61205. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61206. */
  61207. linkOffsetX: string | number;
  61208. /**
  61209. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61210. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61211. */
  61212. linkOffsetXInPixels: number;
  61213. /**
  61214. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61215. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61216. */
  61217. linkOffsetY: string | number;
  61218. /**
  61219. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61220. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61221. */
  61222. linkOffsetYInPixels: number;
  61223. /** Gets the center coordinate on X axis */
  61224. readonly centerX: number;
  61225. /** Gets the center coordinate on Y axis */
  61226. readonly centerY: number;
  61227. /** Gets or sets if control is Enabled*/
  61228. isEnabled: boolean;
  61229. /** Gets or sets background color of control if it's disabled*/
  61230. disabledColor: string;
  61231. /**
  61232. * Creates a new control
  61233. * @param name defines the name of the control
  61234. */
  61235. constructor(
  61236. /** defines the name of the control */
  61237. name?: string | undefined);
  61238. /** @hidden */
  61239. protected _getTypeName(): string;
  61240. /**
  61241. * Gets the first ascendant in the hierarchy of the given type
  61242. * @param className defines the required type
  61243. * @returns the ascendant or null if not found
  61244. */
  61245. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61246. /** @hidden */ private _resetFontCache(): void;
  61247. /**
  61248. * Determines if a container is an ascendant of the current control
  61249. * @param container defines the container to look for
  61250. * @returns true if the container is one of the ascendant of the control
  61251. */
  61252. isAscendant(container: Control): boolean;
  61253. /**
  61254. * Gets coordinates in local control space
  61255. * @param globalCoordinates defines the coordinates to transform
  61256. * @returns the new coordinates in local space
  61257. */
  61258. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61259. /**
  61260. * Gets coordinates in local control space
  61261. * @param globalCoordinates defines the coordinates to transform
  61262. * @param result defines the target vector2 where to store the result
  61263. * @returns the current control
  61264. */
  61265. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61266. /**
  61267. * Gets coordinates in parent local control space
  61268. * @param globalCoordinates defines the coordinates to transform
  61269. * @returns the new coordinates in parent local space
  61270. */
  61271. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61272. /**
  61273. * Move the current control to a vector3 position projected onto the screen.
  61274. * @param position defines the target position
  61275. * @param scene defines the hosting scene
  61276. */
  61277. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61278. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61279. /**
  61280. * Will return all controls that have this control as ascendant
  61281. * @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
  61282. * @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
  61283. * @return all child controls
  61284. */
  61285. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61286. /**
  61287. * Link current control with a target mesh
  61288. * @param mesh defines the mesh to link with
  61289. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61290. */
  61291. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61292. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61293. /** @hidden */ private _offsetLeft(offset: number): void;
  61294. /** @hidden */ private _offsetTop(offset: number): void;
  61295. /** @hidden */ private _markMatrixAsDirty(): void;
  61296. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  61297. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  61298. /** @hidden */
  61299. protected invalidateRect(): void;
  61300. /** @hidden */ private _markAsDirty(force?: boolean): void;
  61301. /** @hidden */ private _markAllAsDirty(): void;
  61302. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  61303. /** @hidden */
  61304. protected _transform(context?: CanvasRenderingContext2D): void;
  61305. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  61306. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61307. /** @hidden */
  61308. protected _applyStates(context: CanvasRenderingContext2D): void;
  61309. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61310. /** @hidden */
  61311. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61312. protected _evaluateClippingState(parentMeasure: Measure): void;
  61313. /** @hidden */ private _measure(): void;
  61314. /** @hidden */
  61315. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61316. /** @hidden */
  61317. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61318. /** @hidden */
  61319. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61320. /** @hidden */
  61321. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61322. private static _ClipMeasure;
  61323. private _tmpMeasureA;
  61324. private _clip;
  61325. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  61326. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  61327. /**
  61328. * Tests if a given coordinates belong to the current control
  61329. * @param x defines x coordinate to test
  61330. * @param y defines y coordinate to test
  61331. * @returns true if the coordinates are inside the control
  61332. */
  61333. contains(x: number, y: number): boolean;
  61334. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61335. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61336. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  61337. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  61338. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61339. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61340. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61341. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  61342. private _prepareFont;
  61343. /** Releases associated resources */
  61344. dispose(): void;
  61345. private static _HORIZONTAL_ALIGNMENT_LEFT;
  61346. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  61347. private static _HORIZONTAL_ALIGNMENT_CENTER;
  61348. private static _VERTICAL_ALIGNMENT_TOP;
  61349. private static _VERTICAL_ALIGNMENT_BOTTOM;
  61350. private static _VERTICAL_ALIGNMENT_CENTER;
  61351. /** HORIZONTAL_ALIGNMENT_LEFT */
  61352. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  61353. /** HORIZONTAL_ALIGNMENT_RIGHT */
  61354. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  61355. /** HORIZONTAL_ALIGNMENT_CENTER */
  61356. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  61357. /** VERTICAL_ALIGNMENT_TOP */
  61358. static readonly VERTICAL_ALIGNMENT_TOP: number;
  61359. /** VERTICAL_ALIGNMENT_BOTTOM */
  61360. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  61361. /** VERTICAL_ALIGNMENT_CENTER */
  61362. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  61363. private static _FontHeightSizes;
  61364. /** @hidden */ private static _GetFontOffset(font: string): {
  61365. ascent: number;
  61366. height: number;
  61367. descent: number;
  61368. };
  61369. /**
  61370. * Creates a stack panel that can be used to render headers
  61371. * @param control defines the control to associate with the header
  61372. * @param text defines the text of the header
  61373. * @param size defines the size of the header
  61374. * @param options defines options used to configure the header
  61375. * @returns a new StackPanel
  61376. * @ignore
  61377. * @hidden
  61378. */
  61379. static AddHeader: (control: Control, text: string, size: string | number, options: {
  61380. isHorizontal: boolean;
  61381. controlFirst: boolean;
  61382. }) => any;
  61383. /** @hidden */
  61384. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  61385. }
  61386. }
  61387. declare module BABYLON.GUI {
  61388. /**
  61389. * Root class for 2D containers
  61390. * @see http://doc.babylonjs.com/how_to/gui#containers
  61391. */
  61392. export class Container extends Control {
  61393. name?: string | undefined;
  61394. /** @hidden */
  61395. protected _children: Control[];
  61396. /** @hidden */
  61397. protected _measureForChildren: Measure;
  61398. /** @hidden */
  61399. protected _background: string;
  61400. /** @hidden */
  61401. protected _adaptWidthToChildren: boolean;
  61402. /** @hidden */
  61403. protected _adaptHeightToChildren: boolean;
  61404. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  61405. adaptHeightToChildren: boolean;
  61406. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  61407. adaptWidthToChildren: boolean;
  61408. /** Gets or sets background color */
  61409. background: string;
  61410. /** Gets the list of children */
  61411. readonly children: Control[];
  61412. /**
  61413. * Creates a new Container
  61414. * @param name defines the name of the container
  61415. */
  61416. constructor(name?: string | undefined);
  61417. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  61418. /**
  61419. * Gets a child using its name
  61420. * @param name defines the child name to look for
  61421. * @returns the child control if found
  61422. */
  61423. getChildByName(name: string): BABYLON.Nullable<Control>;
  61424. /**
  61425. * Gets a child using its type and its name
  61426. * @param name defines the child name to look for
  61427. * @param type defines the child type to look for
  61428. * @returns the child control if found
  61429. */
  61430. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61431. /**
  61432. * Search for a specific control in children
  61433. * @param control defines the control to look for
  61434. * @returns true if the control is in child list
  61435. */
  61436. containsControl(control: Control): boolean;
  61437. /**
  61438. * Adds a new control to the current container
  61439. * @param control defines the control to add
  61440. * @returns the current container
  61441. */
  61442. addControl(control: BABYLON.Nullable<Control>): Container;
  61443. /**
  61444. * Removes all controls from the current container
  61445. * @returns the current container
  61446. */
  61447. clearControls(): Container;
  61448. /**
  61449. * Removes a control from the current container
  61450. * @param control defines the control to remove
  61451. * @returns the current container
  61452. */
  61453. removeControl(control: Control): Container;
  61454. /** @hidden */ private _reOrderControl(control: Control): void;
  61455. /** @hidden */ private _offsetLeft(offset: number): void;
  61456. /** @hidden */ private _offsetTop(offset: number): void;
  61457. /** @hidden */ private _markAllAsDirty(): void;
  61458. /** @hidden */
  61459. protected _localDraw(context: CanvasRenderingContext2D): void;
  61460. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  61461. /** @hidden */
  61462. protected _beforeLayout(): void;
  61463. /** @hidden */
  61464. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61465. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61466. protected _postMeasure(): void;
  61467. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61468. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61469. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61470. /** @hidden */
  61471. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61472. /** Releases associated resources */
  61473. dispose(): void;
  61474. }
  61475. }
  61476. declare module BABYLON.GUI {
  61477. /** Class used to create rectangle container */
  61478. export class Rectangle extends Container {
  61479. name?: string | undefined;
  61480. private _thickness;
  61481. private _cornerRadius;
  61482. /** Gets or sets border thickness */
  61483. thickness: number;
  61484. /** Gets or sets the corner radius angle */
  61485. cornerRadius: number;
  61486. /**
  61487. * Creates a new Rectangle
  61488. * @param name defines the control name
  61489. */
  61490. constructor(name?: string | undefined);
  61491. protected _getTypeName(): string;
  61492. protected _localDraw(context: CanvasRenderingContext2D): void;
  61493. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61494. private _drawRoundedRect;
  61495. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61496. }
  61497. }
  61498. declare module BABYLON.GUI {
  61499. /**
  61500. * Enum that determines the text-wrapping mode to use.
  61501. */
  61502. export enum TextWrapping {
  61503. /**
  61504. * Clip the text when it's larger than Control.width; this is the default mode.
  61505. */
  61506. Clip = 0,
  61507. /**
  61508. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61509. */
  61510. WordWrap = 1,
  61511. /**
  61512. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61513. */
  61514. Ellipsis = 2
  61515. }
  61516. /**
  61517. * Class used to create text block control
  61518. */
  61519. export class TextBlock extends Control {
  61520. /**
  61521. * Defines the name of the control
  61522. */
  61523. name?: string | undefined;
  61524. private _text;
  61525. private _textWrapping;
  61526. private _textHorizontalAlignment;
  61527. private _textVerticalAlignment;
  61528. private _lines;
  61529. private _resizeToFit;
  61530. private _lineSpacing;
  61531. private _outlineWidth;
  61532. private _outlineColor;
  61533. /**
  61534. * An event triggered after the text is changed
  61535. */
  61536. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61537. /**
  61538. * An event triggered after the text was broken up into lines
  61539. */
  61540. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61541. /**
  61542. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61543. */
  61544. readonly lines: any[];
  61545. /**
  61546. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61547. */
  61548. /**
  61549. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61550. */
  61551. resizeToFit: boolean;
  61552. /**
  61553. * Gets or sets a boolean indicating if text must be wrapped
  61554. */
  61555. /**
  61556. * Gets or sets a boolean indicating if text must be wrapped
  61557. */
  61558. textWrapping: TextWrapping | boolean;
  61559. /**
  61560. * Gets or sets text to display
  61561. */
  61562. /**
  61563. * Gets or sets text to display
  61564. */
  61565. text: string;
  61566. /**
  61567. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61568. */
  61569. /**
  61570. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61571. */
  61572. textHorizontalAlignment: number;
  61573. /**
  61574. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61575. */
  61576. /**
  61577. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61578. */
  61579. textVerticalAlignment: number;
  61580. /**
  61581. * Gets or sets line spacing value
  61582. */
  61583. /**
  61584. * Gets or sets line spacing value
  61585. */
  61586. lineSpacing: string | number;
  61587. /**
  61588. * Gets or sets outlineWidth of the text to display
  61589. */
  61590. /**
  61591. * Gets or sets outlineWidth of the text to display
  61592. */
  61593. outlineWidth: number;
  61594. /**
  61595. * Gets or sets outlineColor of the text to display
  61596. */
  61597. /**
  61598. * Gets or sets outlineColor of the text to display
  61599. */
  61600. outlineColor: string;
  61601. /**
  61602. * Creates a new TextBlock object
  61603. * @param name defines the name of the control
  61604. * @param text defines the text to display (emptry string by default)
  61605. */
  61606. constructor(
  61607. /**
  61608. * Defines the name of the control
  61609. */
  61610. name?: string | undefined, text?: string);
  61611. protected _getTypeName(): string;
  61612. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61613. private _drawText;
  61614. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  61615. protected _applyStates(context: CanvasRenderingContext2D): void;
  61616. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61617. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61618. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61619. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61620. protected _renderLines(context: CanvasRenderingContext2D): void;
  61621. /**
  61622. * Given a width constraint applied on the text block, find the expected height
  61623. * @returns expected height
  61624. */
  61625. computeExpectedHeight(): number;
  61626. dispose(): void;
  61627. }
  61628. }
  61629. declare module BABYLON.GUI {
  61630. /**
  61631. * Class used to create 2D images
  61632. */
  61633. export class Image extends Control {
  61634. name?: string | undefined;
  61635. private static _WorkingCanvas;
  61636. private _domImage;
  61637. private _imageWidth;
  61638. private _imageHeight;
  61639. private _loaded;
  61640. private _stretch;
  61641. private _source;
  61642. private _autoScale;
  61643. private _sourceLeft;
  61644. private _sourceTop;
  61645. private _sourceWidth;
  61646. private _sourceHeight;
  61647. private _cellWidth;
  61648. private _cellHeight;
  61649. private _cellId;
  61650. private _populateNinePatchSlicesFromImage;
  61651. private _sliceLeft;
  61652. private _sliceRight;
  61653. private _sliceTop;
  61654. private _sliceBottom;
  61655. private _detectPointerOnOpaqueOnly;
  61656. /**
  61657. * BABYLON.Observable notified when the content is loaded
  61658. */
  61659. onImageLoadedObservable: BABYLON.Observable<Image>;
  61660. /**
  61661. * Gets a boolean indicating that the content is loaded
  61662. */
  61663. readonly isLoaded: boolean;
  61664. /**
  61665. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61666. */
  61667. populateNinePatchSlicesFromImage: boolean;
  61668. /**
  61669. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61670. * Beware using this as this will comsume more memory as the image has to be stored twice
  61671. */
  61672. detectPointerOnOpaqueOnly: boolean;
  61673. /**
  61674. * Gets or sets the left value for slicing (9-patch)
  61675. */
  61676. sliceLeft: number;
  61677. /**
  61678. * Gets or sets the right value for slicing (9-patch)
  61679. */
  61680. sliceRight: number;
  61681. /**
  61682. * Gets or sets the top value for slicing (9-patch)
  61683. */
  61684. sliceTop: number;
  61685. /**
  61686. * Gets or sets the bottom value for slicing (9-patch)
  61687. */
  61688. sliceBottom: number;
  61689. /**
  61690. * Gets or sets the left coordinate in the source image
  61691. */
  61692. sourceLeft: number;
  61693. /**
  61694. * Gets or sets the top coordinate in the source image
  61695. */
  61696. sourceTop: number;
  61697. /**
  61698. * Gets or sets the width to capture in the source image
  61699. */
  61700. sourceWidth: number;
  61701. /**
  61702. * Gets or sets the height to capture in the source image
  61703. */
  61704. sourceHeight: number;
  61705. /**
  61706. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61707. * @see http://doc.babylonjs.com/how_to/gui#image
  61708. */
  61709. autoScale: boolean;
  61710. /** Gets or sets the streching mode used by the image */
  61711. stretch: number;
  61712. /**
  61713. * Gets or sets the internal DOM image used to render the control
  61714. */
  61715. domImage: HTMLImageElement;
  61716. private _onImageLoaded;
  61717. private _extractNinePatchSliceDataFromImage;
  61718. /**
  61719. * Gets or sets image source url
  61720. */
  61721. source: BABYLON.Nullable<string>;
  61722. /**
  61723. * Gets or sets the cell width to use when animation sheet is enabled
  61724. * @see http://doc.babylonjs.com/how_to/gui#image
  61725. */
  61726. cellWidth: number;
  61727. /**
  61728. * Gets or sets the cell height to use when animation sheet is enabled
  61729. * @see http://doc.babylonjs.com/how_to/gui#image
  61730. */
  61731. cellHeight: number;
  61732. /**
  61733. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61734. * @see http://doc.babylonjs.com/how_to/gui#image
  61735. */
  61736. cellId: number;
  61737. /**
  61738. * Creates a new Image
  61739. * @param name defines the control name
  61740. * @param url defines the image url
  61741. */
  61742. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61743. /**
  61744. * Tests if a given coordinates belong to the current control
  61745. * @param x defines x coordinate to test
  61746. * @param y defines y coordinate to test
  61747. * @returns true if the coordinates are inside the control
  61748. */
  61749. contains(x: number, y: number): boolean;
  61750. protected _getTypeName(): string;
  61751. /** Force the control to synchronize with its content */
  61752. synchronizeSizeWithContent(): void;
  61753. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61754. private _prepareWorkingCanvasForOpaqueDetection;
  61755. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  61756. private _renderCornerPatch;
  61757. private _renderNinePatch;
  61758. dispose(): void;
  61759. /** STRETCH_NONE */
  61760. static readonly STRETCH_NONE: number;
  61761. /** STRETCH_FILL */
  61762. static readonly STRETCH_FILL: number;
  61763. /** STRETCH_UNIFORM */
  61764. static readonly STRETCH_UNIFORM: number;
  61765. /** STRETCH_EXTEND */
  61766. static readonly STRETCH_EXTEND: number;
  61767. /** NINE_PATCH */
  61768. static readonly STRETCH_NINE_PATCH: number;
  61769. }
  61770. }
  61771. declare module BABYLON.GUI {
  61772. /**
  61773. * Class used to create 2D buttons
  61774. */
  61775. export class Button extends Rectangle {
  61776. name?: string | undefined;
  61777. /**
  61778. * Function called to generate a pointer enter animation
  61779. */
  61780. pointerEnterAnimation: () => void;
  61781. /**
  61782. * Function called to generate a pointer out animation
  61783. */
  61784. pointerOutAnimation: () => void;
  61785. /**
  61786. * Function called to generate a pointer down animation
  61787. */
  61788. pointerDownAnimation: () => void;
  61789. /**
  61790. * Function called to generate a pointer up animation
  61791. */
  61792. pointerUpAnimation: () => void;
  61793. /**
  61794. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  61795. */
  61796. delegatePickingToChildren: boolean;
  61797. private _image;
  61798. /**
  61799. * Returns the image part of the button (if any)
  61800. */
  61801. readonly image: BABYLON.Nullable<Image>;
  61802. private _textBlock;
  61803. /**
  61804. * Returns the image part of the button (if any)
  61805. */
  61806. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61807. /**
  61808. * Creates a new Button
  61809. * @param name defines the name of the button
  61810. */
  61811. constructor(name?: string | undefined);
  61812. protected _getTypeName(): string;
  61813. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61814. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  61815. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  61816. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61817. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61818. /**
  61819. * Creates a new button made with an image and a text
  61820. * @param name defines the name of the button
  61821. * @param text defines the text of the button
  61822. * @param imageUrl defines the url of the image
  61823. * @returns a new Button
  61824. */
  61825. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61826. /**
  61827. * Creates a new button made with an image
  61828. * @param name defines the name of the button
  61829. * @param imageUrl defines the url of the image
  61830. * @returns a new Button
  61831. */
  61832. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61833. /**
  61834. * Creates a new button made with a text
  61835. * @param name defines the name of the button
  61836. * @param text defines the text of the button
  61837. * @returns a new Button
  61838. */
  61839. static CreateSimpleButton(name: string, text: string): Button;
  61840. /**
  61841. * Creates a new button made with an image and a centered text
  61842. * @param name defines the name of the button
  61843. * @param text defines the text of the button
  61844. * @param imageUrl defines the url of the image
  61845. * @returns a new Button
  61846. */
  61847. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61848. }
  61849. }
  61850. declare module BABYLON.GUI {
  61851. /**
  61852. * Class used to create a 2D stack panel container
  61853. */
  61854. export class StackPanel extends Container {
  61855. name?: string | undefined;
  61856. private _isVertical;
  61857. private _manualWidth;
  61858. private _manualHeight;
  61859. private _doNotTrackManualChanges;
  61860. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61861. isVertical: boolean;
  61862. /**
  61863. * Gets or sets panel width.
  61864. * This value should not be set when in horizontal mode as it will be computed automatically
  61865. */
  61866. width: string | number;
  61867. /**
  61868. * Gets or sets panel height.
  61869. * This value should not be set when in vertical mode as it will be computed automatically
  61870. */
  61871. height: string | number;
  61872. /**
  61873. * Creates a new StackPanel
  61874. * @param name defines control name
  61875. */
  61876. constructor(name?: string | undefined);
  61877. protected _getTypeName(): string;
  61878. /** @hidden */
  61879. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61880. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61881. protected _postMeasure(): void;
  61882. }
  61883. }
  61884. declare module BABYLON.GUI {
  61885. /**
  61886. * Class used to represent a 2D checkbox
  61887. */
  61888. export class Checkbox extends Control {
  61889. name?: string | undefined;
  61890. private _isChecked;
  61891. private _background;
  61892. private _checkSizeRatio;
  61893. private _thickness;
  61894. /** Gets or sets border thickness */
  61895. thickness: number;
  61896. /**
  61897. * BABYLON.Observable raised when isChecked property changes
  61898. */
  61899. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61900. /** Gets or sets a value indicating the ratio between overall size and check size */
  61901. checkSizeRatio: number;
  61902. /** Gets or sets background color */
  61903. background: string;
  61904. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61905. isChecked: boolean;
  61906. /**
  61907. * Creates a new CheckBox
  61908. * @param name defines the control name
  61909. */
  61910. constructor(name?: string | undefined);
  61911. protected _getTypeName(): string;
  61912. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  61913. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61914. /**
  61915. * Utility function to easily create a checkbox with a header
  61916. * @param title defines the label to use for the header
  61917. * @param onValueChanged defines the callback to call when value changes
  61918. * @returns a StackPanel containing the checkbox and a textBlock
  61919. */
  61920. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61921. }
  61922. }
  61923. declare module BABYLON.GUI {
  61924. /**
  61925. * Class used to store key control properties
  61926. */
  61927. export class KeyPropertySet {
  61928. /** Width */
  61929. width?: string;
  61930. /** Height */
  61931. height?: string;
  61932. /** Left padding */
  61933. paddingLeft?: string;
  61934. /** Right padding */
  61935. paddingRight?: string;
  61936. /** Top padding */
  61937. paddingTop?: string;
  61938. /** Bottom padding */
  61939. paddingBottom?: string;
  61940. /** Foreground color */
  61941. color?: string;
  61942. /** Background color */
  61943. background?: string;
  61944. }
  61945. /**
  61946. * Class used to create virtual keyboard
  61947. */
  61948. export class VirtualKeyboard extends StackPanel {
  61949. /** BABYLON.Observable raised when a key is pressed */
  61950. onKeyPressObservable: BABYLON.Observable<string>;
  61951. /** Gets or sets default key button width */
  61952. defaultButtonWidth: string;
  61953. /** Gets or sets default key button height */
  61954. defaultButtonHeight: string;
  61955. /** Gets or sets default key button left padding */
  61956. defaultButtonPaddingLeft: string;
  61957. /** Gets or sets default key button right padding */
  61958. defaultButtonPaddingRight: string;
  61959. /** Gets or sets default key button top padding */
  61960. defaultButtonPaddingTop: string;
  61961. /** Gets or sets default key button bottom padding */
  61962. defaultButtonPaddingBottom: string;
  61963. /** Gets or sets default key button foreground color */
  61964. defaultButtonColor: string;
  61965. /** Gets or sets default key button background color */
  61966. defaultButtonBackground: string;
  61967. /** Gets or sets shift button foreground color */
  61968. shiftButtonColor: string;
  61969. /** Gets or sets shift button thickness*/
  61970. selectedShiftThickness: number;
  61971. /** Gets shift key state */
  61972. shiftState: number;
  61973. protected _getTypeName(): string;
  61974. private _createKey;
  61975. /**
  61976. * Adds a new row of keys
  61977. * @param keys defines the list of keys to add
  61978. * @param propertySets defines the associated property sets
  61979. */
  61980. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61981. /**
  61982. * Set the shift key to a specific state
  61983. * @param shiftState defines the new shift state
  61984. */
  61985. applyShiftState(shiftState: number): void;
  61986. private _currentlyConnectedInputText;
  61987. private _connectedInputTexts;
  61988. private _onKeyPressObserver;
  61989. /** Gets the input text control currently attached to the keyboard */
  61990. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61991. /**
  61992. * Connects the keyboard with an input text control
  61993. *
  61994. * @param input defines the target control
  61995. */
  61996. connect(input: InputText): void;
  61997. /**
  61998. * Disconnects the keyboard from connected InputText controls
  61999. *
  62000. * @param input optionally defines a target control, otherwise all are disconnected
  62001. */
  62002. disconnect(input?: InputText): void;
  62003. private _removeConnectedInputObservables;
  62004. /**
  62005. * Release all resources
  62006. */
  62007. dispose(): void;
  62008. /**
  62009. * Creates a new keyboard using a default layout
  62010. *
  62011. * @param name defines control name
  62012. * @returns a new VirtualKeyboard
  62013. */
  62014. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62015. }
  62016. }
  62017. declare module BABYLON.GUI {
  62018. /**
  62019. * Class used to create input text control
  62020. */
  62021. export class InputText extends Control implements IFocusableControl {
  62022. name?: string | undefined;
  62023. private _text;
  62024. private _placeholderText;
  62025. private _background;
  62026. private _focusedBackground;
  62027. private _focusedColor;
  62028. private _placeholderColor;
  62029. private _thickness;
  62030. private _margin;
  62031. private _autoStretchWidth;
  62032. private _maxWidth;
  62033. private _isFocused;
  62034. private _blinkTimeout;
  62035. private _blinkIsEven;
  62036. private _cursorOffset;
  62037. private _scrollLeft;
  62038. private _textWidth;
  62039. private _clickedCoordinate;
  62040. private _deadKey;
  62041. private _addKey;
  62042. private _currentKey;
  62043. private _isTextHighlightOn;
  62044. private _textHighlightColor;
  62045. private _highligherOpacity;
  62046. private _highlightedText;
  62047. private _startHighlightIndex;
  62048. private _endHighlightIndex;
  62049. private _cursorIndex;
  62050. private _onFocusSelectAll;
  62051. private _isPointerDown;
  62052. private _onClipboardObserver;
  62053. private _onPointerDblTapObserver;
  62054. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62055. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62056. promptMessage: string;
  62057. /** Force disable prompt on mobile device */
  62058. disableMobilePrompt: boolean;
  62059. /** BABYLON.Observable raised when the text changes */
  62060. onTextChangedObservable: BABYLON.Observable<InputText>;
  62061. /** BABYLON.Observable raised just before an entered character is to be added */
  62062. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62063. /** BABYLON.Observable raised when the control gets the focus */
  62064. onFocusObservable: BABYLON.Observable<InputText>;
  62065. /** BABYLON.Observable raised when the control loses the focus */
  62066. onBlurObservable: BABYLON.Observable<InputText>;
  62067. /**Observable raised when the text is highlighted */
  62068. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62069. /**Observable raised when copy event is triggered */
  62070. onTextCopyObservable: BABYLON.Observable<InputText>;
  62071. /** BABYLON.Observable raised when cut event is triggered */
  62072. onTextCutObservable: BABYLON.Observable<InputText>;
  62073. /** BABYLON.Observable raised when paste event is triggered */
  62074. onTextPasteObservable: BABYLON.Observable<InputText>;
  62075. /** BABYLON.Observable raised when a key event was processed */
  62076. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62077. /** Gets or sets the maximum width allowed by the control */
  62078. maxWidth: string | number;
  62079. /** Gets the maximum width allowed by the control in pixels */
  62080. readonly maxWidthInPixels: number;
  62081. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62082. highligherOpacity: number;
  62083. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62084. onFocusSelectAll: boolean;
  62085. /** Gets or sets the text hightlight color */
  62086. textHighlightColor: string;
  62087. /** Gets or sets control margin */
  62088. margin: string;
  62089. /** Gets control margin in pixels */
  62090. readonly marginInPixels: number;
  62091. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62092. autoStretchWidth: boolean;
  62093. /** Gets or sets border thickness */
  62094. thickness: number;
  62095. /** Gets or sets the background color when focused */
  62096. focusedBackground: string;
  62097. /** Gets or sets the background color when focused */
  62098. focusedColor: string;
  62099. /** Gets or sets the background color */
  62100. background: string;
  62101. /** Gets or sets the placeholder color */
  62102. placeholderColor: string;
  62103. /** Gets or sets the text displayed when the control is empty */
  62104. placeholderText: string;
  62105. /** Gets or sets the dead key flag */
  62106. deadKey: boolean;
  62107. /** Gets or sets the highlight text */
  62108. highlightedText: string;
  62109. /** Gets or sets if the current key should be added */
  62110. addKey: boolean;
  62111. /** Gets or sets the value of the current key being entered */
  62112. currentKey: string;
  62113. /** Gets or sets the text displayed in the control */
  62114. text: string;
  62115. /** Gets or sets control width */
  62116. width: string | number;
  62117. /**
  62118. * Creates a new InputText
  62119. * @param name defines the control name
  62120. * @param text defines the text of the control
  62121. */
  62122. constructor(name?: string | undefined, text?: string);
  62123. /** @hidden */
  62124. onBlur(): void;
  62125. /** @hidden */
  62126. onFocus(): void;
  62127. protected _getTypeName(): string;
  62128. /**
  62129. * Function called to get the list of controls that should not steal the focus from this control
  62130. * @returns an array of controls
  62131. */
  62132. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62133. /** @hidden */
  62134. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62135. /** @hidden */
  62136. private _updateValueFromCursorIndex;
  62137. /** @hidden */
  62138. private _processDblClick;
  62139. /** @hidden */
  62140. private _selectAllText;
  62141. /**
  62142. * Handles the keyboard event
  62143. * @param evt Defines the KeyboardEvent
  62144. */
  62145. processKeyboard(evt: KeyboardEvent): void;
  62146. /** @hidden */
  62147. private _onCopyText;
  62148. /** @hidden */
  62149. private _onCutText;
  62150. /** @hidden */
  62151. 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;
  62152. protected _beforeRenderText(text: string): string;
  62153. dispose(): void;
  62154. }
  62155. }
  62156. declare module BABYLON.GUI {
  62157. /**
  62158. * Class used to create a 2D grid container
  62159. */
  62160. export class Grid extends Container {
  62161. name?: string | undefined;
  62162. private _rowDefinitions;
  62163. private _columnDefinitions;
  62164. private _cells;
  62165. private _childControls;
  62166. /**
  62167. * Gets the number of columns
  62168. */
  62169. readonly columnCount: number;
  62170. /**
  62171. * Gets the number of rows
  62172. */
  62173. readonly rowCount: number;
  62174. /** Gets the list of children */
  62175. readonly children: Control[];
  62176. /** Gets the list of cells (e.g. the containers) */
  62177. readonly cells: {
  62178. [key: string]: Container;
  62179. };
  62180. /**
  62181. * Gets the definition of a specific row
  62182. * @param index defines the index of the row
  62183. * @returns the row definition
  62184. */
  62185. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62186. /**
  62187. * Gets the definition of a specific column
  62188. * @param index defines the index of the column
  62189. * @returns the column definition
  62190. */
  62191. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62192. /**
  62193. * Adds a new row to the grid
  62194. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62195. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62196. * @returns the current grid
  62197. */
  62198. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62199. /**
  62200. * Adds a new column to the grid
  62201. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62202. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62203. * @returns the current grid
  62204. */
  62205. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62206. /**
  62207. * Update a row definition
  62208. * @param index defines the index of the row to update
  62209. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62210. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62211. * @returns the current grid
  62212. */
  62213. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62214. /**
  62215. * Update a column definition
  62216. * @param index defines the index of the column to update
  62217. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62218. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62219. * @returns the current grid
  62220. */
  62221. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62222. /**
  62223. * Gets the list of children stored in a specific cell
  62224. * @param row defines the row to check
  62225. * @param column defines the column to check
  62226. * @returns the list of controls
  62227. */
  62228. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62229. /**
  62230. * Gets a string representing the child cell info (row x column)
  62231. * @param child defines the control to get info from
  62232. * @returns a string containing the child cell info (row x column)
  62233. */
  62234. getChildCellInfo(child: Control): string;
  62235. private _removeCell;
  62236. private _offsetCell;
  62237. /**
  62238. * Remove a column definition at specified index
  62239. * @param index defines the index of the column to remove
  62240. * @returns the current grid
  62241. */
  62242. removeColumnDefinition(index: number): Grid;
  62243. /**
  62244. * Remove a row definition at specified index
  62245. * @param index defines the index of the row to remove
  62246. * @returns the current grid
  62247. */
  62248. removeRowDefinition(index: number): Grid;
  62249. /**
  62250. * Adds a new control to the current grid
  62251. * @param control defines the control to add
  62252. * @param row defines the row where to add the control (0 by default)
  62253. * @param column defines the column where to add the control (0 by default)
  62254. * @returns the current grid
  62255. */
  62256. addControl(control: Control, row?: number, column?: number): Grid;
  62257. /**
  62258. * Removes a control from the current container
  62259. * @param control defines the control to remove
  62260. * @returns the current container
  62261. */
  62262. removeControl(control: Control): Container;
  62263. /**
  62264. * Creates a new Grid
  62265. * @param name defines control name
  62266. */
  62267. constructor(name?: string | undefined);
  62268. protected _getTypeName(): string;
  62269. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62270. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62271. /** Releases associated resources */
  62272. dispose(): void;
  62273. }
  62274. }
  62275. declare module BABYLON.GUI {
  62276. /** Class used to create color pickers */
  62277. export class ColorPicker extends Control {
  62278. name?: string | undefined;
  62279. private static _Epsilon;
  62280. private _colorWheelCanvas;
  62281. private _value;
  62282. private _tmpColor;
  62283. private _pointerStartedOnSquare;
  62284. private _pointerStartedOnWheel;
  62285. private _squareLeft;
  62286. private _squareTop;
  62287. private _squareSize;
  62288. private _h;
  62289. private _s;
  62290. private _v;
  62291. private _lastPointerDownID;
  62292. /**
  62293. * BABYLON.Observable raised when the value changes
  62294. */
  62295. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62296. /** Gets or sets the color of the color picker */
  62297. value: BABYLON.Color3;
  62298. /**
  62299. * Gets or sets control width
  62300. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62301. */
  62302. width: string | number;
  62303. /**
  62304. * Gets or sets control height
  62305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62306. */
  62307. /** Gets or sets control height */
  62308. height: string | number;
  62309. /** Gets or sets control size */
  62310. size: string | number;
  62311. /**
  62312. * Creates a new ColorPicker
  62313. * @param name defines the control name
  62314. */
  62315. constructor(name?: string | undefined);
  62316. protected _getTypeName(): string;
  62317. /** @hidden */
  62318. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62319. private _updateSquareProps;
  62320. private _drawGradientSquare;
  62321. private _drawCircle;
  62322. private _createColorWheelCanvas;
  62323. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  62324. private _pointerIsDown;
  62325. private _updateValueFromPointer;
  62326. private _isPointOnSquare;
  62327. 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;
  62328. /**
  62329. * This function expands the color picker by creating a color picker dialog with manual
  62330. * color value input and the ability to save colors into an array to be used later in
  62331. * subsequent launches of the dialogue.
  62332. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  62333. * @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.
  62334. * @returns picked color as a hex string and the saved colors array as hex strings.
  62335. */
  62336. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  62337. pickerWidth?: string;
  62338. pickerHeight?: string;
  62339. headerHeight?: string;
  62340. lastColor?: string;
  62341. swatchLimit?: number;
  62342. numSwatchesPerLine?: number;
  62343. savedColors?: Array<string>;
  62344. }): Promise<{
  62345. savedColors?: string[];
  62346. pickedColor: string;
  62347. }>;
  62348. }
  62349. }
  62350. declare module BABYLON.GUI {
  62351. /** Class used to create 2D ellipse containers */
  62352. export class Ellipse extends Container {
  62353. name?: string | undefined;
  62354. private _thickness;
  62355. /** Gets or sets border thickness */
  62356. thickness: number;
  62357. /**
  62358. * Creates a new Ellipse
  62359. * @param name defines the control name
  62360. */
  62361. constructor(name?: string | undefined);
  62362. protected _getTypeName(): string;
  62363. protected _localDraw(context: CanvasRenderingContext2D): void;
  62364. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62365. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62366. }
  62367. }
  62368. declare module BABYLON.GUI {
  62369. /**
  62370. * Class used to create a password control
  62371. */
  62372. export class InputPassword extends InputText {
  62373. protected _beforeRenderText(text: string): string;
  62374. }
  62375. }
  62376. declare module BABYLON.GUI {
  62377. /** Class used to render 2D lines */
  62378. export class Line extends Control {
  62379. name?: string | undefined;
  62380. private _lineWidth;
  62381. private _x1;
  62382. private _y1;
  62383. private _x2;
  62384. private _y2;
  62385. private _dash;
  62386. private _connectedControl;
  62387. private _connectedControlDirtyObserver;
  62388. /** Gets or sets the dash pattern */
  62389. dash: Array<number>;
  62390. /** Gets or sets the control connected with the line end */
  62391. connectedControl: Control;
  62392. /** Gets or sets start coordinates on X axis */
  62393. x1: string | number;
  62394. /** Gets or sets start coordinates on Y axis */
  62395. y1: string | number;
  62396. /** Gets or sets end coordinates on X axis */
  62397. x2: string | number;
  62398. /** Gets or sets end coordinates on Y axis */
  62399. y2: string | number;
  62400. /** Gets or sets line width */
  62401. lineWidth: number;
  62402. /** Gets or sets horizontal alignment */
  62403. horizontalAlignment: number;
  62404. /** Gets or sets vertical alignment */
  62405. verticalAlignment: number;
  62406. private readonly _effectiveX2;
  62407. private readonly _effectiveY2;
  62408. /**
  62409. * Creates a new Line
  62410. * @param name defines the control name
  62411. */
  62412. constructor(name?: string | undefined);
  62413. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  62414. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62415. /**
  62416. * Move one end of the line given 3D cartesian coordinates.
  62417. * @param position Targeted world position
  62418. * @param scene BABYLON.Scene
  62419. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62420. */
  62421. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62422. /**
  62423. * Move one end of the line to a position in screen absolute space.
  62424. * @param projectedPosition Position in screen absolute space (X, Y)
  62425. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62426. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62427. }
  62428. }
  62429. declare module BABYLON.GUI {
  62430. /**
  62431. * Class used to store a point for a MultiLine object.
  62432. * The point can be pure 2D coordinates, a mesh or a control
  62433. */
  62434. export class MultiLinePoint {
  62435. private _multiLine;
  62436. private _x;
  62437. private _y;
  62438. private _control;
  62439. private _mesh;
  62440. private _controlObserver;
  62441. private _meshObserver;
  62442. /** @hidden */ private _point: BABYLON.Vector2;
  62443. /**
  62444. * Creates a new MultiLinePoint
  62445. * @param multiLine defines the source MultiLine object
  62446. */
  62447. constructor(multiLine: MultiLine);
  62448. /** Gets or sets x coordinate */
  62449. x: string | number;
  62450. /** Gets or sets y coordinate */
  62451. y: string | number;
  62452. /** Gets or sets the control associated with this point */
  62453. control: BABYLON.Nullable<Control>;
  62454. /** Gets or sets the mesh associated with this point */
  62455. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62456. /** Resets links */
  62457. resetLinks(): void;
  62458. /**
  62459. * Gets a translation vector
  62460. * @returns the translation vector
  62461. */
  62462. translate(): BABYLON.Vector2;
  62463. private _translatePoint;
  62464. /** Release associated resources */
  62465. dispose(): void;
  62466. }
  62467. }
  62468. declare module BABYLON.GUI {
  62469. /**
  62470. * Class used to create multi line control
  62471. */
  62472. export class MultiLine extends Control {
  62473. name?: string | undefined;
  62474. private _lineWidth;
  62475. private _dash;
  62476. private _points;
  62477. private _minX;
  62478. private _minY;
  62479. private _maxX;
  62480. private _maxY;
  62481. /**
  62482. * Creates a new MultiLine
  62483. * @param name defines the control name
  62484. */
  62485. constructor(name?: string | undefined);
  62486. /** Gets or sets dash pattern */
  62487. dash: Array<number>;
  62488. /**
  62489. * Gets point stored at specified index
  62490. * @param index defines the index to look for
  62491. * @returns the requested point if found
  62492. */
  62493. getAt(index: number): MultiLinePoint;
  62494. /** Function called when a point is updated */
  62495. onPointUpdate: () => void;
  62496. /**
  62497. * Adds new points to the point collection
  62498. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62499. * @returns the list of created MultiLinePoint
  62500. */
  62501. add(...items: (AbstractMesh | Control | {
  62502. x: string | number;
  62503. y: string | number;
  62504. })[]): MultiLinePoint[];
  62505. /**
  62506. * Adds a new point to the point collection
  62507. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62508. * @returns the created MultiLinePoint
  62509. */
  62510. push(item?: (AbstractMesh | Control | {
  62511. x: string | number;
  62512. y: string | number;
  62513. })): MultiLinePoint;
  62514. /**
  62515. * Remove a specific value or point from the active point collection
  62516. * @param value defines the value or point to remove
  62517. */
  62518. remove(value: number | MultiLinePoint): void;
  62519. /**
  62520. * Resets this object to initial state (no point)
  62521. */
  62522. reset(): void;
  62523. /**
  62524. * Resets all links
  62525. */
  62526. resetLinks(): void;
  62527. /** Gets or sets line width */
  62528. lineWidth: number;
  62529. horizontalAlignment: number;
  62530. verticalAlignment: number;
  62531. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  62532. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  62533. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62534. dispose(): void;
  62535. }
  62536. }
  62537. declare module BABYLON.GUI {
  62538. /**
  62539. * Class used to create radio button controls
  62540. */
  62541. export class RadioButton extends Control {
  62542. name?: string | undefined;
  62543. private _isChecked;
  62544. private _background;
  62545. private _checkSizeRatio;
  62546. private _thickness;
  62547. /** Gets or sets border thickness */
  62548. thickness: number;
  62549. /** Gets or sets group name */
  62550. group: string;
  62551. /** BABYLON.Observable raised when isChecked is changed */
  62552. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62553. /** Gets or sets a value indicating the ratio between overall size and check size */
  62554. checkSizeRatio: number;
  62555. /** Gets or sets background color */
  62556. background: string;
  62557. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62558. isChecked: boolean;
  62559. /**
  62560. * Creates a new RadioButton
  62561. * @param name defines the control name
  62562. */
  62563. constructor(name?: string | undefined);
  62564. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62565. /**
  62566. * Utility function to easily create a radio button with a header
  62567. * @param title defines the label to use for the header
  62568. * @param group defines the group to use for the radio button
  62569. * @param isChecked defines the initial state of the radio button
  62570. * @param onValueChanged defines the callback to call when value changes
  62571. * @returns a StackPanel containing the radio button and a textBlock
  62572. */
  62573. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62574. }
  62575. }
  62576. declare module BABYLON.GUI {
  62577. /**
  62578. * Class used to create slider controls
  62579. */
  62580. export class BaseSlider extends Control {
  62581. name?: string | undefined;
  62582. protected _thumbWidth: ValueAndUnit;
  62583. private _minimum;
  62584. private _maximum;
  62585. private _value;
  62586. private _isVertical;
  62587. protected _barOffset: ValueAndUnit;
  62588. private _isThumbClamped;
  62589. protected _displayThumb: boolean;
  62590. private _step;
  62591. private _lastPointerDownID;
  62592. protected _effectiveBarOffset: number;
  62593. protected _renderLeft: number;
  62594. protected _renderTop: number;
  62595. protected _renderWidth: number;
  62596. protected _renderHeight: number;
  62597. protected _backgroundBoxLength: number;
  62598. protected _backgroundBoxThickness: number;
  62599. protected _effectiveThumbThickness: number;
  62600. /** BABYLON.Observable raised when the sldier value changes */
  62601. onValueChangedObservable: BABYLON.Observable<number>;
  62602. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62603. displayThumb: boolean;
  62604. /** Gets or sets a step to apply to values (0 by default) */
  62605. step: number;
  62606. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62607. barOffset: string | number;
  62608. /** Gets main bar offset in pixels*/
  62609. readonly barOffsetInPixels: number;
  62610. /** Gets or sets thumb width */
  62611. thumbWidth: string | number;
  62612. /** Gets thumb width in pixels */
  62613. readonly thumbWidthInPixels: number;
  62614. /** Gets or sets minimum value */
  62615. minimum: number;
  62616. /** Gets or sets maximum value */
  62617. maximum: number;
  62618. /** Gets or sets current value */
  62619. value: number;
  62620. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62621. isVertical: boolean;
  62622. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62623. isThumbClamped: boolean;
  62624. /**
  62625. * Creates a new BaseSlider
  62626. * @param name defines the control name
  62627. */
  62628. constructor(name?: string | undefined);
  62629. protected _getTypeName(): string;
  62630. protected _getThumbPosition(): number;
  62631. protected _getThumbThickness(type: string): number;
  62632. protected _prepareRenderingData(type: string): void;
  62633. private _pointerIsDown;
  62634. /** @hidden */
  62635. 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;
  62636. }
  62637. }
  62638. declare module BABYLON.GUI {
  62639. /**
  62640. * Class used to create slider controls
  62641. */
  62642. export class Slider extends BaseSlider {
  62643. name?: string | undefined;
  62644. private _background;
  62645. private _borderColor;
  62646. private _isThumbCircle;
  62647. protected _displayValueBar: boolean;
  62648. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62649. displayValueBar: boolean;
  62650. /** Gets or sets border color */
  62651. borderColor: string;
  62652. /** Gets or sets background color */
  62653. background: string;
  62654. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62655. isThumbCircle: boolean;
  62656. /**
  62657. * Creates a new Slider
  62658. * @param name defines the control name
  62659. */
  62660. constructor(name?: string | undefined);
  62661. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  62662. }
  62663. }
  62664. declare module BABYLON.GUI {
  62665. /** Class used to create a RadioGroup
  62666. * which contains groups of radio buttons
  62667. */
  62668. export class SelectorGroup {
  62669. /** name of SelectorGroup */
  62670. name: string;
  62671. private _groupPanel;
  62672. private _selectors;
  62673. private _groupHeader;
  62674. /**
  62675. * Creates a new SelectorGroup
  62676. * @param name of group, used as a group heading
  62677. */
  62678. constructor(
  62679. /** name of SelectorGroup */
  62680. name: string);
  62681. /** Gets the groupPanel of the SelectorGroup */
  62682. readonly groupPanel: StackPanel;
  62683. /** Gets the selectors array */
  62684. readonly selectors: StackPanel[];
  62685. /** Gets and sets the group header */
  62686. header: string;
  62687. /** @hidden */
  62688. private _addGroupHeader;
  62689. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  62690. /** Removes the selector at the given position
  62691. * @param selectorNb the position of the selector within the group
  62692. */
  62693. removeSelector(selectorNb: number): void;
  62694. }
  62695. /** Class used to create a CheckboxGroup
  62696. * which contains groups of checkbox buttons
  62697. */
  62698. export class CheckboxGroup extends SelectorGroup {
  62699. /** Adds a checkbox as a control
  62700. * @param text is the label for the selector
  62701. * @param func is the function called when the Selector is checked
  62702. * @param checked is true when Selector is checked
  62703. */
  62704. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62705. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  62706. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  62707. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  62708. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62709. }
  62710. /** Class used to create a RadioGroup
  62711. * which contains groups of radio buttons
  62712. */
  62713. export class RadioGroup extends SelectorGroup {
  62714. private _selectNb;
  62715. /** Adds a radio button as a control
  62716. * @param label is the label for the selector
  62717. * @param func is the function called when the Selector is checked
  62718. * @param checked is true when Selector is checked
  62719. */
  62720. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62721. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  62722. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  62723. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  62724. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62725. }
  62726. /** Class used to create a SliderGroup
  62727. * which contains groups of slider buttons
  62728. */
  62729. export class SliderGroup extends SelectorGroup {
  62730. /**
  62731. * Adds a slider to the SelectorGroup
  62732. * @param label is the label for the SliderBar
  62733. * @param func is the function called when the Slider moves
  62734. * @param unit is a string describing the units used, eg degrees or metres
  62735. * @param min is the minimum value for the Slider
  62736. * @param max is the maximum value for the Slider
  62737. * @param value is the start value for the Slider between min and max
  62738. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62739. */
  62740. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62741. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  62742. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  62743. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  62744. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62745. }
  62746. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62747. * @see http://doc.babylonjs.com/how_to/selector
  62748. */
  62749. export class SelectionPanel extends Rectangle {
  62750. /** name of SelectionPanel */
  62751. name: string;
  62752. /** an array of SelectionGroups */
  62753. groups: SelectorGroup[];
  62754. private _panel;
  62755. private _buttonColor;
  62756. private _buttonBackground;
  62757. private _headerColor;
  62758. private _barColor;
  62759. private _barHeight;
  62760. private _spacerHeight;
  62761. private _labelColor;
  62762. private _groups;
  62763. private _bars;
  62764. /**
  62765. * Creates a new SelectionPanel
  62766. * @param name of SelectionPanel
  62767. * @param groups is an array of SelectionGroups
  62768. */
  62769. constructor(
  62770. /** name of SelectionPanel */
  62771. name: string,
  62772. /** an array of SelectionGroups */
  62773. groups?: SelectorGroup[]);
  62774. protected _getTypeName(): string;
  62775. /** Gets or sets the headerColor */
  62776. headerColor: string;
  62777. private _setHeaderColor;
  62778. /** Gets or sets the button color */
  62779. buttonColor: string;
  62780. private _setbuttonColor;
  62781. /** Gets or sets the label color */
  62782. labelColor: string;
  62783. private _setLabelColor;
  62784. /** Gets or sets the button background */
  62785. buttonBackground: string;
  62786. private _setButtonBackground;
  62787. /** Gets or sets the color of separator bar */
  62788. barColor: string;
  62789. private _setBarColor;
  62790. /** Gets or sets the height of separator bar */
  62791. barHeight: string;
  62792. private _setBarHeight;
  62793. /** Gets or sets the height of spacers*/
  62794. spacerHeight: string;
  62795. private _setSpacerHeight;
  62796. /** Adds a bar between groups */
  62797. private _addSpacer;
  62798. /** Add a group to the selection panel
  62799. * @param group is the selector group to add
  62800. */
  62801. addGroup(group: SelectorGroup): void;
  62802. /** Remove the group from the given position
  62803. * @param groupNb is the position of the group in the list
  62804. */
  62805. removeGroup(groupNb: number): void;
  62806. /** Change a group header label
  62807. * @param label is the new group header label
  62808. * @param groupNb is the number of the group to relabel
  62809. * */
  62810. setHeaderName(label: string, groupNb: number): void;
  62811. /** Change selector label to the one given
  62812. * @param label is the new selector label
  62813. * @param groupNb is the number of the groupcontaining the selector
  62814. * @param selectorNb is the number of the selector within a group to relabel
  62815. * */
  62816. relabel(label: string, groupNb: number, selectorNb: number): void;
  62817. /** For a given group position remove the selector at the given position
  62818. * @param groupNb is the number of the group to remove the selector from
  62819. * @param selectorNb is the number of the selector within the group
  62820. */
  62821. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62822. /** For a given group position of correct type add a checkbox button
  62823. * @param groupNb is the number of the group to remove the selector from
  62824. * @param label is the label for the selector
  62825. * @param func is the function called when the Selector is checked
  62826. * @param checked is true when Selector is checked
  62827. */
  62828. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62829. /** For a given group position of correct type add a radio button
  62830. * @param groupNb is the number of the group to remove the selector from
  62831. * @param label is the label for the selector
  62832. * @param func is the function called when the Selector is checked
  62833. * @param checked is true when Selector is checked
  62834. */
  62835. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62836. /**
  62837. * For a given slider group add a slider
  62838. * @param groupNb is the number of the group to add the slider to
  62839. * @param label is the label for the Slider
  62840. * @param func is the function called when the Slider moves
  62841. * @param unit is a string describing the units used, eg degrees or metres
  62842. * @param min is the minimum value for the Slider
  62843. * @param max is the maximum value for the Slider
  62844. * @param value is the start value for the Slider between min and max
  62845. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62846. */
  62847. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62848. }
  62849. }
  62850. declare module BABYLON.GUI {
  62851. /**
  62852. * Class used to hold a the container for ScrollViewer
  62853. * @hidden
  62854. */
  62855. export class _ScrollViewerWindow extends Container {
  62856. parentClientWidth: number;
  62857. parentClientHeight: number;
  62858. /**
  62859. * Creates a new ScrollViewerWindow
  62860. * @param name of ScrollViewerWindow
  62861. */
  62862. constructor(name?: string);
  62863. protected _getTypeName(): string;
  62864. /** @hidden */
  62865. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62866. protected _postMeasure(): void;
  62867. }
  62868. }
  62869. declare module BABYLON.GUI {
  62870. /**
  62871. * Class used to create slider controls
  62872. */
  62873. export class ScrollBar extends BaseSlider {
  62874. name?: string | undefined;
  62875. private _background;
  62876. private _borderColor;
  62877. private _thumbMeasure;
  62878. /** Gets or sets border color */
  62879. borderColor: string;
  62880. /** Gets or sets background color */
  62881. background: string;
  62882. /**
  62883. * Creates a new Slider
  62884. * @param name defines the control name
  62885. */
  62886. constructor(name?: string | undefined);
  62887. protected _getTypeName(): string;
  62888. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  62889. private _first;
  62890. private _originX;
  62891. private _originY;
  62892. /** @hidden */
  62893. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62894. }
  62895. }
  62896. declare module BABYLON.GUI {
  62897. /**
  62898. * Class used to hold a viewer window and sliders in a grid
  62899. */
  62900. export class ScrollViewer extends Rectangle {
  62901. private _grid;
  62902. private _horizontalBarSpace;
  62903. private _verticalBarSpace;
  62904. private _dragSpace;
  62905. private _horizontalBar;
  62906. private _verticalBar;
  62907. private _barColor;
  62908. private _barBackground;
  62909. private _barSize;
  62910. private _endLeft;
  62911. private _endTop;
  62912. private _window;
  62913. private _pointerIsOver;
  62914. private _wheelPrecision;
  62915. private _onPointerObserver;
  62916. private _clientWidth;
  62917. private _clientHeight;
  62918. /**
  62919. * Gets the horizontal scrollbar
  62920. */
  62921. readonly horizontalBar: ScrollBar;
  62922. /**
  62923. * Gets the vertical scrollbar
  62924. */
  62925. readonly verticalBar: ScrollBar;
  62926. /**
  62927. * Adds a new control to the current container
  62928. * @param control defines the control to add
  62929. * @returns the current container
  62930. */
  62931. addControl(control: BABYLON.Nullable<Control>): Container;
  62932. /**
  62933. * Removes a control from the current container
  62934. * @param control defines the control to remove
  62935. * @returns the current container
  62936. */
  62937. removeControl(control: Control): Container;
  62938. /** Gets the list of children */
  62939. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  62940. /**
  62941. * Creates a new ScrollViewer
  62942. * @param name of ScrollViewer
  62943. */
  62944. constructor(name?: string);
  62945. /** Reset the scroll viewer window to initial size */
  62946. resetWindow(): void;
  62947. protected _getTypeName(): string;
  62948. private _buildClientSizes;
  62949. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62950. protected _postMeasure(): void;
  62951. /**
  62952. * Gets or sets the mouse wheel precision
  62953. * from 0 to 1 with a default value of 0.05
  62954. * */
  62955. wheelPrecision: number;
  62956. /** Gets or sets the bar color */
  62957. barColor: string;
  62958. /** Gets or sets the size of the bar */
  62959. barSize: number;
  62960. /** Gets or sets the bar background */
  62961. barBackground: string;
  62962. /** @hidden */
  62963. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  62964. /** @hidden */
  62965. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62966. /** Releases associated resources */
  62967. dispose(): void;
  62968. }
  62969. }
  62970. declare module BABYLON.GUI {
  62971. /** Class used to render a grid */
  62972. export class DisplayGrid extends Control {
  62973. name?: string | undefined;
  62974. private _cellWidth;
  62975. private _cellHeight;
  62976. private _minorLineTickness;
  62977. private _minorLineColor;
  62978. private _majorLineTickness;
  62979. private _majorLineColor;
  62980. private _majorLineFrequency;
  62981. private _background;
  62982. private _displayMajorLines;
  62983. private _displayMinorLines;
  62984. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62985. displayMinorLines: boolean;
  62986. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62987. displayMajorLines: boolean;
  62988. /** Gets or sets background color (Black by default) */
  62989. background: string;
  62990. /** Gets or sets the width of each cell (20 by default) */
  62991. cellWidth: number;
  62992. /** Gets or sets the height of each cell (20 by default) */
  62993. cellHeight: number;
  62994. /** Gets or sets the tickness of minor lines (1 by default) */
  62995. minorLineTickness: number;
  62996. /** Gets or sets the color of minor lines (DarkGray by default) */
  62997. minorLineColor: string;
  62998. /** Gets or sets the tickness of major lines (2 by default) */
  62999. majorLineTickness: number;
  63000. /** Gets or sets the color of major lines (White by default) */
  63001. majorLineColor: string;
  63002. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63003. majorLineFrequency: number;
  63004. /**
  63005. * Creates a new GridDisplayRectangle
  63006. * @param name defines the control name
  63007. */
  63008. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  63009. protected _getTypeName(): string;
  63010. }
  63011. }
  63012. declare module BABYLON.GUI {
  63013. /**
  63014. * Class used to create slider controls based on images
  63015. */
  63016. export class ImageBasedSlider extends BaseSlider {
  63017. name?: string | undefined;
  63018. private _backgroundImage;
  63019. private _thumbImage;
  63020. private _valueBarImage;
  63021. private _tempMeasure;
  63022. displayThumb: boolean;
  63023. /**
  63024. * Gets or sets the image used to render the background
  63025. */
  63026. backgroundImage: Image;
  63027. /**
  63028. * Gets or sets the image used to render the value bar
  63029. */
  63030. valueBarImage: Image;
  63031. /**
  63032. * Gets or sets the image used to render the thumb
  63033. */
  63034. thumbImage: Image;
  63035. /**
  63036. * Creates a new ImageBasedSlider
  63037. * @param name defines the control name
  63038. */
  63039. constructor(name?: string | undefined);
  63040. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63041. }
  63042. }
  63043. declare module BABYLON.GUI {
  63044. /**
  63045. * Forcing an export so that this code will execute
  63046. * @hidden
  63047. */
  63048. const name = "Statics";
  63049. }
  63050. declare module BABYLON.GUI {
  63051. /**
  63052. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63053. */
  63054. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63055. /**
  63056. * Define the instrumented AdvancedDynamicTexture.
  63057. */
  63058. texture: AdvancedDynamicTexture;
  63059. private _captureRenderTime;
  63060. private _renderTime;
  63061. private _captureLayoutTime;
  63062. private _layoutTime;
  63063. private _onBeginRenderObserver;
  63064. private _onEndRenderObserver;
  63065. private _onBeginLayoutObserver;
  63066. private _onEndLayoutObserver;
  63067. /**
  63068. * Gets the perf counter used to capture render time
  63069. */
  63070. readonly renderTimeCounter: BABYLON.PerfCounter;
  63071. /**
  63072. * Gets the perf counter used to capture layout time
  63073. */
  63074. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63075. /**
  63076. * Enable or disable the render time capture
  63077. */
  63078. captureRenderTime: boolean;
  63079. /**
  63080. * Enable or disable the layout time capture
  63081. */
  63082. captureLayoutTime: boolean;
  63083. /**
  63084. * Instantiates a new advanced dynamic texture instrumentation.
  63085. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63086. * @param texture Defines the AdvancedDynamicTexture to instrument
  63087. */
  63088. constructor(
  63089. /**
  63090. * Define the instrumented AdvancedDynamicTexture.
  63091. */
  63092. texture: AdvancedDynamicTexture);
  63093. /**
  63094. * Dispose and release associated resources.
  63095. */
  63096. dispose(): void;
  63097. }
  63098. }
  63099. declare module BABYLON.GUI {
  63100. /**
  63101. * Class used to create containers for controls
  63102. */
  63103. export class Container3D extends Control3D {
  63104. private _blockLayout;
  63105. /**
  63106. * Gets the list of child controls
  63107. */
  63108. protected _children: Control3D[];
  63109. /**
  63110. * Gets the list of child controls
  63111. */
  63112. readonly children: Array<Control3D>;
  63113. /**
  63114. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63115. * This is helpful to optimize layout operation when adding multiple children in a row
  63116. */
  63117. blockLayout: boolean;
  63118. /**
  63119. * Creates a new container
  63120. * @param name defines the container name
  63121. */
  63122. constructor(name?: string);
  63123. /**
  63124. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63125. * @returns the current container
  63126. */
  63127. updateLayout(): Container3D;
  63128. /**
  63129. * Gets a boolean indicating if the given control is in the children of this control
  63130. * @param control defines the control to check
  63131. * @returns true if the control is in the child list
  63132. */
  63133. containsControl(control: Control3D): boolean;
  63134. /**
  63135. * Adds a control to the children of this control
  63136. * @param control defines the control to add
  63137. * @returns the current container
  63138. */
  63139. addControl(control: Control3D): Container3D;
  63140. /**
  63141. * This function will be called everytime a new control is added
  63142. */
  63143. protected _arrangeChildren(): void;
  63144. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63145. /**
  63146. * Removes a control from the children of this control
  63147. * @param control defines the control to remove
  63148. * @returns the current container
  63149. */
  63150. removeControl(control: Control3D): Container3D;
  63151. protected _getTypeName(): string;
  63152. /**
  63153. * Releases all associated resources
  63154. */
  63155. dispose(): void;
  63156. /** Control rotation will remain unchanged */
  63157. static readonly UNSET_ORIENTATION: number;
  63158. /** Control will rotate to make it look at sphere central axis */
  63159. static readonly FACEORIGIN_ORIENTATION: number;
  63160. /** Control will rotate to make it look back at sphere central axis */
  63161. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63162. /** Control will rotate to look at z axis (0, 0, 1) */
  63163. static readonly FACEFORWARD_ORIENTATION: number;
  63164. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63165. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63166. }
  63167. }
  63168. declare module BABYLON.GUI {
  63169. /**
  63170. * Class used to manage 3D user interface
  63171. * @see http://doc.babylonjs.com/how_to/gui3d
  63172. */
  63173. export class GUI3DManager implements BABYLON.IDisposable {
  63174. private _scene;
  63175. private _sceneDisposeObserver;
  63176. private _utilityLayer;
  63177. private _rootContainer;
  63178. private _pointerObserver;
  63179. private _pointerOutObserver;
  63180. /** @hidden */ private _lastPickedControl: Control3D;
  63181. /** @hidden */ private _lastControlOver: {
  63182. [pointerId: number]: Control3D;
  63183. };
  63184. /** @hidden */ private _lastControlDown: {
  63185. [pointerId: number]: Control3D;
  63186. };
  63187. /**
  63188. * BABYLON.Observable raised when the point picked by the pointer events changed
  63189. */
  63190. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63191. /** @hidden */ private _sharedMaterials: {
  63192. [key: string]: BABYLON.Material;
  63193. };
  63194. /** Gets the hosting scene */
  63195. readonly scene: BABYLON.Scene;
  63196. /** Gets associated utility layer */
  63197. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63198. /**
  63199. * Creates a new GUI3DManager
  63200. * @param scene
  63201. */
  63202. constructor(scene?: BABYLON.Scene);
  63203. private _handlePointerOut;
  63204. private _doPicking;
  63205. /**
  63206. * Gets the root container
  63207. */
  63208. readonly rootContainer: Container3D;
  63209. /**
  63210. * Gets a boolean indicating if the given control is in the root child list
  63211. * @param control defines the control to check
  63212. * @returns true if the control is in the root child list
  63213. */
  63214. containsControl(control: Control3D): boolean;
  63215. /**
  63216. * Adds a control to the root child list
  63217. * @param control defines the control to add
  63218. * @returns the current manager
  63219. */
  63220. addControl(control: Control3D): GUI3DManager;
  63221. /**
  63222. * Removes a control from the root child list
  63223. * @param control defines the control to remove
  63224. * @returns the current container
  63225. */
  63226. removeControl(control: Control3D): GUI3DManager;
  63227. /**
  63228. * Releases all associated resources
  63229. */
  63230. dispose(): void;
  63231. }
  63232. }
  63233. declare module BABYLON.GUI {
  63234. /**
  63235. * Class used to transport BABYLON.Vector3 information for pointer events
  63236. */
  63237. export class Vector3WithInfo extends BABYLON.Vector3 {
  63238. /** defines the current mouse button index */
  63239. buttonIndex: number;
  63240. /**
  63241. * Creates a new Vector3WithInfo
  63242. * @param source defines the vector3 data to transport
  63243. * @param buttonIndex defines the current mouse button index
  63244. */
  63245. constructor(source: BABYLON.Vector3,
  63246. /** defines the current mouse button index */
  63247. buttonIndex?: number);
  63248. }
  63249. }
  63250. declare module BABYLON.GUI {
  63251. /**
  63252. * Class used as base class for controls
  63253. */
  63254. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63255. /** Defines the control name */
  63256. name?: string | undefined;
  63257. /** @hidden */ private _host: GUI3DManager;
  63258. private _node;
  63259. private _downCount;
  63260. private _enterCount;
  63261. private _downPointerIds;
  63262. private _isVisible;
  63263. /** Gets or sets the control position in world space */
  63264. position: BABYLON.Vector3;
  63265. /** Gets or sets the control scaling in world space */
  63266. scaling: BABYLON.Vector3;
  63267. /** Callback used to start pointer enter animation */
  63268. pointerEnterAnimation: () => void;
  63269. /** Callback used to start pointer out animation */
  63270. pointerOutAnimation: () => void;
  63271. /** Callback used to start pointer down animation */
  63272. pointerDownAnimation: () => void;
  63273. /** Callback used to start pointer up animation */
  63274. pointerUpAnimation: () => void;
  63275. /**
  63276. * An event triggered when the pointer move over the control
  63277. */
  63278. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63279. /**
  63280. * An event triggered when the pointer move out of the control
  63281. */
  63282. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63283. /**
  63284. * An event triggered when the pointer taps the control
  63285. */
  63286. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  63287. /**
  63288. * An event triggered when pointer is up
  63289. */
  63290. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  63291. /**
  63292. * An event triggered when a control is clicked on (with a mouse)
  63293. */
  63294. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  63295. /**
  63296. * An event triggered when pointer enters the control
  63297. */
  63298. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  63299. /**
  63300. * Gets or sets the parent container
  63301. */
  63302. parent: BABYLON.Nullable<Container3D>;
  63303. private _behaviors;
  63304. /**
  63305. * Gets the list of attached behaviors
  63306. * @see http://doc.babylonjs.com/features/behaviour
  63307. */
  63308. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63309. /**
  63310. * Attach a behavior to the control
  63311. * @see http://doc.babylonjs.com/features/behaviour
  63312. * @param behavior defines the behavior to attach
  63313. * @returns the current control
  63314. */
  63315. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63316. /**
  63317. * Remove an attached behavior
  63318. * @see http://doc.babylonjs.com/features/behaviour
  63319. * @param behavior defines the behavior to attach
  63320. * @returns the current control
  63321. */
  63322. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63323. /**
  63324. * Gets an attached behavior by name
  63325. * @param name defines the name of the behavior to look for
  63326. * @see http://doc.babylonjs.com/features/behaviour
  63327. * @returns null if behavior was not found else the requested behavior
  63328. */
  63329. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  63330. /** Gets or sets a boolean indicating if the control is visible */
  63331. isVisible: boolean;
  63332. /**
  63333. * Creates a new control
  63334. * @param name defines the control name
  63335. */
  63336. constructor(
  63337. /** Defines the control name */
  63338. name?: string | undefined);
  63339. /**
  63340. * Gets a string representing the class name
  63341. */
  63342. readonly typeName: string;
  63343. /**
  63344. * Get the current class name of the control.
  63345. * @returns current class name
  63346. */
  63347. getClassName(): string;
  63348. protected _getTypeName(): string;
  63349. /**
  63350. * Gets the transform node used by this control
  63351. */
  63352. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63353. /**
  63354. * Gets the mesh used to render this control
  63355. */
  63356. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63357. /**
  63358. * Link the control as child of the given node
  63359. * @param node defines the node to link to. Use null to unlink the control
  63360. * @returns the current control
  63361. */
  63362. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63363. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  63364. /**
  63365. * Node creation.
  63366. * Can be overriden by children
  63367. * @param scene defines the scene where the node must be attached
  63368. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63369. */
  63370. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63371. /**
  63372. * Affect a material to the given mesh
  63373. * @param mesh defines the mesh which will represent the control
  63374. */
  63375. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63376. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63377. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  63378. /** @hidden */ private _onPointerOut(target: Control3D): void;
  63379. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63380. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63381. /** @hidden */
  63382. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63383. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63384. /** @hidden */ private _disposeNode(): void;
  63385. /**
  63386. * Releases all associated resources
  63387. */
  63388. dispose(): void;
  63389. }
  63390. }
  63391. declare module BABYLON.GUI {
  63392. /**
  63393. * Class used as a root to all buttons
  63394. */
  63395. export class AbstractButton3D extends Control3D {
  63396. /**
  63397. * Creates a new button
  63398. * @param name defines the control name
  63399. */
  63400. constructor(name?: string);
  63401. protected _getTypeName(): string;
  63402. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63403. }
  63404. }
  63405. declare module BABYLON.GUI {
  63406. /**
  63407. * Class used to create a button in 3D
  63408. */
  63409. export class Button3D extends AbstractButton3D {
  63410. /** @hidden */
  63411. protected _currentMaterial: BABYLON.Material;
  63412. private _facadeTexture;
  63413. private _content;
  63414. private _contentResolution;
  63415. private _contentScaleRatio;
  63416. /**
  63417. * Gets or sets the texture resolution used to render content (512 by default)
  63418. */
  63419. contentResolution: BABYLON.int;
  63420. /**
  63421. * Gets or sets the texture scale ratio used to render content (2 by default)
  63422. */
  63423. contentScaleRatio: number;
  63424. protected _disposeFacadeTexture(): void;
  63425. protected _resetContent(): void;
  63426. /**
  63427. * Creates a new button
  63428. * @param name defines the control name
  63429. */
  63430. constructor(name?: string);
  63431. /**
  63432. * Gets or sets the GUI 2D content used to display the button's facade
  63433. */
  63434. content: Control;
  63435. /**
  63436. * Apply the facade texture (created from the content property).
  63437. * This function can be overloaded by child classes
  63438. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63439. */
  63440. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63441. protected _getTypeName(): string;
  63442. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63443. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63444. /**
  63445. * Releases all associated resources
  63446. */
  63447. dispose(): void;
  63448. }
  63449. }
  63450. declare module BABYLON.GUI {
  63451. /**
  63452. * Abstract class used to create a container panel deployed on the surface of a volume
  63453. */
  63454. export abstract class VolumeBasedPanel extends Container3D {
  63455. private _columns;
  63456. private _rows;
  63457. private _rowThenColum;
  63458. private _orientation;
  63459. protected _cellWidth: number;
  63460. protected _cellHeight: number;
  63461. /**
  63462. * Gets or sets the distance between elements
  63463. */
  63464. margin: number;
  63465. /**
  63466. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63467. * | Value | Type | Description |
  63468. * | ----- | ----------------------------------- | ----------- |
  63469. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63470. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63471. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63472. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63473. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63474. */
  63475. orientation: number;
  63476. /**
  63477. * Gets or sets the number of columns requested (10 by default).
  63478. * The panel will automatically compute the number of rows based on number of child controls.
  63479. */
  63480. columns: BABYLON.int;
  63481. /**
  63482. * Gets or sets a the number of rows requested.
  63483. * The panel will automatically compute the number of columns based on number of child controls.
  63484. */
  63485. rows: BABYLON.int;
  63486. /**
  63487. * Creates new VolumeBasedPanel
  63488. */
  63489. constructor();
  63490. protected _arrangeChildren(): void;
  63491. /** Child classes must implement this function to provide correct control positioning */
  63492. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63493. /** Child classes can implement this function to provide additional processing */
  63494. protected _finalProcessing(): void;
  63495. }
  63496. }
  63497. declare module BABYLON.GUI {
  63498. /**
  63499. * Class used to create a container panel deployed on the surface of a cylinder
  63500. */
  63501. export class CylinderPanel extends VolumeBasedPanel {
  63502. private _radius;
  63503. /**
  63504. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63505. */
  63506. radius: BABYLON.float;
  63507. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63508. private _cylindricalMapping;
  63509. }
  63510. }
  63511. declare module BABYLON.GUI {
  63512. /** @hidden */
  63513. export var fluentVertexShader: {
  63514. name: string;
  63515. shader: string;
  63516. };
  63517. }
  63518. declare module BABYLON.GUI {
  63519. /** @hidden */
  63520. export var fluentPixelShader: {
  63521. name: string;
  63522. shader: string;
  63523. };
  63524. }
  63525. declare module BABYLON.GUI {
  63526. /** @hidden */
  63527. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63528. INNERGLOW: boolean;
  63529. BORDER: boolean;
  63530. HOVERLIGHT: boolean;
  63531. TEXTURE: boolean;
  63532. constructor();
  63533. }
  63534. /**
  63535. * Class used to render controls with fluent desgin
  63536. */
  63537. export class FluentMaterial extends BABYLON.PushMaterial {
  63538. /**
  63539. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63540. */
  63541. innerGlowColorIntensity: number;
  63542. /**
  63543. * Gets or sets the inner glow color (white by default)
  63544. */
  63545. innerGlowColor: BABYLON.Color3;
  63546. /**
  63547. * Gets or sets alpha value (default is 1.0)
  63548. */
  63549. alpha: number;
  63550. /**
  63551. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63552. */
  63553. albedoColor: BABYLON.Color3;
  63554. /**
  63555. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63556. */
  63557. renderBorders: boolean;
  63558. /**
  63559. * Gets or sets border width (default is 0.5)
  63560. */
  63561. borderWidth: number;
  63562. /**
  63563. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63564. */
  63565. edgeSmoothingValue: number;
  63566. /**
  63567. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63568. */
  63569. borderMinValue: number;
  63570. /**
  63571. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63572. */
  63573. renderHoverLight: boolean;
  63574. /**
  63575. * Gets or sets the radius used to render the hover light (default is 1.0)
  63576. */
  63577. hoverRadius: number;
  63578. /**
  63579. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63580. */
  63581. hoverColor: BABYLON.Color4;
  63582. /**
  63583. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63584. */
  63585. hoverPosition: BABYLON.Vector3;
  63586. private _albedoTexture;
  63587. /** Gets or sets the texture to use for albedo color */
  63588. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63589. /**
  63590. * Creates a new Fluent material
  63591. * @param name defines the name of the material
  63592. * @param scene defines the hosting scene
  63593. */
  63594. constructor(name: string, scene: BABYLON.Scene);
  63595. needAlphaBlending(): boolean;
  63596. needAlphaTesting(): boolean;
  63597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63600. getActiveTextures(): BABYLON.BaseTexture[];
  63601. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63602. dispose(forceDisposeEffect?: boolean): void;
  63603. clone(name: string): FluentMaterial;
  63604. serialize(): any;
  63605. getClassName(): string;
  63606. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63607. }
  63608. }
  63609. declare module BABYLON.GUI {
  63610. /**
  63611. * Class used to create a holographic button in 3D
  63612. */
  63613. export class HolographicButton extends Button3D {
  63614. private _backPlate;
  63615. private _textPlate;
  63616. private _frontPlate;
  63617. private _text;
  63618. private _imageUrl;
  63619. private _shareMaterials;
  63620. private _frontMaterial;
  63621. private _backMaterial;
  63622. private _plateMaterial;
  63623. private _pickedPointObserver;
  63624. private _tooltipFade;
  63625. private _tooltipTextBlock;
  63626. private _tooltipTexture;
  63627. private _tooltipMesh;
  63628. private _tooltipHoverObserver;
  63629. private _tooltipOutObserver;
  63630. private _disposeTooltip;
  63631. /**
  63632. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63633. */
  63634. tooltipText: BABYLON.Nullable<string>;
  63635. /**
  63636. * Gets or sets text for the button
  63637. */
  63638. text: string;
  63639. /**
  63640. * Gets or sets the image url for the button
  63641. */
  63642. imageUrl: string;
  63643. /**
  63644. * Gets the back material used by this button
  63645. */
  63646. readonly backMaterial: FluentMaterial;
  63647. /**
  63648. * Gets the front material used by this button
  63649. */
  63650. readonly frontMaterial: FluentMaterial;
  63651. /**
  63652. * Gets the plate material used by this button
  63653. */
  63654. readonly plateMaterial: BABYLON.StandardMaterial;
  63655. /**
  63656. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63657. */
  63658. readonly shareMaterials: boolean;
  63659. /**
  63660. * Creates a new button
  63661. * @param name defines the control name
  63662. */
  63663. constructor(name?: string, shareMaterials?: boolean);
  63664. protected _getTypeName(): string;
  63665. private _rebuildContent;
  63666. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63667. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63668. private _createBackMaterial;
  63669. private _createFrontMaterial;
  63670. private _createPlateMaterial;
  63671. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63672. /**
  63673. * Releases all associated resources
  63674. */
  63675. dispose(): void;
  63676. }
  63677. }
  63678. declare module BABYLON.GUI {
  63679. /**
  63680. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63681. */
  63682. export class MeshButton3D extends Button3D {
  63683. /** @hidden */
  63684. protected _currentMesh: BABYLON.Mesh;
  63685. /**
  63686. * Creates a new 3D button based on a mesh
  63687. * @param mesh mesh to become a 3D button
  63688. * @param name defines the control name
  63689. */
  63690. constructor(mesh: BABYLON.Mesh, name?: string);
  63691. protected _getTypeName(): string;
  63692. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63693. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63694. }
  63695. }
  63696. declare module BABYLON.GUI {
  63697. /**
  63698. * Class used to create a container panel deployed on the surface of a plane
  63699. */
  63700. export class PlanePanel extends VolumeBasedPanel {
  63701. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63702. }
  63703. }
  63704. declare module BABYLON.GUI {
  63705. /**
  63706. * Class used to create a container panel where items get randomized planar mapping
  63707. */
  63708. export class ScatterPanel extends VolumeBasedPanel {
  63709. private _iteration;
  63710. /**
  63711. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63712. */
  63713. iteration: BABYLON.float;
  63714. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63715. private _scatterMapping;
  63716. protected _finalProcessing(): void;
  63717. }
  63718. }
  63719. declare module BABYLON.GUI {
  63720. /**
  63721. * Class used to create a container panel deployed on the surface of a sphere
  63722. */
  63723. export class SpherePanel extends VolumeBasedPanel {
  63724. private _radius;
  63725. /**
  63726. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63727. */
  63728. radius: BABYLON.float;
  63729. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63730. private _sphericalMapping;
  63731. }
  63732. }
  63733. declare module BABYLON.GUI {
  63734. /**
  63735. * Class used to create a stack panel in 3D on XY plane
  63736. */
  63737. export class StackPanel3D extends Container3D {
  63738. private _isVertical;
  63739. /**
  63740. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63741. */
  63742. isVertical: boolean;
  63743. /**
  63744. * Gets or sets the distance between elements
  63745. */
  63746. margin: number;
  63747. /**
  63748. * Creates new StackPanel
  63749. * @param isVertical
  63750. */
  63751. constructor(isVertical?: boolean);
  63752. protected _arrangeChildren(): void;
  63753. }
  63754. }
  63755. declare module BABYLON {
  63756. /**
  63757. * Mode that determines the coordinate system to use.
  63758. */
  63759. export enum GLTFLoaderCoordinateSystemMode {
  63760. /**
  63761. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63762. */
  63763. AUTO = 0,
  63764. /**
  63765. * Sets the useRightHandedSystem flag on the scene.
  63766. */
  63767. FORCE_RIGHT_HANDED = 1
  63768. }
  63769. /**
  63770. * Mode that determines what animations will start.
  63771. */
  63772. export enum GLTFLoaderAnimationStartMode {
  63773. /**
  63774. * No animation will start.
  63775. */
  63776. NONE = 0,
  63777. /**
  63778. * The first animation will start.
  63779. */
  63780. FIRST = 1,
  63781. /**
  63782. * All animations will start.
  63783. */
  63784. ALL = 2
  63785. }
  63786. /**
  63787. * Interface that contains the data for the glTF asset.
  63788. */
  63789. export interface IGLTFLoaderData {
  63790. /**
  63791. * Object that represents the glTF JSON.
  63792. */
  63793. json: Object;
  63794. /**
  63795. * The BIN chunk of a binary glTF.
  63796. */
  63797. bin: Nullable<ArrayBufferView>;
  63798. }
  63799. /**
  63800. * Interface for extending the loader.
  63801. */
  63802. export interface IGLTFLoaderExtension {
  63803. /**
  63804. * The name of this extension.
  63805. */
  63806. readonly name: string;
  63807. /**
  63808. * Defines whether this extension is enabled.
  63809. */
  63810. enabled: boolean;
  63811. }
  63812. /**
  63813. * Loader state.
  63814. */
  63815. export enum GLTFLoaderState {
  63816. /**
  63817. * The asset is loading.
  63818. */
  63819. LOADING = 0,
  63820. /**
  63821. * The asset is ready for rendering.
  63822. */
  63823. READY = 1,
  63824. /**
  63825. * The asset is completely loaded.
  63826. */
  63827. COMPLETE = 2
  63828. }
  63829. /** @hidden */
  63830. export interface IGLTFLoader extends IDisposable {
  63831. readonly state: Nullable<GLTFLoaderState>;
  63832. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63833. meshes: AbstractMesh[];
  63834. particleSystems: IParticleSystem[];
  63835. skeletons: Skeleton[];
  63836. animationGroups: AnimationGroup[];
  63837. }>;
  63838. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63839. }
  63840. /**
  63841. * File loader for loading glTF files into a scene.
  63842. */
  63843. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63844. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63845. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63846. /**
  63847. * Raised when the asset has been parsed
  63848. */
  63849. onParsedObservable: Observable<IGLTFLoaderData>;
  63850. private _onParsedObserver;
  63851. /**
  63852. * Raised when the asset has been parsed
  63853. */
  63854. onParsed: (loaderData: IGLTFLoaderData) => void;
  63855. /**
  63856. * 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.
  63857. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63858. * Defaults to true.
  63859. * @hidden
  63860. */
  63861. static IncrementalLoading: boolean;
  63862. /**
  63863. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63864. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63865. * @hidden
  63866. */
  63867. static HomogeneousCoordinates: boolean;
  63868. /**
  63869. * The coordinate system mode. Defaults to AUTO.
  63870. */
  63871. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63872. /**
  63873. * The animation start mode. Defaults to FIRST.
  63874. */
  63875. animationStartMode: GLTFLoaderAnimationStartMode;
  63876. /**
  63877. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63878. */
  63879. compileMaterials: boolean;
  63880. /**
  63881. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63882. */
  63883. useClipPlane: boolean;
  63884. /**
  63885. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63886. */
  63887. compileShadowGenerators: boolean;
  63888. /**
  63889. * Defines if the Alpha blended materials are only applied as coverage.
  63890. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63891. * If true, no extra effects are applied to transparent pixels.
  63892. */
  63893. transparencyAsCoverage: boolean;
  63894. /**
  63895. * Function called before loading a url referenced by the asset.
  63896. */
  63897. preprocessUrlAsync: (url: string) => Promise<string>;
  63898. /**
  63899. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63900. */
  63901. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63902. private _onMeshLoadedObserver;
  63903. /**
  63904. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63905. */
  63906. onMeshLoaded: (mesh: AbstractMesh) => void;
  63907. /**
  63908. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63909. */
  63910. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63911. private _onTextureLoadedObserver;
  63912. /**
  63913. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63914. */
  63915. onTextureLoaded: (texture: BaseTexture) => void;
  63916. /**
  63917. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63918. */
  63919. readonly onMaterialLoadedObservable: Observable<Material>;
  63920. private _onMaterialLoadedObserver;
  63921. /**
  63922. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63923. */
  63924. onMaterialLoaded: (material: Material) => void;
  63925. /**
  63926. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63927. */
  63928. readonly onCameraLoadedObservable: Observable<Camera>;
  63929. private _onCameraLoadedObserver;
  63930. /**
  63931. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63932. */
  63933. onCameraLoaded: (camera: Camera) => void;
  63934. /**
  63935. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63936. * For assets with LODs, raised when all of the LODs are complete.
  63937. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63938. */
  63939. readonly onCompleteObservable: Observable<void>;
  63940. private _onCompleteObserver;
  63941. /**
  63942. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63943. * For assets with LODs, raised when all of the LODs are complete.
  63944. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63945. */
  63946. onComplete: () => void;
  63947. /**
  63948. * Observable raised when an error occurs.
  63949. */
  63950. readonly onErrorObservable: Observable<any>;
  63951. private _onErrorObserver;
  63952. /**
  63953. * Callback raised when an error occurs.
  63954. */
  63955. onError: (reason: any) => void;
  63956. /**
  63957. * Observable raised after the loader is disposed.
  63958. */
  63959. readonly onDisposeObservable: Observable<void>;
  63960. private _onDisposeObserver;
  63961. /**
  63962. * Callback raised after the loader is disposed.
  63963. */
  63964. onDispose: () => void;
  63965. /**
  63966. * Observable raised after a loader extension is created.
  63967. * Set additional options for a loader extension in this event.
  63968. */
  63969. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63970. private _onExtensionLoadedObserver;
  63971. /**
  63972. * Callback raised after a loader extension is created.
  63973. */
  63974. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63975. /**
  63976. * Defines if the loader logging is enabled.
  63977. */
  63978. loggingEnabled: boolean;
  63979. /**
  63980. * Defines if the loader should capture performance counters.
  63981. */
  63982. capturePerformanceCounters: boolean;
  63983. /**
  63984. * Defines if the loader should validate the asset.
  63985. */
  63986. validate: boolean;
  63987. /**
  63988. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63989. */
  63990. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63991. private _onValidatedObserver;
  63992. /**
  63993. * Callback raised after a loader extension is created.
  63994. */
  63995. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63996. private _loader;
  63997. /**
  63998. * Name of the loader ("gltf")
  63999. */
  64000. name: string;
  64001. /**
  64002. * Supported file extensions of the loader (.gltf, .glb)
  64003. */
  64004. extensions: ISceneLoaderPluginExtensions;
  64005. /**
  64006. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64007. */
  64008. dispose(): void;
  64009. /** @hidden */ private _clear(): void;
  64010. /**
  64011. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64012. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64013. * @param scene the scene the meshes should be added to
  64014. * @param data the glTF data to load
  64015. * @param rootUrl root url to load from
  64016. * @param onProgress event that fires when loading progress has occured
  64017. * @param fileName Defines the name of the file to load
  64018. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64019. */
  64020. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64021. meshes: AbstractMesh[];
  64022. particleSystems: IParticleSystem[];
  64023. skeletons: Skeleton[];
  64024. animationGroups: AnimationGroup[];
  64025. }>;
  64026. /**
  64027. * Imports all objects from the loaded glTF data and adds them to the scene
  64028. * @param scene the scene the objects should be added to
  64029. * @param data the glTF data to load
  64030. * @param rootUrl root url to load from
  64031. * @param onProgress event that fires when loading progress has occured
  64032. * @param fileName Defines the name of the file to load
  64033. * @returns a promise which completes when objects have been loaded to the scene
  64034. */
  64035. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64036. /**
  64037. * Load into an asset container.
  64038. * @param scene The scene to load into
  64039. * @param data The data to import
  64040. * @param rootUrl The root url for scene and resources
  64041. * @param onProgress The callback when the load progresses
  64042. * @param fileName Defines the name of the file to load
  64043. * @returns The loaded asset container
  64044. */
  64045. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64046. /**
  64047. * If the data string can be loaded directly.
  64048. * @param data string contianing the file data
  64049. * @returns if the data can be loaded directly
  64050. */
  64051. canDirectLoad(data: string): boolean;
  64052. /**
  64053. * Rewrites a url by combining a root url and response url.
  64054. */
  64055. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64056. /**
  64057. * Instantiates a glTF file loader plugin.
  64058. * @returns the created plugin
  64059. */
  64060. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64061. /**
  64062. * The loader state or null if the loader is not active.
  64063. */
  64064. readonly loaderState: Nullable<GLTFLoaderState>;
  64065. /**
  64066. * Returns a promise that resolves when the asset is completely loaded.
  64067. * @returns a promise that resolves when the asset is completely loaded.
  64068. */
  64069. whenCompleteAsync(): Promise<void>;
  64070. private _parseAsync;
  64071. private _validateAsync;
  64072. private _getLoader;
  64073. private _unpackBinary;
  64074. private _unpackBinaryV1;
  64075. private _unpackBinaryV2;
  64076. private static _parseVersion;
  64077. private static _compareVersion;
  64078. private static _decodeBufferToText;
  64079. private static readonly _logSpaces;
  64080. private _logIndentLevel;
  64081. private _loggingEnabled;
  64082. /** @hidden */ private _log: (message: string) => void;
  64083. /** @hidden */ private _logOpen(message: string): void;
  64084. /** @hidden */ private _logClose(): void;
  64085. private _logEnabled;
  64086. private _logDisabled;
  64087. private _capturePerformanceCounters;
  64088. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  64089. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  64090. private _startPerformanceCounterEnabled;
  64091. private _startPerformanceCounterDisabled;
  64092. private _endPerformanceCounterEnabled;
  64093. private _endPerformanceCounterDisabled;
  64094. }
  64095. }
  64096. declare module BABYLON.GLTF1 {
  64097. /**
  64098. * Enums
  64099. * @hidden
  64100. */
  64101. export enum EComponentType {
  64102. BYTE = 5120,
  64103. UNSIGNED_BYTE = 5121,
  64104. SHORT = 5122,
  64105. UNSIGNED_SHORT = 5123,
  64106. FLOAT = 5126
  64107. }
  64108. /** @hidden */
  64109. export enum EShaderType {
  64110. FRAGMENT = 35632,
  64111. VERTEX = 35633
  64112. }
  64113. /** @hidden */
  64114. export enum EParameterType {
  64115. BYTE = 5120,
  64116. UNSIGNED_BYTE = 5121,
  64117. SHORT = 5122,
  64118. UNSIGNED_SHORT = 5123,
  64119. INT = 5124,
  64120. UNSIGNED_INT = 5125,
  64121. FLOAT = 5126,
  64122. FLOAT_VEC2 = 35664,
  64123. FLOAT_VEC3 = 35665,
  64124. FLOAT_VEC4 = 35666,
  64125. INT_VEC2 = 35667,
  64126. INT_VEC3 = 35668,
  64127. INT_VEC4 = 35669,
  64128. BOOL = 35670,
  64129. BOOL_VEC2 = 35671,
  64130. BOOL_VEC3 = 35672,
  64131. BOOL_VEC4 = 35673,
  64132. FLOAT_MAT2 = 35674,
  64133. FLOAT_MAT3 = 35675,
  64134. FLOAT_MAT4 = 35676,
  64135. SAMPLER_2D = 35678
  64136. }
  64137. /** @hidden */
  64138. export enum ETextureWrapMode {
  64139. CLAMP_TO_EDGE = 33071,
  64140. MIRRORED_REPEAT = 33648,
  64141. REPEAT = 10497
  64142. }
  64143. /** @hidden */
  64144. export enum ETextureFilterType {
  64145. NEAREST = 9728,
  64146. LINEAR = 9728,
  64147. NEAREST_MIPMAP_NEAREST = 9984,
  64148. LINEAR_MIPMAP_NEAREST = 9985,
  64149. NEAREST_MIPMAP_LINEAR = 9986,
  64150. LINEAR_MIPMAP_LINEAR = 9987
  64151. }
  64152. /** @hidden */
  64153. export enum ETextureFormat {
  64154. ALPHA = 6406,
  64155. RGB = 6407,
  64156. RGBA = 6408,
  64157. LUMINANCE = 6409,
  64158. LUMINANCE_ALPHA = 6410
  64159. }
  64160. /** @hidden */
  64161. export enum ECullingType {
  64162. FRONT = 1028,
  64163. BACK = 1029,
  64164. FRONT_AND_BACK = 1032
  64165. }
  64166. /** @hidden */
  64167. export enum EBlendingFunction {
  64168. ZERO = 0,
  64169. ONE = 1,
  64170. SRC_COLOR = 768,
  64171. ONE_MINUS_SRC_COLOR = 769,
  64172. DST_COLOR = 774,
  64173. ONE_MINUS_DST_COLOR = 775,
  64174. SRC_ALPHA = 770,
  64175. ONE_MINUS_SRC_ALPHA = 771,
  64176. DST_ALPHA = 772,
  64177. ONE_MINUS_DST_ALPHA = 773,
  64178. CONSTANT_COLOR = 32769,
  64179. ONE_MINUS_CONSTANT_COLOR = 32770,
  64180. CONSTANT_ALPHA = 32771,
  64181. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64182. SRC_ALPHA_SATURATE = 776
  64183. }
  64184. /** @hidden */
  64185. export interface IGLTFProperty {
  64186. extensions?: {
  64187. [key: string]: any;
  64188. };
  64189. extras?: Object;
  64190. }
  64191. /** @hidden */
  64192. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64193. name?: string;
  64194. }
  64195. /** @hidden */
  64196. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64197. bufferView: string;
  64198. byteOffset: number;
  64199. byteStride: number;
  64200. count: number;
  64201. type: string;
  64202. componentType: EComponentType;
  64203. max?: number[];
  64204. min?: number[];
  64205. name?: string;
  64206. }
  64207. /** @hidden */
  64208. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64209. buffer: string;
  64210. byteOffset: number;
  64211. byteLength: number;
  64212. byteStride: number;
  64213. target?: number;
  64214. }
  64215. /** @hidden */
  64216. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64217. uri: string;
  64218. byteLength?: number;
  64219. type?: string;
  64220. }
  64221. /** @hidden */
  64222. export interface IGLTFShader extends IGLTFChildRootProperty {
  64223. uri: string;
  64224. type: EShaderType;
  64225. }
  64226. /** @hidden */
  64227. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64228. attributes: string[];
  64229. fragmentShader: string;
  64230. vertexShader: string;
  64231. }
  64232. /** @hidden */
  64233. export interface IGLTFTechniqueParameter {
  64234. type: number;
  64235. count?: number;
  64236. semantic?: string;
  64237. node?: string;
  64238. value?: number | boolean | string | Array<any>;
  64239. source?: string;
  64240. babylonValue?: any;
  64241. }
  64242. /** @hidden */
  64243. export interface IGLTFTechniqueCommonProfile {
  64244. lightingModel: string;
  64245. texcoordBindings: Object;
  64246. parameters?: Array<any>;
  64247. }
  64248. /** @hidden */
  64249. export interface IGLTFTechniqueStatesFunctions {
  64250. blendColor?: number[];
  64251. blendEquationSeparate?: number[];
  64252. blendFuncSeparate?: number[];
  64253. colorMask: boolean[];
  64254. cullFace: number[];
  64255. }
  64256. /** @hidden */
  64257. export interface IGLTFTechniqueStates {
  64258. enable: number[];
  64259. functions: IGLTFTechniqueStatesFunctions;
  64260. }
  64261. /** @hidden */
  64262. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64263. parameters: {
  64264. [key: string]: IGLTFTechniqueParameter;
  64265. };
  64266. program: string;
  64267. attributes: {
  64268. [key: string]: string;
  64269. };
  64270. uniforms: {
  64271. [key: string]: string;
  64272. };
  64273. states: IGLTFTechniqueStates;
  64274. }
  64275. /** @hidden */
  64276. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  64277. technique?: string;
  64278. values: string[];
  64279. }
  64280. /** @hidden */
  64281. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  64282. attributes: {
  64283. [key: string]: string;
  64284. };
  64285. indices: string;
  64286. material: string;
  64287. mode?: number;
  64288. }
  64289. /** @hidden */
  64290. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64291. primitives: IGLTFMeshPrimitive[];
  64292. }
  64293. /** @hidden */
  64294. export interface IGLTFImage extends IGLTFChildRootProperty {
  64295. uri: string;
  64296. }
  64297. /** @hidden */
  64298. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64299. magFilter?: number;
  64300. minFilter?: number;
  64301. wrapS?: number;
  64302. wrapT?: number;
  64303. }
  64304. /** @hidden */
  64305. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64306. sampler: string;
  64307. source: string;
  64308. format?: ETextureFormat;
  64309. internalFormat?: ETextureFormat;
  64310. target?: number;
  64311. type?: number;
  64312. babylonTexture?: Texture;
  64313. }
  64314. /** @hidden */
  64315. export interface IGLTFAmbienLight {
  64316. color?: number[];
  64317. }
  64318. /** @hidden */
  64319. export interface IGLTFDirectionalLight {
  64320. color?: number[];
  64321. }
  64322. /** @hidden */
  64323. export interface IGLTFPointLight {
  64324. color?: number[];
  64325. constantAttenuation?: number;
  64326. linearAttenuation?: number;
  64327. quadraticAttenuation?: number;
  64328. }
  64329. /** @hidden */
  64330. export interface IGLTFSpotLight {
  64331. color?: number[];
  64332. constantAttenuation?: number;
  64333. fallOfAngle?: number;
  64334. fallOffExponent?: number;
  64335. linearAttenuation?: number;
  64336. quadraticAttenuation?: number;
  64337. }
  64338. /** @hidden */
  64339. export interface IGLTFLight extends IGLTFChildRootProperty {
  64340. type: string;
  64341. }
  64342. /** @hidden */
  64343. export interface IGLTFCameraOrthographic {
  64344. xmag: number;
  64345. ymag: number;
  64346. zfar: number;
  64347. znear: number;
  64348. }
  64349. /** @hidden */
  64350. export interface IGLTFCameraPerspective {
  64351. aspectRatio: number;
  64352. yfov: number;
  64353. zfar: number;
  64354. znear: number;
  64355. }
  64356. /** @hidden */
  64357. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64358. type: string;
  64359. }
  64360. /** @hidden */
  64361. export interface IGLTFAnimationChannelTarget {
  64362. id: string;
  64363. path: string;
  64364. }
  64365. /** @hidden */
  64366. export interface IGLTFAnimationChannel {
  64367. sampler: string;
  64368. target: IGLTFAnimationChannelTarget;
  64369. }
  64370. /** @hidden */
  64371. export interface IGLTFAnimationSampler {
  64372. input: string;
  64373. output: string;
  64374. interpolation?: string;
  64375. }
  64376. /** @hidden */
  64377. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64378. channels?: IGLTFAnimationChannel[];
  64379. parameters?: {
  64380. [key: string]: string;
  64381. };
  64382. samplers?: {
  64383. [key: string]: IGLTFAnimationSampler;
  64384. };
  64385. }
  64386. /** @hidden */
  64387. export interface IGLTFNodeInstanceSkin {
  64388. skeletons: string[];
  64389. skin: string;
  64390. meshes: string[];
  64391. }
  64392. /** @hidden */
  64393. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64394. bindShapeMatrix: number[];
  64395. inverseBindMatrices: string;
  64396. jointNames: string[];
  64397. babylonSkeleton?: Skeleton;
  64398. }
  64399. /** @hidden */
  64400. export interface IGLTFNode extends IGLTFChildRootProperty {
  64401. camera?: string;
  64402. children: string[];
  64403. skin?: string;
  64404. jointName?: string;
  64405. light?: string;
  64406. matrix: number[];
  64407. mesh?: string;
  64408. meshes?: string[];
  64409. rotation?: number[];
  64410. scale?: number[];
  64411. translation?: number[];
  64412. babylonNode?: Node;
  64413. }
  64414. /** @hidden */
  64415. export interface IGLTFScene extends IGLTFChildRootProperty {
  64416. nodes: string[];
  64417. }
  64418. /** @hidden */
  64419. export interface IGLTFRuntime {
  64420. extensions: {
  64421. [key: string]: any;
  64422. };
  64423. accessors: {
  64424. [key: string]: IGLTFAccessor;
  64425. };
  64426. buffers: {
  64427. [key: string]: IGLTFBuffer;
  64428. };
  64429. bufferViews: {
  64430. [key: string]: IGLTFBufferView;
  64431. };
  64432. meshes: {
  64433. [key: string]: IGLTFMesh;
  64434. };
  64435. lights: {
  64436. [key: string]: IGLTFLight;
  64437. };
  64438. cameras: {
  64439. [key: string]: IGLTFCamera;
  64440. };
  64441. nodes: {
  64442. [key: string]: IGLTFNode;
  64443. };
  64444. images: {
  64445. [key: string]: IGLTFImage;
  64446. };
  64447. textures: {
  64448. [key: string]: IGLTFTexture;
  64449. };
  64450. shaders: {
  64451. [key: string]: IGLTFShader;
  64452. };
  64453. programs: {
  64454. [key: string]: IGLTFProgram;
  64455. };
  64456. samplers: {
  64457. [key: string]: IGLTFSampler;
  64458. };
  64459. techniques: {
  64460. [key: string]: IGLTFTechnique;
  64461. };
  64462. materials: {
  64463. [key: string]: IGLTFMaterial;
  64464. };
  64465. animations: {
  64466. [key: string]: IGLTFAnimation;
  64467. };
  64468. skins: {
  64469. [key: string]: IGLTFSkins;
  64470. };
  64471. currentScene?: Object;
  64472. scenes: {
  64473. [key: string]: IGLTFScene;
  64474. };
  64475. extensionsUsed: string[];
  64476. extensionsRequired?: string[];
  64477. buffersCount: number;
  64478. shaderscount: number;
  64479. scene: Scene;
  64480. rootUrl: string;
  64481. loadedBufferCount: number;
  64482. loadedBufferViews: {
  64483. [name: string]: ArrayBufferView;
  64484. };
  64485. loadedShaderCount: number;
  64486. importOnlyMeshes: boolean;
  64487. importMeshesNames?: string[];
  64488. dummyNodes: Node[];
  64489. }
  64490. /** @hidden */
  64491. export interface INodeToRoot {
  64492. bone: Bone;
  64493. node: IGLTFNode;
  64494. id: string;
  64495. }
  64496. /** @hidden */
  64497. export interface IJointNode {
  64498. node: IGLTFNode;
  64499. id: string;
  64500. }
  64501. }
  64502. declare module BABYLON.GLTF1 {
  64503. /**
  64504. * Utils functions for GLTF
  64505. * @hidden
  64506. */
  64507. export class GLTFUtils {
  64508. /**
  64509. * Sets the given "parameter" matrix
  64510. * @param scene: the Scene object
  64511. * @param source: the source node where to pick the matrix
  64512. * @param parameter: the GLTF technique parameter
  64513. * @param uniformName: the name of the shader's uniform
  64514. * @param shaderMaterial: the shader material
  64515. */
  64516. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64517. /**
  64518. * Sets the given "parameter" matrix
  64519. * @param shaderMaterial: the shader material
  64520. * @param uniform: the name of the shader's uniform
  64521. * @param value: the value of the uniform
  64522. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64523. */
  64524. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64525. /**
  64526. * Returns the wrap mode of the texture
  64527. * @param mode: the mode value
  64528. */
  64529. static GetWrapMode(mode: number): number;
  64530. /**
  64531. * Returns the byte stride giving an accessor
  64532. * @param accessor: the GLTF accessor objet
  64533. */
  64534. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64535. /**
  64536. * Returns the texture filter mode giving a mode value
  64537. * @param mode: the filter mode value
  64538. */
  64539. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64540. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64541. /**
  64542. * Returns a buffer from its accessor
  64543. * @param gltfRuntime: the GLTF runtime
  64544. * @param accessor: the GLTF accessor
  64545. */
  64546. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64547. /**
  64548. * Decodes a buffer view into a string
  64549. * @param view: the buffer view
  64550. */
  64551. static DecodeBufferToText(view: ArrayBufferView): string;
  64552. /**
  64553. * Returns the default material of gltf. Related to
  64554. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64555. * @param scene: the Babylon.js scene
  64556. */
  64557. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64558. private static _DefaultMaterial;
  64559. }
  64560. }
  64561. declare module BABYLON.GLTF1 {
  64562. /**
  64563. * Implementation of the base glTF spec
  64564. * @hidden
  64565. */
  64566. export class GLTFLoaderBase {
  64567. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64568. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64569. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64570. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64571. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64572. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64573. }
  64574. /**
  64575. * glTF V1 Loader
  64576. * @hidden
  64577. */
  64578. export class GLTFLoader implements IGLTFLoader {
  64579. static Extensions: {
  64580. [name: string]: GLTFLoaderExtension;
  64581. };
  64582. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64583. state: Nullable<GLTFLoaderState>;
  64584. dispose(): void;
  64585. private _importMeshAsync;
  64586. /**
  64587. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64588. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64589. * @param scene the scene the meshes should be added to
  64590. * @param data gltf data containing information of the meshes in a loaded file
  64591. * @param rootUrl root url to load from
  64592. * @param onProgress event that fires when loading progress has occured
  64593. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64594. */
  64595. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64596. meshes: AbstractMesh[];
  64597. particleSystems: IParticleSystem[];
  64598. skeletons: Skeleton[];
  64599. animationGroups: AnimationGroup[];
  64600. }>;
  64601. private _loadAsync;
  64602. /**
  64603. * Imports all objects from a loaded gltf file and adds them to the scene
  64604. * @param scene the scene the objects should be added to
  64605. * @param data gltf data containing information of the meshes in a loaded file
  64606. * @param rootUrl root url to load from
  64607. * @param onProgress event that fires when loading progress has occured
  64608. * @returns a promise which completes when objects have been loaded to the scene
  64609. */
  64610. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64611. private _loadShadersAsync;
  64612. private _loadBuffersAsync;
  64613. private _createNodes;
  64614. }
  64615. /** @hidden */
  64616. export abstract class GLTFLoaderExtension {
  64617. private _name;
  64618. constructor(name: string);
  64619. readonly name: string;
  64620. /**
  64621. * Defines an override for loading the runtime
  64622. * Return true to stop further extensions from loading the runtime
  64623. */
  64624. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64625. /**
  64626. * Defines an onverride for creating gltf runtime
  64627. * Return true to stop further extensions from creating the runtime
  64628. */
  64629. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64630. /**
  64631. * Defines an override for loading buffers
  64632. * Return true to stop further extensions from loading this buffer
  64633. */
  64634. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64635. /**
  64636. * Defines an override for loading texture buffers
  64637. * Return true to stop further extensions from loading this texture data
  64638. */
  64639. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64640. /**
  64641. * Defines an override for creating textures
  64642. * Return true to stop further extensions from loading this texture
  64643. */
  64644. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64645. /**
  64646. * Defines an override for loading shader strings
  64647. * Return true to stop further extensions from loading this shader data
  64648. */
  64649. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64650. /**
  64651. * Defines an override for loading materials
  64652. * Return true to stop further extensions from loading this material
  64653. */
  64654. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64655. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64656. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64657. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64658. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64659. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64660. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64661. private static LoadTextureBufferAsync;
  64662. private static CreateTextureAsync;
  64663. private static ApplyExtensions;
  64664. }
  64665. }
  64666. declare module BABYLON.GLTF1 {
  64667. /** @hidden */
  64668. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64669. private _bin;
  64670. constructor();
  64671. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64672. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64673. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64674. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64675. }
  64676. }
  64677. declare module BABYLON.GLTF1 {
  64678. /** @hidden */
  64679. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64680. constructor();
  64681. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64682. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64683. private _loadTexture;
  64684. }
  64685. }
  64686. declare module BABYLON.GLTF2.Loader {
  64687. /**
  64688. * Loader interface with an index field.
  64689. */
  64690. export interface IArrayItem {
  64691. /**
  64692. * The index of this item in the array.
  64693. */
  64694. index: number;
  64695. }
  64696. /**
  64697. * Loader interface with additional members.
  64698. */
  64699. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64700. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  64701. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  64702. }
  64703. /**
  64704. * Loader interface with additional members.
  64705. */
  64706. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64707. }
  64708. /** @hidden */
  64709. export interface _IAnimationSamplerData {
  64710. input: Float32Array;
  64711. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64712. output: Float32Array;
  64713. }
  64714. /**
  64715. * Loader interface with additional members.
  64716. */
  64717. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64718. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  64719. }
  64720. /**
  64721. * Loader interface with additional members.
  64722. */
  64723. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64724. channels: IAnimationChannel[];
  64725. samplers: IAnimationSampler[];
  64726. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  64727. }
  64728. /**
  64729. * Loader interface with additional members.
  64730. */
  64731. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64732. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  64733. }
  64734. /**
  64735. * Loader interface with additional members.
  64736. */
  64737. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64738. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  64739. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  64740. }
  64741. /**
  64742. * Loader interface with additional members.
  64743. */
  64744. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64745. }
  64746. /**
  64747. * Loader interface with additional members.
  64748. */
  64749. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64750. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  64751. }
  64752. /**
  64753. * Loader interface with additional members.
  64754. */
  64755. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64756. }
  64757. /**
  64758. * Loader interface with additional members.
  64759. */
  64760. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64761. }
  64762. /**
  64763. * Loader interface with additional members.
  64764. */
  64765. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64766. baseColorTexture?: ITextureInfo;
  64767. metallicRoughnessTexture?: ITextureInfo;
  64768. }
  64769. /**
  64770. * Loader interface with additional members.
  64771. */
  64772. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64773. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64774. normalTexture?: IMaterialNormalTextureInfo;
  64775. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64776. emissiveTexture?: ITextureInfo;
  64777. /** @hidden */ private _data?: {
  64778. [babylonDrawMode: number]: {
  64779. babylonMaterial: Material;
  64780. babylonMeshes: AbstractMesh[];
  64781. promise: Promise<void>;
  64782. };
  64783. };
  64784. }
  64785. /**
  64786. * Loader interface with additional members.
  64787. */
  64788. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64789. primitives: IMeshPrimitive[];
  64790. }
  64791. /**
  64792. * Loader interface with additional members.
  64793. */
  64794. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64795. /** @hidden */ private _instanceData?: {
  64796. babylonSourceMesh: Mesh;
  64797. promise: Promise<any>;
  64798. };
  64799. }
  64800. /**
  64801. * Loader interface with additional members.
  64802. */
  64803. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64804. /**
  64805. * The parent glTF node.
  64806. */
  64807. parent?: INode;
  64808. /** @hidden */ private _babylonTransformNode?: TransformNode;
  64809. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  64810. /** @hidden */ private _babylonBones?: Bone[];
  64811. /** @hidden */ private _numMorphTargets?: number;
  64812. }
  64813. /** @hidden */
  64814. export interface _ISamplerData {
  64815. noMipMaps: boolean;
  64816. samplingMode: number;
  64817. wrapU: number;
  64818. wrapV: number;
  64819. }
  64820. /**
  64821. * Loader interface with additional members.
  64822. */
  64823. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64824. /** @hidden */ private _data?: _ISamplerData;
  64825. }
  64826. /**
  64827. * Loader interface with additional members.
  64828. */
  64829. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64830. }
  64831. /**
  64832. * Loader interface with additional members.
  64833. */
  64834. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64835. /** @hidden */ private _data?: {
  64836. babylonSkeleton: Skeleton;
  64837. promise: Promise<void>;
  64838. };
  64839. }
  64840. /**
  64841. * Loader interface with additional members.
  64842. */
  64843. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64844. }
  64845. /**
  64846. * Loader interface with additional members.
  64847. */
  64848. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64849. }
  64850. /**
  64851. * Loader interface with additional members.
  64852. */
  64853. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64854. accessors?: IAccessor[];
  64855. animations?: IAnimation[];
  64856. buffers?: IBuffer[];
  64857. bufferViews?: IBufferView[];
  64858. cameras?: ICamera[];
  64859. images?: IImage[];
  64860. materials?: IMaterial[];
  64861. meshes?: IMesh[];
  64862. nodes?: INode[];
  64863. samplers?: ISampler[];
  64864. scenes?: IScene[];
  64865. skins?: ISkin[];
  64866. textures?: ITexture[];
  64867. }
  64868. }
  64869. declare module BABYLON.GLTF2 {
  64870. /**
  64871. * Interface for a glTF loader extension.
  64872. */
  64873. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64874. /**
  64875. * Called after the loader state changes to LOADING.
  64876. */
  64877. onLoading?(): void;
  64878. /**
  64879. * Called after the loader state changes to READY.
  64880. */
  64881. onReady?(): void;
  64882. /**
  64883. * Define this method to modify the default behavior when loading scenes.
  64884. * @param context The context when loading the asset
  64885. * @param scene The glTF scene property
  64886. * @returns A promise that resolves when the load is complete or null if not handled
  64887. */
  64888. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64889. /**
  64890. * Define this method to modify the default behavior when loading nodes.
  64891. * @param context The context when loading the asset
  64892. * @param node The glTF node property
  64893. * @param assign A function called synchronously after parsing the glTF properties
  64894. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64895. */
  64896. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64897. /**
  64898. * Define this method to modify the default behavior when loading cameras.
  64899. * @param context The context when loading the asset
  64900. * @param camera The glTF camera property
  64901. * @param assign A function called synchronously after parsing the glTF properties
  64902. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64903. */
  64904. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64905. /**
  64906. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64907. * @param context The context when loading the asset
  64908. * @param primitive The glTF mesh primitive property
  64909. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64910. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64911. /**
  64912. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64913. * @param context The context when loading the asset
  64914. * @param name The mesh name when loading the asset
  64915. * @param node The glTF node when loading the asset
  64916. * @param mesh The glTF mesh when loading the asset
  64917. * @param primitive The glTF mesh primitive property
  64918. * @param assign A function called synchronously after parsing the glTF properties
  64919. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64920. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64921. /**
  64922. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64923. * @param context The context when loading the asset
  64924. * @param material The glTF material property
  64925. * @param assign A function called synchronously after parsing the glTF properties
  64926. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64927. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64928. /**
  64929. * Define this method to modify the default behavior when creating materials.
  64930. * @param context The context when loading the asset
  64931. * @param material The glTF material property
  64932. * @param babylonDrawMode The draw mode for the Babylon material
  64933. * @returns The Babylon material or null if not handled
  64934. */
  64935. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64936. /**
  64937. * Define this method to modify the default behavior when loading material properties.
  64938. * @param context The context when loading the asset
  64939. * @param material The glTF material property
  64940. * @param babylonMaterial The Babylon material
  64941. * @returns A promise that resolves when the load is complete or null if not handled
  64942. */
  64943. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64944. /**
  64945. * Define this method to modify the default behavior when loading texture infos.
  64946. * @param context The context when loading the asset
  64947. * @param textureInfo The glTF texture info property
  64948. * @param assign A function called synchronously after parsing the glTF properties
  64949. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64950. */
  64951. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64952. /**
  64953. * Define this method to modify the default behavior when loading animations.
  64954. * @param context The context when loading the asset
  64955. * @param animation The glTF animation property
  64956. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64957. */
  64958. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64959. /**
  64960. * @hidden Define this method to modify the default behavior when loading skins.
  64961. * @param context The context when loading the asset
  64962. * @param node The glTF node property
  64963. * @param skin The glTF skin property
  64964. * @returns A promise that resolves when the load is complete or null if not handled
  64965. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64966. /**
  64967. * @hidden Define this method to modify the default behavior when loading uris.
  64968. * @param context The context when loading the asset
  64969. * @param property The glTF property associated with the uri
  64970. * @param uri The uri to load
  64971. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64972. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64973. }
  64974. }
  64975. declare module BABYLON.GLTF2 {
  64976. /**
  64977. * Helper class for working with arrays when loading the glTF asset
  64978. */
  64979. export class ArrayItem {
  64980. /**
  64981. * Gets an item from the given array.
  64982. * @param context The context when loading the asset
  64983. * @param array The array to get the item from
  64984. * @param index The index to the array
  64985. * @returns The array item
  64986. */
  64987. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64988. /**
  64989. * Assign an `index` field to each item of the given array.
  64990. * @param array The array of items
  64991. */
  64992. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64993. }
  64994. /**
  64995. * The glTF 2.0 loader
  64996. */
  64997. export class GLTFLoader implements IGLTFLoader {
  64998. /** @hidden */ private _completePromises: Promise<any>[];
  64999. private _disposed;
  65000. private _parent;
  65001. private _state;
  65002. private _extensions;
  65003. private _rootUrl;
  65004. private _fileName;
  65005. private _uniqueRootUrl;
  65006. private _gltf;
  65007. private _babylonScene;
  65008. private _rootBabylonMesh;
  65009. private _defaultBabylonMaterialData;
  65010. private _progressCallback?;
  65011. private _requests;
  65012. private static readonly _DefaultSampler;
  65013. private static _ExtensionNames;
  65014. private static _ExtensionFactories;
  65015. /**
  65016. * Registers a loader extension.
  65017. * @param name The name of the loader extension.
  65018. * @param factory The factory function that creates the loader extension.
  65019. */
  65020. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65021. /**
  65022. * Unregisters a loader extension.
  65023. * @param name The name of the loader extenion.
  65024. * @returns A boolean indicating whether the extension has been unregistered
  65025. */
  65026. static UnregisterExtension(name: string): boolean;
  65027. /**
  65028. * Gets the loader state.
  65029. */
  65030. readonly state: Nullable<GLTFLoaderState>;
  65031. /**
  65032. * The glTF object parsed from the JSON.
  65033. */
  65034. readonly gltf: IGLTF;
  65035. /**
  65036. * The Babylon scene when loading the asset.
  65037. */
  65038. readonly babylonScene: Scene;
  65039. /**
  65040. * The root Babylon mesh when loading the asset.
  65041. */
  65042. readonly rootBabylonMesh: Mesh;
  65043. /** @hidden */
  65044. constructor(parent: GLTFFileLoader);
  65045. /** @hidden */
  65046. dispose(): void;
  65047. /** @hidden */
  65048. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65049. meshes: AbstractMesh[];
  65050. particleSystems: IParticleSystem[];
  65051. skeletons: Skeleton[];
  65052. animationGroups: AnimationGroup[];
  65053. }>;
  65054. /** @hidden */
  65055. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65056. private _loadAsync;
  65057. private _loadData;
  65058. private _setupData;
  65059. private _loadExtensions;
  65060. private _checkExtensions;
  65061. private _setState;
  65062. private _createRootNode;
  65063. /**
  65064. * Loads a glTF scene.
  65065. * @param context The context when loading the asset
  65066. * @param scene The glTF scene property
  65067. * @returns A promise that resolves when the load is complete
  65068. */
  65069. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65070. private _forEachPrimitive;
  65071. private _getMeshes;
  65072. private _getSkeletons;
  65073. private _getAnimationGroups;
  65074. private _startAnimations;
  65075. /**
  65076. * Loads a glTF node.
  65077. * @param context The context when loading the asset
  65078. * @param node The glTF node property
  65079. * @param assign A function called synchronously after parsing the glTF properties
  65080. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65081. */
  65082. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65083. private _loadMeshAsync;
  65084. /**
  65085. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65086. * @param context The context when loading the asset
  65087. * @param name The mesh name when loading the asset
  65088. * @param node The glTF node when loading the asset
  65089. * @param mesh The glTF mesh when loading the asset
  65090. * @param primitive The glTF mesh primitive property
  65091. * @param assign A function called synchronously after parsing the glTF properties
  65092. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65093. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65094. private _loadVertexDataAsync;
  65095. private _createMorphTargets;
  65096. private _loadMorphTargetsAsync;
  65097. private _loadMorphTargetVertexDataAsync;
  65098. private static _LoadTransform;
  65099. private _loadSkinAsync;
  65100. private _loadBones;
  65101. private _loadBone;
  65102. private _loadSkinInverseBindMatricesDataAsync;
  65103. private _updateBoneMatrices;
  65104. private _getNodeMatrix;
  65105. /**
  65106. * Loads a glTF camera.
  65107. * @param context The context when loading the asset
  65108. * @param camera The glTF camera property
  65109. * @param assign A function called synchronously after parsing the glTF properties
  65110. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65111. */
  65112. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65113. private _loadAnimationsAsync;
  65114. /**
  65115. * Loads a glTF animation.
  65116. * @param context The context when loading the asset
  65117. * @param animation The glTF animation property
  65118. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65119. */
  65120. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65121. /**
  65122. * @hidden Loads a glTF animation channel.
  65123. * @param context The context when loading the asset
  65124. * @param animationContext The context of the animation when loading the asset
  65125. * @param animation The glTF animation property
  65126. * @param channel The glTF animation channel property
  65127. * @param babylonAnimationGroup The babylon animation group property
  65128. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65129. * @returns A void promise when the channel load is complete
  65130. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65131. private _loadAnimationSamplerAsync;
  65132. private _loadBufferAsync;
  65133. /**
  65134. * Loads a glTF buffer view.
  65135. * @param context The context when loading the asset
  65136. * @param bufferView The glTF buffer view property
  65137. * @returns A promise that resolves with the loaded data when the load is complete
  65138. */
  65139. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65140. private _loadAccessorAsync;
  65141. private _loadFloatAccessorAsync;
  65142. private _loadIndicesAccessorAsync;
  65143. private _loadVertexBufferViewAsync;
  65144. private _loadVertexAccessorAsync;
  65145. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65146. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65147. private _createDefaultMaterial;
  65148. /**
  65149. * Creates a Babylon material from a glTF material.
  65150. * @param context The context when loading the asset
  65151. * @param material The glTF material property
  65152. * @param babylonDrawMode The draw mode for the Babylon material
  65153. * @returns The Babylon material
  65154. */
  65155. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65156. /**
  65157. * Loads properties from a glTF material into a Babylon material.
  65158. * @param context The context when loading the asset
  65159. * @param material The glTF material property
  65160. * @param babylonMaterial The Babylon material
  65161. * @returns A promise that resolves when the load is complete
  65162. */
  65163. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65164. /**
  65165. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65166. * @param context The context when loading the asset
  65167. * @param material The glTF material property
  65168. * @param babylonMaterial The Babylon material
  65169. * @returns A promise that resolves when the load is complete
  65170. */
  65171. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65172. /**
  65173. * Loads the alpha properties from a glTF material into a Babylon material.
  65174. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65175. * @param context The context when loading the asset
  65176. * @param material The glTF material property
  65177. * @param babylonMaterial The Babylon material
  65178. */
  65179. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65180. /**
  65181. * Loads a glTF texture info.
  65182. * @param context The context when loading the asset
  65183. * @param textureInfo The glTF texture info property
  65184. * @param assign A function called synchronously after parsing the glTF properties
  65185. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65186. */
  65187. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65188. private _loadTextureAsync;
  65189. private _loadSampler;
  65190. /**
  65191. * Loads a glTF image.
  65192. * @param context The context when loading the asset
  65193. * @param image The glTF image property
  65194. * @returns A promise that resolves with the loaded data when the load is complete
  65195. */
  65196. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65197. /**
  65198. * Loads a glTF uri.
  65199. * @param context The context when loading the asset
  65200. * @param property The glTF property associated with the uri
  65201. * @param uri The base64 or relative uri
  65202. * @returns A promise that resolves with the loaded data when the load is complete
  65203. */
  65204. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65205. private _onProgress;
  65206. /**
  65207. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65208. * @param babylonObject the Babylon object with metadata
  65209. * @param pointer the JSON pointer
  65210. */
  65211. static AddPointerMetadata(babylonObject: {
  65212. metadata: any;
  65213. }, pointer: string): void;
  65214. private static _GetTextureWrapMode;
  65215. private static _GetTextureSamplingMode;
  65216. private static _GetTypedArrayConstructor;
  65217. private static _GetTypedArray;
  65218. private static _GetNumComponents;
  65219. private static _ValidateUri;
  65220. private static _GetDrawMode;
  65221. private _compileMaterialsAsync;
  65222. private _compileShadowGeneratorsAsync;
  65223. private _forEachExtensions;
  65224. private _applyExtensions;
  65225. private _extensionsOnLoading;
  65226. private _extensionsOnReady;
  65227. private _extensionsLoadSceneAsync;
  65228. private _extensionsLoadNodeAsync;
  65229. private _extensionsLoadCameraAsync;
  65230. private _extensionsLoadVertexDataAsync;
  65231. private _extensionsLoadMeshPrimitiveAsync;
  65232. private _extensionsLoadMaterialAsync;
  65233. private _extensionsCreateMaterial;
  65234. private _extensionsLoadMaterialPropertiesAsync;
  65235. private _extensionsLoadTextureInfoAsync;
  65236. private _extensionsLoadAnimationAsync;
  65237. private _extensionsLoadSkinAsync;
  65238. private _extensionsLoadUriAsync;
  65239. /**
  65240. * Helper method called by a loader extension to load an glTF extension.
  65241. * @param context The context when loading the asset
  65242. * @param property The glTF property to load the extension from
  65243. * @param extensionName The name of the extension to load
  65244. * @param actionAsync The action to run
  65245. * @returns The promise returned by actionAsync or null if the extension does not exist
  65246. */
  65247. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65248. /**
  65249. * Helper method called by a loader extension to load a glTF extra.
  65250. * @param context The context when loading the asset
  65251. * @param property The glTF property to load the extra from
  65252. * @param extensionName The name of the extension to load
  65253. * @param actionAsync The action to run
  65254. * @returns The promise returned by actionAsync or null if the extra does not exist
  65255. */
  65256. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65257. /**
  65258. * Increments the indentation level and logs a message.
  65259. * @param message The message to log
  65260. */
  65261. logOpen(message: string): void;
  65262. /**
  65263. * Decrements the indentation level.
  65264. */
  65265. logClose(): void;
  65266. /**
  65267. * Logs a message
  65268. * @param message The message to log
  65269. */
  65270. log(message: string): void;
  65271. /**
  65272. * Starts a performance counter.
  65273. * @param counterName The name of the performance counter
  65274. */
  65275. startPerformanceCounter(counterName: string): void;
  65276. /**
  65277. * Ends a performance counter.
  65278. * @param counterName The name of the performance counter
  65279. */
  65280. endPerformanceCounter(counterName: string): void;
  65281. }
  65282. }
  65283. declare module BABYLON.GLTF2.Loader.Extensions {
  65284. /**
  65285. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65286. */
  65287. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65288. /** The name of this extension. */
  65289. readonly name: string;
  65290. /** Defines whether this extension is enabled. */
  65291. enabled: boolean;
  65292. private _loader;
  65293. private _lights?;
  65294. /** @hidden */
  65295. constructor(loader: GLTFLoader);
  65296. /** @hidden */
  65297. dispose(): void;
  65298. /** @hidden */
  65299. onLoading(): void;
  65300. /** @hidden */
  65301. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65302. private _loadLightAsync;
  65303. }
  65304. }
  65305. declare module BABYLON.GLTF2.Loader.Extensions {
  65306. /**
  65307. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65308. */
  65309. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  65310. /** The name of this extension. */
  65311. readonly name: string;
  65312. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  65313. dracoCompression?: DracoCompression;
  65314. /** Defines whether this extension is enabled. */
  65315. enabled: boolean;
  65316. private _loader;
  65317. /** @hidden */
  65318. constructor(loader: GLTFLoader);
  65319. /** @hidden */
  65320. dispose(): void;
  65321. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65322. }
  65323. }
  65324. declare module BABYLON.GLTF2.Loader.Extensions {
  65325. /**
  65326. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65327. */
  65328. export class KHR_lights implements IGLTFLoaderExtension {
  65329. /** The name of this extension. */
  65330. readonly name: string;
  65331. /** Defines whether this extension is enabled. */
  65332. enabled: boolean;
  65333. private _loader;
  65334. private _lights?;
  65335. /** @hidden */
  65336. constructor(loader: GLTFLoader);
  65337. /** @hidden */
  65338. dispose(): void;
  65339. /** @hidden */
  65340. onLoading(): void;
  65341. /** @hidden */
  65342. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65343. }
  65344. }
  65345. declare module BABYLON.GLTF2.Loader.Extensions {
  65346. /**
  65347. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65348. */
  65349. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65350. /** The name of this extension. */
  65351. readonly name: string;
  65352. /** Defines whether this extension is enabled. */
  65353. enabled: boolean;
  65354. private _loader;
  65355. /** @hidden */
  65356. constructor(loader: GLTFLoader);
  65357. /** @hidden */
  65358. dispose(): void;
  65359. /** @hidden */
  65360. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65361. private _loadSpecularGlossinessPropertiesAsync;
  65362. }
  65363. }
  65364. declare module BABYLON.GLTF2.Loader.Extensions {
  65365. /**
  65366. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65367. */
  65368. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65369. /** The name of this extension. */
  65370. readonly name: string;
  65371. /** Defines whether this extension is enabled. */
  65372. enabled: boolean;
  65373. private _loader;
  65374. /** @hidden */
  65375. constructor(loader: GLTFLoader);
  65376. /** @hidden */
  65377. dispose(): void;
  65378. /** @hidden */
  65379. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65380. private _loadUnlitPropertiesAsync;
  65381. }
  65382. }
  65383. declare module BABYLON.GLTF2.Loader.Extensions {
  65384. /**
  65385. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65386. */
  65387. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65388. /** The name of this extension. */
  65389. readonly name: string;
  65390. /** Defines whether this extension is enabled. */
  65391. enabled: boolean;
  65392. private _loader;
  65393. /** @hidden */
  65394. constructor(loader: GLTFLoader);
  65395. /** @hidden */
  65396. dispose(): void;
  65397. /** @hidden */
  65398. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65399. }
  65400. }
  65401. declare module BABYLON.GLTF2.Loader.Extensions {
  65402. /**
  65403. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65404. */
  65405. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65406. /** The name of this extension. */
  65407. readonly name: string;
  65408. /** Defines whether this extension is enabled. */
  65409. enabled: boolean;
  65410. private _loader;
  65411. private _clips;
  65412. private _emitters;
  65413. /** @hidden */
  65414. constructor(loader: GLTFLoader);
  65415. /** @hidden */
  65416. dispose(): void;
  65417. /** @hidden */
  65418. onLoading(): void;
  65419. /** @hidden */
  65420. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65421. /** @hidden */
  65422. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65423. /** @hidden */
  65424. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65425. private _loadClipAsync;
  65426. private _loadEmitterAsync;
  65427. private _getEventAction;
  65428. private _loadAnimationEventAsync;
  65429. }
  65430. }
  65431. declare module BABYLON.GLTF2.Loader.Extensions {
  65432. /**
  65433. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65434. */
  65435. export class MSFT_lod implements IGLTFLoaderExtension {
  65436. /** The name of this extension. */
  65437. readonly name: string;
  65438. /** Defines whether this extension is enabled. */
  65439. enabled: boolean;
  65440. /**
  65441. * Maximum number of LODs to load, starting from the lowest LOD.
  65442. */
  65443. maxLODsToLoad: number;
  65444. /**
  65445. * Observable raised when all node LODs of one level are loaded.
  65446. * The event data is the index of the loaded LOD starting from zero.
  65447. * Dispose the loader to cancel the loading of the next level of LODs.
  65448. */
  65449. onNodeLODsLoadedObservable: Observable<number>;
  65450. /**
  65451. * Observable raised when all material LODs of one level are loaded.
  65452. * The event data is the index of the loaded LOD starting from zero.
  65453. * Dispose the loader to cancel the loading of the next level of LODs.
  65454. */
  65455. onMaterialLODsLoadedObservable: Observable<number>;
  65456. private _loader;
  65457. private _nodeIndexLOD;
  65458. private _nodeSignalLODs;
  65459. private _nodePromiseLODs;
  65460. private _materialIndexLOD;
  65461. private _materialSignalLODs;
  65462. private _materialPromiseLODs;
  65463. /** @hidden */
  65464. constructor(loader: GLTFLoader);
  65465. /** @hidden */
  65466. dispose(): void;
  65467. /** @hidden */
  65468. onReady(): void;
  65469. /** @hidden */
  65470. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65471. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65472. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65473. /**
  65474. * Gets an array of LOD properties from lowest to highest.
  65475. */
  65476. private _getLODs;
  65477. private _disposeUnusedMaterials;
  65478. }
  65479. }
  65480. declare module BABYLON.GLTF2.Loader.Extensions {
  65481. /** @hidden */
  65482. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65483. readonly name: string;
  65484. enabled: boolean;
  65485. private _loader;
  65486. constructor(loader: GLTFLoader);
  65487. dispose(): void;
  65488. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65489. }
  65490. }
  65491. declare module BABYLON.GLTF2.Loader.Extensions {
  65492. /** @hidden */
  65493. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65494. readonly name: string;
  65495. enabled: boolean;
  65496. private _loader;
  65497. constructor(loader: GLTFLoader);
  65498. dispose(): void;
  65499. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65500. }
  65501. }
  65502. declare module BABYLON.GLTF2.Loader.Extensions {
  65503. /**
  65504. * Store glTF extras (if present) in BJS objects' metadata
  65505. */
  65506. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  65507. /** The name of this extension. */
  65508. readonly name: string;
  65509. /** Defines whether this extension is enabled. */
  65510. enabled: boolean;
  65511. private _loader;
  65512. private _assignExtras;
  65513. /** @hidden */
  65514. constructor(loader: GLTFLoader);
  65515. /** @hidden */
  65516. dispose(): void;
  65517. /** @hidden */
  65518. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65519. /** @hidden */
  65520. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65521. /** @hidden */
  65522. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65523. }
  65524. }
  65525. declare module BABYLON {
  65526. /**
  65527. * Class reading and parsing the MTL file bundled with the obj file.
  65528. */
  65529. export class MTLFileLoader {
  65530. /**
  65531. * All material loaded from the mtl will be set here
  65532. */
  65533. materials: StandardMaterial[];
  65534. /**
  65535. * This function will read the mtl file and create each material described inside
  65536. * This function could be improve by adding :
  65537. * -some component missing (Ni, Tf...)
  65538. * -including the specific options available
  65539. *
  65540. * @param scene defines the scene the material will be created in
  65541. * @param data defines the mtl data to parse
  65542. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65543. */
  65544. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65545. /**
  65546. * Gets the texture for the material.
  65547. *
  65548. * If the material is imported from input file,
  65549. * We sanitize the url to ensure it takes the textre from aside the material.
  65550. *
  65551. * @param rootUrl The root url to load from
  65552. * @param value The value stored in the mtl
  65553. * @return The Texture
  65554. */
  65555. private static _getTexture;
  65556. }
  65557. /**
  65558. * Options for loading OBJ/MTL files
  65559. */
  65560. type MeshLoadOptions = {
  65561. /**
  65562. * Defines if UVs are optimized by default during load.
  65563. */
  65564. OptimizeWithUV: boolean;
  65565. /**
  65566. * Defines custom scaling of UV coordinates of loaded meshes.
  65567. */
  65568. UVScaling: Vector2;
  65569. /**
  65570. * Invert model on y-axis (does a model scaling inversion)
  65571. */
  65572. InvertY: boolean;
  65573. /**
  65574. * Invert Y-Axis of referenced textures on load
  65575. */
  65576. InvertTextureY: boolean;
  65577. /**
  65578. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65579. */
  65580. ImportVertexColors: boolean;
  65581. /**
  65582. * Compute the normals for the model, even if normals are present in the file.
  65583. */
  65584. ComputeNormals: boolean;
  65585. /**
  65586. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65587. */
  65588. SkipMaterials: boolean;
  65589. /**
  65590. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65591. */
  65592. MaterialLoadingFailsSilently: boolean;
  65593. };
  65594. /**
  65595. * OBJ file type loader.
  65596. * This is a babylon scene loader plugin.
  65597. */
  65598. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65599. /**
  65600. * Defines if UVs are optimized by default during load.
  65601. */
  65602. static OPTIMIZE_WITH_UV: boolean;
  65603. /**
  65604. * Invert model on y-axis (does a model scaling inversion)
  65605. */
  65606. static INVERT_Y: boolean;
  65607. /**
  65608. * Invert Y-Axis of referenced textures on load
  65609. */
  65610. static INVERT_TEXTURE_Y: boolean;
  65611. /**
  65612. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65613. */
  65614. static IMPORT_VERTEX_COLORS: boolean;
  65615. /**
  65616. * Compute the normals for the model, even if normals are present in the file.
  65617. */
  65618. static COMPUTE_NORMALS: boolean;
  65619. /**
  65620. * Defines custom scaling of UV coordinates of loaded meshes.
  65621. */
  65622. static UV_SCALING: Vector2;
  65623. /**
  65624. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65625. */
  65626. static SKIP_MATERIALS: boolean;
  65627. /**
  65628. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65629. *
  65630. * Defaults to true for backwards compatibility.
  65631. */
  65632. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65633. /**
  65634. * Defines the name of the plugin.
  65635. */
  65636. name: string;
  65637. /**
  65638. * Defines the extension the plugin is able to load.
  65639. */
  65640. extensions: string;
  65641. /** @hidden */
  65642. obj: RegExp;
  65643. /** @hidden */
  65644. group: RegExp;
  65645. /** @hidden */
  65646. mtllib: RegExp;
  65647. /** @hidden */
  65648. usemtl: RegExp;
  65649. /** @hidden */
  65650. smooth: RegExp;
  65651. /** @hidden */
  65652. vertexPattern: RegExp;
  65653. /** @hidden */
  65654. normalPattern: RegExp;
  65655. /** @hidden */
  65656. uvPattern: RegExp;
  65657. /** @hidden */
  65658. facePattern1: RegExp;
  65659. /** @hidden */
  65660. facePattern2: RegExp;
  65661. /** @hidden */
  65662. facePattern3: RegExp;
  65663. /** @hidden */
  65664. facePattern4: RegExp;
  65665. /** @hidden */
  65666. facePattern5: RegExp;
  65667. private _meshLoadOptions;
  65668. /**
  65669. * Creates loader for .OBJ files
  65670. *
  65671. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65672. */
  65673. constructor(meshLoadOptions?: MeshLoadOptions);
  65674. private static readonly currentMeshLoadOptions;
  65675. /**
  65676. * Calls synchronously the MTL file attached to this obj.
  65677. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65678. * Without this function materials are not displayed in the first frame (but displayed after).
  65679. * In consequence it is impossible to get material information in your HTML file
  65680. *
  65681. * @param url The URL of the MTL file
  65682. * @param rootUrl
  65683. * @param onSuccess Callback function to be called when the MTL file is loaded
  65684. * @private
  65685. */
  65686. private _loadMTL;
  65687. /**
  65688. * Instantiates a OBJ file loader plugin.
  65689. * @returns the created plugin
  65690. */
  65691. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65692. /**
  65693. * If the data string can be loaded directly.
  65694. *
  65695. * @param data string containing the file data
  65696. * @returns if the data can be loaded directly
  65697. */
  65698. canDirectLoad(data: string): boolean;
  65699. /**
  65700. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65701. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65702. * @param scene the scene the meshes should be added to
  65703. * @param data the OBJ data to load
  65704. * @param rootUrl root url to load from
  65705. * @param onProgress event that fires when loading progress has occured
  65706. * @param fileName Defines the name of the file to load
  65707. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65708. */
  65709. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65710. meshes: AbstractMesh[];
  65711. particleSystems: IParticleSystem[];
  65712. skeletons: Skeleton[];
  65713. animationGroups: AnimationGroup[];
  65714. }>;
  65715. /**
  65716. * Imports all objects from the loaded OBJ data and adds them to the scene
  65717. * @param scene the scene the objects should be added to
  65718. * @param data the OBJ data to load
  65719. * @param rootUrl root url to load from
  65720. * @param onProgress event that fires when loading progress has occured
  65721. * @param fileName Defines the name of the file to load
  65722. * @returns a promise which completes when objects have been loaded to the scene
  65723. */
  65724. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65725. /**
  65726. * Load into an asset container.
  65727. * @param scene The scene to load into
  65728. * @param data The data to import
  65729. * @param rootUrl The root url for scene and resources
  65730. * @param onProgress The callback when the load progresses
  65731. * @param fileName Defines the name of the file to load
  65732. * @returns The loaded asset container
  65733. */
  65734. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65735. /**
  65736. * Read the OBJ file and create an Array of meshes.
  65737. * Each mesh contains all information given by the OBJ and the MTL file.
  65738. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65739. *
  65740. * @param meshesNames
  65741. * @param scene Scene The scene where are displayed the data
  65742. * @param data String The content of the obj file
  65743. * @param rootUrl String The path to the folder
  65744. * @returns Array<AbstractMesh>
  65745. * @private
  65746. */
  65747. private _parseSolid;
  65748. }
  65749. }
  65750. declare module BABYLON {
  65751. /**
  65752. * STL file type loader.
  65753. * This is a babylon scene loader plugin.
  65754. */
  65755. export class STLFileLoader implements ISceneLoaderPlugin {
  65756. /** @hidden */
  65757. solidPattern: RegExp;
  65758. /** @hidden */
  65759. facetsPattern: RegExp;
  65760. /** @hidden */
  65761. normalPattern: RegExp;
  65762. /** @hidden */
  65763. vertexPattern: RegExp;
  65764. /**
  65765. * Defines the name of the plugin.
  65766. */
  65767. name: string;
  65768. /**
  65769. * Defines the extensions the stl loader is able to load.
  65770. * force data to come in as an ArrayBuffer
  65771. * we'll convert to string if it looks like it's an ASCII .stl
  65772. */
  65773. extensions: ISceneLoaderPluginExtensions;
  65774. /**
  65775. * Import meshes into a scene.
  65776. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65777. * @param scene The scene to import into
  65778. * @param data The data to import
  65779. * @param rootUrl The root url for scene and resources
  65780. * @param meshes The meshes array to import into
  65781. * @param particleSystems The particle systems array to import into
  65782. * @param skeletons The skeletons array to import into
  65783. * @param onError The callback when import fails
  65784. * @returns True if successful or false otherwise
  65785. */
  65786. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65787. /**
  65788. * Load into a scene.
  65789. * @param scene The scene to load into
  65790. * @param data The data to import
  65791. * @param rootUrl The root url for scene and resources
  65792. * @param onError The callback when import fails
  65793. * @returns true if successful or false otherwise
  65794. */
  65795. load(scene: Scene, data: any, rootUrl: string): boolean;
  65796. /**
  65797. * Load into an asset container.
  65798. * @param scene The scene to load into
  65799. * @param data The data to import
  65800. * @param rootUrl The root url for scene and resources
  65801. * @param onError The callback when import fails
  65802. * @returns The loaded asset container
  65803. */
  65804. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65805. private _isBinary;
  65806. private _parseBinary;
  65807. private _parseASCII;
  65808. }
  65809. }
  65810. declare module BABYLON {
  65811. /**
  65812. * Class for generating OBJ data from a Babylon scene.
  65813. */
  65814. export class OBJExport {
  65815. /**
  65816. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65817. * @param mesh defines the list of meshes to serialize
  65818. * @param materials defines if materials should be exported
  65819. * @param matlibname defines the name of the associated mtl file
  65820. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65821. * @returns the OBJ content
  65822. */
  65823. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65824. /**
  65825. * Exports the material(s) of a mesh in .MTL file format (text)
  65826. * @param mesh defines the mesh to extract the material from
  65827. * @returns the mtl content
  65828. */
  65829. static MTL(mesh: Mesh): string;
  65830. }
  65831. }
  65832. declare module BABYLON {
  65833. /** @hidden */
  65834. export var __IGLTFExporterExtension: number;
  65835. /**
  65836. * Interface for extending the exporter
  65837. * @hidden
  65838. */
  65839. export interface IGLTFExporterExtension {
  65840. /**
  65841. * The name of this extension
  65842. */
  65843. readonly name: string;
  65844. /**
  65845. * Defines whether this extension is enabled
  65846. */
  65847. enabled: boolean;
  65848. /**
  65849. * Defines whether this extension is required
  65850. */
  65851. required: boolean;
  65852. }
  65853. }
  65854. declare module BABYLON.GLTF2.Exporter {
  65855. /** @hidden */
  65856. export var __IGLTFExporterExtensionV2: number;
  65857. /**
  65858. * Interface for a glTF exporter extension
  65859. * @hidden
  65860. */
  65861. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65862. /**
  65863. * Define this method to modify the default behavior before exporting a texture
  65864. * @param context The context when loading the asset
  65865. * @param babylonTexture The glTF texture info property
  65866. * @param mimeType The mime-type of the generated image
  65867. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65868. */
  65869. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65870. /**
  65871. * Define this method to modify the default behavior when exporting texture info
  65872. * @param context The context when loading the asset
  65873. * @param meshPrimitive glTF mesh primitive
  65874. * @param babylonSubMesh Babylon submesh
  65875. * @param binaryWriter glTF serializer binary writer instance
  65876. * @returns nullable IMeshPrimitive promise
  65877. */
  65878. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65879. /**
  65880. * Define this method to modify the default behavior when exporting a node
  65881. * @param context The context when exporting the node
  65882. * @param node glTF node
  65883. * @param babylonNode BabylonJS node
  65884. * @returns nullable INode promise
  65885. */
  65886. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65887. /**
  65888. * Called after the exporter state changes to EXPORTING
  65889. */
  65890. onExporting?(): void;
  65891. }
  65892. }
  65893. declare module BABYLON.GLTF2.Exporter {
  65894. /**
  65895. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65896. * @hidden
  65897. */
  65898. export class _GLTFMaterialExporter {
  65899. /**
  65900. * Represents the dielectric specular values for R, G and B
  65901. */
  65902. private static readonly _DielectricSpecular;
  65903. /**
  65904. * Allows the maximum specular power to be defined for material calculations
  65905. */
  65906. private static readonly _MaxSpecularPower;
  65907. /**
  65908. * Mapping to store textures
  65909. */
  65910. private _textureMap;
  65911. /**
  65912. * Numeric tolerance value
  65913. */
  65914. private static readonly _Epsilon;
  65915. /**
  65916. * Reference to the glTF Exporter
  65917. */
  65918. private _exporter;
  65919. constructor(exporter: _Exporter);
  65920. /**
  65921. * Specifies if two colors are approximately equal in value
  65922. * @param color1 first color to compare to
  65923. * @param color2 second color to compare to
  65924. * @param epsilon threshold value
  65925. */
  65926. private static FuzzyEquals;
  65927. /**
  65928. * Gets the materials from a Babylon scene and converts them to glTF materials
  65929. * @param scene babylonjs scene
  65930. * @param mimeType texture mime type
  65931. * @param images array of images
  65932. * @param textures array of textures
  65933. * @param materials array of materials
  65934. * @param imageData mapping of texture names to base64 textures
  65935. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65936. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65937. /**
  65938. * Makes a copy of the glTF material without the texture parameters
  65939. * @param originalMaterial original glTF material
  65940. * @returns glTF material without texture parameters
  65941. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65942. /**
  65943. * Specifies if the material has any texture parameters present
  65944. * @param material glTF Material
  65945. * @returns boolean specifying if texture parameters are present
  65946. */ private _hasTexturesPresent(material: IMaterial): boolean;
  65947. /**
  65948. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65949. * @param babylonStandardMaterial
  65950. * @returns glTF Metallic Roughness Material representation
  65951. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65952. /**
  65953. * Computes the metallic factor
  65954. * @param diffuse diffused value
  65955. * @param specular specular value
  65956. * @param oneMinusSpecularStrength one minus the specular strength
  65957. * @returns metallic value
  65958. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65959. /**
  65960. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65961. * @param glTFMaterial glTF material
  65962. * @param babylonMaterial Babylon material
  65963. */
  65964. private static _SetAlphaMode;
  65965. /**
  65966. * Converts a Babylon Standard Material to a glTF Material
  65967. * @param babylonStandardMaterial BJS Standard Material
  65968. * @param mimeType mime type to use for the textures
  65969. * @param images array of glTF image interfaces
  65970. * @param textures array of glTF texture interfaces
  65971. * @param materials array of glTF material interfaces
  65972. * @param imageData map of image file name to data
  65973. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65974. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65975. /**
  65976. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65977. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65978. * @param mimeType mime type to use for the textures
  65979. * @param images array of glTF image interfaces
  65980. * @param textures array of glTF texture interfaces
  65981. * @param materials array of glTF material interfaces
  65982. * @param imageData map of image file name to data
  65983. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65984. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65985. /**
  65986. * Converts an image typed array buffer to a base64 image
  65987. * @param buffer typed array buffer
  65988. * @param width width of the image
  65989. * @param height height of the image
  65990. * @param mimeType mimetype of the image
  65991. * @returns base64 image string
  65992. */
  65993. private _createBase64FromCanvasAsync;
  65994. /**
  65995. * Generates a white texture based on the specified width and height
  65996. * @param width width of the texture in pixels
  65997. * @param height height of the texture in pixels
  65998. * @param scene babylonjs scene
  65999. * @returns white texture
  66000. */
  66001. private _createWhiteTexture;
  66002. /**
  66003. * 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
  66004. * @param texture1 first texture to resize
  66005. * @param texture2 second texture to resize
  66006. * @param scene babylonjs scene
  66007. * @returns resized textures or null
  66008. */
  66009. private _resizeTexturesToSameDimensions;
  66010. /**
  66011. * Converts an array of pixels to a Float32Array
  66012. * Throws an error if the pixel format is not supported
  66013. * @param pixels - array buffer containing pixel values
  66014. * @returns Float32 of pixels
  66015. */
  66016. private _convertPixelArrayToFloat32;
  66017. /**
  66018. * Convert Specular Glossiness Textures to Metallic Roughness
  66019. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66020. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66021. * @param diffuseTexture texture used to store diffuse information
  66022. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66023. * @param factors specular glossiness material factors
  66024. * @param mimeType the mime type to use for the texture
  66025. * @returns pbr metallic roughness interface or null
  66026. */
  66027. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66028. /**
  66029. * Converts specular glossiness material properties to metallic roughness
  66030. * @param specularGlossiness interface with specular glossiness material properties
  66031. * @returns interface with metallic roughness material properties
  66032. */
  66033. private _convertSpecularGlossinessToMetallicRoughness;
  66034. /**
  66035. * Calculates the surface reflectance, independent of lighting conditions
  66036. * @param color Color source to calculate brightness from
  66037. * @returns number representing the perceived brightness, or zero if color is undefined
  66038. */
  66039. private _getPerceivedBrightness;
  66040. /**
  66041. * Returns the maximum color component value
  66042. * @param color
  66043. * @returns maximum color component value, or zero if color is null or undefined
  66044. */
  66045. private _getMaxComponent;
  66046. /**
  66047. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66048. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66049. * @param mimeType mime type to use for the textures
  66050. * @param images array of glTF image interfaces
  66051. * @param textures array of glTF texture interfaces
  66052. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66053. * @param imageData map of image file name to data
  66054. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66055. * @returns glTF PBR Metallic Roughness factors
  66056. */
  66057. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66058. private _getGLTFTextureSampler;
  66059. private _getGLTFTextureWrapMode;
  66060. private _getGLTFTextureWrapModesSampler;
  66061. /**
  66062. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66063. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66064. * @param mimeType mime type to use for the textures
  66065. * @param images array of glTF image interfaces
  66066. * @param textures array of glTF texture interfaces
  66067. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66068. * @param imageData map of image file name to data
  66069. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66070. * @returns glTF PBR Metallic Roughness factors
  66071. */
  66072. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66073. /**
  66074. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66075. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66076. * @param mimeType mime type to use for the textures
  66077. * @param images array of glTF image interfaces
  66078. * @param textures array of glTF texture interfaces
  66079. * @param materials array of glTF material interfaces
  66080. * @param imageData map of image file name to data
  66081. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66082. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66083. private setMetallicRoughnessPbrMaterial;
  66084. private getPixelsFromTexture;
  66085. /**
  66086. * Extracts a texture from a Babylon texture into file data and glTF data
  66087. * @param babylonTexture Babylon texture to extract
  66088. * @param mimeType Mime Type of the babylonTexture
  66089. * @return glTF texture info, or null if the texture format is not supported
  66090. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66091. /**
  66092. * Builds a texture from base64 string
  66093. * @param base64Texture base64 texture string
  66094. * @param baseTextureName Name to use for the texture
  66095. * @param mimeType image mime type for the texture
  66096. * @param images array of images
  66097. * @param textures array of textures
  66098. * @param imageData map of image data
  66099. * @returns glTF texture info, or null if the texture format is not supported
  66100. */
  66101. private _getTextureInfoFromBase64;
  66102. }
  66103. }
  66104. declare module BABYLON {
  66105. /**
  66106. * Class for holding and downloading glTF file data
  66107. */
  66108. export class GLTFData {
  66109. /**
  66110. * Object which contains the file name as the key and its data as the value
  66111. */
  66112. glTFFiles: {
  66113. [fileName: string]: string | Blob;
  66114. };
  66115. /**
  66116. * Initializes the glTF file object
  66117. */
  66118. constructor();
  66119. /**
  66120. * Downloads the glTF data as files based on their names and data
  66121. */
  66122. downloadFiles(): void;
  66123. }
  66124. }
  66125. declare module BABYLON {
  66126. /**
  66127. * Holds a collection of exporter options and parameters
  66128. */
  66129. export interface IExportOptions {
  66130. /**
  66131. * Function which indicates whether a babylon node should be exported or not
  66132. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66133. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66134. */
  66135. shouldExportNode?(node: Node): boolean;
  66136. /**
  66137. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66138. * @param metadata source metadata to read from
  66139. * @returns the data to store to glTF node extras
  66140. */
  66141. metadataSelector?(metadata: any): any;
  66142. /**
  66143. * The sample rate to bake animation curves
  66144. */
  66145. animationSampleRate?: number;
  66146. /**
  66147. * Begin serialization without waiting for the scene to be ready
  66148. */
  66149. exportWithoutWaitingForScene?: boolean;
  66150. }
  66151. /**
  66152. * Class for generating glTF data from a Babylon scene.
  66153. */
  66154. export class GLTF2Export {
  66155. /**
  66156. * Exports the geometry of the scene to .gltf file format asynchronously
  66157. * @param scene Babylon scene with scene hierarchy information
  66158. * @param filePrefix File prefix to use when generating the glTF file
  66159. * @param options Exporter options
  66160. * @returns Returns an object with a .gltf file and associates texture names
  66161. * as keys and their data and paths as values
  66162. */
  66163. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66164. private static _PreExportAsync;
  66165. private static _PostExportAsync;
  66166. /**
  66167. * Exports the geometry of the scene to .glb file format asychronously
  66168. * @param scene Babylon scene with scene hierarchy information
  66169. * @param filePrefix File prefix to use when generating glb file
  66170. * @param options Exporter options
  66171. * @returns Returns an object with a .glb filename as key and data as value
  66172. */
  66173. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66174. }
  66175. }
  66176. declare module BABYLON.GLTF2.Exporter {
  66177. /**
  66178. * @hidden
  66179. */
  66180. export class _GLTFUtilities {
  66181. /**
  66182. * Creates a buffer view based on the supplied arguments
  66183. * @param bufferIndex index value of the specified buffer
  66184. * @param byteOffset byte offset value
  66185. * @param byteLength byte length of the bufferView
  66186. * @param byteStride byte distance between conequential elements
  66187. * @param name name of the buffer view
  66188. * @returns bufferView for glTF
  66189. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66190. /**
  66191. * Creates an accessor based on the supplied arguments
  66192. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66193. * @param name The name of the accessor
  66194. * @param type The type of the accessor
  66195. * @param componentType The datatype of components in the attribute
  66196. * @param count The number of attributes referenced by this accessor
  66197. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66198. * @param min Minimum value of each component in this attribute
  66199. * @param max Maximum value of each component in this attribute
  66200. * @returns accessor for glTF
  66201. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66202. /**
  66203. * Calculates the minimum and maximum values of an array of position floats
  66204. * @param positions Positions array of a mesh
  66205. * @param vertexStart Starting vertex offset to calculate min and max values
  66206. * @param vertexCount Number of vertices to check for min and max values
  66207. * @returns min number array and max number array
  66208. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66209. min: number[];
  66210. max: number[];
  66211. };
  66212. /**
  66213. * Converts a new right-handed Vector3
  66214. * @param vector vector3 array
  66215. * @returns right-handed Vector3
  66216. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66217. /**
  66218. * Converts a Vector3 to right-handed
  66219. * @param vector Vector3 to convert to right-handed
  66220. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66221. /**
  66222. * Converts a three element number array to right-handed
  66223. * @param vector number array to convert to right-handed
  66224. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66225. /**
  66226. * Converts a new right-handed Vector3
  66227. * @param vector vector3 array
  66228. * @returns right-handed Vector3
  66229. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  66230. /**
  66231. * Converts a Vector3 to right-handed
  66232. * @param vector Vector3 to convert to right-handed
  66233. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  66234. /**
  66235. * Converts a three element number array to right-handed
  66236. * @param vector number array to convert to right-handed
  66237. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  66238. /**
  66239. * Converts a Vector4 to right-handed
  66240. * @param vector Vector4 to convert to right-handed
  66241. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66242. /**
  66243. * Converts a Vector4 to right-handed
  66244. * @param vector Vector4 to convert to right-handed
  66245. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  66246. /**
  66247. * Converts a Quaternion to right-handed
  66248. * @param quaternion Source quaternion to convert to right-handed
  66249. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66250. /**
  66251. * Converts a Quaternion to right-handed
  66252. * @param quaternion Source quaternion to convert to right-handed
  66253. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  66254. }
  66255. }
  66256. declare module BABYLON.GLTF2.Exporter {
  66257. /**
  66258. * Converts Babylon Scene into glTF 2.0.
  66259. * @hidden
  66260. */
  66261. export class _Exporter {
  66262. /**
  66263. * Stores the glTF to export
  66264. */ private _glTF: IGLTF;
  66265. /**
  66266. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66267. */ private _bufferViews: IBufferView[];
  66268. /**
  66269. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66270. */ private _accessors: IAccessor[];
  66271. /**
  66272. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66273. */
  66274. private _nodes;
  66275. /**
  66276. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66277. */
  66278. private _scenes;
  66279. /**
  66280. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66281. */
  66282. private _meshes;
  66283. /**
  66284. * Stores all the generated material information, which represents the appearance of each primitive
  66285. */ private _materials: IMaterial[]; private _materialMap: {
  66286. [materialID: number]: number;
  66287. };
  66288. /**
  66289. * Stores all the generated texture information, which is referenced by glTF materials
  66290. */ private _textures: ITexture[];
  66291. /**
  66292. * Stores all the generated image information, which is referenced by glTF textures
  66293. */ private _images: IImage[];
  66294. /**
  66295. * Stores all the texture samplers
  66296. */ private _samplers: ISampler[];
  66297. /**
  66298. * Stores all the generated animation samplers, which is referenced by glTF animations
  66299. */
  66300. /**
  66301. * Stores the animations for glTF models
  66302. */
  66303. private _animations;
  66304. /**
  66305. * Stores the total amount of bytes stored in the glTF buffer
  66306. */
  66307. private _totalByteLength;
  66308. /**
  66309. * Stores a reference to the Babylon scene containing the source geometry and material information
  66310. */ private _babylonScene: Scene;
  66311. /**
  66312. * Stores a map of the image data, where the key is the file name and the value
  66313. * is the image data
  66314. */ private _imageData: {
  66315. [fileName: string]: {
  66316. data: Uint8Array;
  66317. mimeType: ImageMimeType;
  66318. };
  66319. };
  66320. /**
  66321. * Stores a map of the unique id of a node to its index in the node array
  66322. */
  66323. private _nodeMap;
  66324. /**
  66325. * Specifies if the Babylon scene should be converted to right-handed on export
  66326. */ private _convertToRightHandedSystem: boolean;
  66327. /**
  66328. * Baked animation sample rate
  66329. */
  66330. private _animationSampleRate;
  66331. private _options;
  66332. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  66333. private _extensions;
  66334. private static _ExtensionNames;
  66335. private static _ExtensionFactories;
  66336. 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>>;
  66337. private _forEachExtensions;
  66338. private _extensionsOnExporting;
  66339. /**
  66340. * Load glTF serializer extensions
  66341. */
  66342. private _loadExtensions;
  66343. /**
  66344. * Creates a glTF Exporter instance, which can accept optional exporter options
  66345. * @param babylonScene Babylon scene object
  66346. * @param options Options to modify the behavior of the exporter
  66347. */
  66348. constructor(babylonScene: Scene, options?: IExportOptions);
  66349. /**
  66350. * Registers a glTF exporter extension
  66351. * @param name Name of the extension to export
  66352. * @param factory The factory function that creates the exporter extension
  66353. */
  66354. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66355. /**
  66356. * Un-registers an exporter extension
  66357. * @param name The name fo the exporter extension
  66358. * @returns A boolean indicating whether the extension has been un-registered
  66359. */
  66360. static UnregisterExtension(name: string): boolean;
  66361. /**
  66362. * Lazy load a local engine with premultiplied alpha set to false
  66363. */ private _getLocalEngine(): Engine;
  66364. private reorderIndicesBasedOnPrimitiveMode;
  66365. /**
  66366. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66367. * clock-wise during export to glTF
  66368. * @param submesh BabylonJS submesh
  66369. * @param primitiveMode Primitive mode of the mesh
  66370. * @param sideOrientation the winding order of the submesh
  66371. * @param vertexBufferKind The type of vertex attribute
  66372. * @param meshAttributeArray The vertex attribute data
  66373. * @param byteOffset The offset to the binary data
  66374. * @param binaryWriter The binary data for the glTF file
  66375. */
  66376. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66377. /**
  66378. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66379. * clock-wise during export to glTF
  66380. * @param submesh BabylonJS submesh
  66381. * @param primitiveMode Primitive mode of the mesh
  66382. * @param sideOrientation the winding order of the submesh
  66383. * @param vertexBufferKind The type of vertex attribute
  66384. * @param meshAttributeArray The vertex attribute data
  66385. * @param byteOffset The offset to the binary data
  66386. * @param binaryWriter The binary data for the glTF file
  66387. */
  66388. private reorderTriangleFillMode;
  66389. /**
  66390. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66391. * clock-wise during export to glTF
  66392. * @param submesh BabylonJS submesh
  66393. * @param primitiveMode Primitive mode of the mesh
  66394. * @param sideOrientation the winding order of the submesh
  66395. * @param vertexBufferKind The type of vertex attribute
  66396. * @param meshAttributeArray The vertex attribute data
  66397. * @param byteOffset The offset to the binary data
  66398. * @param binaryWriter The binary data for the glTF file
  66399. */
  66400. private reorderTriangleStripDrawMode;
  66401. /**
  66402. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66403. * clock-wise during export to glTF
  66404. * @param submesh BabylonJS submesh
  66405. * @param primitiveMode Primitive mode of the mesh
  66406. * @param sideOrientation the winding order of the submesh
  66407. * @param vertexBufferKind The type of vertex attribute
  66408. * @param meshAttributeArray The vertex attribute data
  66409. * @param byteOffset The offset to the binary data
  66410. * @param binaryWriter The binary data for the glTF file
  66411. */
  66412. private reorderTriangleFanMode;
  66413. /**
  66414. * Writes the vertex attribute data to binary
  66415. * @param vertices The vertices to write to the binary writer
  66416. * @param byteOffset The offset into the binary writer to overwrite binary data
  66417. * @param vertexAttributeKind The vertex attribute type
  66418. * @param meshAttributeArray The vertex attribute data
  66419. * @param binaryWriter The writer containing the binary data
  66420. */
  66421. private writeVertexAttributeData;
  66422. /**
  66423. * Writes mesh attribute data to a data buffer
  66424. * Returns the bytelength of the data
  66425. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66426. * @param meshAttributeArray Array containing the attribute data
  66427. * @param binaryWriter The buffer to write the binary data to
  66428. * @param indices Used to specify the order of the vertex data
  66429. */
  66430. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66431. /**
  66432. * Generates glTF json data
  66433. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66434. * @param glTFPrefix Text to use when prefixing a glTF file
  66435. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66436. * @returns json data as string
  66437. */
  66438. private generateJSON;
  66439. /**
  66440. * Generates data for .gltf and .bin files based on the glTF prefix string
  66441. * @param glTFPrefix Text to use when prefixing a glTF file
  66442. * @returns GLTFData with glTF file data
  66443. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66444. /**
  66445. * Creates a binary buffer for glTF
  66446. * @returns array buffer for binary data
  66447. */
  66448. private _generateBinaryAsync;
  66449. /**
  66450. * Pads the number to a multiple of 4
  66451. * @param num number to pad
  66452. * @returns padded number
  66453. */
  66454. private _getPadding;
  66455. /**
  66456. * Generates a glb file from the json and binary data
  66457. * Returns an object with the glb file name as the key and data as the value
  66458. * @param glTFPrefix
  66459. * @returns object with glb filename as key and data as value
  66460. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66461. /**
  66462. * Sets the TRS for each node
  66463. * @param node glTF Node for storing the transformation data
  66464. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66465. */
  66466. private setNodeTransformation;
  66467. private getVertexBufferFromMesh;
  66468. /**
  66469. * Creates a bufferview based on the vertices type for the Babylon mesh
  66470. * @param kind Indicates the type of vertices data
  66471. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66472. * @param binaryWriter The buffer to write the bufferview data to
  66473. */
  66474. private createBufferViewKind;
  66475. /**
  66476. * The primitive mode of the Babylon mesh
  66477. * @param babylonMesh The BabylonJS mesh
  66478. */
  66479. private getMeshPrimitiveMode;
  66480. /**
  66481. * Sets the primitive mode of the glTF mesh primitive
  66482. * @param meshPrimitive glTF mesh primitive
  66483. * @param primitiveMode The primitive mode
  66484. */
  66485. private setPrimitiveMode;
  66486. /**
  66487. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66488. * @param meshPrimitive glTF mesh primitive
  66489. * @param attributeKind vertex attribute
  66490. * @returns boolean specifying if uv coordinates are present
  66491. */
  66492. private setAttributeKind;
  66493. /**
  66494. * Sets data for the primitive attributes of each submesh
  66495. * @param mesh glTF Mesh object to store the primitive attribute information
  66496. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66497. * @param binaryWriter Buffer to write the attribute data to
  66498. */
  66499. private setPrimitiveAttributesAsync;
  66500. /**
  66501. * Creates a glTF scene based on the array of meshes
  66502. * Returns the the total byte offset
  66503. * @param babylonScene Babylon scene to get the mesh data from
  66504. * @param binaryWriter Buffer to write binary data to
  66505. */
  66506. private createSceneAsync;
  66507. /**
  66508. * Creates a mapping of Node unique id to node index and handles animations
  66509. * @param babylonScene Babylon Scene
  66510. * @param nodes Babylon transform nodes
  66511. * @param binaryWriter Buffer to write binary data to
  66512. * @returns Node mapping of unique id to index
  66513. */
  66514. private createNodeMapAndAnimationsAsync;
  66515. /**
  66516. * Creates a glTF node from a Babylon mesh
  66517. * @param babylonMesh Source Babylon mesh
  66518. * @param binaryWriter Buffer for storing geometry data
  66519. * @returns glTF node
  66520. */
  66521. private createNodeAsync;
  66522. }
  66523. /**
  66524. * @hidden
  66525. *
  66526. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66527. */
  66528. export class _BinaryWriter {
  66529. /**
  66530. * Array buffer which stores all binary data
  66531. */
  66532. private _arrayBuffer;
  66533. /**
  66534. * View of the array buffer
  66535. */
  66536. private _dataView;
  66537. /**
  66538. * byte offset of data in array buffer
  66539. */
  66540. private _byteOffset;
  66541. /**
  66542. * Initialize binary writer with an initial byte length
  66543. * @param byteLength Initial byte length of the array buffer
  66544. */
  66545. constructor(byteLength: number);
  66546. /**
  66547. * Resize the array buffer to the specified byte length
  66548. * @param byteLength
  66549. */
  66550. private resizeBuffer;
  66551. /**
  66552. * Get an array buffer with the length of the byte offset
  66553. * @returns ArrayBuffer resized to the byte offset
  66554. */
  66555. getArrayBuffer(): ArrayBuffer;
  66556. /**
  66557. * Get the byte offset of the array buffer
  66558. * @returns byte offset
  66559. */
  66560. getByteOffset(): number;
  66561. /**
  66562. * Stores an UInt8 in the array buffer
  66563. * @param entry
  66564. * @param byteOffset If defined, specifies where to set the value as an offset.
  66565. */
  66566. setUInt8(entry: number, byteOffset?: number): void;
  66567. /**
  66568. * Gets an UInt32 in the array buffer
  66569. * @param entry
  66570. * @param byteOffset If defined, specifies where to set the value as an offset.
  66571. */
  66572. getUInt32(byteOffset: number): number;
  66573. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66574. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66575. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66576. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66577. /**
  66578. * Stores a Float32 in the array buffer
  66579. * @param entry
  66580. */
  66581. setFloat32(entry: number, byteOffset?: number): void;
  66582. /**
  66583. * Stores an UInt32 in the array buffer
  66584. * @param entry
  66585. * @param byteOffset If defined, specifies where to set the value as an offset.
  66586. */
  66587. setUInt32(entry: number, byteOffset?: number): void;
  66588. }
  66589. }
  66590. declare module BABYLON.GLTF2.Exporter {
  66591. /**
  66592. * @hidden
  66593. * Interface to store animation data.
  66594. */
  66595. export interface _IAnimationData {
  66596. /**
  66597. * Keyframe data.
  66598. */
  66599. inputs: number[];
  66600. /**
  66601. * Value data.
  66602. */
  66603. outputs: number[][];
  66604. /**
  66605. * Animation interpolation data.
  66606. */
  66607. samplerInterpolation: AnimationSamplerInterpolation;
  66608. /**
  66609. * Minimum keyframe value.
  66610. */
  66611. inputsMin: number;
  66612. /**
  66613. * Maximum keyframe value.
  66614. */
  66615. inputsMax: number;
  66616. }
  66617. /**
  66618. * @hidden
  66619. */
  66620. export interface _IAnimationInfo {
  66621. /**
  66622. * The target channel for the animation
  66623. */
  66624. animationChannelTargetPath: AnimationChannelTargetPath;
  66625. /**
  66626. * The glTF accessor type for the data.
  66627. */
  66628. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66629. /**
  66630. * Specifies if quaternions should be used.
  66631. */
  66632. useQuaternion: boolean;
  66633. }
  66634. /**
  66635. * @hidden
  66636. * Utility class for generating glTF animation data from BabylonJS.
  66637. */
  66638. export class _GLTFAnimation {
  66639. /**
  66640. * @ignore
  66641. *
  66642. * Creates glTF channel animation from BabylonJS animation.
  66643. * @param babylonTransformNode - BabylonJS mesh.
  66644. * @param animation - animation.
  66645. * @param animationChannelTargetPath - The target animation channel.
  66646. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66647. * @param useQuaternion - Specifies if quaternions are used.
  66648. * @returns nullable IAnimationData
  66649. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66650. private static _DeduceAnimationInfo;
  66651. /**
  66652. * @ignore
  66653. * Create node animations from the transform node animations
  66654. * @param babylonNode
  66655. * @param runtimeGLTFAnimation
  66656. * @param idleGLTFAnimations
  66657. * @param nodeMap
  66658. * @param nodes
  66659. * @param binaryWriter
  66660. * @param bufferViews
  66661. * @param accessors
  66662. * @param convertToRightHandedSystem
  66663. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66664. [key: number]: number;
  66665. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66666. /**
  66667. * @ignore
  66668. * Create node animations from the animation groups
  66669. * @param babylonScene
  66670. * @param glTFAnimations
  66671. * @param nodeMap
  66672. * @param nodes
  66673. * @param binaryWriter
  66674. * @param bufferViews
  66675. * @param accessors
  66676. * @param convertToRightHandedSystem
  66677. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66678. [key: number]: number;
  66679. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66680. private static AddAnimation;
  66681. /**
  66682. * Create a baked animation
  66683. * @param babylonTransformNode BabylonJS mesh
  66684. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66685. * @param animationChannelTargetPath animation target channel
  66686. * @param minFrame minimum animation frame
  66687. * @param maxFrame maximum animation frame
  66688. * @param fps frames per second of the animation
  66689. * @param inputs input key frames of the animation
  66690. * @param outputs output key frame data of the animation
  66691. * @param convertToRightHandedSystem converts the values to right-handed
  66692. * @param useQuaternion specifies if quaternions should be used
  66693. */
  66694. private static _CreateBakedAnimation;
  66695. private static _ConvertFactorToVector3OrQuaternion;
  66696. private static _SetInterpolatedValue;
  66697. /**
  66698. * Creates linear animation from the animation key frames
  66699. * @param babylonTransformNode BabylonJS mesh
  66700. * @param animation BabylonJS animation
  66701. * @param animationChannelTargetPath The target animation channel
  66702. * @param frameDelta The difference between the last and first frame of the animation
  66703. * @param inputs Array to store the key frame times
  66704. * @param outputs Array to store the key frame data
  66705. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66706. * @param useQuaternion Specifies if quaternions are used in the animation
  66707. */
  66708. private static _CreateLinearOrStepAnimation;
  66709. /**
  66710. * Creates cubic spline animation from the animation key frames
  66711. * @param babylonTransformNode BabylonJS mesh
  66712. * @param animation BabylonJS animation
  66713. * @param animationChannelTargetPath The target animation channel
  66714. * @param frameDelta The difference between the last and first frame of the animation
  66715. * @param inputs Array to store the key frame times
  66716. * @param outputs Array to store the key frame data
  66717. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66718. * @param useQuaternion Specifies if quaternions are used in the animation
  66719. */
  66720. private static _CreateCubicSplineAnimation;
  66721. private static _GetBasePositionRotationOrScale;
  66722. /**
  66723. * Adds a key frame value
  66724. * @param keyFrame
  66725. * @param animation
  66726. * @param outputs
  66727. * @param animationChannelTargetPath
  66728. * @param basePositionRotationOrScale
  66729. * @param convertToRightHandedSystem
  66730. * @param useQuaternion
  66731. */
  66732. private static _AddKeyframeValue;
  66733. /**
  66734. * Determine the interpolation based on the key frames
  66735. * @param keyFrames
  66736. * @param animationChannelTargetPath
  66737. * @param useQuaternion
  66738. */
  66739. private static _DeduceInterpolation;
  66740. /**
  66741. * Adds an input tangent or output tangent to the output data
  66742. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66743. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66744. * @param outputs The animation data by keyframe
  66745. * @param animationChannelTargetPath The target animation channel
  66746. * @param interpolation The interpolation type
  66747. * @param keyFrame The key frame with the animation data
  66748. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66749. * @param useQuaternion Specifies if quaternions are used
  66750. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66751. */
  66752. private static AddSplineTangent;
  66753. /**
  66754. * Get the minimum and maximum key frames' frame values
  66755. * @param keyFrames animation key frames
  66756. * @returns the minimum and maximum key frame value
  66757. */
  66758. private static calculateMinMaxKeyFrames;
  66759. }
  66760. }
  66761. declare module BABYLON.GLTF2.Exporter {
  66762. /** @hidden */
  66763. export var textureTransformPixelShader: {
  66764. name: string;
  66765. shader: string;
  66766. };
  66767. }
  66768. declare module BABYLON.GLTF2.Exporter.Extensions {
  66769. /**
  66770. * @hidden
  66771. */
  66772. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66773. /** Name of this extension */
  66774. readonly name: string;
  66775. /** Defines whether this extension is enabled */
  66776. enabled: boolean;
  66777. /** Defines whether this extension is required */
  66778. required: boolean;
  66779. /** Reference to the glTF exporter */
  66780. private _exporter;
  66781. constructor(exporter: _Exporter);
  66782. dispose(): void;
  66783. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66784. /**
  66785. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66786. * @param babylonTexture
  66787. * @param offset
  66788. * @param rotation
  66789. * @param scale
  66790. * @param scene
  66791. */
  66792. private _textureTransformTextureAsync;
  66793. }
  66794. }
  66795. declare module BABYLON.GLTF2.Exporter.Extensions {
  66796. /**
  66797. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66798. */
  66799. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66800. /** The name of this extension. */
  66801. readonly name: string;
  66802. /** Defines whether this extension is enabled. */
  66803. enabled: boolean;
  66804. /** Defines whether this extension is required */
  66805. required: boolean;
  66806. /** Reference to the glTF exporter */
  66807. private _exporter;
  66808. private _lights;
  66809. /** @hidden */
  66810. constructor(exporter: _Exporter);
  66811. /** @hidden */
  66812. dispose(): void;
  66813. /** @hidden */
  66814. onExporting(): void;
  66815. /**
  66816. * Define this method to modify the default behavior when exporting a node
  66817. * @param context The context when exporting the node
  66818. * @param node glTF node
  66819. * @param babylonNode BabylonJS node
  66820. * @returns nullable INode promise
  66821. */
  66822. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66823. }
  66824. }
  66825. declare module BABYLON {
  66826. /**
  66827. * Class for generating STL data from a Babylon scene.
  66828. */
  66829. export class STLExport {
  66830. /**
  66831. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66832. * @param meshes list defines the mesh to serialize
  66833. * @param download triggers the automatic download of the file.
  66834. * @param fileName changes the downloads fileName.
  66835. * @param binary changes the STL to a binary type.
  66836. * @param isLittleEndian toggle for binary type exporter.
  66837. * @returns the STL as UTF8 string
  66838. */
  66839. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66840. }
  66841. }
  66842. /**
  66843. * @ignoreChildren
  66844. * @ignore
  66845. */
  66846. declare module "babylonjs-gltf2interface" {
  66847. export = BABYLON.GLTF2;
  66848. }
  66849. /**
  66850. * Module for glTF 2.0 Interface
  66851. * @ignoreChildren
  66852. * @ignore
  66853. */
  66854. declare module BABYLON.GLTF2 {
  66855. /**
  66856. * The datatype of the components in the attribute
  66857. */
  66858. const enum AccessorComponentType {
  66859. /**
  66860. * Byte
  66861. */
  66862. BYTE = 5120,
  66863. /**
  66864. * Unsigned Byte
  66865. */
  66866. UNSIGNED_BYTE = 5121,
  66867. /**
  66868. * Short
  66869. */
  66870. SHORT = 5122,
  66871. /**
  66872. * Unsigned Short
  66873. */
  66874. UNSIGNED_SHORT = 5123,
  66875. /**
  66876. * Unsigned Int
  66877. */
  66878. UNSIGNED_INT = 5125,
  66879. /**
  66880. * Float
  66881. */
  66882. FLOAT = 5126,
  66883. }
  66884. /**
  66885. * Specifies if the attirbute is a scalar, vector, or matrix
  66886. */
  66887. const enum AccessorType {
  66888. /**
  66889. * Scalar
  66890. */
  66891. SCALAR = "SCALAR",
  66892. /**
  66893. * Vector2
  66894. */
  66895. VEC2 = "VEC2",
  66896. /**
  66897. * Vector3
  66898. */
  66899. VEC3 = "VEC3",
  66900. /**
  66901. * Vector4
  66902. */
  66903. VEC4 = "VEC4",
  66904. /**
  66905. * Matrix2x2
  66906. */
  66907. MAT2 = "MAT2",
  66908. /**
  66909. * Matrix3x3
  66910. */
  66911. MAT3 = "MAT3",
  66912. /**
  66913. * Matrix4x4
  66914. */
  66915. MAT4 = "MAT4",
  66916. }
  66917. /**
  66918. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66919. */
  66920. const enum AnimationChannelTargetPath {
  66921. /**
  66922. * Translation
  66923. */
  66924. TRANSLATION = "translation",
  66925. /**
  66926. * Rotation
  66927. */
  66928. ROTATION = "rotation",
  66929. /**
  66930. * Scale
  66931. */
  66932. SCALE = "scale",
  66933. /**
  66934. * Weights
  66935. */
  66936. WEIGHTS = "weights",
  66937. }
  66938. /**
  66939. * Interpolation algorithm
  66940. */
  66941. const enum AnimationSamplerInterpolation {
  66942. /**
  66943. * The animated values are linearly interpolated between keyframes
  66944. */
  66945. LINEAR = "LINEAR",
  66946. /**
  66947. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66948. */
  66949. STEP = "STEP",
  66950. /**
  66951. * The animation's interpolation is computed using a cubic spline with specified tangents
  66952. */
  66953. CUBICSPLINE = "CUBICSPLINE",
  66954. }
  66955. /**
  66956. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66957. */
  66958. const enum CameraType {
  66959. /**
  66960. * A perspective camera containing properties to create a perspective projection matrix
  66961. */
  66962. PERSPECTIVE = "perspective",
  66963. /**
  66964. * An orthographic camera containing properties to create an orthographic projection matrix
  66965. */
  66966. ORTHOGRAPHIC = "orthographic",
  66967. }
  66968. /**
  66969. * The mime-type of the image
  66970. */
  66971. const enum ImageMimeType {
  66972. /**
  66973. * JPEG Mime-type
  66974. */
  66975. JPEG = "image/jpeg",
  66976. /**
  66977. * PNG Mime-type
  66978. */
  66979. PNG = "image/png",
  66980. }
  66981. /**
  66982. * The alpha rendering mode of the material
  66983. */
  66984. const enum MaterialAlphaMode {
  66985. /**
  66986. * The alpha value is ignored and the rendered output is fully opaque
  66987. */
  66988. OPAQUE = "OPAQUE",
  66989. /**
  66990. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66991. */
  66992. MASK = "MASK",
  66993. /**
  66994. * 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)
  66995. */
  66996. BLEND = "BLEND",
  66997. }
  66998. /**
  66999. * The type of the primitives to render
  67000. */
  67001. const enum MeshPrimitiveMode {
  67002. /**
  67003. * Points
  67004. */
  67005. POINTS = 0,
  67006. /**
  67007. * Lines
  67008. */
  67009. LINES = 1,
  67010. /**
  67011. * Line Loop
  67012. */
  67013. LINE_LOOP = 2,
  67014. /**
  67015. * Line Strip
  67016. */
  67017. LINE_STRIP = 3,
  67018. /**
  67019. * Triangles
  67020. */
  67021. TRIANGLES = 4,
  67022. /**
  67023. * Triangle Strip
  67024. */
  67025. TRIANGLE_STRIP = 5,
  67026. /**
  67027. * Triangle Fan
  67028. */
  67029. TRIANGLE_FAN = 6,
  67030. }
  67031. /**
  67032. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67033. */
  67034. const enum TextureMagFilter {
  67035. /**
  67036. * Nearest
  67037. */
  67038. NEAREST = 9728,
  67039. /**
  67040. * Linear
  67041. */
  67042. LINEAR = 9729,
  67043. }
  67044. /**
  67045. * Minification filter. All valid values correspond to WebGL enums
  67046. */
  67047. const enum TextureMinFilter {
  67048. /**
  67049. * Nearest
  67050. */
  67051. NEAREST = 9728,
  67052. /**
  67053. * Linear
  67054. */
  67055. LINEAR = 9729,
  67056. /**
  67057. * Nearest Mip-Map Nearest
  67058. */
  67059. NEAREST_MIPMAP_NEAREST = 9984,
  67060. /**
  67061. * Linear Mipmap Nearest
  67062. */
  67063. LINEAR_MIPMAP_NEAREST = 9985,
  67064. /**
  67065. * Nearest Mipmap Linear
  67066. */
  67067. NEAREST_MIPMAP_LINEAR = 9986,
  67068. /**
  67069. * Linear Mipmap Linear
  67070. */
  67071. LINEAR_MIPMAP_LINEAR = 9987,
  67072. }
  67073. /**
  67074. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67075. */
  67076. const enum TextureWrapMode {
  67077. /**
  67078. * Clamp to Edge
  67079. */
  67080. CLAMP_TO_EDGE = 33071,
  67081. /**
  67082. * Mirrored Repeat
  67083. */
  67084. MIRRORED_REPEAT = 33648,
  67085. /**
  67086. * Repeat
  67087. */
  67088. REPEAT = 10497,
  67089. }
  67090. /**
  67091. * glTF Property
  67092. */
  67093. interface IProperty {
  67094. /**
  67095. * Dictionary object with extension-specific objects
  67096. */
  67097. extensions?: {
  67098. [key: string]: any;
  67099. };
  67100. /**
  67101. * Application-Specific data
  67102. */
  67103. extras?: any;
  67104. }
  67105. /**
  67106. * glTF Child of Root Property
  67107. */
  67108. interface IChildRootProperty extends IProperty {
  67109. /**
  67110. * The user-defined name of this object
  67111. */
  67112. name?: string;
  67113. }
  67114. /**
  67115. * Indices of those attributes that deviate from their initialization value
  67116. */
  67117. interface IAccessorSparseIndices extends IProperty {
  67118. /**
  67119. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67120. */
  67121. bufferView: number;
  67122. /**
  67123. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67124. */
  67125. byteOffset?: number;
  67126. /**
  67127. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67128. */
  67129. componentType: AccessorComponentType;
  67130. }
  67131. /**
  67132. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67133. */
  67134. interface IAccessorSparseValues extends IProperty {
  67135. /**
  67136. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67137. */
  67138. bufferView: number;
  67139. /**
  67140. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67141. */
  67142. byteOffset?: number;
  67143. }
  67144. /**
  67145. * Sparse storage of attributes that deviate from their initialization value
  67146. */
  67147. interface IAccessorSparse extends IProperty {
  67148. /**
  67149. * The number of attributes encoded in this sparse accessor
  67150. */
  67151. count: number;
  67152. /**
  67153. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67154. */
  67155. indices: IAccessorSparseIndices;
  67156. /**
  67157. * 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
  67158. */
  67159. values: IAccessorSparseValues;
  67160. }
  67161. /**
  67162. * 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
  67163. */
  67164. interface IAccessor extends IChildRootProperty {
  67165. /**
  67166. * The index of the bufferview
  67167. */
  67168. bufferView?: number;
  67169. /**
  67170. * The offset relative to the start of the bufferView in bytes
  67171. */
  67172. byteOffset?: number;
  67173. /**
  67174. * The datatype of components in the attribute
  67175. */
  67176. componentType: AccessorComponentType;
  67177. /**
  67178. * Specifies whether integer data values should be normalized
  67179. */
  67180. normalized?: boolean;
  67181. /**
  67182. * The number of attributes referenced by this accessor
  67183. */
  67184. count: number;
  67185. /**
  67186. * Specifies if the attribute is a scalar, vector, or matrix
  67187. */
  67188. type: AccessorType;
  67189. /**
  67190. * Maximum value of each component in this attribute
  67191. */
  67192. max?: number[];
  67193. /**
  67194. * Minimum value of each component in this attribute
  67195. */
  67196. min?: number[];
  67197. /**
  67198. * Sparse storage of attributes that deviate from their initialization value
  67199. */
  67200. sparse?: IAccessorSparse;
  67201. }
  67202. /**
  67203. * Targets an animation's sampler at a node's property
  67204. */
  67205. interface IAnimationChannel extends IProperty {
  67206. /**
  67207. * The index of a sampler in this animation used to compute the value for the target
  67208. */
  67209. sampler: number;
  67210. /**
  67211. * The index of the node and TRS property to target
  67212. */
  67213. target: IAnimationChannelTarget;
  67214. }
  67215. /**
  67216. * The index of the node and TRS property that an animation channel targets
  67217. */
  67218. interface IAnimationChannelTarget extends IProperty {
  67219. /**
  67220. * The index of the node to target
  67221. */
  67222. node: number;
  67223. /**
  67224. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67225. */
  67226. path: AnimationChannelTargetPath;
  67227. }
  67228. /**
  67229. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67230. */
  67231. interface IAnimationSampler extends IProperty {
  67232. /**
  67233. * The index of an accessor containing keyframe input values, e.g., time
  67234. */
  67235. input: number;
  67236. /**
  67237. * Interpolation algorithm
  67238. */
  67239. interpolation?: AnimationSamplerInterpolation;
  67240. /**
  67241. * The index of an accessor, containing keyframe output values
  67242. */
  67243. output: number;
  67244. }
  67245. /**
  67246. * A keyframe animation
  67247. */
  67248. interface IAnimation extends IChildRootProperty {
  67249. /**
  67250. * An array of channels, each of which targets an animation's sampler at a node's property
  67251. */
  67252. channels: IAnimationChannel[];
  67253. /**
  67254. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67255. */
  67256. samplers: IAnimationSampler[];
  67257. }
  67258. /**
  67259. * Metadata about the glTF asset
  67260. */
  67261. interface IAsset extends IChildRootProperty {
  67262. /**
  67263. * A copyright message suitable for display to credit the content creator
  67264. */
  67265. copyright?: string;
  67266. /**
  67267. * Tool that generated this glTF model. Useful for debugging
  67268. */
  67269. generator?: string;
  67270. /**
  67271. * The glTF version that this asset targets
  67272. */
  67273. version: string;
  67274. /**
  67275. * The minimum glTF version that this asset targets
  67276. */
  67277. minVersion?: string;
  67278. }
  67279. /**
  67280. * A buffer points to binary geometry, animation, or skins
  67281. */
  67282. interface IBuffer extends IChildRootProperty {
  67283. /**
  67284. * 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
  67285. */
  67286. uri?: string;
  67287. /**
  67288. * The length of the buffer in bytes
  67289. */
  67290. byteLength: number;
  67291. }
  67292. /**
  67293. * A view into a buffer generally representing a subset of the buffer
  67294. */
  67295. interface IBufferView extends IChildRootProperty {
  67296. /**
  67297. * The index of the buffer
  67298. */
  67299. buffer: number;
  67300. /**
  67301. * The offset into the buffer in bytes
  67302. */
  67303. byteOffset?: number;
  67304. /**
  67305. * The lenth of the bufferView in bytes
  67306. */
  67307. byteLength: number;
  67308. /**
  67309. * The stride, in bytes
  67310. */
  67311. byteStride?: number;
  67312. }
  67313. /**
  67314. * An orthographic camera containing properties to create an orthographic projection matrix
  67315. */
  67316. interface ICameraOrthographic extends IProperty {
  67317. /**
  67318. * The floating-point horizontal magnification of the view. Must not be zero
  67319. */
  67320. xmag: number;
  67321. /**
  67322. * The floating-point vertical magnification of the view. Must not be zero
  67323. */
  67324. ymag: number;
  67325. /**
  67326. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67327. */
  67328. zfar: number;
  67329. /**
  67330. * The floating-point distance to the near clipping plane
  67331. */
  67332. znear: number;
  67333. }
  67334. /**
  67335. * A perspective camera containing properties to create a perspective projection matrix
  67336. */
  67337. interface ICameraPerspective extends IProperty {
  67338. /**
  67339. * The floating-point aspect ratio of the field of view
  67340. */
  67341. aspectRatio?: number;
  67342. /**
  67343. * The floating-point vertical field of view in radians
  67344. */
  67345. yfov: number;
  67346. /**
  67347. * The floating-point distance to the far clipping plane
  67348. */
  67349. zfar?: number;
  67350. /**
  67351. * The floating-point distance to the near clipping plane
  67352. */
  67353. znear: number;
  67354. }
  67355. /**
  67356. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67357. */
  67358. interface ICamera extends IChildRootProperty {
  67359. /**
  67360. * An orthographic camera containing properties to create an orthographic projection matrix
  67361. */
  67362. orthographic?: ICameraOrthographic;
  67363. /**
  67364. * A perspective camera containing properties to create a perspective projection matrix
  67365. */
  67366. perspective?: ICameraPerspective;
  67367. /**
  67368. * Specifies if the camera uses a perspective or orthographic projection
  67369. */
  67370. type: CameraType;
  67371. }
  67372. /**
  67373. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67374. */
  67375. interface IImage extends IChildRootProperty {
  67376. /**
  67377. * 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
  67378. */
  67379. uri?: string;
  67380. /**
  67381. * The image's MIME type
  67382. */
  67383. mimeType?: ImageMimeType;
  67384. /**
  67385. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67386. */
  67387. bufferView?: number;
  67388. }
  67389. /**
  67390. * Material Normal Texture Info
  67391. */
  67392. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67393. /**
  67394. * The scalar multiplier applied to each normal vector of the normal texture
  67395. */
  67396. scale?: number;
  67397. }
  67398. /**
  67399. * Material Occlusion Texture Info
  67400. */
  67401. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67402. /**
  67403. * A scalar multiplier controlling the amount of occlusion applied
  67404. */
  67405. strength?: number;
  67406. }
  67407. /**
  67408. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67409. */
  67410. interface IMaterialPbrMetallicRoughness {
  67411. /**
  67412. * The material's base color factor
  67413. */
  67414. baseColorFactor?: number[];
  67415. /**
  67416. * The base color texture
  67417. */
  67418. baseColorTexture?: ITextureInfo;
  67419. /**
  67420. * The metalness of the material
  67421. */
  67422. metallicFactor?: number;
  67423. /**
  67424. * The roughness of the material
  67425. */
  67426. roughnessFactor?: number;
  67427. /**
  67428. * The metallic-roughness texture
  67429. */
  67430. metallicRoughnessTexture?: ITextureInfo;
  67431. }
  67432. /**
  67433. * The material appearance of a primitive
  67434. */
  67435. interface IMaterial extends IChildRootProperty {
  67436. /**
  67437. * 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
  67438. */
  67439. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67440. /**
  67441. * The normal map texture
  67442. */
  67443. normalTexture?: IMaterialNormalTextureInfo;
  67444. /**
  67445. * The occlusion map texture
  67446. */
  67447. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67448. /**
  67449. * The emissive map texture
  67450. */
  67451. emissiveTexture?: ITextureInfo;
  67452. /**
  67453. * 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
  67454. */
  67455. emissiveFactor?: number[];
  67456. /**
  67457. * The alpha rendering mode of the material
  67458. */
  67459. alphaMode?: MaterialAlphaMode;
  67460. /**
  67461. * The alpha cutoff value of the material
  67462. */
  67463. alphaCutoff?: number;
  67464. /**
  67465. * Specifies whether the material is double sided
  67466. */
  67467. doubleSided?: boolean;
  67468. }
  67469. /**
  67470. * Geometry to be rendered with the given material
  67471. */
  67472. interface IMeshPrimitive extends IProperty {
  67473. /**
  67474. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67475. */
  67476. attributes: {
  67477. [name: string]: number;
  67478. };
  67479. /**
  67480. * The index of the accessor that contains the indices
  67481. */
  67482. indices?: number;
  67483. /**
  67484. * The index of the material to apply to this primitive when rendering
  67485. */
  67486. material?: number;
  67487. /**
  67488. * The type of primitives to render. All valid values correspond to WebGL enums
  67489. */
  67490. mode?: MeshPrimitiveMode;
  67491. /**
  67492. * 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
  67493. */
  67494. targets?: {
  67495. [name: string]: number;
  67496. }[];
  67497. }
  67498. /**
  67499. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67500. */
  67501. interface IMesh extends IChildRootProperty {
  67502. /**
  67503. * An array of primitives, each defining geometry to be rendered with a material
  67504. */
  67505. primitives: IMeshPrimitive[];
  67506. /**
  67507. * Array of weights to be applied to the Morph Targets
  67508. */
  67509. weights?: number[];
  67510. }
  67511. /**
  67512. * A node in the node hierarchy
  67513. */
  67514. interface INode extends IChildRootProperty {
  67515. /**
  67516. * The index of the camera referenced by this node
  67517. */
  67518. camera?: number;
  67519. /**
  67520. * The indices of this node's children
  67521. */
  67522. children?: number[];
  67523. /**
  67524. * The index of the skin referenced by this node
  67525. */
  67526. skin?: number;
  67527. /**
  67528. * A floating-point 4x4 transformation matrix stored in column-major order
  67529. */
  67530. matrix?: number[];
  67531. /**
  67532. * The index of the mesh in this node
  67533. */
  67534. mesh?: number;
  67535. /**
  67536. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67537. */
  67538. rotation?: number[];
  67539. /**
  67540. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67541. */
  67542. scale?: number[];
  67543. /**
  67544. * The node's translation along the x, y, and z axes
  67545. */
  67546. translation?: number[];
  67547. /**
  67548. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67549. */
  67550. weights?: number[];
  67551. }
  67552. /**
  67553. * Texture sampler properties for filtering and wrapping modes
  67554. */
  67555. interface ISampler extends IChildRootProperty {
  67556. /**
  67557. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67558. */
  67559. magFilter?: TextureMagFilter;
  67560. /**
  67561. * Minification filter. All valid values correspond to WebGL enums
  67562. */
  67563. minFilter?: TextureMinFilter;
  67564. /**
  67565. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67566. */
  67567. wrapS?: TextureWrapMode;
  67568. /**
  67569. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67570. */
  67571. wrapT?: TextureWrapMode;
  67572. }
  67573. /**
  67574. * The root nodes of a scene
  67575. */
  67576. interface IScene extends IChildRootProperty {
  67577. /**
  67578. * The indices of each root node
  67579. */
  67580. nodes: number[];
  67581. }
  67582. /**
  67583. * Joints and matrices defining a skin
  67584. */
  67585. interface ISkin extends IChildRootProperty {
  67586. /**
  67587. * 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
  67588. */
  67589. inverseBindMatrices?: number;
  67590. /**
  67591. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67592. */
  67593. skeleton?: number;
  67594. /**
  67595. * 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)
  67596. */
  67597. joints: number[];
  67598. }
  67599. /**
  67600. * A texture and its sampler
  67601. */
  67602. interface ITexture extends IChildRootProperty {
  67603. /**
  67604. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67605. */
  67606. sampler?: number;
  67607. /**
  67608. * The index of the image used by this texture
  67609. */
  67610. source: number;
  67611. }
  67612. /**
  67613. * Reference to a texture
  67614. */
  67615. interface ITextureInfo extends IProperty {
  67616. /**
  67617. * The index of the texture
  67618. */
  67619. index: number;
  67620. /**
  67621. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67622. */
  67623. texCoord?: number;
  67624. }
  67625. /**
  67626. * The root object for a glTF asset
  67627. */
  67628. interface IGLTF extends IProperty {
  67629. /**
  67630. * An array of accessors. An accessor is a typed view into a bufferView
  67631. */
  67632. accessors?: IAccessor[];
  67633. /**
  67634. * An array of keyframe animations
  67635. */
  67636. animations?: IAnimation[];
  67637. /**
  67638. * Metadata about the glTF asset
  67639. */
  67640. asset: IAsset;
  67641. /**
  67642. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67643. */
  67644. buffers?: IBuffer[];
  67645. /**
  67646. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67647. */
  67648. bufferViews?: IBufferView[];
  67649. /**
  67650. * An array of cameras
  67651. */
  67652. cameras?: ICamera[];
  67653. /**
  67654. * Names of glTF extensions used somewhere in this asset
  67655. */
  67656. extensionsUsed?: string[];
  67657. /**
  67658. * Names of glTF extensions required to properly load this asset
  67659. */
  67660. extensionsRequired?: string[];
  67661. /**
  67662. * An array of images. An image defines data used to create a texture
  67663. */
  67664. images?: IImage[];
  67665. /**
  67666. * An array of materials. A material defines the appearance of a primitive
  67667. */
  67668. materials?: IMaterial[];
  67669. /**
  67670. * An array of meshes. A mesh is a set of primitives to be rendered
  67671. */
  67672. meshes?: IMesh[];
  67673. /**
  67674. * An array of nodes
  67675. */
  67676. nodes?: INode[];
  67677. /**
  67678. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67679. */
  67680. samplers?: ISampler[];
  67681. /**
  67682. * The index of the default scene
  67683. */
  67684. scene?: number;
  67685. /**
  67686. * An array of scenes
  67687. */
  67688. scenes?: IScene[];
  67689. /**
  67690. * An array of skins. A skin is defined by joints and matrices
  67691. */
  67692. skins?: ISkin[];
  67693. /**
  67694. * An array of textures
  67695. */
  67696. textures?: ITexture[];
  67697. }
  67698. /**
  67699. * The glTF validation results
  67700. */
  67701. interface IGLTFValidationResults {
  67702. info: {
  67703. generator: string;
  67704. hasAnimations: boolean;
  67705. hasDefaultScene: boolean;
  67706. hasMaterials: boolean;
  67707. hasMorphTargets: boolean;
  67708. hasSkins: boolean;
  67709. hasTextures: boolean;
  67710. maxAttributesUsed: number;
  67711. primitivesCount: number
  67712. };
  67713. issues: {
  67714. messages: Array<string>;
  67715. numErrors: number;
  67716. numHints: number;
  67717. numInfos: number;
  67718. numWarnings: number;
  67719. truncated: boolean
  67720. };
  67721. mimeType: string;
  67722. uri: string;
  67723. validatedAt: string;
  67724. validatorVersion: string;
  67725. }
  67726. /**
  67727. * The glTF validation options
  67728. */
  67729. interface IGLTFValidationOptions {
  67730. uri?: string;
  67731. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67732. validateAccessorData?: boolean;
  67733. maxIssues?: number;
  67734. ignoredIssues?: Array<string>;
  67735. severityOverrides?: Object;
  67736. }
  67737. /**
  67738. * The glTF validator object
  67739. */
  67740. interface IGLTFValidator {
  67741. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67742. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67743. }
  67744. }
  67745. declare module BABYLON {
  67746. /** @hidden */
  67747. export var cellPixelShader: {
  67748. name: string;
  67749. shader: string;
  67750. };
  67751. }
  67752. declare module BABYLON {
  67753. /** @hidden */
  67754. export var cellVertexShader: {
  67755. name: string;
  67756. shader: string;
  67757. };
  67758. }
  67759. declare module BABYLON {
  67760. export class CellMaterial extends BABYLON.PushMaterial {
  67761. private _diffuseTexture;
  67762. diffuseTexture: BABYLON.BaseTexture;
  67763. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  67764. computeHighLevel: boolean;
  67765. private _disableLighting;
  67766. disableLighting: boolean;
  67767. private _maxSimultaneousLights;
  67768. maxSimultaneousLights: number;
  67769. private _renderId;
  67770. constructor(name: string, scene: BABYLON.Scene);
  67771. needAlphaBlending(): boolean;
  67772. needAlphaTesting(): boolean;
  67773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67774. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67775. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67776. getAnimatables(): BABYLON.IAnimatable[];
  67777. getActiveTextures(): BABYLON.BaseTexture[];
  67778. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67779. dispose(forceDisposeEffect?: boolean): void;
  67780. getClassName(): string;
  67781. clone(name: string): CellMaterial;
  67782. serialize(): any;
  67783. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67784. }
  67785. }
  67786. declare module BABYLON {
  67787. export class CustomShaderStructure {
  67788. FragmentStore: string;
  67789. VertexStore: string;
  67790. constructor();
  67791. }
  67792. export class ShaderSpecialParts {
  67793. constructor();
  67794. Fragment_Begin: string;
  67795. Fragment_Definitions: string;
  67796. Fragment_MainBegin: string;
  67797. Fragment_Custom_Diffuse: string;
  67798. Fragment_Before_Lights: string;
  67799. Fragment_Before_Fog: string;
  67800. Fragment_Custom_Alpha: string;
  67801. Fragment_Before_FragColor: string;
  67802. Vertex_Begin: string;
  67803. Vertex_Definitions: string;
  67804. Vertex_MainBegin: string;
  67805. Vertex_Before_PositionUpdated: string;
  67806. Vertex_Before_NormalUpdated: string;
  67807. Vertex_MainEnd: string;
  67808. }
  67809. export class CustomMaterial extends BABYLON.StandardMaterial {
  67810. static ShaderIndexer: number;
  67811. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  67812. FragmentShader: string;
  67813. VertexShader: string;
  67814. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67815. ReviewUniform(name: string, arr: string[]): string[];
  67816. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67817. constructor(name: string, scene: BABYLON.Scene);
  67818. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67819. Fragment_Begin(shaderPart: string): CustomMaterial;
  67820. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67821. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67822. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67823. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67824. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67825. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67826. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67827. Vertex_Begin(shaderPart: string): CustomMaterial;
  67828. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67829. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67830. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67831. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67832. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67833. }
  67834. }
  67835. declare module BABYLON {
  67836. export class ShaderAlebdoParts {
  67837. constructor();
  67838. Fragment_Begin: string;
  67839. Fragment_Definitions: string;
  67840. Fragment_MainBegin: string;
  67841. Fragment_Custom_Albedo: string;
  67842. Fragment_Before_Lights: string;
  67843. Fragment_Custom_MetallicRoughness: string;
  67844. Fragment_Custom_MicroSurface: string;
  67845. Fragment_Before_Fog: string;
  67846. Fragment_Custom_Alpha: string;
  67847. Fragment_Before_FragColor: string;
  67848. Vertex_Begin: string;
  67849. Vertex_Definitions: string;
  67850. Vertex_MainBegin: string;
  67851. Vertex_Before_PositionUpdated: string;
  67852. Vertex_Before_NormalUpdated: string;
  67853. Vertex_MainEnd: string;
  67854. }
  67855. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67856. static ShaderIndexer: number;
  67857. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  67858. FragmentShader: string;
  67859. VertexShader: string;
  67860. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67861. ReviewUniform(name: string, arr: string[]): string[];
  67862. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67863. constructor(name: string, scene: BABYLON.Scene);
  67864. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67865. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67866. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67867. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67868. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67869. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67870. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67871. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67872. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67873. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67874. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67875. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67876. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67877. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67878. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67879. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67880. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /** @hidden */
  67885. export var firePixelShader: {
  67886. name: string;
  67887. shader: string;
  67888. };
  67889. }
  67890. declare module BABYLON {
  67891. /** @hidden */
  67892. export var fireVertexShader: {
  67893. name: string;
  67894. shader: string;
  67895. };
  67896. }
  67897. declare module BABYLON {
  67898. export class FireMaterial extends BABYLON.PushMaterial {
  67899. private _diffuseTexture;
  67900. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67901. private _distortionTexture;
  67902. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67903. private _opacityTexture;
  67904. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67905. diffuseColor: BABYLON.Color3;
  67906. speed: number;
  67907. private _scaledDiffuse;
  67908. private _renderId;
  67909. private _lastTime;
  67910. constructor(name: string, scene: BABYLON.Scene);
  67911. needAlphaBlending(): boolean;
  67912. needAlphaTesting(): boolean;
  67913. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67914. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67915. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67916. getAnimatables(): BABYLON.IAnimatable[];
  67917. getActiveTextures(): BABYLON.BaseTexture[];
  67918. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67919. getClassName(): string;
  67920. dispose(forceDisposeEffect?: boolean): void;
  67921. clone(name: string): FireMaterial;
  67922. serialize(): any;
  67923. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67924. }
  67925. }
  67926. declare module BABYLON {
  67927. /** @hidden */
  67928. export var furPixelShader: {
  67929. name: string;
  67930. shader: string;
  67931. };
  67932. }
  67933. declare module BABYLON {
  67934. /** @hidden */
  67935. export var furVertexShader: {
  67936. name: string;
  67937. shader: string;
  67938. };
  67939. }
  67940. declare module BABYLON {
  67941. export class FurMaterial extends BABYLON.PushMaterial {
  67942. private _diffuseTexture;
  67943. diffuseTexture: BABYLON.BaseTexture;
  67944. private _heightTexture;
  67945. heightTexture: BABYLON.BaseTexture;
  67946. diffuseColor: BABYLON.Color3;
  67947. furLength: number;
  67948. furAngle: number;
  67949. furColor: BABYLON.Color3;
  67950. furOffset: number;
  67951. furSpacing: number;
  67952. furGravity: BABYLON.Vector3;
  67953. furSpeed: number;
  67954. furDensity: number;
  67955. furOcclusion: number;
  67956. furTexture: BABYLON.DynamicTexture;
  67957. private _disableLighting;
  67958. disableLighting: boolean;
  67959. private _maxSimultaneousLights;
  67960. maxSimultaneousLights: number;
  67961. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  67962. private _renderId;
  67963. private _furTime;
  67964. constructor(name: string, scene: BABYLON.Scene);
  67965. furTime: number;
  67966. needAlphaBlending(): boolean;
  67967. needAlphaTesting(): boolean;
  67968. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67969. updateFur(): void;
  67970. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67971. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67972. getAnimatables(): BABYLON.IAnimatable[];
  67973. getActiveTextures(): BABYLON.BaseTexture[];
  67974. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67975. dispose(forceDisposeEffect?: boolean): void;
  67976. clone(name: string): FurMaterial;
  67977. serialize(): any;
  67978. getClassName(): string;
  67979. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67980. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67981. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /** @hidden */
  67986. export var gradientPixelShader: {
  67987. name: string;
  67988. shader: string;
  67989. };
  67990. }
  67991. declare module BABYLON {
  67992. /** @hidden */
  67993. export var gradientVertexShader: {
  67994. name: string;
  67995. shader: string;
  67996. };
  67997. }
  67998. declare module BABYLON {
  67999. export class GradientMaterial extends BABYLON.PushMaterial {
  68000. private _maxSimultaneousLights;
  68001. maxSimultaneousLights: number;
  68002. topColor: BABYLON.Color3;
  68003. topColorAlpha: number;
  68004. bottomColor: BABYLON.Color3;
  68005. bottomColorAlpha: number;
  68006. offset: number;
  68007. scale: number;
  68008. smoothness: number;
  68009. private _disableLighting;
  68010. disableLighting: boolean;
  68011. private _renderId;
  68012. constructor(name: string, scene: BABYLON.Scene);
  68013. needAlphaBlending(): boolean;
  68014. needAlphaTesting(): boolean;
  68015. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68016. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68017. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68018. getAnimatables(): BABYLON.IAnimatable[];
  68019. dispose(forceDisposeEffect?: boolean): void;
  68020. clone(name: string): GradientMaterial;
  68021. serialize(): any;
  68022. getClassName(): string;
  68023. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68024. }
  68025. }
  68026. declare module BABYLON {
  68027. /** @hidden */
  68028. export var gridPixelShader: {
  68029. name: string;
  68030. shader: string;
  68031. };
  68032. }
  68033. declare module BABYLON {
  68034. /** @hidden */
  68035. export var gridVertexShader: {
  68036. name: string;
  68037. shader: string;
  68038. };
  68039. }
  68040. declare module BABYLON {
  68041. /**
  68042. * The grid materials allows you to wrap any shape with a grid.
  68043. * Colors are customizable.
  68044. */
  68045. export class GridMaterial extends BABYLON.PushMaterial {
  68046. /**
  68047. * Main color of the grid (e.g. between lines)
  68048. */
  68049. mainColor: BABYLON.Color3;
  68050. /**
  68051. * Color of the grid lines.
  68052. */
  68053. lineColor: BABYLON.Color3;
  68054. /**
  68055. * The scale of the grid compared to unit.
  68056. */
  68057. gridRatio: number;
  68058. /**
  68059. * Allows setting an offset for the grid lines.
  68060. */
  68061. gridOffset: BABYLON.Vector3;
  68062. /**
  68063. * The frequency of thicker lines.
  68064. */
  68065. majorUnitFrequency: number;
  68066. /**
  68067. * The visibility of minor units in the grid.
  68068. */
  68069. minorUnitVisibility: number;
  68070. /**
  68071. * The grid opacity outside of the lines.
  68072. */
  68073. opacity: number;
  68074. /**
  68075. * Determine RBG output is premultiplied by alpha value.
  68076. */
  68077. preMultiplyAlpha: boolean;
  68078. private _opacityTexture;
  68079. opacityTexture: BABYLON.BaseTexture;
  68080. private _gridControl;
  68081. private _renderId;
  68082. /**
  68083. * constructor
  68084. * @param name The name given to the material in order to identify it afterwards.
  68085. * @param scene The scene the material is used in.
  68086. */
  68087. constructor(name: string, scene: BABYLON.Scene);
  68088. /**
  68089. * Returns wehter or not the grid requires alpha blending.
  68090. */
  68091. needAlphaBlending(): boolean;
  68092. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68093. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68094. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68095. /**
  68096. * Dispose the material and its associated resources.
  68097. * @param forceDisposeEffect will also dispose the used effect when true
  68098. */
  68099. dispose(forceDisposeEffect?: boolean): void;
  68100. clone(name: string): GridMaterial;
  68101. serialize(): any;
  68102. getClassName(): string;
  68103. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68104. }
  68105. }
  68106. declare module BABYLON {
  68107. /** @hidden */
  68108. export var lavaPixelShader: {
  68109. name: string;
  68110. shader: string;
  68111. };
  68112. }
  68113. declare module BABYLON {
  68114. /** @hidden */
  68115. export var lavaVertexShader: {
  68116. name: string;
  68117. shader: string;
  68118. };
  68119. }
  68120. declare module BABYLON {
  68121. export class LavaMaterial extends BABYLON.PushMaterial {
  68122. private _diffuseTexture;
  68123. diffuseTexture: BABYLON.BaseTexture;
  68124. noiseTexture: BABYLON.BaseTexture;
  68125. fogColor: BABYLON.Color3;
  68126. speed: number;
  68127. movingSpeed: number;
  68128. lowFrequencySpeed: number;
  68129. fogDensity: number;
  68130. private _lastTime;
  68131. diffuseColor: BABYLON.Color3;
  68132. private _disableLighting;
  68133. disableLighting: boolean;
  68134. private _unlit;
  68135. unlit: boolean;
  68136. private _maxSimultaneousLights;
  68137. maxSimultaneousLights: number;
  68138. private _scaledDiffuse;
  68139. private _renderId;
  68140. constructor(name: string, scene: BABYLON.Scene);
  68141. needAlphaBlending(): boolean;
  68142. needAlphaTesting(): boolean;
  68143. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68145. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68146. getAnimatables(): BABYLON.IAnimatable[];
  68147. getActiveTextures(): BABYLON.BaseTexture[];
  68148. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68149. dispose(forceDisposeEffect?: boolean): void;
  68150. clone(name: string): LavaMaterial;
  68151. serialize(): any;
  68152. getClassName(): string;
  68153. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68154. }
  68155. }
  68156. declare module BABYLON {
  68157. /** @hidden */
  68158. export var mixPixelShader: {
  68159. name: string;
  68160. shader: string;
  68161. };
  68162. }
  68163. declare module BABYLON {
  68164. /** @hidden */
  68165. export var mixVertexShader: {
  68166. name: string;
  68167. shader: string;
  68168. };
  68169. }
  68170. declare module BABYLON {
  68171. export class MixMaterial extends BABYLON.PushMaterial {
  68172. /**
  68173. * Mix textures
  68174. */
  68175. private _mixTexture1;
  68176. mixTexture1: BABYLON.BaseTexture;
  68177. private _mixTexture2;
  68178. mixTexture2: BABYLON.BaseTexture;
  68179. /**
  68180. * Diffuse textures
  68181. */
  68182. private _diffuseTexture1;
  68183. diffuseTexture1: BABYLON.Texture;
  68184. private _diffuseTexture2;
  68185. diffuseTexture2: BABYLON.Texture;
  68186. private _diffuseTexture3;
  68187. diffuseTexture3: BABYLON.Texture;
  68188. private _diffuseTexture4;
  68189. diffuseTexture4: BABYLON.Texture;
  68190. private _diffuseTexture5;
  68191. diffuseTexture5: BABYLON.Texture;
  68192. private _diffuseTexture6;
  68193. diffuseTexture6: BABYLON.Texture;
  68194. private _diffuseTexture7;
  68195. diffuseTexture7: BABYLON.Texture;
  68196. private _diffuseTexture8;
  68197. diffuseTexture8: BABYLON.Texture;
  68198. /**
  68199. * Uniforms
  68200. */
  68201. diffuseColor: BABYLON.Color3;
  68202. specularColor: BABYLON.Color3;
  68203. specularPower: number;
  68204. private _disableLighting;
  68205. disableLighting: boolean;
  68206. private _maxSimultaneousLights;
  68207. maxSimultaneousLights: number;
  68208. private _renderId;
  68209. constructor(name: string, scene: BABYLON.Scene);
  68210. needAlphaBlending(): boolean;
  68211. needAlphaTesting(): boolean;
  68212. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68213. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68214. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68215. getAnimatables(): BABYLON.IAnimatable[];
  68216. getActiveTextures(): BABYLON.BaseTexture[];
  68217. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68218. dispose(forceDisposeEffect?: boolean): void;
  68219. clone(name: string): MixMaterial;
  68220. serialize(): any;
  68221. getClassName(): string;
  68222. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68223. }
  68224. }
  68225. declare module BABYLON {
  68226. /** @hidden */
  68227. export var normalPixelShader: {
  68228. name: string;
  68229. shader: string;
  68230. };
  68231. }
  68232. declare module BABYLON {
  68233. /** @hidden */
  68234. export var normalVertexShader: {
  68235. name: string;
  68236. shader: string;
  68237. };
  68238. }
  68239. declare module BABYLON {
  68240. export class NormalMaterial extends BABYLON.PushMaterial {
  68241. private _diffuseTexture;
  68242. diffuseTexture: BABYLON.BaseTexture;
  68243. diffuseColor: BABYLON.Color3;
  68244. private _disableLighting;
  68245. disableLighting: boolean;
  68246. private _maxSimultaneousLights;
  68247. maxSimultaneousLights: number;
  68248. private _renderId;
  68249. constructor(name: string, scene: BABYLON.Scene);
  68250. needAlphaBlending(): boolean;
  68251. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68252. needAlphaTesting(): boolean;
  68253. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68254. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68255. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68256. getAnimatables(): BABYLON.IAnimatable[];
  68257. getActiveTextures(): BABYLON.BaseTexture[];
  68258. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68259. dispose(forceDisposeEffect?: boolean): void;
  68260. clone(name: string): NormalMaterial;
  68261. serialize(): any;
  68262. getClassName(): string;
  68263. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68264. }
  68265. }
  68266. declare module BABYLON {
  68267. /** @hidden */
  68268. export var shadowOnlyPixelShader: {
  68269. name: string;
  68270. shader: string;
  68271. };
  68272. }
  68273. declare module BABYLON {
  68274. /** @hidden */
  68275. export var shadowOnlyVertexShader: {
  68276. name: string;
  68277. shader: string;
  68278. };
  68279. }
  68280. declare module BABYLON {
  68281. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68282. private _renderId;
  68283. private _activeLight;
  68284. constructor(name: string, scene: BABYLON.Scene);
  68285. shadowColor: BABYLON.Color3;
  68286. needAlphaBlending(): boolean;
  68287. needAlphaTesting(): boolean;
  68288. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68289. activeLight: BABYLON.IShadowLight;
  68290. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68291. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68292. clone(name: string): ShadowOnlyMaterial;
  68293. serialize(): any;
  68294. getClassName(): string;
  68295. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68296. }
  68297. }
  68298. declare module BABYLON {
  68299. /** @hidden */
  68300. export var simplePixelShader: {
  68301. name: string;
  68302. shader: string;
  68303. };
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export var simpleVertexShader: {
  68308. name: string;
  68309. shader: string;
  68310. };
  68311. }
  68312. declare module BABYLON {
  68313. export class SimpleMaterial extends BABYLON.PushMaterial {
  68314. private _diffuseTexture;
  68315. diffuseTexture: BABYLON.BaseTexture;
  68316. diffuseColor: BABYLON.Color3;
  68317. private _disableLighting;
  68318. disableLighting: boolean;
  68319. private _maxSimultaneousLights;
  68320. maxSimultaneousLights: number;
  68321. private _renderId;
  68322. constructor(name: string, scene: BABYLON.Scene);
  68323. needAlphaBlending(): boolean;
  68324. needAlphaTesting(): boolean;
  68325. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68326. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68327. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68328. getAnimatables(): BABYLON.IAnimatable[];
  68329. getActiveTextures(): BABYLON.BaseTexture[];
  68330. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68331. dispose(forceDisposeEffect?: boolean): void;
  68332. clone(name: string): SimpleMaterial;
  68333. serialize(): any;
  68334. getClassName(): string;
  68335. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68336. }
  68337. }
  68338. declare module BABYLON {
  68339. /** @hidden */
  68340. export var skyPixelShader: {
  68341. name: string;
  68342. shader: string;
  68343. };
  68344. }
  68345. declare module BABYLON {
  68346. /** @hidden */
  68347. export var skyVertexShader: {
  68348. name: string;
  68349. shader: string;
  68350. };
  68351. }
  68352. declare module BABYLON {
  68353. /**
  68354. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68355. * @see https://doc.babylonjs.com/extensions/sky
  68356. */
  68357. export class SkyMaterial extends BABYLON.PushMaterial {
  68358. /**
  68359. * Defines the overall luminance of sky in interval ]0, 1[.
  68360. */
  68361. luminance: number;
  68362. /**
  68363. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68364. */
  68365. turbidity: number;
  68366. /**
  68367. * Defines the sky appearance (light intensity).
  68368. */
  68369. rayleigh: number;
  68370. /**
  68371. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68372. */
  68373. mieCoefficient: number;
  68374. /**
  68375. * Defines the amount of haze particles following the Mie scattering theory.
  68376. */
  68377. mieDirectionalG: number;
  68378. /**
  68379. * Defines the distance of the sun according to the active scene camera.
  68380. */
  68381. distance: number;
  68382. /**
  68383. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68384. * "inclined".
  68385. */
  68386. inclination: number;
  68387. /**
  68388. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68389. * an object direction and a reference direction.
  68390. */
  68391. azimuth: number;
  68392. /**
  68393. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68394. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68395. */
  68396. sunPosition: BABYLON.Vector3;
  68397. /**
  68398. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68399. * .sunPosition property.
  68400. */
  68401. useSunPosition: boolean;
  68402. /**
  68403. * Defines an offset vector used to get a horizon offset.
  68404. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68405. */
  68406. cameraOffset: BABYLON.Vector3;
  68407. private _cameraPosition;
  68408. private _renderId;
  68409. /**
  68410. * Instantiates a new sky material.
  68411. * This material allows to create dynamic and texture free
  68412. * effects for skyboxes by taking care of the atmosphere state.
  68413. * @see https://doc.babylonjs.com/extensions/sky
  68414. * @param name Define the name of the material in the scene
  68415. * @param scene Define the scene the material belong to
  68416. */
  68417. constructor(name: string, scene: BABYLON.Scene);
  68418. /**
  68419. * Specifies if the material will require alpha blending
  68420. * @returns a boolean specifying if alpha blending is needed
  68421. */
  68422. needAlphaBlending(): boolean;
  68423. /**
  68424. * Specifies if this material should be rendered in alpha test mode
  68425. * @returns false as the sky material doesn't need alpha testing.
  68426. */
  68427. needAlphaTesting(): boolean;
  68428. /**
  68429. * Get the texture used for alpha test purpose.
  68430. * @returns null as the sky material has no texture.
  68431. */
  68432. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68433. /**
  68434. * Get if the submesh is ready to be used and all its information available.
  68435. * Child classes can use it to update shaders
  68436. * @param mesh defines the mesh to check
  68437. * @param subMesh defines which submesh to check
  68438. * @param useInstances specifies that instances should be used
  68439. * @returns a boolean indicating that the submesh is ready or not
  68440. */
  68441. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68442. /**
  68443. * Binds the submesh to this material by preparing the effect and shader to draw
  68444. * @param world defines the world transformation matrix
  68445. * @param mesh defines the mesh containing the submesh
  68446. * @param subMesh defines the submesh to bind the material to
  68447. */
  68448. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68449. /**
  68450. * Get the list of animatables in the material.
  68451. * @returns the list of animatables object used in the material
  68452. */
  68453. getAnimatables(): BABYLON.IAnimatable[];
  68454. /**
  68455. * Disposes the material
  68456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68457. */
  68458. dispose(forceDisposeEffect?: boolean): void;
  68459. /**
  68460. * Makes a duplicate of the material, and gives it a new name
  68461. * @param name defines the new name for the duplicated material
  68462. * @returns the cloned material
  68463. */
  68464. clone(name: string): SkyMaterial;
  68465. /**
  68466. * Serializes this material in a JSON representation
  68467. * @returns the serialized material object
  68468. */
  68469. serialize(): any;
  68470. /**
  68471. * Gets the current class name of the material e.g. "SkyMaterial"
  68472. * Mainly use in serialization.
  68473. * @returns the class name
  68474. */
  68475. getClassName(): string;
  68476. /**
  68477. * Creates a sky material from parsed material data
  68478. * @param source defines the JSON representation of the material
  68479. * @param scene defines the hosting scene
  68480. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68481. * @returns a new sky material
  68482. */
  68483. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68484. }
  68485. }
  68486. declare module BABYLON {
  68487. /** @hidden */
  68488. export var terrainPixelShader: {
  68489. name: string;
  68490. shader: string;
  68491. };
  68492. }
  68493. declare module BABYLON {
  68494. /** @hidden */
  68495. export var terrainVertexShader: {
  68496. name: string;
  68497. shader: string;
  68498. };
  68499. }
  68500. declare module BABYLON {
  68501. export class TerrainMaterial extends BABYLON.PushMaterial {
  68502. private _mixTexture;
  68503. mixTexture: BABYLON.BaseTexture;
  68504. private _diffuseTexture1;
  68505. diffuseTexture1: BABYLON.Texture;
  68506. private _diffuseTexture2;
  68507. diffuseTexture2: BABYLON.Texture;
  68508. private _diffuseTexture3;
  68509. diffuseTexture3: BABYLON.Texture;
  68510. private _bumpTexture1;
  68511. bumpTexture1: BABYLON.Texture;
  68512. private _bumpTexture2;
  68513. bumpTexture2: BABYLON.Texture;
  68514. private _bumpTexture3;
  68515. bumpTexture3: BABYLON.Texture;
  68516. diffuseColor: BABYLON.Color3;
  68517. specularColor: BABYLON.Color3;
  68518. specularPower: number;
  68519. private _disableLighting;
  68520. disableLighting: boolean;
  68521. private _maxSimultaneousLights;
  68522. maxSimultaneousLights: number;
  68523. private _renderId;
  68524. constructor(name: string, scene: BABYLON.Scene);
  68525. needAlphaBlending(): boolean;
  68526. needAlphaTesting(): boolean;
  68527. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68528. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68529. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68530. getAnimatables(): BABYLON.IAnimatable[];
  68531. getActiveTextures(): BABYLON.BaseTexture[];
  68532. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68533. dispose(forceDisposeEffect?: boolean): void;
  68534. clone(name: string): TerrainMaterial;
  68535. serialize(): any;
  68536. getClassName(): string;
  68537. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68538. }
  68539. }
  68540. declare module BABYLON {
  68541. /** @hidden */
  68542. export var triplanarPixelShader: {
  68543. name: string;
  68544. shader: string;
  68545. };
  68546. }
  68547. declare module BABYLON {
  68548. /** @hidden */
  68549. export var triplanarVertexShader: {
  68550. name: string;
  68551. shader: string;
  68552. };
  68553. }
  68554. declare module BABYLON {
  68555. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68556. mixTexture: BABYLON.BaseTexture;
  68557. private _diffuseTextureX;
  68558. diffuseTextureX: BABYLON.BaseTexture;
  68559. private _diffuseTextureY;
  68560. diffuseTextureY: BABYLON.BaseTexture;
  68561. private _diffuseTextureZ;
  68562. diffuseTextureZ: BABYLON.BaseTexture;
  68563. private _normalTextureX;
  68564. normalTextureX: BABYLON.BaseTexture;
  68565. private _normalTextureY;
  68566. normalTextureY: BABYLON.BaseTexture;
  68567. private _normalTextureZ;
  68568. normalTextureZ: BABYLON.BaseTexture;
  68569. tileSize: number;
  68570. diffuseColor: BABYLON.Color3;
  68571. specularColor: BABYLON.Color3;
  68572. specularPower: number;
  68573. private _disableLighting;
  68574. disableLighting: boolean;
  68575. private _maxSimultaneousLights;
  68576. maxSimultaneousLights: number;
  68577. private _renderId;
  68578. constructor(name: string, scene: BABYLON.Scene);
  68579. needAlphaBlending(): boolean;
  68580. needAlphaTesting(): boolean;
  68581. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68582. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68583. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68584. getAnimatables(): BABYLON.IAnimatable[];
  68585. getActiveTextures(): BABYLON.BaseTexture[];
  68586. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68587. dispose(forceDisposeEffect?: boolean): void;
  68588. clone(name: string): TriPlanarMaterial;
  68589. serialize(): any;
  68590. getClassName(): string;
  68591. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68592. }
  68593. }
  68594. declare module BABYLON {
  68595. /** @hidden */
  68596. export var waterPixelShader: {
  68597. name: string;
  68598. shader: string;
  68599. };
  68600. }
  68601. declare module BABYLON {
  68602. /** @hidden */
  68603. export var waterVertexShader: {
  68604. name: string;
  68605. shader: string;
  68606. };
  68607. }
  68608. declare module BABYLON {
  68609. export class WaterMaterial extends BABYLON.PushMaterial {
  68610. renderTargetSize: BABYLON.Vector2;
  68611. private _bumpTexture;
  68612. bumpTexture: BABYLON.BaseTexture;
  68613. diffuseColor: BABYLON.Color3;
  68614. specularColor: BABYLON.Color3;
  68615. specularPower: number;
  68616. private _disableLighting;
  68617. disableLighting: boolean;
  68618. private _maxSimultaneousLights;
  68619. maxSimultaneousLights: number;
  68620. /**
  68621. * @param {number}: Represents the wind force
  68622. */
  68623. windForce: number;
  68624. /**
  68625. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68626. */
  68627. windDirection: BABYLON.Vector2;
  68628. /**
  68629. * @param {number}: Wave height, represents the height of the waves
  68630. */
  68631. waveHeight: number;
  68632. /**
  68633. * @param {number}: Bump height, represents the bump height related to the bump map
  68634. */
  68635. bumpHeight: number;
  68636. /**
  68637. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68638. */
  68639. private _bumpSuperimpose;
  68640. bumpSuperimpose: boolean;
  68641. /**
  68642. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68643. */
  68644. private _fresnelSeparate;
  68645. fresnelSeparate: boolean;
  68646. /**
  68647. * @param {boolean}: bump Waves modify the reflection.
  68648. */
  68649. private _bumpAffectsReflection;
  68650. bumpAffectsReflection: boolean;
  68651. /**
  68652. * @param {number}: The water color blended with the refraction (near)
  68653. */
  68654. waterColor: BABYLON.Color3;
  68655. /**
  68656. * @param {number}: The blend factor related to the water color
  68657. */
  68658. colorBlendFactor: number;
  68659. /**
  68660. * @param {number}: The water color blended with the reflection (far)
  68661. */
  68662. waterColor2: BABYLON.Color3;
  68663. /**
  68664. * @param {number}: The blend factor related to the water color (reflection, far)
  68665. */
  68666. colorBlendFactor2: number;
  68667. /**
  68668. * @param {number}: Represents the maximum length of a wave
  68669. */
  68670. waveLength: number;
  68671. /**
  68672. * @param {number}: Defines the waves speed
  68673. */
  68674. waveSpeed: number;
  68675. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68676. private _mesh;
  68677. private _refractionRTT;
  68678. private _reflectionRTT;
  68679. private _reflectionTransform;
  68680. private _lastTime;
  68681. private _lastDeltaTime;
  68682. private _renderId;
  68683. private _useLogarithmicDepth;
  68684. private _waitingRenderList;
  68685. /**
  68686. * Gets a boolean indicating that current material needs to register RTT
  68687. */
  68688. readonly hasRenderTargetTextures: boolean;
  68689. /**
  68690. * Constructor
  68691. */
  68692. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68693. useLogarithmicDepth: boolean;
  68694. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68695. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68696. addToRenderList(node: any): void;
  68697. enableRenderTargets(enable: boolean): void;
  68698. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68699. readonly renderTargetsEnabled: boolean;
  68700. needAlphaBlending(): boolean;
  68701. needAlphaTesting(): boolean;
  68702. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68703. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68704. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68705. private _createRenderTargets;
  68706. getAnimatables(): BABYLON.IAnimatable[];
  68707. getActiveTextures(): BABYLON.BaseTexture[];
  68708. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68709. dispose(forceDisposeEffect?: boolean): void;
  68710. clone(name: string): WaterMaterial;
  68711. serialize(): any;
  68712. getClassName(): string;
  68713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68714. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68715. }
  68716. }
  68717. declare module BABYLON {
  68718. /** @hidden */
  68719. export var asciiartPixelShader: {
  68720. name: string;
  68721. shader: string;
  68722. };
  68723. }
  68724. declare module BABYLON {
  68725. /**
  68726. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68727. *
  68728. * It basically takes care rendering the font front the given font size to a texture.
  68729. * This is used later on in the postprocess.
  68730. */
  68731. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68732. private _font;
  68733. private _text;
  68734. private _charSize;
  68735. /**
  68736. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68737. */
  68738. readonly charSize: number;
  68739. /**
  68740. * Create a new instance of the Ascii Art FontTexture class
  68741. * @param name the name of the texture
  68742. * @param font the font to use, use the W3C CSS notation
  68743. * @param text the caracter set to use in the rendering.
  68744. * @param scene the scene that owns the texture
  68745. */
  68746. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68747. /**
  68748. * Gets the max char width of a font.
  68749. * @param font the font to use, use the W3C CSS notation
  68750. * @return the max char width
  68751. */
  68752. private getFontWidth;
  68753. /**
  68754. * Gets the max char height of a font.
  68755. * @param font the font to use, use the W3C CSS notation
  68756. * @return the max char height
  68757. */
  68758. private getFontHeight;
  68759. /**
  68760. * Clones the current AsciiArtTexture.
  68761. * @return the clone of the texture.
  68762. */
  68763. clone(): AsciiArtFontTexture;
  68764. /**
  68765. * Parses a json object representing the texture and returns an instance of it.
  68766. * @param source the source JSON representation
  68767. * @param scene the scene to create the texture for
  68768. * @return the parsed texture
  68769. */
  68770. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68771. }
  68772. /**
  68773. * Option available in the Ascii Art Post Process.
  68774. */
  68775. export interface IAsciiArtPostProcessOptions {
  68776. /**
  68777. * The font to use following the w3c font definition.
  68778. */
  68779. font?: string;
  68780. /**
  68781. * The character set to use in the postprocess.
  68782. */
  68783. characterSet?: string;
  68784. /**
  68785. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68786. * This number is defined between 0 and 1;
  68787. */
  68788. mixToTile?: number;
  68789. /**
  68790. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68791. * This number is defined between 0 and 1;
  68792. */
  68793. mixToNormal?: number;
  68794. }
  68795. /**
  68796. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68797. *
  68798. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68799. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68800. */
  68801. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68802. /**
  68803. * The font texture used to render the char in the post process.
  68804. */
  68805. private _asciiArtFontTexture;
  68806. /**
  68807. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68808. * This number is defined between 0 and 1;
  68809. */
  68810. mixToTile: number;
  68811. /**
  68812. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68813. * This number is defined between 0 and 1;
  68814. */
  68815. mixToNormal: number;
  68816. /**
  68817. * Instantiates a new Ascii Art Post Process.
  68818. * @param name the name to give to the postprocess
  68819. * @camera the camera to apply the post process to.
  68820. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68821. */
  68822. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68823. }
  68824. }
  68825. declare module BABYLON {
  68826. /** @hidden */
  68827. export var digitalrainPixelShader: {
  68828. name: string;
  68829. shader: string;
  68830. };
  68831. }
  68832. declare module BABYLON {
  68833. /**
  68834. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68835. *
  68836. * It basically takes care rendering the font front the given font size to a texture.
  68837. * This is used later on in the postprocess.
  68838. */
  68839. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68840. private _font;
  68841. private _text;
  68842. private _charSize;
  68843. /**
  68844. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68845. */
  68846. readonly charSize: number;
  68847. /**
  68848. * Create a new instance of the Digital Rain FontTexture class
  68849. * @param name the name of the texture
  68850. * @param font the font to use, use the W3C CSS notation
  68851. * @param text the caracter set to use in the rendering.
  68852. * @param scene the scene that owns the texture
  68853. */
  68854. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68855. /**
  68856. * Gets the max char width of a font.
  68857. * @param font the font to use, use the W3C CSS notation
  68858. * @return the max char width
  68859. */
  68860. private getFontWidth;
  68861. /**
  68862. * Gets the max char height of a font.
  68863. * @param font the font to use, use the W3C CSS notation
  68864. * @return the max char height
  68865. */
  68866. private getFontHeight;
  68867. /**
  68868. * Clones the current DigitalRainFontTexture.
  68869. * @return the clone of the texture.
  68870. */
  68871. clone(): DigitalRainFontTexture;
  68872. /**
  68873. * Parses a json object representing the texture and returns an instance of it.
  68874. * @param source the source JSON representation
  68875. * @param scene the scene to create the texture for
  68876. * @return the parsed texture
  68877. */
  68878. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68879. }
  68880. /**
  68881. * Option available in the Digital Rain Post Process.
  68882. */
  68883. export interface IDigitalRainPostProcessOptions {
  68884. /**
  68885. * The font to use following the w3c font definition.
  68886. */
  68887. font?: string;
  68888. /**
  68889. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68890. * This number is defined between 0 and 1;
  68891. */
  68892. mixToTile?: number;
  68893. /**
  68894. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68895. * This number is defined between 0 and 1;
  68896. */
  68897. mixToNormal?: number;
  68898. }
  68899. /**
  68900. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68901. *
  68902. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68903. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68904. */
  68905. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68906. /**
  68907. * The font texture used to render the char in the post process.
  68908. */
  68909. private _digitalRainFontTexture;
  68910. /**
  68911. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68912. * This number is defined between 0 and 1;
  68913. */
  68914. mixToTile: number;
  68915. /**
  68916. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68917. * This number is defined between 0 and 1;
  68918. */
  68919. mixToNormal: number;
  68920. /**
  68921. * Instantiates a new Digital Rain Post Process.
  68922. * @param name the name to give to the postprocess
  68923. * @camera the camera to apply the post process to.
  68924. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68925. */
  68926. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68927. }
  68928. }
  68929. declare module BABYLON {
  68930. /** @hidden */
  68931. export var oceanPostProcessPixelShader: {
  68932. name: string;
  68933. shader: string;
  68934. };
  68935. }
  68936. declare module BABYLON {
  68937. /**
  68938. * Option available in the Ocean Post Process.
  68939. */
  68940. export interface IOceanPostProcessOptions {
  68941. /**
  68942. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68943. */
  68944. reflectionSize?: number | {
  68945. width: number;
  68946. height: number;
  68947. } | {
  68948. ratio: number;
  68949. };
  68950. /**
  68951. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68952. */
  68953. refractionSize?: number | {
  68954. width: number;
  68955. height: number;
  68956. } | {
  68957. ratio: number;
  68958. };
  68959. }
  68960. /**
  68961. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68962. *
  68963. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68964. * Example usage:
  68965. * var pp = new OceanPostProcess("myOcean", camera);
  68966. * pp.reflectionEnabled = true;
  68967. * pp.refractionEnabled = true;
  68968. */
  68969. export class OceanPostProcess extends BABYLON.PostProcess {
  68970. /**
  68971. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68972. */
  68973. /**
  68974. * Sets weither or not the real-time reflection is enabled on the ocean.
  68975. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68976. */
  68977. reflectionEnabled: boolean;
  68978. /**
  68979. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68980. */
  68981. /**
  68982. * Sets weither or not the real-time refraction is enabled on the ocean.
  68983. * Is set to true, the refraction render target texture will be used as refraction texture.
  68984. */
  68985. refractionEnabled: boolean;
  68986. /**
  68987. * Gets wether or not the post-processes is supported by the running hardware.
  68988. * This requires draw buffer supports.
  68989. */
  68990. readonly isSupported: boolean;
  68991. /**
  68992. * This is the reflection mirror texture used to display reflections on the ocean.
  68993. * By default, render list is empty.
  68994. */
  68995. reflectionTexture: BABYLON.MirrorTexture;
  68996. /**
  68997. * This is the refraction render target texture used to display refraction on the ocean.
  68998. * By default, render list is empty.
  68999. */
  69000. refractionTexture: BABYLON.RenderTargetTexture;
  69001. private _time;
  69002. private _cameraRotation;
  69003. private _cameraViewMatrix;
  69004. private _reflectionEnabled;
  69005. private _refractionEnabled;
  69006. private _geometryRenderer;
  69007. /**
  69008. * Instantiates a new Ocean Post Process.
  69009. * @param name the name to give to the postprocess.
  69010. * @camera the camera to apply the post process to.
  69011. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69012. */
  69013. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69014. /**
  69015. * Returns the appropriate defines according to the current configuration.
  69016. */
  69017. private _getDefines;
  69018. /**
  69019. * Computes the current camera rotation as the shader requires a camera rotation.
  69020. */
  69021. private _computeCameraRotation;
  69022. }
  69023. }
  69024. declare module BABYLON {
  69025. /** @hidden */
  69026. export var brickProceduralTexturePixelShader: {
  69027. name: string;
  69028. shader: string;
  69029. };
  69030. }
  69031. declare module BABYLON {
  69032. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69033. private _numberOfBricksHeight;
  69034. private _numberOfBricksWidth;
  69035. private _jointColor;
  69036. private _brickColor;
  69037. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69038. updateShaderUniforms(): void;
  69039. numberOfBricksHeight: number;
  69040. numberOfBricksWidth: number;
  69041. jointColor: BABYLON.Color3;
  69042. brickColor: BABYLON.Color3;
  69043. /**
  69044. * Serializes this brick procedural texture
  69045. * @returns a serialized brick procedural texture object
  69046. */
  69047. serialize(): any;
  69048. /**
  69049. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69050. * @param parsedTexture defines parsed texture data
  69051. * @param scene defines the current scene
  69052. * @param rootUrl defines the root URL containing brick procedural texture information
  69053. * @returns a parsed Brick Procedural BABYLON.Texture
  69054. */
  69055. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69056. }
  69057. }
  69058. declare module BABYLON {
  69059. /** @hidden */
  69060. export var cloudProceduralTexturePixelShader: {
  69061. name: string;
  69062. shader: string;
  69063. };
  69064. }
  69065. declare module BABYLON {
  69066. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69067. private _skyColor;
  69068. private _cloudColor;
  69069. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69070. updateShaderUniforms(): void;
  69071. skyColor: BABYLON.Color4;
  69072. cloudColor: BABYLON.Color4;
  69073. /**
  69074. * Serializes this cloud procedural texture
  69075. * @returns a serialized cloud procedural texture object
  69076. */
  69077. serialize(): any;
  69078. /**
  69079. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69080. * @param parsedTexture defines parsed texture data
  69081. * @param scene defines the current scene
  69082. * @param rootUrl defines the root URL containing cloud procedural texture information
  69083. * @returns a parsed Cloud Procedural BABYLON.Texture
  69084. */
  69085. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69086. }
  69087. }
  69088. declare module BABYLON {
  69089. /** @hidden */
  69090. export var fireProceduralTexturePixelShader: {
  69091. name: string;
  69092. shader: string;
  69093. };
  69094. }
  69095. declare module BABYLON {
  69096. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69097. private _time;
  69098. private _speed;
  69099. private _autoGenerateTime;
  69100. private _fireColors;
  69101. private _alphaThreshold;
  69102. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69103. updateShaderUniforms(): void;
  69104. render(useCameraPostProcess?: boolean): void;
  69105. static readonly PurpleFireColors: BABYLON.Color3[];
  69106. static readonly GreenFireColors: BABYLON.Color3[];
  69107. static readonly RedFireColors: BABYLON.Color3[];
  69108. static readonly BlueFireColors: BABYLON.Color3[];
  69109. autoGenerateTime: boolean;
  69110. fireColors: BABYLON.Color3[];
  69111. time: number;
  69112. speed: BABYLON.Vector2;
  69113. alphaThreshold: number;
  69114. /**
  69115. * Serializes this fire procedural texture
  69116. * @returns a serialized fire procedural texture object
  69117. */
  69118. serialize(): any;
  69119. /**
  69120. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69121. * @param parsedTexture defines parsed texture data
  69122. * @param scene defines the current scene
  69123. * @param rootUrl defines the root URL containing fire procedural texture information
  69124. * @returns a parsed Fire Procedural BABYLON.Texture
  69125. */
  69126. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69127. }
  69128. }
  69129. declare module BABYLON {
  69130. /** @hidden */
  69131. export var grassProceduralTexturePixelShader: {
  69132. name: string;
  69133. shader: string;
  69134. };
  69135. }
  69136. declare module BABYLON {
  69137. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69138. private _grassColors;
  69139. private _groundColor;
  69140. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69141. updateShaderUniforms(): void;
  69142. grassColors: BABYLON.Color3[];
  69143. groundColor: BABYLON.Color3;
  69144. /**
  69145. * Serializes this grass procedural texture
  69146. * @returns a serialized grass procedural texture object
  69147. */
  69148. serialize(): any;
  69149. /**
  69150. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69151. * @param parsedTexture defines parsed texture data
  69152. * @param scene defines the current scene
  69153. * @param rootUrl defines the root URL containing grass procedural texture information
  69154. * @returns a parsed Grass Procedural BABYLON.Texture
  69155. */
  69156. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69157. }
  69158. }
  69159. declare module BABYLON {
  69160. /** @hidden */
  69161. export var marbleProceduralTexturePixelShader: {
  69162. name: string;
  69163. shader: string;
  69164. };
  69165. }
  69166. declare module BABYLON {
  69167. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69168. private _numberOfTilesHeight;
  69169. private _numberOfTilesWidth;
  69170. private _amplitude;
  69171. private _jointColor;
  69172. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69173. updateShaderUniforms(): void;
  69174. numberOfTilesHeight: number;
  69175. amplitude: number;
  69176. numberOfTilesWidth: number;
  69177. jointColor: BABYLON.Color3;
  69178. /**
  69179. * Serializes this marble procedural texture
  69180. * @returns a serialized marble procedural texture object
  69181. */
  69182. serialize(): any;
  69183. /**
  69184. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  69185. * @param parsedTexture defines parsed texture data
  69186. * @param scene defines the current scene
  69187. * @param rootUrl defines the root URL containing marble procedural texture information
  69188. * @returns a parsed Marble Procedural BABYLON.Texture
  69189. */
  69190. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  69191. }
  69192. }
  69193. declare module BABYLON {
  69194. /** @hidden */
  69195. export var normalMapProceduralTexturePixelShader: {
  69196. name: string;
  69197. shader: string;
  69198. };
  69199. }
  69200. declare module BABYLON {
  69201. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  69202. private _baseTexture;
  69203. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69204. updateShaderUniforms(): void;
  69205. render(useCameraPostProcess?: boolean): void;
  69206. resize(size: any, generateMipMaps: any): void;
  69207. baseTexture: BABYLON.Texture;
  69208. /**
  69209. * Serializes this normal map procedural texture
  69210. * @returns a serialized normal map procedural texture object
  69211. */
  69212. serialize(): any;
  69213. /**
  69214. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69215. * @param parsedTexture defines parsed texture data
  69216. * @param scene defines the current scene
  69217. * @param rootUrl defines the root URL containing normal map procedural texture information
  69218. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69219. */
  69220. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69221. }
  69222. }
  69223. declare module BABYLON {
  69224. /** @hidden */
  69225. export var perlinNoiseProceduralTexturePixelShader: {
  69226. name: string;
  69227. shader: string;
  69228. };
  69229. }
  69230. declare module BABYLON {
  69231. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69232. time: number;
  69233. timeScale: number;
  69234. translationSpeed: number;
  69235. private _currentTranslation;
  69236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69237. updateShaderUniforms(): void;
  69238. render(useCameraPostProcess?: boolean): void;
  69239. resize(size: any, generateMipMaps: any): void;
  69240. /**
  69241. * Serializes this perlin noise procedural texture
  69242. * @returns a serialized perlin noise procedural texture object
  69243. */
  69244. serialize(): any;
  69245. /**
  69246. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69247. * @param parsedTexture defines parsed texture data
  69248. * @param scene defines the current scene
  69249. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69250. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69251. */
  69252. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69253. }
  69254. }
  69255. declare module BABYLON {
  69256. /** @hidden */
  69257. export var roadProceduralTexturePixelShader: {
  69258. name: string;
  69259. shader: string;
  69260. };
  69261. }
  69262. declare module BABYLON {
  69263. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69264. private _roadColor;
  69265. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69266. updateShaderUniforms(): void;
  69267. roadColor: BABYLON.Color3;
  69268. /**
  69269. * Serializes this road procedural texture
  69270. * @returns a serialized road procedural texture object
  69271. */
  69272. serialize(): any;
  69273. /**
  69274. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69275. * @param parsedTexture defines parsed texture data
  69276. * @param scene defines the current scene
  69277. * @param rootUrl defines the root URL containing road procedural texture information
  69278. * @returns a parsed Road Procedural BABYLON.Texture
  69279. */
  69280. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69281. }
  69282. }
  69283. declare module BABYLON {
  69284. /** @hidden */
  69285. export var starfieldProceduralTexturePixelShader: {
  69286. name: string;
  69287. shader: string;
  69288. };
  69289. }
  69290. declare module BABYLON {
  69291. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69292. private _time;
  69293. private _alpha;
  69294. private _beta;
  69295. private _zoom;
  69296. private _formuparam;
  69297. private _stepsize;
  69298. private _tile;
  69299. private _brightness;
  69300. private _darkmatter;
  69301. private _distfading;
  69302. private _saturation;
  69303. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69304. updateShaderUniforms(): void;
  69305. time: number;
  69306. alpha: number;
  69307. beta: number;
  69308. formuparam: number;
  69309. stepsize: number;
  69310. zoom: number;
  69311. tile: number;
  69312. brightness: number;
  69313. darkmatter: number;
  69314. distfading: number;
  69315. saturation: number;
  69316. /**
  69317. * Serializes this starfield procedural texture
  69318. * @returns a serialized starfield procedural texture object
  69319. */
  69320. serialize(): any;
  69321. /**
  69322. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69323. * @param parsedTexture defines parsed texture data
  69324. * @param scene defines the current scene
  69325. * @param rootUrl defines the root URL containing startfield procedural texture information
  69326. * @returns a parsed Starfield Procedural BABYLON.Texture
  69327. */
  69328. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69329. }
  69330. }
  69331. declare module BABYLON {
  69332. /** @hidden */
  69333. export var woodProceduralTexturePixelShader: {
  69334. name: string;
  69335. shader: string;
  69336. };
  69337. }
  69338. declare module BABYLON {
  69339. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69340. private _ampScale;
  69341. private _woodColor;
  69342. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69343. updateShaderUniforms(): void;
  69344. ampScale: number;
  69345. woodColor: BABYLON.Color3;
  69346. /**
  69347. * Serializes this wood procedural texture
  69348. * @returns a serialized wood procedural texture object
  69349. */
  69350. serialize(): any;
  69351. /**
  69352. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69353. * @param parsedTexture defines parsed texture data
  69354. * @param scene defines the current scene
  69355. * @param rootUrl defines the root URL containing wood procedural texture information
  69356. * @returns a parsed Wood Procedural BABYLON.Texture
  69357. */
  69358. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69359. }
  69360. }