babylon.d.txt 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param transform defines the transform (view x projection) matrix to use
  1851. * @returns the new Vector3
  1852. */
  1853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param view defines the view matrix to use
  1861. * @param projection defines the projection matrix to use
  1862. * @returns the new Vector3
  1863. */
  1864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1865. /**
  1866. * Unproject from screen space to object space
  1867. * @param source defines the screen space Vector3 to use
  1868. * @param viewportWidth defines the current width of the viewport
  1869. * @param viewportHeight defines the current height of the viewport
  1870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1871. * @param view defines the view matrix to use
  1872. * @param projection defines the projection matrix to use
  1873. * @param result defines the Vector3 where to store the result
  1874. */
  1875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1876. /**
  1877. * Unproject from screen space to object space
  1878. * @param sourceX defines the screen space x coordinate to use
  1879. * @param sourceY defines the screen space y coordinate to use
  1880. * @param sourceZ defines the screen space z coordinate to use
  1881. * @param viewportWidth defines the current width of the viewport
  1882. * @param viewportHeight defines the current height of the viewport
  1883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1884. * @param view defines the view matrix to use
  1885. * @param projection defines the projection matrix to use
  1886. * @param result defines the Vector3 where to store the result
  1887. */
  1888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1889. /**
  1890. * Gets the minimal coordinate values between two Vector3
  1891. * @param left defines the first operand
  1892. * @param right defines the second operand
  1893. * @returns the new Vector3
  1894. */
  1895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1896. /**
  1897. * Gets the maximal coordinate values between two Vector3
  1898. * @param left defines the first operand
  1899. * @param right defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Returns the distance between the vectors "value1" and "value2"
  1905. * @param value1 defines the first operand
  1906. * @param value2 defines the second operand
  1907. * @returns the distance
  1908. */
  1909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1910. /**
  1911. * Returns the squared distance between the vectors "value1" and "value2"
  1912. * @param value1 defines the first operand
  1913. * @param value2 defines the second operand
  1914. * @returns the squared distance
  1915. */
  1916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1917. /**
  1918. * Returns a new Vector3 located at the center between "value1" and "value2"
  1919. * @param value1 defines the first operand
  1920. * @param value2 defines the second operand
  1921. * @returns the new Vector3
  1922. */
  1923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1924. /**
  1925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1927. * to something in order to rotate it from its local system to the given target system
  1928. * Note: axis1, axis2 and axis3 are normalized during this operation
  1929. * @param axis1 defines the first axis
  1930. * @param axis2 defines the second axis
  1931. * @param axis3 defines the third axis
  1932. * @returns a new Vector3
  1933. */
  1934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1935. /**
  1936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1937. * @param axis1 defines the first axis
  1938. * @param axis2 defines the second axis
  1939. * @param axis3 defines the third axis
  1940. * @param ref defines the Vector3 where to store the result
  1941. */
  1942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1943. }
  1944. /**
  1945. * Vector4 class created for EulerAngle class conversion to Quaternion
  1946. */
  1947. export class Vector4 {
  1948. /** x value of the vector */
  1949. x: number;
  1950. /** y value of the vector */
  1951. y: number;
  1952. /** z value of the vector */
  1953. z: number;
  1954. /** w value of the vector */
  1955. w: number;
  1956. /**
  1957. * Creates a Vector4 object from the given floats.
  1958. * @param x x value of the vector
  1959. * @param y y value of the vector
  1960. * @param z z value of the vector
  1961. * @param w w value of the vector
  1962. */
  1963. constructor(
  1964. /** x value of the vector */
  1965. x: number,
  1966. /** y value of the vector */
  1967. y: number,
  1968. /** z value of the vector */
  1969. z: number,
  1970. /** w value of the vector */
  1971. w: number);
  1972. /**
  1973. * Returns the string with the Vector4 coordinates.
  1974. * @returns a string containing all the vector values
  1975. */
  1976. toString(): string;
  1977. /**
  1978. * Returns the string "Vector4".
  1979. * @returns "Vector4"
  1980. */
  1981. getClassName(): string;
  1982. /**
  1983. * Returns the Vector4 hash code.
  1984. * @returns a unique hash code
  1985. */
  1986. getHashCode(): number;
  1987. /**
  1988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1989. * @returns the resulting array
  1990. */
  1991. asArray(): number[];
  1992. /**
  1993. * Populates the given array from the given index with the Vector4 coordinates.
  1994. * @param array array to populate
  1995. * @param index index of the array to start at (default: 0)
  1996. * @returns the Vector4.
  1997. */
  1998. toArray(array: FloatArray, index?: number): Vector4;
  1999. /**
  2000. * Adds the given vector to the current Vector4.
  2001. * @param otherVector the vector to add
  2002. * @returns the updated Vector4.
  2003. */
  2004. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2005. /**
  2006. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2007. * @param otherVector the vector to add
  2008. * @returns the resulting vector
  2009. */
  2010. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2011. /**
  2012. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2013. * @param otherVector the vector to add
  2014. * @param result the vector to store the result
  2015. * @returns the current Vector4.
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2018. /**
  2019. * Subtract in place the given vector from the current Vector4.
  2020. * @param otherVector the vector to subtract
  2021. * @returns the updated Vector4.
  2022. */
  2023. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2024. /**
  2025. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2026. * @param otherVector the vector to add
  2027. * @returns the new vector with the result
  2028. */
  2029. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2030. /**
  2031. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2032. * @param otherVector the vector to subtract
  2033. * @param result the vector to store the result
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2039. */
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. * @param x value to subtract
  2043. * @param y value to subtract
  2044. * @param z value to subtract
  2045. * @param w value to subtract
  2046. * @returns new vector containing the result
  2047. */
  2048. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2049. /**
  2050. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2051. * @param x value to subtract
  2052. * @param y value to subtract
  2053. * @param z value to subtract
  2054. * @param w value to subtract
  2055. * @param result the vector to store the result in
  2056. * @returns the current Vector4.
  2057. */
  2058. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2059. /**
  2060. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2061. * @returns a new vector with the negated values
  2062. */
  2063. negate(): Vector4;
  2064. /**
  2065. * Multiplies the current Vector4 coordinates by scale (float).
  2066. * @param scale the number to scale with
  2067. * @returns the updated Vector4.
  2068. */
  2069. scaleInPlace(scale: number): Vector4;
  2070. /**
  2071. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2072. * @param scale the number to scale with
  2073. * @returns a new vector with the result
  2074. */
  2075. scale(scale: number): Vector4;
  2076. /**
  2077. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2078. * @param scale the number to scale with
  2079. * @param result a vector to store the result in
  2080. * @returns the current Vector4.
  2081. */
  2082. scaleToRef(scale: number, result: Vector4): Vector4;
  2083. /**
  2084. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2085. * @param scale defines the scale factor
  2086. * @param result defines the Vector4 object where to store the result
  2087. * @returns the unmodified current Vector4
  2088. */
  2089. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2090. /**
  2091. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2092. * @param otherVector the vector to compare against
  2093. * @returns true if they are equal
  2094. */
  2095. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2096. /**
  2097. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2098. * @param otherVector vector to compare against
  2099. * @param epsilon (Default: very small number)
  2100. * @returns true if they are equal
  2101. */
  2102. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2103. /**
  2104. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2105. * @param x x value to compare against
  2106. * @param y y value to compare against
  2107. * @param z z value to compare against
  2108. * @param w w value to compare against
  2109. * @returns true if equal
  2110. */
  2111. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2112. /**
  2113. * Multiplies in place the current Vector4 by the given one.
  2114. * @param otherVector vector to multiple with
  2115. * @returns the updated Vector4.
  2116. */
  2117. multiplyInPlace(otherVector: Vector4): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2120. * @param otherVector vector to multiple with
  2121. * @returns resulting new vector
  2122. */
  2123. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2126. * @param otherVector vector to multiple with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2133. * @param x x value multiply with
  2134. * @param y y value multiply with
  2135. * @param z z value multiply with
  2136. * @param w w value multiply with
  2137. * @returns resulting new vector
  2138. */
  2139. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2142. * @param otherVector vector to devide with
  2143. * @returns resulting new vector
  2144. */
  2145. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2146. /**
  2147. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2148. * @param otherVector vector to devide with
  2149. * @param result vector to store the result
  2150. * @returns the current Vector4.
  2151. */
  2152. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2153. /**
  2154. * Divides the current Vector3 coordinates by the given ones.
  2155. * @param otherVector vector to devide with
  2156. * @returns the updated Vector3.
  2157. */
  2158. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2159. /**
  2160. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2161. * @param other defines the second operand
  2162. * @returns the current updated Vector4
  2163. */
  2164. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2165. /**
  2166. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2167. * @param other defines the second operand
  2168. * @returns the current updated Vector4
  2169. */
  2170. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2171. /**
  2172. * Gets a new Vector4 from current Vector4 floored values
  2173. * @returns a new Vector4
  2174. */
  2175. floor(): Vector4;
  2176. /**
  2177. * Gets a new Vector4 from current Vector3 floored values
  2178. * @returns a new Vector4
  2179. */
  2180. fract(): Vector4;
  2181. /**
  2182. * Returns the Vector4 length (float).
  2183. * @returns the length
  2184. */
  2185. length(): number;
  2186. /**
  2187. * Returns the Vector4 squared length (float).
  2188. * @returns the length squared
  2189. */
  2190. lengthSquared(): number;
  2191. /**
  2192. * Normalizes in place the Vector4.
  2193. * @returns the updated Vector4.
  2194. */
  2195. normalize(): Vector4;
  2196. /**
  2197. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2198. * @returns this converted to a new vector3
  2199. */
  2200. toVector3(): Vector3;
  2201. /**
  2202. * Returns a new Vector4 copied from the current one.
  2203. * @returns the new cloned vector
  2204. */
  2205. clone(): Vector4;
  2206. /**
  2207. * Updates the current Vector4 with the given one coordinates.
  2208. * @param source the source vector to copy from
  2209. * @returns the updated Vector4.
  2210. */
  2211. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2212. /**
  2213. * Updates the current Vector4 coordinates with the given floats.
  2214. * @param x float to copy from
  2215. * @param y float to copy from
  2216. * @param z float to copy from
  2217. * @param w float to copy from
  2218. * @returns the updated Vector4.
  2219. */
  2220. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2221. /**
  2222. * Updates the current Vector4 coordinates with the given floats.
  2223. * @param x float to set from
  2224. * @param y float to set from
  2225. * @param z float to set from
  2226. * @param w float to set from
  2227. * @returns the updated Vector4.
  2228. */
  2229. set(x: number, y: number, z: number, w: number): Vector4;
  2230. /**
  2231. * Copies the given float to the current Vector3 coordinates
  2232. * @param v defines the x, y, z and w coordinates of the operand
  2233. * @returns the current updated Vector3
  2234. */
  2235. setAll(v: number): Vector4;
  2236. /**
  2237. * Returns a new Vector4 set from the starting index of the given array.
  2238. * @param array the array to pull values from
  2239. * @param offset the offset into the array to start at
  2240. * @returns the new vector
  2241. */
  2242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2243. /**
  2244. * Updates the given vector "result" from the starting index of the given array.
  2245. * @param array the array to pull values from
  2246. * @param offset the offset into the array to start at
  2247. * @param result the vector to store the result in
  2248. */
  2249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2250. /**
  2251. * Updates the given vector "result" from the starting index of the given Float32Array.
  2252. * @param array the array to pull values from
  2253. * @param offset the offset into the array to start at
  2254. * @param result the vector to store the result in
  2255. */
  2256. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2257. /**
  2258. * Updates the given vector "result" coordinates from the given floats.
  2259. * @param x float to set from
  2260. * @param y float to set from
  2261. * @param z float to set from
  2262. * @param w float to set from
  2263. * @param result the vector to the floats in
  2264. */
  2265. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2266. /**
  2267. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2268. * @returns the new vector
  2269. */
  2270. static Zero(): Vector4;
  2271. /**
  2272. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2273. * @returns the new vector
  2274. */
  2275. static One(): Vector4;
  2276. /**
  2277. * Returns a new normalized Vector4 from the given one.
  2278. * @param vector the vector to normalize
  2279. * @returns the vector
  2280. */
  2281. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Updates the given vector "result" from the normalization of the given one.
  2284. * @param vector the vector to normalize
  2285. * @param result the vector to store the result in
  2286. */
  2287. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2288. /**
  2289. * Returns a vector with the minimum values from the left and right vectors
  2290. * @param left left vector to minimize
  2291. * @param right right vector to minimize
  2292. * @returns a new vector with the minimum of the left and right vector values
  2293. */
  2294. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2295. /**
  2296. * Returns a vector with the maximum values from the left and right vectors
  2297. * @param left left vector to maximize
  2298. * @param right right vector to maximize
  2299. * @returns a new vector with the maximum of the left and right vector values
  2300. */
  2301. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns the distance (float) between the vectors "value1" and "value2".
  2304. * @param value1 value to calulate the distance between
  2305. * @param value2 value to calulate the distance between
  2306. * @return the distance between the two vectors
  2307. */
  2308. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2309. /**
  2310. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2311. * @param value1 value to calulate the distance between
  2312. * @param value2 value to calulate the distance between
  2313. * @return the distance between the two vectors squared
  2314. */
  2315. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2316. /**
  2317. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2318. * @param value1 value to calulate the center between
  2319. * @param value2 value to calulate the center between
  2320. * @return the center between the two vectors
  2321. */
  2322. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2323. /**
  2324. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2325. * This methods computes transformed normalized direction vectors only.
  2326. * @param vector the vector to transform
  2327. * @param transformation the transformation matrix to apply
  2328. * @returns the new vector
  2329. */
  2330. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2331. /**
  2332. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2333. * This methods computes transformed normalized direction vectors only.
  2334. * @param vector the vector to transform
  2335. * @param transformation the transformation matrix to apply
  2336. * @param result the vector to store the result in
  2337. */
  2338. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2339. /**
  2340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2341. * This methods computes transformed normalized direction vectors only.
  2342. * @param x value to transform
  2343. * @param y value to transform
  2344. * @param z value to transform
  2345. * @param w value to transform
  2346. * @param transformation the transformation matrix to apply
  2347. * @param result the vector to store the results in
  2348. */
  2349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2350. /**
  2351. * Creates a new Vector4 from a Vector3
  2352. * @param source defines the source data
  2353. * @param w defines the 4th component (default is 0)
  2354. * @returns a new Vector4
  2355. */
  2356. static FromVector3(source: Vector3, w?: number): Vector4;
  2357. }
  2358. /**
  2359. * Interface for the size containing width and height
  2360. */
  2361. export interface ISize {
  2362. /**
  2363. * Width
  2364. */
  2365. width: number;
  2366. /**
  2367. * Heighht
  2368. */
  2369. height: number;
  2370. }
  2371. /**
  2372. * Size containing widht and height
  2373. */
  2374. export class Size implements ISize {
  2375. /**
  2376. * Width
  2377. */
  2378. width: number;
  2379. /**
  2380. * Height
  2381. */
  2382. height: number;
  2383. /**
  2384. * Creates a Size object from the given width and height (floats).
  2385. * @param width width of the new size
  2386. * @param height height of the new size
  2387. */
  2388. constructor(width: number, height: number);
  2389. /**
  2390. * Returns a string with the Size width and height
  2391. * @returns a string with the Size width and height
  2392. */
  2393. toString(): string;
  2394. /**
  2395. * "Size"
  2396. * @returns the string "Size"
  2397. */
  2398. getClassName(): string;
  2399. /**
  2400. * Returns the Size hash code.
  2401. * @returns a hash code for a unique width and height
  2402. */
  2403. getHashCode(): number;
  2404. /**
  2405. * Updates the current size from the given one.
  2406. * @param src the given size
  2407. */
  2408. copyFrom(src: Size): void;
  2409. /**
  2410. * Updates in place the current Size from the given floats.
  2411. * @param width width of the new size
  2412. * @param height height of the new size
  2413. * @returns the updated Size.
  2414. */
  2415. copyFromFloats(width: number, height: number): Size;
  2416. /**
  2417. * Updates in place the current Size from the given floats.
  2418. * @param width width to set
  2419. * @param height height to set
  2420. * @returns the updated Size.
  2421. */
  2422. set(width: number, height: number): Size;
  2423. /**
  2424. * Multiplies the width and height by numbers
  2425. * @param w factor to multiple the width by
  2426. * @param h factor to multiple the height by
  2427. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2428. */
  2429. multiplyByFloats(w: number, h: number): Size;
  2430. /**
  2431. * Clones the size
  2432. * @returns a new Size copied from the given one.
  2433. */
  2434. clone(): Size;
  2435. /**
  2436. * True if the current Size and the given one width and height are strictly equal.
  2437. * @param other the other size to compare against
  2438. * @returns True if the current Size and the given one width and height are strictly equal.
  2439. */
  2440. equals(other: Size): boolean;
  2441. /**
  2442. * The surface of the Size : width * height (float).
  2443. */
  2444. readonly surface: number;
  2445. /**
  2446. * Create a new size of zero
  2447. * @returns a new Size set to (0.0, 0.0)
  2448. */
  2449. static Zero(): Size;
  2450. /**
  2451. * Sums the width and height of two sizes
  2452. * @param otherSize size to add to this size
  2453. * @returns a new Size set as the addition result of the current Size and the given one.
  2454. */
  2455. add(otherSize: Size): Size;
  2456. /**
  2457. * Subtracts the width and height of two
  2458. * @param otherSize size to subtract to this size
  2459. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2460. */
  2461. subtract(otherSize: Size): Size;
  2462. /**
  2463. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2464. * @param start starting size to lerp between
  2465. * @param end end size to lerp between
  2466. * @param amount amount to lerp between the start and end values
  2467. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2468. */
  2469. static Lerp(start: Size, end: Size, amount: number): Size;
  2470. }
  2471. /**
  2472. * Class used to store quaternion data
  2473. * @see https://en.wikipedia.org/wiki/Quaternion
  2474. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2475. */
  2476. export class Quaternion {
  2477. /** defines the first component (0 by default) */
  2478. x: number;
  2479. /** defines the second component (0 by default) */
  2480. y: number;
  2481. /** defines the third component (0 by default) */
  2482. z: number;
  2483. /** defines the fourth component (1.0 by default) */
  2484. w: number;
  2485. /**
  2486. * Creates a new Quaternion from the given floats
  2487. * @param x defines the first component (0 by default)
  2488. * @param y defines the second component (0 by default)
  2489. * @param z defines the third component (0 by default)
  2490. * @param w defines the fourth component (1.0 by default)
  2491. */
  2492. constructor(
  2493. /** defines the first component (0 by default) */
  2494. x?: number,
  2495. /** defines the second component (0 by default) */
  2496. y?: number,
  2497. /** defines the third component (0 by default) */
  2498. z?: number,
  2499. /** defines the fourth component (1.0 by default) */
  2500. w?: number);
  2501. /**
  2502. * Gets a string representation for the current quaternion
  2503. * @returns a string with the Quaternion coordinates
  2504. */
  2505. toString(): string;
  2506. /**
  2507. * Gets the class name of the quaternion
  2508. * @returns the string "Quaternion"
  2509. */
  2510. getClassName(): string;
  2511. /**
  2512. * Gets a hash code for this quaternion
  2513. * @returns the quaternion hash code
  2514. */
  2515. getHashCode(): number;
  2516. /**
  2517. * Copy the quaternion to an array
  2518. * @returns a new array populated with 4 elements from the quaternion coordinates
  2519. */
  2520. asArray(): number[];
  2521. /**
  2522. * Check if two quaternions are equals
  2523. * @param otherQuaternion defines the second operand
  2524. * @return true if the current quaternion and the given one coordinates are strictly equals
  2525. */
  2526. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2527. /**
  2528. * Clone the current quaternion
  2529. * @returns a new quaternion copied from the current one
  2530. */
  2531. clone(): Quaternion;
  2532. /**
  2533. * Copy a quaternion to the current one
  2534. * @param other defines the other quaternion
  2535. * @returns the updated current quaternion
  2536. */
  2537. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2538. /**
  2539. * Updates the current quaternion with the given float coordinates
  2540. * @param x defines the x coordinate
  2541. * @param y defines the y coordinate
  2542. * @param z defines the z coordinate
  2543. * @param w defines the w coordinate
  2544. * @returns the updated current quaternion
  2545. */
  2546. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2547. /**
  2548. * Updates the current quaternion from the given float coordinates
  2549. * @param x defines the x coordinate
  2550. * @param y defines the y coordinate
  2551. * @param z defines the z coordinate
  2552. * @param w defines the w coordinate
  2553. * @returns the updated current quaternion
  2554. */
  2555. set(x: number, y: number, z: number, w: number): Quaternion;
  2556. /**
  2557. * Adds two quaternions
  2558. * @param other defines the second operand
  2559. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2560. */
  2561. add(other: DeepImmutable<Quaternion>): Quaternion;
  2562. /**
  2563. * Add a quaternion to the current one
  2564. * @param other defines the quaternion to add
  2565. * @returns the current quaternion
  2566. */
  2567. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2568. /**
  2569. * Subtract two quaternions
  2570. * @param other defines the second operand
  2571. * @returns a new quaternion as the subtraction result of the given one from the current one
  2572. */
  2573. subtract(other: Quaternion): Quaternion;
  2574. /**
  2575. * Multiplies the current quaternion by a scale factor
  2576. * @param value defines the scale factor
  2577. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2578. */
  2579. scale(value: number): Quaternion;
  2580. /**
  2581. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2582. * @param scale defines the scale factor
  2583. * @param result defines the Quaternion object where to store the result
  2584. * @returns the unmodified current quaternion
  2585. */
  2586. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2587. /**
  2588. * Multiplies in place the current quaternion by a scale factor
  2589. * @param value defines the scale factor
  2590. * @returns the current modified quaternion
  2591. */
  2592. scaleInPlace(value: number): Quaternion;
  2593. /**
  2594. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2595. * @param scale defines the scale factor
  2596. * @param result defines the Quaternion object where to store the result
  2597. * @returns the unmodified current quaternion
  2598. */
  2599. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2600. /**
  2601. * Multiplies two quaternions
  2602. * @param q1 defines the second operand
  2603. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2604. */
  2605. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2606. /**
  2607. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2608. * @param q1 defines the second operand
  2609. * @param result defines the target quaternion
  2610. * @returns the current quaternion
  2611. */
  2612. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2613. /**
  2614. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2615. * @param q1 defines the second operand
  2616. * @returns the currentupdated quaternion
  2617. */
  2618. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2619. /**
  2620. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2621. * @param ref defines the target quaternion
  2622. * @returns the current quaternion
  2623. */
  2624. conjugateToRef(ref: Quaternion): Quaternion;
  2625. /**
  2626. * Conjugates in place (1-q) the current quaternion
  2627. * @returns the current updated quaternion
  2628. */
  2629. conjugateInPlace(): Quaternion;
  2630. /**
  2631. * Conjugates in place (1-q) the current quaternion
  2632. * @returns a new quaternion
  2633. */
  2634. conjugate(): Quaternion;
  2635. /**
  2636. * Gets length of current quaternion
  2637. * @returns the quaternion length (float)
  2638. */
  2639. length(): number;
  2640. /**
  2641. * Normalize in place the current quaternion
  2642. * @returns the current updated quaternion
  2643. */
  2644. normalize(): Quaternion;
  2645. /**
  2646. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2647. * @param order is a reserved parameter and is ignore for now
  2648. * @returns a new Vector3 containing the Euler angles
  2649. */
  2650. toEulerAngles(order?: string): Vector3;
  2651. /**
  2652. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2653. * @param result defines the vector which will be filled with the Euler angles
  2654. * @param order is a reserved parameter and is ignore for now
  2655. * @returns the current unchanged quaternion
  2656. */
  2657. toEulerAnglesToRef(result: Vector3): Quaternion;
  2658. /**
  2659. * Updates the given rotation matrix with the current quaternion values
  2660. * @param result defines the target matrix
  2661. * @returns the current unchanged quaternion
  2662. */
  2663. toRotationMatrix(result: Matrix): Quaternion;
  2664. /**
  2665. * Updates the current quaternion from the given rotation matrix values
  2666. * @param matrix defines the source matrix
  2667. * @returns the current updated quaternion
  2668. */
  2669. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2670. /**
  2671. * Creates a new quaternion from a rotation matrix
  2672. * @param matrix defines the source matrix
  2673. * @returns a new quaternion created from the given rotation matrix values
  2674. */
  2675. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2676. /**
  2677. * Updates the given quaternion with the given rotation matrix values
  2678. * @param matrix defines the source matrix
  2679. * @param result defines the target quaternion
  2680. */
  2681. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2682. /**
  2683. * Returns the dot product (float) between the quaternions "left" and "right"
  2684. * @param left defines the left operand
  2685. * @param right defines the right operand
  2686. * @returns the dot product
  2687. */
  2688. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2689. /**
  2690. * Checks if the two quaternions are close to each other
  2691. * @param quat0 defines the first quaternion to check
  2692. * @param quat1 defines the second quaternion to check
  2693. * @returns true if the two quaternions are close to each other
  2694. */
  2695. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2696. /**
  2697. * Creates an empty quaternion
  2698. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2699. */
  2700. static Zero(): Quaternion;
  2701. /**
  2702. * Inverse a given quaternion
  2703. * @param q defines the source quaternion
  2704. * @returns a new quaternion as the inverted current quaternion
  2705. */
  2706. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2707. /**
  2708. * Inverse a given quaternion
  2709. * @param q defines the source quaternion
  2710. * @param result the quaternion the result will be stored in
  2711. * @returns the result quaternion
  2712. */
  2713. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2714. /**
  2715. * Creates an identity quaternion
  2716. * @returns the identity quaternion
  2717. */
  2718. static Identity(): Quaternion;
  2719. /**
  2720. * Gets a boolean indicating if the given quaternion is identity
  2721. * @param quaternion defines the quaternion to check
  2722. * @returns true if the quaternion is identity
  2723. */
  2724. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2725. /**
  2726. * Creates a quaternion from a rotation around an axis
  2727. * @param axis defines the axis to use
  2728. * @param angle defines the angle to use
  2729. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2730. */
  2731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2732. /**
  2733. * Creates a rotation around an axis and stores it into the given quaternion
  2734. * @param axis defines the axis to use
  2735. * @param angle defines the angle to use
  2736. * @param result defines the target quaternion
  2737. * @returns the target quaternion
  2738. */
  2739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2740. /**
  2741. * Creates a new quaternion from data stored into an array
  2742. * @param array defines the data source
  2743. * @param offset defines the offset in the source array where the data starts
  2744. * @returns a new quaternion
  2745. */
  2746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2747. /**
  2748. * Create a quaternion from Euler rotation angles
  2749. * @param x Pitch
  2750. * @param y Yaw
  2751. * @param z Roll
  2752. * @returns the new Quaternion
  2753. */
  2754. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2755. /**
  2756. * Updates a quaternion from Euler rotation angles
  2757. * @param x Pitch
  2758. * @param y Yaw
  2759. * @param z Roll
  2760. * @param result the quaternion to store the result
  2761. * @returns the updated quaternion
  2762. */
  2763. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2764. /**
  2765. * Create a quaternion from Euler rotation vector
  2766. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2767. * @returns the new Quaternion
  2768. */
  2769. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2770. /**
  2771. * Updates a quaternion from Euler rotation vector
  2772. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2773. * @param result the quaternion to store the result
  2774. * @returns the updated quaternion
  2775. */
  2776. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2777. /**
  2778. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2779. * @param yaw defines the rotation around Y axis
  2780. * @param pitch defines the rotation around X axis
  2781. * @param roll defines the rotation around Z axis
  2782. * @returns the new quaternion
  2783. */
  2784. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2785. /**
  2786. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2787. * @param yaw defines the rotation around Y axis
  2788. * @param pitch defines the rotation around X axis
  2789. * @param roll defines the rotation around Z axis
  2790. * @param result defines the target quaternion
  2791. */
  2792. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2793. /**
  2794. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2795. * @param alpha defines the rotation around first axis
  2796. * @param beta defines the rotation around second axis
  2797. * @param gamma defines the rotation around third axis
  2798. * @returns the new quaternion
  2799. */
  2800. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2801. /**
  2802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2803. * @param alpha defines the rotation around first axis
  2804. * @param beta defines the rotation around second axis
  2805. * @param gamma defines the rotation around third axis
  2806. * @param result defines the target quaternion
  2807. */
  2808. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2809. /**
  2810. * 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)
  2811. * @param axis1 defines the first axis
  2812. * @param axis2 defines the second axis
  2813. * @param axis3 defines the third axis
  2814. * @returns the new quaternion
  2815. */
  2816. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2817. /**
  2818. * 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
  2819. * @param axis1 defines the first axis
  2820. * @param axis2 defines the second axis
  2821. * @param axis3 defines the third axis
  2822. * @param ref defines the target quaternion
  2823. */
  2824. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2825. /**
  2826. * Interpolates between two quaternions
  2827. * @param left defines first quaternion
  2828. * @param right defines second quaternion
  2829. * @param amount defines the gradient to use
  2830. * @returns the new interpolated quaternion
  2831. */
  2832. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2833. /**
  2834. * Interpolates between two quaternions and stores it into a target quaternion
  2835. * @param left defines first quaternion
  2836. * @param right defines second quaternion
  2837. * @param amount defines the gradient to use
  2838. * @param result defines the target quaternion
  2839. */
  2840. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2841. /**
  2842. * Interpolate between two quaternions using Hermite interpolation
  2843. * @param value1 defines first quaternion
  2844. * @param tangent1 defines the incoming tangent
  2845. * @param value2 defines second quaternion
  2846. * @param tangent2 defines the outgoing tangent
  2847. * @param amount defines the target quaternion
  2848. * @returns the new interpolated quaternion
  2849. */
  2850. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2851. }
  2852. /**
  2853. * Class used to store matrix data (4x4)
  2854. */
  2855. export class Matrix {
  2856. private static _updateFlagSeed;
  2857. private static _identityReadOnly;
  2858. private _isIdentity;
  2859. private _isIdentityDirty;
  2860. private _isIdentity3x2;
  2861. private _isIdentity3x2Dirty;
  2862. /**
  2863. * Gets the update flag of the matrix which is an unique number for the matrix.
  2864. * It will be incremented every time the matrix data change.
  2865. * You can use it to speed the comparison between two versions of the same matrix.
  2866. */
  2867. updateFlag: number;
  2868. private readonly _m;
  2869. /**
  2870. * Gets the internal data of the matrix
  2871. */
  2872. readonly m: DeepImmutable<Float32Array>;
  2873. /** @hidden */ private _markAsUpdated(): void;
  2874. /** @hidden */
  2875. private _updateIdentityStatus;
  2876. /**
  2877. * Creates an empty matrix (filled with zeros)
  2878. */
  2879. constructor();
  2880. /**
  2881. * Check if the current matrix is identity
  2882. * @returns true is the matrix is the identity matrix
  2883. */
  2884. isIdentity(): boolean;
  2885. /**
  2886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2887. * @returns true is the matrix is the identity matrix
  2888. */
  2889. isIdentityAs3x2(): boolean;
  2890. /**
  2891. * Gets the determinant of the matrix
  2892. * @returns the matrix determinant
  2893. */
  2894. determinant(): number;
  2895. /**
  2896. * Returns the matrix as a Float32Array
  2897. * @returns the matrix underlying array
  2898. */
  2899. toArray(): DeepImmutable<Float32Array>;
  2900. /**
  2901. * Returns the matrix as a Float32Array
  2902. * @returns the matrix underlying array.
  2903. */
  2904. asArray(): DeepImmutable<Float32Array>;
  2905. /**
  2906. * Inverts the current matrix in place
  2907. * @returns the current inverted matrix
  2908. */
  2909. invert(): Matrix;
  2910. /**
  2911. * Sets all the matrix elements to zero
  2912. * @returns the current matrix
  2913. */
  2914. reset(): Matrix;
  2915. /**
  2916. * Adds the current matrix with a second one
  2917. * @param other defines the matrix to add
  2918. * @returns a new matrix as the addition of the current matrix and the given one
  2919. */
  2920. add(other: DeepImmutable<Matrix>): Matrix;
  2921. /**
  2922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2923. * @param other defines the matrix to add
  2924. * @param result defines the target matrix
  2925. * @returns the current matrix
  2926. */
  2927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2928. /**
  2929. * Adds in place the given matrix to the current matrix
  2930. * @param other defines the second operand
  2931. * @returns the current updated matrix
  2932. */
  2933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2934. /**
  2935. * Sets the given matrix to the current inverted Matrix
  2936. * @param other defines the target matrix
  2937. * @returns the unmodified current matrix
  2938. */
  2939. invertToRef(other: Matrix): Matrix;
  2940. /**
  2941. * add a value at the specified position in the current Matrix
  2942. * @param index the index of the value within the matrix. between 0 and 15.
  2943. * @param value the value to be added
  2944. * @returns the current updated matrix
  2945. */
  2946. addAtIndex(index: number, value: number): Matrix;
  2947. /**
  2948. * mutiply the specified position in the current Matrix by a value
  2949. * @param index the index of the value within the matrix. between 0 and 15.
  2950. * @param value the value to be added
  2951. * @returns the current updated matrix
  2952. */
  2953. multiplyAtIndex(index: number, value: number): Matrix;
  2954. /**
  2955. * Inserts the translation vector (using 3 floats) in the current matrix
  2956. * @param x defines the 1st component of the translation
  2957. * @param y defines the 2nd component of the translation
  2958. * @param z defines the 3rd component of the translation
  2959. * @returns the current updated matrix
  2960. */
  2961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2962. /**
  2963. * Adds the translation vector (using 3 floats) in the current matrix
  2964. * @param x defines the 1st component of the translation
  2965. * @param y defines the 2nd component of the translation
  2966. * @param z defines the 3rd component of the translation
  2967. * @returns the current updated matrix
  2968. */
  2969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2970. /**
  2971. * Inserts the translation vector in the current matrix
  2972. * @param vector3 defines the translation to insert
  2973. * @returns the current updated matrix
  2974. */
  2975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2976. /**
  2977. * Gets the translation value of the current matrix
  2978. * @returns a new Vector3 as the extracted translation from the matrix
  2979. */
  2980. getTranslation(): Vector3;
  2981. /**
  2982. * Fill a Vector3 with the extracted translation from the matrix
  2983. * @param result defines the Vector3 where to store the translation
  2984. * @returns the current matrix
  2985. */
  2986. getTranslationToRef(result: Vector3): Matrix;
  2987. /**
  2988. * Remove rotation and scaling part from the matrix
  2989. * @returns the updated matrix
  2990. */
  2991. removeRotationAndScaling(): Matrix;
  2992. /**
  2993. * Multiply two matrices
  2994. * @param other defines the second operand
  2995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2996. */
  2997. multiply(other: DeepImmutable<Matrix>): Matrix;
  2998. /**
  2999. * Copy the current matrix from the given one
  3000. * @param other defines the source matrix
  3001. * @returns the current updated matrix
  3002. */
  3003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3004. /**
  3005. * Populates the given array from the starting index with the current matrix values
  3006. * @param array defines the target array
  3007. * @param offset defines the offset in the target array where to start storing values
  3008. * @returns the current matrix
  3009. */
  3010. copyToArray(array: Float32Array, offset?: number): Matrix;
  3011. /**
  3012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3013. * @param other defines the second operand
  3014. * @param result defines the matrix where to store the multiplication
  3015. * @returns the current matrix
  3016. */
  3017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3018. /**
  3019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3020. * @param other defines the second operand
  3021. * @param result defines the array where to store the multiplication
  3022. * @param offset defines the offset in the target array where to start storing values
  3023. * @returns the current matrix
  3024. */
  3025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3026. /**
  3027. * Check equality between this matrix and a second one
  3028. * @param value defines the second matrix to compare
  3029. * @returns true is the current matrix and the given one values are strictly equal
  3030. */
  3031. equals(value: DeepImmutable<Matrix>): boolean;
  3032. /**
  3033. * Clone the current matrix
  3034. * @returns a new matrix from the current matrix
  3035. */
  3036. clone(): Matrix;
  3037. /**
  3038. * Returns the name of the current matrix class
  3039. * @returns the string "Matrix"
  3040. */
  3041. getClassName(): string;
  3042. /**
  3043. * Gets the hash code of the current matrix
  3044. * @returns the hash code
  3045. */
  3046. getHashCode(): number;
  3047. /**
  3048. * Decomposes the current Matrix into a translation, rotation and scaling components
  3049. * @param scale defines the scale vector3 given as a reference to update
  3050. * @param rotation defines the rotation quaternion given as a reference to update
  3051. * @param translation defines the translation vector3 given as a reference to update
  3052. * @returns true if operation was successful
  3053. */
  3054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3055. /**
  3056. * Gets specific row of the matrix
  3057. * @param index defines the number of the row to get
  3058. * @returns the index-th row of the current matrix as a new Vector4
  3059. */
  3060. getRow(index: number): Nullable<Vector4>;
  3061. /**
  3062. * Sets the index-th row of the current matrix to the vector4 values
  3063. * @param index defines the number of the row to set
  3064. * @param row defines the target vector4
  3065. * @returns the updated current matrix
  3066. */
  3067. setRow(index: number, row: Vector4): Matrix;
  3068. /**
  3069. * Compute the transpose of the matrix
  3070. * @returns the new transposed matrix
  3071. */
  3072. transpose(): Matrix;
  3073. /**
  3074. * Compute the transpose of the matrix and store it in a given matrix
  3075. * @param result defines the target matrix
  3076. * @returns the current matrix
  3077. */
  3078. transposeToRef(result: Matrix): Matrix;
  3079. /**
  3080. * Sets the index-th row of the current matrix with the given 4 x float values
  3081. * @param index defines the row index
  3082. * @param x defines the x component to set
  3083. * @param y defines the y component to set
  3084. * @param z defines the z component to set
  3085. * @param w defines the w component to set
  3086. * @returns the updated current matrix
  3087. */
  3088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3089. /**
  3090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3091. * @param scale defines the scale factor
  3092. * @returns a new matrix
  3093. */
  3094. scale(scale: number): Matrix;
  3095. /**
  3096. * Scale the current matrix values by a factor to a given result matrix
  3097. * @param scale defines the scale factor
  3098. * @param result defines the matrix to store the result
  3099. * @returns the current matrix
  3100. */
  3101. scaleToRef(scale: number, result: Matrix): Matrix;
  3102. /**
  3103. * Scale the current matrix values by a factor and add the result to a given matrix
  3104. * @param scale defines the scale factor
  3105. * @param result defines the Matrix to store the result
  3106. * @returns the current matrix
  3107. */
  3108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3109. /**
  3110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3111. * @param ref matrix to store the result
  3112. */
  3113. toNormalMatrix(ref: Matrix): void;
  3114. /**
  3115. * Gets only rotation part of the current matrix
  3116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3117. */
  3118. getRotationMatrix(): Matrix;
  3119. /**
  3120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3121. * @param result defines the target matrix to store data to
  3122. * @returns the current matrix
  3123. */
  3124. getRotationMatrixToRef(result: Matrix): Matrix;
  3125. /**
  3126. * Toggles model matrix from being right handed to left handed in place and vice versa
  3127. */
  3128. toggleModelMatrixHandInPlace(): void;
  3129. /**
  3130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleProjectionMatrixHandInPlace(): void;
  3133. /**
  3134. * Creates a matrix from an array
  3135. * @param array defines the source array
  3136. * @param offset defines an offset in the source array
  3137. * @returns a new Matrix set from the starting index of the given array
  3138. */
  3139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3140. /**
  3141. * Copy the content of an array into a given matrix
  3142. * @param array defines the source array
  3143. * @param offset defines an offset in the source array
  3144. * @param result defines the target matrix
  3145. */
  3146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3147. /**
  3148. * Stores an array into a matrix after having multiplied each component by a given factor
  3149. * @param array defines the source array
  3150. * @param offset defines the offset in the source array
  3151. * @param scale defines the scaling factor
  3152. * @param result defines the target matrix
  3153. */
  3154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3155. /**
  3156. * Gets an identity matrix that must not be updated
  3157. */
  3158. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3159. /**
  3160. * Stores a list of values (16) inside a given matrix
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @param result defines the target matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates new matrix from a list of values (16)
  3182. * @param initialM11 defines 1st value of 1st row
  3183. * @param initialM12 defines 2nd value of 1st row
  3184. * @param initialM13 defines 3rd value of 1st row
  3185. * @param initialM14 defines 4th value of 1st row
  3186. * @param initialM21 defines 1st value of 2nd row
  3187. * @param initialM22 defines 2nd value of 2nd row
  3188. * @param initialM23 defines 3rd value of 2nd row
  3189. * @param initialM24 defines 4th value of 2nd row
  3190. * @param initialM31 defines 1st value of 3rd row
  3191. * @param initialM32 defines 2nd value of 3rd row
  3192. * @param initialM33 defines 3rd value of 3rd row
  3193. * @param initialM34 defines 4th value of 3rd row
  3194. * @param initialM41 defines 1st value of 4th row
  3195. * @param initialM42 defines 2nd value of 4th row
  3196. * @param initialM43 defines 3rd value of 4th row
  3197. * @param initialM44 defines 4th value of 4th row
  3198. * @returns the new matrix
  3199. */
  3200. 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;
  3201. /**
  3202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3203. * @param scale defines the scale vector3
  3204. * @param rotation defines the rotation quaternion
  3205. * @param translation defines the translation vector3
  3206. * @returns a new matrix
  3207. */
  3208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3209. /**
  3210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3211. * @param scale defines the scale vector3
  3212. * @param rotation defines the rotation quaternion
  3213. * @param translation defines the translation vector3
  3214. * @param result defines the target matrix
  3215. */
  3216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3217. /**
  3218. * Creates a new identity matrix
  3219. * @returns a new identity matrix
  3220. */
  3221. static Identity(): Matrix;
  3222. /**
  3223. * Creates a new identity matrix and stores the result in a given matrix
  3224. * @param result defines the target matrix
  3225. */
  3226. static IdentityToRef(result: Matrix): void;
  3227. /**
  3228. * Creates a new zero matrix
  3229. * @returns a new zero matrix
  3230. */
  3231. static Zero(): Matrix;
  3232. /**
  3233. * Creates a new rotation matrix for "angle" radians around the X axis
  3234. * @param angle defines the angle (in radians) to use
  3235. * @return the new matrix
  3236. */
  3237. static RotationX(angle: number): Matrix;
  3238. /**
  3239. * Creates a new matrix as the invert of a given matrix
  3240. * @param source defines the source matrix
  3241. * @returns the new matrix
  3242. */
  3243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3244. /**
  3245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3246. * @param angle defines the angle (in radians) to use
  3247. * @param result defines the target matrix
  3248. */
  3249. static RotationXToRef(angle: number, result: Matrix): void;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the Y axis
  3252. * @param angle defines the angle (in radians) to use
  3253. * @return the new matrix
  3254. */
  3255. static RotationY(angle: number): Matrix;
  3256. /**
  3257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3258. * @param angle defines the angle (in radians) to use
  3259. * @param result defines the target matrix
  3260. */
  3261. static RotationYToRef(angle: number, result: Matrix): void;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the Z axis
  3264. * @param angle defines the angle (in radians) to use
  3265. * @return the new matrix
  3266. */
  3267. static RotationZ(angle: number): Matrix;
  3268. /**
  3269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3270. * @param angle defines the angle (in radians) to use
  3271. * @param result defines the target matrix
  3272. */
  3273. static RotationZToRef(angle: number, result: Matrix): void;
  3274. /**
  3275. * Creates a new rotation matrix for "angle" radians around the given axis
  3276. * @param axis defines the axis to use
  3277. * @param angle defines the angle (in radians) to use
  3278. * @return the new matrix
  3279. */
  3280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3281. /**
  3282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3283. * @param axis defines the axis to use
  3284. * @param angle defines the angle (in radians) to use
  3285. * @param result defines the target matrix
  3286. */
  3287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3288. /**
  3289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3291. * @param from defines the vector to align
  3292. * @param to defines the vector to align to
  3293. * @param result defines the target matrix
  3294. */
  3295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3296. /**
  3297. * Creates a rotation matrix
  3298. * @param yaw defines the yaw angle in radians (Y axis)
  3299. * @param pitch defines the pitch angle in radians (X axis)
  3300. * @param roll defines the roll angle in radians (X axis)
  3301. * @returns the new rotation matrix
  3302. */
  3303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3304. /**
  3305. * Creates a rotation matrix and stores it in a given matrix
  3306. * @param yaw defines the yaw angle in radians (Y axis)
  3307. * @param pitch defines the pitch angle in radians (X axis)
  3308. * @param roll defines the roll angle in radians (X axis)
  3309. * @param result defines the target matrix
  3310. */
  3311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3312. /**
  3313. * Creates a scaling matrix
  3314. * @param x defines the scale factor on X axis
  3315. * @param y defines the scale factor on Y axis
  3316. * @param z defines the scale factor on Z axis
  3317. * @returns the new matrix
  3318. */
  3319. static Scaling(x: number, y: number, z: number): Matrix;
  3320. /**
  3321. * Creates a scaling matrix and stores it in a given matrix
  3322. * @param x defines the scale factor on X axis
  3323. * @param y defines the scale factor on Y axis
  3324. * @param z defines the scale factor on Z axis
  3325. * @param result defines the target matrix
  3326. */
  3327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3328. /**
  3329. * Creates a translation matrix
  3330. * @param x defines the translation on X axis
  3331. * @param y defines the translation on Y axis
  3332. * @param z defines the translationon Z axis
  3333. * @returns the new matrix
  3334. */
  3335. static Translation(x: number, y: number, z: number): Matrix;
  3336. /**
  3337. * Creates a translation matrix and stores it in a given matrix
  3338. * @param x defines the translation on X axis
  3339. * @param y defines the translation on Y axis
  3340. * @param z defines the translationon Z axis
  3341. * @param result defines the target matrix
  3342. */
  3343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3344. /**
  3345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3346. * @param startValue defines the start value
  3347. * @param endValue defines the end value
  3348. * @param gradient defines the gradient factor
  3349. * @returns the new matrix
  3350. */
  3351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3354. * @param startValue defines the start value
  3355. * @param endValue defines the end value
  3356. * @param gradient defines the gradient factor
  3357. * @param result defines the Matrix object where to store data
  3358. */
  3359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3360. /**
  3361. * Builds a new matrix whose values are computed by:
  3362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3365. * @param startValue defines the first matrix
  3366. * @param endValue defines the second matrix
  3367. * @param gradient defines the gradient between the two matrices
  3368. * @returns the new matrix
  3369. */
  3370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3371. /**
  3372. * Update a matrix to values which are computed by:
  3373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3376. * @param startValue defines the first matrix
  3377. * @param endValue defines the second matrix
  3378. * @param gradient defines the gradient between the two matrices
  3379. * @param result defines the target matrix
  3380. */
  3381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3382. /**
  3383. * 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"
  3384. * This function works in left handed mode
  3385. * @param eye defines the final position of the entity
  3386. * @param target defines where the entity should look at
  3387. * @param up defines the up vector for the entity
  3388. * @returns the new matrix
  3389. */
  3390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3391. /**
  3392. * 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".
  3393. * This function works in left handed mode
  3394. * @param eye defines the final position of the entity
  3395. * @param target defines where the entity should look at
  3396. * @param up defines the up vector for the entity
  3397. * @param result defines the target matrix
  3398. */
  3399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3400. /**
  3401. * 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"
  3402. * This function works in right handed mode
  3403. * @param eye defines the final position of the entity
  3404. * @param target defines where the entity should look at
  3405. * @param up defines the up vector for the entity
  3406. * @returns the new matrix
  3407. */
  3408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3409. /**
  3410. * 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".
  3411. * This function works in right handed mode
  3412. * @param eye defines the final position of the entity
  3413. * @param target defines where the entity should look at
  3414. * @param up defines the up vector for the entity
  3415. * @param result defines the target matrix
  3416. */
  3417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3418. /**
  3419. * Create a left-handed orthographic projection matrix
  3420. * @param width defines the viewport width
  3421. * @param height defines the viewport height
  3422. * @param znear defines the near clip plane
  3423. * @param zfar defines the far clip plane
  3424. * @returns a new matrix as a left-handed orthographic projection matrix
  3425. */
  3426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3427. /**
  3428. * Store a left-handed orthographic projection to a given matrix
  3429. * @param width defines the viewport width
  3430. * @param height defines the viewport height
  3431. * @param znear defines the near clip plane
  3432. * @param zfar defines the far clip plane
  3433. * @param result defines the target matrix
  3434. */
  3435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3436. /**
  3437. * Create a left-handed orthographic projection matrix
  3438. * @param left defines the viewport left coordinate
  3439. * @param right defines the viewport right coordinate
  3440. * @param bottom defines the viewport bottom coordinate
  3441. * @param top defines the viewport top coordinate
  3442. * @param znear defines the near clip plane
  3443. * @param zfar defines the far clip plane
  3444. * @returns a new matrix as a left-handed orthographic projection matrix
  3445. */
  3446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3447. /**
  3448. * Stores a left-handed orthographic projection into a given matrix
  3449. * @param left defines the viewport left coordinate
  3450. * @param right defines the viewport right coordinate
  3451. * @param bottom defines the viewport bottom coordinate
  3452. * @param top defines the viewport top coordinate
  3453. * @param znear defines the near clip plane
  3454. * @param zfar defines the far clip plane
  3455. * @param result defines the target matrix
  3456. */
  3457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3458. /**
  3459. * Creates a right-handed orthographic projection matrix
  3460. * @param left defines the viewport left coordinate
  3461. * @param right defines the viewport right coordinate
  3462. * @param bottom defines the viewport bottom coordinate
  3463. * @param top defines the viewport top coordinate
  3464. * @param znear defines the near clip plane
  3465. * @param zfar defines the far clip plane
  3466. * @returns a new matrix as a right-handed orthographic projection matrix
  3467. */
  3468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3469. /**
  3470. * Stores a right-handed orthographic projection into a given matrix
  3471. * @param left defines the viewport left coordinate
  3472. * @param right defines the viewport right coordinate
  3473. * @param bottom defines the viewport bottom coordinate
  3474. * @param top defines the viewport top coordinate
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @param result defines the target matrix
  3478. */
  3479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3480. /**
  3481. * Creates a left-handed perspective projection matrix
  3482. * @param width defines the viewport width
  3483. * @param height defines the viewport height
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @returns a new matrix as a left-handed perspective projection matrix
  3487. */
  3488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3489. /**
  3490. * Creates a left-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a left-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a left-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Creates a right-handed perspective projection matrix
  3510. * @param fov defines the horizontal field of view
  3511. * @param aspect defines the aspect ratio
  3512. * @param znear defines the near clip plane
  3513. * @param zfar defines the far clip plane
  3514. * @returns a new matrix as a right-handed perspective projection matrix
  3515. */
  3516. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3517. /**
  3518. * Stores a right-handed perspective projection into a given matrix
  3519. * @param fov defines the horizontal field of view
  3520. * @param aspect defines the aspect ratio
  3521. * @param znear defines the near clip plane
  3522. * @param zfar defines the far clip plane
  3523. * @param result defines the target matrix
  3524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3525. */
  3526. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3527. /**
  3528. * Stores a perspective projection for WebVR info a given matrix
  3529. * @param fov defines the field of view
  3530. * @param znear defines the near clip plane
  3531. * @param zfar defines the far clip plane
  3532. * @param result defines the target matrix
  3533. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3534. */
  3535. static PerspectiveFovWebVRToRef(fov: {
  3536. upDegrees: number;
  3537. downDegrees: number;
  3538. leftDegrees: number;
  3539. rightDegrees: number;
  3540. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3541. /**
  3542. * Computes a complete transformation matrix
  3543. * @param viewport defines the viewport to use
  3544. * @param world defines the world matrix
  3545. * @param view defines the view matrix
  3546. * @param projection defines the projection matrix
  3547. * @param zmin defines the near clip plane
  3548. * @param zmax defines the far clip plane
  3549. * @returns the transformation matrix
  3550. */
  3551. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3552. /**
  3553. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3554. * @param matrix defines the matrix to use
  3555. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3556. */
  3557. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3558. /**
  3559. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3560. * @param matrix defines the matrix to use
  3561. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3562. */
  3563. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3564. /**
  3565. * Compute the transpose of a given matrix
  3566. * @param matrix defines the matrix to transpose
  3567. * @returns the new matrix
  3568. */
  3569. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3570. /**
  3571. * Compute the transpose of a matrix and store it in a target matrix
  3572. * @param matrix defines the matrix to transpose
  3573. * @param result defines the target matrix
  3574. */
  3575. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3576. /**
  3577. * Computes a reflection matrix from a plane
  3578. * @param plane defines the reflection plane
  3579. * @returns a new matrix
  3580. */
  3581. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3582. /**
  3583. * Computes a reflection matrix from a plane
  3584. * @param plane defines the reflection plane
  3585. * @param result defines the target matrix
  3586. */
  3587. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3588. /**
  3589. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3590. * @param xaxis defines the value of the 1st axis
  3591. * @param yaxis defines the value of the 2nd axis
  3592. * @param zaxis defines the value of the 3rd axis
  3593. * @param result defines the target matrix
  3594. */
  3595. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3596. /**
  3597. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3598. * @param quat defines the quaternion to use
  3599. * @param result defines the target matrix
  3600. */
  3601. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3602. }
  3603. /**
  3604. * Represens a plane by the equation ax + by + cz + d = 0
  3605. */
  3606. export class Plane {
  3607. /**
  3608. * Normal of the plane (a,b,c)
  3609. */
  3610. normal: Vector3;
  3611. /**
  3612. * d component of the plane
  3613. */
  3614. d: number;
  3615. /**
  3616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3617. * @param a a component of the plane
  3618. * @param b b component of the plane
  3619. * @param c c component of the plane
  3620. * @param d d component of the plane
  3621. */
  3622. constructor(a: number, b: number, c: number, d: number);
  3623. /**
  3624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3625. */
  3626. asArray(): number[];
  3627. /**
  3628. * @returns a new plane copied from the current Plane.
  3629. */
  3630. clone(): Plane;
  3631. /**
  3632. * @returns the string "Plane".
  3633. */
  3634. getClassName(): string;
  3635. /**
  3636. * @returns the Plane hash code.
  3637. */
  3638. getHashCode(): number;
  3639. /**
  3640. * Normalize the current Plane in place.
  3641. * @returns the updated Plane.
  3642. */
  3643. normalize(): Plane;
  3644. /**
  3645. * Applies a transformation the plane and returns the result
  3646. * @param transformation the transformation matrix to be applied to the plane
  3647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3648. */
  3649. transform(transformation: DeepImmutable<Matrix>): Plane;
  3650. /**
  3651. * Calcualtte the dot product between the point and the plane normal
  3652. * @param point point to calculate the dot product with
  3653. * @returns the dot product (float) of the point coordinates and the plane normal.
  3654. */
  3655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Updates the current Plane from the plane defined by the three given points.
  3658. * @param point1 one of the points used to contruct the plane
  3659. * @param point2 one of the points used to contruct the plane
  3660. * @param point3 one of the points used to contruct the plane
  3661. * @returns the updated Plane.
  3662. */
  3663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3664. /**
  3665. * Checks if the plane is facing a given direction
  3666. * @param direction the direction to check if the plane is facing
  3667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3668. * @returns True is the vector "direction" is the same side than the plane normal.
  3669. */
  3670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3671. /**
  3672. * Calculates the distance to a point
  3673. * @param point point to calculate distance to
  3674. * @returns the signed distance (float) from the given point to the Plane.
  3675. */
  3676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3677. /**
  3678. * Creates a plane from an array
  3679. * @param array the array to create a plane from
  3680. * @returns a new Plane from the given array.
  3681. */
  3682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3683. /**
  3684. * Creates a plane from three points
  3685. * @param point1 point used to create the plane
  3686. * @param point2 point used to create the plane
  3687. * @param point3 point used to create the plane
  3688. * @returns a new Plane defined by the three given points.
  3689. */
  3690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3691. /**
  3692. * Creates a plane from an origin point and a normal
  3693. * @param origin origin of the plane to be constructed
  3694. * @param normal normal of the plane to be constructed
  3695. * @returns a new Plane the normal vector to this plane at the given origin point.
  3696. * Note : the vector "normal" is updated because normalized.
  3697. */
  3698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3699. /**
  3700. * Calculates the distance from a plane and a point
  3701. * @param origin origin of the plane to be constructed
  3702. * @param normal normal of the plane to be constructed
  3703. * @param point point to calculate distance to
  3704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3705. */
  3706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3707. }
  3708. /**
  3709. * Class used to represent a viewport on screen
  3710. */
  3711. export class Viewport {
  3712. /** viewport left coordinate */
  3713. x: number;
  3714. /** viewport top coordinate */
  3715. y: number;
  3716. /**viewport width */
  3717. width: number;
  3718. /** viewport height */
  3719. height: number;
  3720. /**
  3721. * Creates a Viewport object located at (x, y) and sized (width, height)
  3722. * @param x defines viewport left coordinate
  3723. * @param y defines viewport top coordinate
  3724. * @param width defines the viewport width
  3725. * @param height defines the viewport height
  3726. */
  3727. constructor(
  3728. /** viewport left coordinate */
  3729. x: number,
  3730. /** viewport top coordinate */
  3731. y: number,
  3732. /**viewport width */
  3733. width: number,
  3734. /** viewport height */
  3735. height: number);
  3736. /**
  3737. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3738. * @param renderWidth defines the rendering width
  3739. * @param renderHeight defines the rendering height
  3740. * @returns a new Viewport
  3741. */
  3742. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3743. /**
  3744. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3745. * @param renderWidth defines the rendering width
  3746. * @param renderHeight defines the rendering height
  3747. * @param ref defines the target viewport
  3748. * @returns the current viewport
  3749. */
  3750. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3751. /**
  3752. * Returns a new Viewport copied from the current one
  3753. * @returns a new Viewport
  3754. */
  3755. clone(): Viewport;
  3756. }
  3757. /**
  3758. * Reprasents a camera frustum
  3759. */
  3760. export class Frustum {
  3761. /**
  3762. * Gets the planes representing the frustum
  3763. * @param transform matrix to be applied to the returned planes
  3764. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3765. */
  3766. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3767. /**
  3768. * Gets the near frustum plane transformed by the transform matrix
  3769. * @param transform transformation matrix to be applied to the resulting frustum plane
  3770. * @param frustumPlane the resuling frustum plane
  3771. */
  3772. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3773. /**
  3774. * Gets the far frustum plane transformed by the transform matrix
  3775. * @param transform transformation matrix to be applied to the resulting frustum plane
  3776. * @param frustumPlane the resuling frustum plane
  3777. */
  3778. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3779. /**
  3780. * Gets the left frustum plane transformed by the transform matrix
  3781. * @param transform transformation matrix to be applied to the resulting frustum plane
  3782. * @param frustumPlane the resuling frustum plane
  3783. */
  3784. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3785. /**
  3786. * Gets the right frustum plane transformed by the transform matrix
  3787. * @param transform transformation matrix to be applied to the resulting frustum plane
  3788. * @param frustumPlane the resuling frustum plane
  3789. */
  3790. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3791. /**
  3792. * Gets the top frustum plane transformed by the transform matrix
  3793. * @param transform transformation matrix to be applied to the resulting frustum plane
  3794. * @param frustumPlane the resuling frustum plane
  3795. */
  3796. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3797. /**
  3798. * Gets the bottom frustum plane transformed by the transform matrix
  3799. * @param transform transformation matrix to be applied to the resulting frustum plane
  3800. * @param frustumPlane the resuling frustum plane
  3801. */
  3802. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3803. /**
  3804. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3805. * @param transform transformation matrix to be applied to the resulting frustum planes
  3806. * @param frustumPlanes the resuling frustum planes
  3807. */
  3808. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3809. }
  3810. /** Defines supported spaces */
  3811. export enum Space {
  3812. /** Local (object) space */
  3813. LOCAL = 0,
  3814. /** World space */
  3815. WORLD = 1,
  3816. /** Bone space */
  3817. BONE = 2
  3818. }
  3819. /** Defines the 3 main axes */
  3820. export class Axis {
  3821. /** X axis */
  3822. static X: Vector3;
  3823. /** Y axis */
  3824. static Y: Vector3;
  3825. /** Z axis */
  3826. static Z: Vector3;
  3827. }
  3828. /** Class used to represent a Bezier curve */
  3829. export class BezierCurve {
  3830. /**
  3831. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3832. * @param t defines the time
  3833. * @param x1 defines the left coordinate on X axis
  3834. * @param y1 defines the left coordinate on Y axis
  3835. * @param x2 defines the right coordinate on X axis
  3836. * @param y2 defines the right coordinate on Y axis
  3837. * @returns the interpolated value
  3838. */
  3839. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3840. }
  3841. /**
  3842. * Defines potential orientation for back face culling
  3843. */
  3844. export enum Orientation {
  3845. /**
  3846. * Clockwise
  3847. */
  3848. CW = 0,
  3849. /** Counter clockwise */
  3850. CCW = 1
  3851. }
  3852. /**
  3853. * Defines angle representation
  3854. */
  3855. export class Angle {
  3856. private _radians;
  3857. /**
  3858. * Creates an Angle object of "radians" radians (float).
  3859. * @param radians the angle in radians
  3860. */
  3861. constructor(radians: number);
  3862. /**
  3863. * Get value in degrees
  3864. * @returns the Angle value in degrees (float)
  3865. */
  3866. degrees(): number;
  3867. /**
  3868. * Get value in radians
  3869. * @returns the Angle value in radians (float)
  3870. */
  3871. radians(): number;
  3872. /**
  3873. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3874. * @param a defines first vector
  3875. * @param b defines second vector
  3876. * @returns a new Angle
  3877. */
  3878. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3879. /**
  3880. * Gets a new Angle object from the given float in radians
  3881. * @param radians defines the angle value in radians
  3882. * @returns a new Angle
  3883. */
  3884. static FromRadians(radians: number): Angle;
  3885. /**
  3886. * Gets a new Angle object from the given float in degrees
  3887. * @param degrees defines the angle value in degrees
  3888. * @returns a new Angle
  3889. */
  3890. static FromDegrees(degrees: number): Angle;
  3891. }
  3892. /**
  3893. * This represents an arc in a 2d space.
  3894. */
  3895. export class Arc2 {
  3896. /** Defines the start point of the arc */
  3897. startPoint: Vector2;
  3898. /** Defines the mid point of the arc */
  3899. midPoint: Vector2;
  3900. /** Defines the end point of the arc */
  3901. endPoint: Vector2;
  3902. /**
  3903. * Defines the center point of the arc.
  3904. */
  3905. centerPoint: Vector2;
  3906. /**
  3907. * Defines the radius of the arc.
  3908. */
  3909. radius: number;
  3910. /**
  3911. * Defines the angle of the arc (from mid point to end point).
  3912. */
  3913. angle: Angle;
  3914. /**
  3915. * Defines the start angle of the arc (from start point to middle point).
  3916. */
  3917. startAngle: Angle;
  3918. /**
  3919. * Defines the orientation of the arc (clock wise/counter clock wise).
  3920. */
  3921. orientation: Orientation;
  3922. /**
  3923. * Creates an Arc object from the three given points : start, middle and end.
  3924. * @param startPoint Defines the start point of the arc
  3925. * @param midPoint Defines the midlle point of the arc
  3926. * @param endPoint Defines the end point of the arc
  3927. */
  3928. constructor(
  3929. /** Defines the start point of the arc */
  3930. startPoint: Vector2,
  3931. /** Defines the mid point of the arc */
  3932. midPoint: Vector2,
  3933. /** Defines the end point of the arc */
  3934. endPoint: Vector2);
  3935. }
  3936. /**
  3937. * Represents a 2D path made up of multiple 2D points
  3938. */
  3939. export class Path2 {
  3940. private _points;
  3941. private _length;
  3942. /**
  3943. * If the path start and end point are the same
  3944. */
  3945. closed: boolean;
  3946. /**
  3947. * Creates a Path2 object from the starting 2D coordinates x and y.
  3948. * @param x the starting points x value
  3949. * @param y the starting points y value
  3950. */
  3951. constructor(x: number, y: number);
  3952. /**
  3953. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3954. * @param x the added points x value
  3955. * @param y the added points y value
  3956. * @returns the updated Path2.
  3957. */
  3958. addLineTo(x: number, y: number): Path2;
  3959. /**
  3960. * 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.
  3961. * @param midX middle point x value
  3962. * @param midY middle point y value
  3963. * @param endX end point x value
  3964. * @param endY end point y value
  3965. * @param numberOfSegments (default: 36)
  3966. * @returns the updated Path2.
  3967. */
  3968. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3969. /**
  3970. * Closes the Path2.
  3971. * @returns the Path2.
  3972. */
  3973. close(): Path2;
  3974. /**
  3975. * Gets the sum of the distance between each sequential point in the path
  3976. * @returns the Path2 total length (float).
  3977. */
  3978. length(): number;
  3979. /**
  3980. * Gets the points which construct the path
  3981. * @returns the Path2 internal array of points.
  3982. */
  3983. getPoints(): Vector2[];
  3984. /**
  3985. * Retreives the point at the distance aways from the starting point
  3986. * @param normalizedLengthPosition the length along the path to retreive the point from
  3987. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3988. */
  3989. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3990. /**
  3991. * Creates a new path starting from an x and y position
  3992. * @param x starting x value
  3993. * @param y starting y value
  3994. * @returns a new Path2 starting at the coordinates (x, y).
  3995. */
  3996. static StartingAt(x: number, y: number): Path2;
  3997. }
  3998. /**
  3999. * Represents a 3D path made up of multiple 3D points
  4000. */
  4001. export class Path3D {
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[];
  4006. private _curve;
  4007. private _distances;
  4008. private _tangents;
  4009. private _normals;
  4010. private _binormals;
  4011. private _raw;
  4012. /**
  4013. * new Path3D(path, normal, raw)
  4014. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4015. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4016. * @param path an array of Vector3, the curve axis of the Path3D
  4017. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4018. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4019. */
  4020. constructor(
  4021. /**
  4022. * an array of Vector3, the curve axis of the Path3D
  4023. */
  4024. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4025. /**
  4026. * Returns the Path3D array of successive Vector3 designing its curve.
  4027. * @returns the Path3D array of successive Vector3 designing its curve.
  4028. */
  4029. getCurve(): Vector3[];
  4030. /**
  4031. * Returns an array populated with tangent vectors on each Path3D curve point.
  4032. * @returns an array populated with tangent vectors on each Path3D curve point.
  4033. */
  4034. getTangents(): Vector3[];
  4035. /**
  4036. * Returns an array populated with normal vectors on each Path3D curve point.
  4037. * @returns an array populated with normal vectors on each Path3D curve point.
  4038. */
  4039. getNormals(): Vector3[];
  4040. /**
  4041. * Returns an array populated with binormal vectors on each Path3D curve point.
  4042. * @returns an array populated with binormal vectors on each Path3D curve point.
  4043. */
  4044. getBinormals(): Vector3[];
  4045. /**
  4046. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4047. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4048. */
  4049. getDistances(): number[];
  4050. /**
  4051. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4052. * @param path path which all values are copied into the curves points
  4053. * @param firstNormal which should be projected onto the curve
  4054. * @returns the same object updated.
  4055. */
  4056. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4057. private _compute;
  4058. private _getFirstNonNullVector;
  4059. private _getLastNonNullVector;
  4060. private _normalVector;
  4061. }
  4062. /**
  4063. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4064. * A Curve3 is designed from a series of successive Vector3.
  4065. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4066. */
  4067. export class Curve3 {
  4068. private _points;
  4069. private _length;
  4070. /**
  4071. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4072. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4073. * @param v1 (Vector3) the control point
  4074. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4075. * @param nbPoints (integer) the wanted number of points in the curve
  4076. * @returns the created Curve3
  4077. */
  4078. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4079. /**
  4080. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4081. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4082. * @param v1 (Vector3) the first control point
  4083. * @param v2 (Vector3) the second control point
  4084. * @param v3 (Vector3) the end point of the Cubic Bezier
  4085. * @param nbPoints (integer) the wanted number of points in the curve
  4086. * @returns the created Curve3
  4087. */
  4088. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4089. /**
  4090. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4091. * @param p1 (Vector3) the origin point of the Hermite Spline
  4092. * @param t1 (Vector3) the tangent vector at the origin point
  4093. * @param p2 (Vector3) the end point of the Hermite Spline
  4094. * @param t2 (Vector3) the tangent vector at the end point
  4095. * @param nbPoints (integer) the wanted number of points in the curve
  4096. * @returns the created Curve3
  4097. */
  4098. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4099. /**
  4100. * Returns a Curve3 object along a CatmullRom Spline curve :
  4101. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4102. * @param nbPoints (integer) the wanted number of points between each curve control points
  4103. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4104. * @returns the created Curve3
  4105. */
  4106. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4107. /**
  4108. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4109. * A Curve3 is designed from a series of successive Vector3.
  4110. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4111. * @param points points which make up the curve
  4112. */
  4113. constructor(points: Vector3[]);
  4114. /**
  4115. * @returns the Curve3 stored array of successive Vector3
  4116. */
  4117. getPoints(): Vector3[];
  4118. /**
  4119. * @returns the computed length (float) of the curve.
  4120. */
  4121. length(): number;
  4122. /**
  4123. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4124. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4125. * curveA and curveB keep unchanged.
  4126. * @param curve the curve to continue from this curve
  4127. * @returns the newly constructed curve
  4128. */
  4129. continue(curve: DeepImmutable<Curve3>): Curve3;
  4130. private _computeLength;
  4131. }
  4132. /**
  4133. * Contains position and normal vectors for a vertex
  4134. */
  4135. export class PositionNormalVertex {
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position: Vector3;
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal: Vector3;
  4140. /**
  4141. * Creates a PositionNormalVertex
  4142. * @param position the position of the vertex (defaut: 0,0,0)
  4143. * @param normal the normal of the vertex (defaut: 0,1,0)
  4144. */
  4145. constructor(
  4146. /** the position of the vertex (defaut: 0,0,0) */
  4147. position?: Vector3,
  4148. /** the normal of the vertex (defaut: 0,1,0) */
  4149. normal?: Vector3);
  4150. /**
  4151. * Clones the PositionNormalVertex
  4152. * @returns the cloned PositionNormalVertex
  4153. */
  4154. clone(): PositionNormalVertex;
  4155. }
  4156. /**
  4157. * Contains position, normal and uv vectors for a vertex
  4158. */
  4159. export class PositionNormalTextureVertex {
  4160. /** the position of the vertex (defaut: 0,0,0) */
  4161. position: Vector3;
  4162. /** the normal of the vertex (defaut: 0,1,0) */
  4163. normal: Vector3;
  4164. /** the uv of the vertex (default: 0,0) */
  4165. uv: Vector2;
  4166. /**
  4167. * Creates a PositionNormalTextureVertex
  4168. * @param position the position of the vertex (defaut: 0,0,0)
  4169. * @param normal the normal of the vertex (defaut: 0,1,0)
  4170. * @param uv the uv of the vertex (default: 0,0)
  4171. */
  4172. constructor(
  4173. /** the position of the vertex (defaut: 0,0,0) */
  4174. position?: Vector3,
  4175. /** the normal of the vertex (defaut: 0,1,0) */
  4176. normal?: Vector3,
  4177. /** the uv of the vertex (default: 0,0) */
  4178. uv?: Vector2);
  4179. /**
  4180. * Clones the PositionNormalTextureVertex
  4181. * @returns the cloned PositionNormalTextureVertex
  4182. */
  4183. clone(): PositionNormalTextureVertex;
  4184. }
  4185. /**
  4186. * @hidden
  4187. */
  4188. export class Tmp {
  4189. static Color3: Color3[];
  4190. static Color4: Color4[];
  4191. static Vector2: Vector2[];
  4192. static Vector3: Vector3[];
  4193. static Vector4: Vector4[];
  4194. static Quaternion: Quaternion[];
  4195. static Matrix: Matrix[];
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * Class used to enable access to offline support
  4201. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4202. */
  4203. export interface IOfflineProvider {
  4204. /**
  4205. * Gets a boolean indicating if scene must be saved in the database
  4206. */
  4207. enableSceneOffline: boolean;
  4208. /**
  4209. * Gets a boolean indicating if textures must be saved in the database
  4210. */
  4211. enableTexturesOffline: boolean;
  4212. /**
  4213. * Open the offline support and make it available
  4214. * @param successCallback defines the callback to call on success
  4215. * @param errorCallback defines the callback to call on error
  4216. */
  4217. open(successCallback: () => void, errorCallback: () => void): void;
  4218. /**
  4219. * Loads an image from the offline support
  4220. * @param url defines the url to load from
  4221. * @param image defines the target DOM image
  4222. */
  4223. loadImage(url: string, image: HTMLImageElement): void;
  4224. /**
  4225. * Loads a file from offline support
  4226. * @param url defines the URL to load from
  4227. * @param sceneLoaded defines a callback to call on success
  4228. * @param progressCallBack defines a callback to call when progress changed
  4229. * @param errorCallback defines a callback to call on error
  4230. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4231. */
  4232. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4233. }
  4234. }
  4235. declare module BABYLON {
  4236. /**
  4237. * A class serves as a medium between the observable and its observers
  4238. */
  4239. export class EventState {
  4240. /**
  4241. * Create a new EventState
  4242. * @param mask defines the mask associated with this state
  4243. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4244. * @param target defines the original target of the state
  4245. * @param currentTarget defines the current target of the state
  4246. */
  4247. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4248. /**
  4249. * Initialize the current event state
  4250. * @param mask defines the mask associated with this state
  4251. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4252. * @param target defines the original target of the state
  4253. * @param currentTarget defines the current target of the state
  4254. * @returns the current event state
  4255. */
  4256. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4257. /**
  4258. * An Observer can set this property to true to prevent subsequent observers of being notified
  4259. */
  4260. skipNextObservers: boolean;
  4261. /**
  4262. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4263. */
  4264. mask: number;
  4265. /**
  4266. * The object that originally notified the event
  4267. */
  4268. target?: any;
  4269. /**
  4270. * The current object in the bubbling phase
  4271. */
  4272. currentTarget?: any;
  4273. /**
  4274. * This will be populated with the return value of the last function that was executed.
  4275. * If it is the first function in the callback chain it will be the event data.
  4276. */
  4277. lastReturnValue?: any;
  4278. }
  4279. /**
  4280. * Represent an Observer registered to a given Observable object.
  4281. */
  4282. export class Observer<T> {
  4283. /**
  4284. * Defines the callback to call when the observer is notified
  4285. */
  4286. callback: (eventData: T, eventState: EventState) => void;
  4287. /**
  4288. * Defines the mask of the observer (used to filter notifications)
  4289. */
  4290. mask: number;
  4291. /**
  4292. * Defines the current scope used to restore the JS context
  4293. */
  4294. scope: any;
  4295. /** @hidden */ private _willBeUnregistered: boolean;
  4296. /**
  4297. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4298. */
  4299. unregisterOnNextCall: boolean;
  4300. /**
  4301. * Creates a new observer
  4302. * @param callback defines the callback to call when the observer is notified
  4303. * @param mask defines the mask of the observer (used to filter notifications)
  4304. * @param scope defines the current scope used to restore the JS context
  4305. */
  4306. constructor(
  4307. /**
  4308. * Defines the callback to call when the observer is notified
  4309. */
  4310. callback: (eventData: T, eventState: EventState) => void,
  4311. /**
  4312. * Defines the mask of the observer (used to filter notifications)
  4313. */
  4314. mask: number,
  4315. /**
  4316. * Defines the current scope used to restore the JS context
  4317. */
  4318. scope?: any);
  4319. }
  4320. /**
  4321. * Represent a list of observers registered to multiple Observables object.
  4322. */
  4323. export class MultiObserver<T> {
  4324. private _observers;
  4325. private _observables;
  4326. /**
  4327. * Release associated resources
  4328. */
  4329. dispose(): void;
  4330. /**
  4331. * Raise a callback when one of the observable will notify
  4332. * @param observables defines a list of observables to watch
  4333. * @param callback defines the callback to call on notification
  4334. * @param mask defines the mask used to filter notifications
  4335. * @param scope defines the current scope used to restore the JS context
  4336. * @returns the new MultiObserver
  4337. */
  4338. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4339. }
  4340. /**
  4341. * The Observable class is a simple implementation of the Observable pattern.
  4342. *
  4343. * 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.
  4344. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4345. * 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).
  4346. * 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.
  4347. */
  4348. export class Observable<T> {
  4349. private _observers;
  4350. private _eventState;
  4351. private _onObserverAdded;
  4352. /**
  4353. * Gets the list of observers
  4354. */
  4355. readonly observers: Array<Observer<T>>;
  4356. /**
  4357. * Creates a new observable
  4358. * @param onObserverAdded defines a callback to call when a new observer is added
  4359. */
  4360. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4361. /**
  4362. * Create a new Observer with the specified callback
  4363. * @param callback the callback that will be executed for that Observer
  4364. * @param mask the mask used to filter observers
  4365. * @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.
  4366. * @param scope optional scope for the callback to be called from
  4367. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4368. * @returns the new observer created for the callback
  4369. */
  4370. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4371. /**
  4372. * Create a new Observer with the specified callback and unregisters after the next notification
  4373. * @param callback the callback that will be executed for that Observer
  4374. * @returns the new observer created for the callback
  4375. */
  4376. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4377. /**
  4378. * Remove an Observer from the Observable object
  4379. * @param observer the instance of the Observer to remove
  4380. * @returns false if it doesn't belong to this Observable
  4381. */
  4382. remove(observer: Nullable<Observer<T>>): boolean;
  4383. /**
  4384. * Remove a callback from the Observable object
  4385. * @param callback the callback to remove
  4386. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4387. * @returns false if it doesn't belong to this Observable
  4388. */
  4389. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4390. private _deferUnregister;
  4391. private _remove;
  4392. /**
  4393. * Moves the observable to the top of the observer list making it get called first when notified
  4394. * @param observer the observer to move
  4395. */
  4396. makeObserverTopPriority(observer: Observer<T>): void;
  4397. /**
  4398. * Moves the observable to the bottom of the observer list making it get called last when notified
  4399. * @param observer the observer to move
  4400. */
  4401. makeObserverBottomPriority(observer: Observer<T>): void;
  4402. /**
  4403. * Notify all Observers by calling their respective callback with the given data
  4404. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4405. * @param eventData defines the data to send to all observers
  4406. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4407. * @param target defines the original target of the state
  4408. * @param currentTarget defines the current target of the state
  4409. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4410. */
  4411. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4412. /**
  4413. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4414. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4415. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4416. * and it is crucial that all callbacks will be executed.
  4417. * The order of the callbacks is kept, callbacks are not executed parallel.
  4418. *
  4419. * @param eventData The data to be sent to each callback
  4420. * @param mask is used to filter observers defaults to -1
  4421. * @param target defines the callback target (see EventState)
  4422. * @param currentTarget defines he current object in the bubbling phase
  4423. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4424. */
  4425. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4426. /**
  4427. * Notify a specific observer
  4428. * @param observer defines the observer to notify
  4429. * @param eventData defines the data to be sent to each callback
  4430. * @param mask is used to filter observers defaults to -1
  4431. */
  4432. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4433. /**
  4434. * Gets a boolean indicating if the observable has at least one observer
  4435. * @returns true is the Observable has at least one Observer registered
  4436. */
  4437. hasObservers(): boolean;
  4438. /**
  4439. * Clear the list of observers
  4440. */
  4441. clear(): void;
  4442. /**
  4443. * Clone the current observable
  4444. * @returns a new observable
  4445. */
  4446. clone(): Observable<T>;
  4447. /**
  4448. * Does this observable handles observer registered with a given mask
  4449. * @param mask defines the mask to be tested
  4450. * @return whether or not one observer registered with the given mask is handeled
  4451. **/
  4452. hasSpecificMask(mask?: number): boolean;
  4453. }
  4454. }
  4455. declare module BABYLON {
  4456. /**
  4457. * Class used to help managing file picking and drag'n'drop
  4458. * File Storage
  4459. */
  4460. export class FilesInputStore {
  4461. /**
  4462. * List of files ready to be loaded
  4463. */
  4464. static FilesToLoad: {
  4465. [key: string]: File;
  4466. };
  4467. }
  4468. }
  4469. declare module BABYLON {
  4470. /** Defines the cross module used constants to avoid circular dependncies */
  4471. export class Constants {
  4472. /** Defines that alpha blending is disabled */
  4473. static readonly ALPHA_DISABLE: number;
  4474. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4475. static readonly ALPHA_ADD: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4477. static readonly ALPHA_COMBINE: number;
  4478. /** Defines that alpha blending to DEST - SRC * DEST */
  4479. static readonly ALPHA_SUBTRACT: number;
  4480. /** Defines that alpha blending to SRC * DEST */
  4481. static readonly ALPHA_MULTIPLY: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4483. static readonly ALPHA_MAXIMIZED: number;
  4484. /** Defines that alpha blending to SRC + DEST */
  4485. static readonly ALPHA_ONEONE: number;
  4486. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4487. static readonly ALPHA_PREMULTIPLIED: number;
  4488. /**
  4489. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4490. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4491. */
  4492. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4493. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4494. static readonly ALPHA_INTERPOLATE: number;
  4495. /**
  4496. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4497. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4498. */
  4499. static readonly ALPHA_SCREENMODE: number;
  4500. /** Defines that the ressource is not delayed*/
  4501. static readonly DELAYLOADSTATE_NONE: number;
  4502. /** Defines that the ressource was successfully delay loaded */
  4503. static readonly DELAYLOADSTATE_LOADED: number;
  4504. /** Defines that the ressource is currently delay loading */
  4505. static readonly DELAYLOADSTATE_LOADING: number;
  4506. /** Defines that the ressource is delayed and has not started loading */
  4507. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4509. static readonly NEVER: number;
  4510. /** 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 */
  4511. static readonly ALWAYS: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4513. static readonly LESS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4515. static readonly EQUAL: number;
  4516. /** 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 */
  4517. static readonly LEQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4519. static readonly GREATER: number;
  4520. /** 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 */
  4521. static readonly GEQUAL: number;
  4522. /** 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 */
  4523. static readonly NOTEQUAL: number;
  4524. /** Passed to stencilOperation to specify that stencil value must be kept */
  4525. static readonly KEEP: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4527. static readonly REPLACE: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4529. static readonly INCR: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4531. static readonly DECR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4533. static readonly INVERT: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4535. static readonly INCR_WRAP: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4537. static readonly DECR_WRAP: number;
  4538. /** Texture is not repeating outside of 0..1 UVs */
  4539. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4540. /** Texture is repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4542. /** Texture is repeating and mirrored */
  4543. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4544. /** ALPHA */
  4545. static readonly TEXTUREFORMAT_ALPHA: number;
  4546. /** LUMINANCE */
  4547. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4548. /** LUMINANCE_ALPHA */
  4549. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4550. /** RGB */
  4551. static readonly TEXTUREFORMAT_RGB: number;
  4552. /** RGBA */
  4553. static readonly TEXTUREFORMAT_RGBA: number;
  4554. /** RED */
  4555. static readonly TEXTUREFORMAT_RED: number;
  4556. /** RED (2nd reference) */
  4557. static readonly TEXTUREFORMAT_R: number;
  4558. /** RG */
  4559. static readonly TEXTUREFORMAT_RG: number;
  4560. /** RED_INTEGER */
  4561. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4562. /** RED_INTEGER (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4564. /** RG_INTEGER */
  4565. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4566. /** RGB_INTEGER */
  4567. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4568. /** RGBA_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4570. /** UNSIGNED_BYTE */
  4571. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4572. /** UNSIGNED_BYTE (2nd reference) */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4574. /** FLOAT */
  4575. static readonly TEXTURETYPE_FLOAT: number;
  4576. /** HALF_FLOAT */
  4577. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4578. /** BYTE */
  4579. static readonly TEXTURETYPE_BYTE: number;
  4580. /** SHORT */
  4581. static readonly TEXTURETYPE_SHORT: number;
  4582. /** UNSIGNED_SHORT */
  4583. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4584. /** INT */
  4585. static readonly TEXTURETYPE_INT: number;
  4586. /** UNSIGNED_INT */
  4587. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4588. /** UNSIGNED_SHORT_4_4_4_4 */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4590. /** UNSIGNED_SHORT_5_5_5_1 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4592. /** UNSIGNED_SHORT_5_6_5 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4594. /** UNSIGNED_INT_2_10_10_10_REV */
  4595. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4596. /** UNSIGNED_INT_24_8 */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4598. /** UNSIGNED_INT_10F_11F_11F_REV */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4600. /** UNSIGNED_INT_5_9_9_9_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4602. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4603. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4604. /** nearest is mag = nearest and min = nearest and mip = linear */
  4605. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4606. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4607. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4608. /** Trilinear is mag = linear and min = linear and mip = linear */
  4609. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4616. /** mag = nearest and min = nearest and mip = nearest */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4618. /** mag = nearest and min = linear and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = linear */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = linear and mip = none */
  4623. static readonly TEXTURE_NEAREST_LINEAR: number;
  4624. /** mag = nearest and min = nearest and mip = none */
  4625. static readonly TEXTURE_NEAREST_NEAREST: number;
  4626. /** mag = linear and min = nearest and mip = nearest */
  4627. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4628. /** mag = linear and min = nearest and mip = linear */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4630. /** mag = linear and min = linear and mip = none */
  4631. static readonly TEXTURE_LINEAR_LINEAR: number;
  4632. /** mag = linear and min = nearest and mip = none */
  4633. static readonly TEXTURE_LINEAR_NEAREST: number;
  4634. /** Explicit coordinates mode */
  4635. static readonly TEXTURE_EXPLICIT_MODE: number;
  4636. /** Spherical coordinates mode */
  4637. static readonly TEXTURE_SPHERICAL_MODE: number;
  4638. /** Planar coordinates mode */
  4639. static readonly TEXTURE_PLANAR_MODE: number;
  4640. /** Cubic coordinates mode */
  4641. static readonly TEXTURE_CUBIC_MODE: number;
  4642. /** Projection coordinates mode */
  4643. static readonly TEXTURE_PROJECTION_MODE: number;
  4644. /** Skybox coordinates mode */
  4645. static readonly TEXTURE_SKYBOX_MODE: number;
  4646. /** Inverse Cubic coordinates mode */
  4647. static readonly TEXTURE_INVCUBIC_MODE: number;
  4648. /** Equirectangular coordinates mode */
  4649. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4650. /** Equirectangular Fixed coordinates mode */
  4651. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed Mirrored coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4654. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4655. static readonly SCALEMODE_FLOOR: number;
  4656. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4657. static readonly SCALEMODE_NEAREST: number;
  4658. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4659. static readonly SCALEMODE_CEILING: number;
  4660. /**
  4661. * The dirty texture flag value
  4662. */
  4663. static readonly MATERIAL_TextureDirtyFlag: number;
  4664. /**
  4665. * The dirty light flag value
  4666. */
  4667. static readonly MATERIAL_LightDirtyFlag: number;
  4668. /**
  4669. * The dirty fresnel flag value
  4670. */
  4671. static readonly MATERIAL_FresnelDirtyFlag: number;
  4672. /**
  4673. * The dirty attribute flag value
  4674. */
  4675. static readonly MATERIAL_AttributesDirtyFlag: number;
  4676. /**
  4677. * The dirty misc flag value
  4678. */
  4679. static readonly MATERIAL_MiscDirtyFlag: number;
  4680. /**
  4681. * The all dirty flag value
  4682. */
  4683. static readonly MATERIAL_AllDirtyFlag: number;
  4684. /**
  4685. * Returns the triangle fill mode
  4686. */
  4687. static readonly MATERIAL_TriangleFillMode: number;
  4688. /**
  4689. * Returns the wireframe mode
  4690. */
  4691. static readonly MATERIAL_WireFrameFillMode: number;
  4692. /**
  4693. * Returns the point fill mode
  4694. */
  4695. static readonly MATERIAL_PointFillMode: number;
  4696. /**
  4697. * Returns the point list draw mode
  4698. */
  4699. static readonly MATERIAL_PointListDrawMode: number;
  4700. /**
  4701. * Returns the line list draw mode
  4702. */
  4703. static readonly MATERIAL_LineListDrawMode: number;
  4704. /**
  4705. * Returns the line loop draw mode
  4706. */
  4707. static readonly MATERIAL_LineLoopDrawMode: number;
  4708. /**
  4709. * Returns the line strip draw mode
  4710. */
  4711. static readonly MATERIAL_LineStripDrawMode: number;
  4712. /**
  4713. * Returns the triangle strip draw mode
  4714. */
  4715. static readonly MATERIAL_TriangleStripDrawMode: number;
  4716. /**
  4717. * Returns the triangle fan draw mode
  4718. */
  4719. static readonly MATERIAL_TriangleFanDrawMode: number;
  4720. /**
  4721. * Stores the clock-wise side orientation
  4722. */
  4723. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4724. /**
  4725. * Stores the counter clock-wise side orientation
  4726. */
  4727. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4728. /**
  4729. * Nothing
  4730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4731. */
  4732. static readonly ACTION_NothingTrigger: number;
  4733. /**
  4734. * On pick
  4735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4736. */
  4737. static readonly ACTION_OnPickTrigger: number;
  4738. /**
  4739. * On left pick
  4740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4741. */
  4742. static readonly ACTION_OnLeftPickTrigger: number;
  4743. /**
  4744. * On right pick
  4745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4746. */
  4747. static readonly ACTION_OnRightPickTrigger: number;
  4748. /**
  4749. * On center pick
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnCenterPickTrigger: number;
  4753. /**
  4754. * On pick down
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnPickDownTrigger: number;
  4758. /**
  4759. * On double pick
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnDoublePickTrigger: number;
  4763. /**
  4764. * On pick up
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPickUpTrigger: number;
  4768. /**
  4769. * On pick out.
  4770. * This trigger will only be raised if you also declared a OnPickDown
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickOutTrigger: number;
  4774. /**
  4775. * On long press
  4776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4777. */
  4778. static readonly ACTION_OnLongPressTrigger: number;
  4779. /**
  4780. * On pointer over
  4781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4782. */
  4783. static readonly ACTION_OnPointerOverTrigger: number;
  4784. /**
  4785. * On pointer out
  4786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4787. */
  4788. static readonly ACTION_OnPointerOutTrigger: number;
  4789. /**
  4790. * On every frame
  4791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4792. */
  4793. static readonly ACTION_OnEveryFrameTrigger: number;
  4794. /**
  4795. * On intersection enter
  4796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4797. */
  4798. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4799. /**
  4800. * On intersection exit
  4801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4802. */
  4803. static readonly ACTION_OnIntersectionExitTrigger: number;
  4804. /**
  4805. * On key down
  4806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4807. */
  4808. static readonly ACTION_OnKeyDownTrigger: number;
  4809. /**
  4810. * On key up
  4811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4812. */
  4813. static readonly ACTION_OnKeyUpTrigger: number;
  4814. /**
  4815. * Billboard mode will only apply to Y axis
  4816. */
  4817. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4818. /**
  4819. * Billboard mode will apply to all axes
  4820. */
  4821. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4822. /**
  4823. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4824. */
  4825. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4826. /**
  4827. * Gets or sets base Assets URL
  4828. */
  4829. static PARTICLES_BaseAssetsUrl: string;
  4830. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4831. * Test order :
  4832. * Is the bounding sphere outside the frustum ?
  4833. * If not, are the bounding box vertices outside the frustum ?
  4834. * It not, then the cullable object is in the frustum.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4837. /** Culling strategy : Bounding Sphere Only.
  4838. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4839. * It's also less accurate than the standard because some not visible objects can still be selected.
  4840. * Test : is the bounding sphere outside the frustum ?
  4841. * If not, then the cullable object is in the frustum.
  4842. */
  4843. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4844. /** Culling strategy : Optimistic Inclusion.
  4845. * This in an inclusion test first, then the standard exclusion test.
  4846. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4847. * 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.
  4848. * Anyway, it's as accurate as the standard strategy.
  4849. * Test :
  4850. * Is the cullable object bounding sphere center in the frustum ?
  4851. * If not, apply the default culling strategy.
  4852. */
  4853. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4854. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4855. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4856. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4857. * 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.
  4858. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4859. * Test :
  4860. * Is the cullable object bounding sphere center in the frustum ?
  4861. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4862. */
  4863. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4864. /**
  4865. * No logging while loading
  4866. */
  4867. static readonly SCENELOADER_NO_LOGGING: number;
  4868. /**
  4869. * Minimal logging while loading
  4870. */
  4871. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4872. /**
  4873. * Summary logging while loading
  4874. */
  4875. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4876. /**
  4877. * Detailled logging while loading
  4878. */
  4879. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4880. }
  4881. }
  4882. declare module BABYLON {
  4883. /**
  4884. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4885. * Babylon.js
  4886. */
  4887. export class DomManagement {
  4888. /**
  4889. * Checks if the window object exists
  4890. * @returns true if the window object exists
  4891. */
  4892. static IsWindowObjectExist(): boolean;
  4893. /**
  4894. * Extracts text content from a DOM element hierarchy
  4895. * @param element defines the root element
  4896. * @returns a string
  4897. */
  4898. static GetDOMTextContent(element: HTMLElement): string;
  4899. }
  4900. }
  4901. declare module BABYLON {
  4902. /**
  4903. * Logger used througouht the application to allow configuration of
  4904. * the log level required for the messages.
  4905. */
  4906. export class Logger {
  4907. /**
  4908. * No log
  4909. */
  4910. static readonly NoneLogLevel: number;
  4911. /**
  4912. * Only message logs
  4913. */
  4914. static readonly MessageLogLevel: number;
  4915. /**
  4916. * Only warning logs
  4917. */
  4918. static readonly WarningLogLevel: number;
  4919. /**
  4920. * Only error logs
  4921. */
  4922. static readonly ErrorLogLevel: number;
  4923. /**
  4924. * All logs
  4925. */
  4926. static readonly AllLogLevel: number;
  4927. private static _LogCache;
  4928. /**
  4929. * Gets a value indicating the number of loading errors
  4930. * @ignorenaming
  4931. */
  4932. static errorsCount: number;
  4933. /**
  4934. * Callback called when a new log is added
  4935. */
  4936. static OnNewCacheEntry: (entry: string) => void;
  4937. private static _AddLogEntry;
  4938. private static _FormatMessage;
  4939. private static _LogDisabled;
  4940. private static _LogEnabled;
  4941. private static _WarnDisabled;
  4942. private static _WarnEnabled;
  4943. private static _ErrorDisabled;
  4944. private static _ErrorEnabled;
  4945. /**
  4946. * Log a message to the console
  4947. */
  4948. static Log: (message: string) => void;
  4949. /**
  4950. * Write a warning message to the console
  4951. */
  4952. static Warn: (message: string) => void;
  4953. /**
  4954. * Write an error message to the console
  4955. */
  4956. static Error: (message: string) => void;
  4957. /**
  4958. * Gets current log cache (list of logs)
  4959. */
  4960. static readonly LogCache: string;
  4961. /**
  4962. * Clears the log cache
  4963. */
  4964. static ClearLogCache(): void;
  4965. /**
  4966. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4967. */
  4968. static LogLevels: number;
  4969. }
  4970. }
  4971. declare module BABYLON {
  4972. /** @hidden */
  4973. export class _TypeStore {
  4974. /** @hidden */
  4975. static RegisteredTypes: {
  4976. [key: string]: Object;
  4977. };
  4978. /** @hidden */
  4979. static GetClass(fqdn: string): any;
  4980. }
  4981. }
  4982. declare module BABYLON {
  4983. /**
  4984. * Class containing a set of static utilities functions for deep copy.
  4985. */
  4986. export class DeepCopier {
  4987. /**
  4988. * Tries to copy an object by duplicating every property
  4989. * @param source defines the source object
  4990. * @param destination defines the target object
  4991. * @param doNotCopyList defines a list of properties to avoid
  4992. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4993. */
  4994. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * Class containing a set of static utilities functions for precision date
  5000. */
  5001. export class PrecisionDate {
  5002. /**
  5003. * Gets either window.performance.now() if supported or Date.now() else
  5004. */
  5005. static readonly Now: number;
  5006. }
  5007. }
  5008. declare module BABYLON {
  5009. /** @hidden */
  5010. export class _DevTools {
  5011. static WarnImport(name: string): string;
  5012. }
  5013. }
  5014. declare module BABYLON {
  5015. /**
  5016. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5017. */
  5018. export class WebRequest {
  5019. private _xhr;
  5020. /**
  5021. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5022. * i.e. when loading files, where the server/service expects an Authorization header
  5023. */
  5024. static CustomRequestHeaders: {
  5025. [key: string]: string;
  5026. };
  5027. /**
  5028. * Add callback functions in this array to update all the requests before they get sent to the network
  5029. */
  5030. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5031. private _injectCustomRequestHeaders;
  5032. /**
  5033. * Gets or sets a function to be called when loading progress changes
  5034. */
  5035. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5036. /**
  5037. * Returns client's state
  5038. */
  5039. readonly readyState: number;
  5040. /**
  5041. * Returns client's status
  5042. */
  5043. readonly status: number;
  5044. /**
  5045. * Returns client's status as a text
  5046. */
  5047. readonly statusText: string;
  5048. /**
  5049. * Returns client's response
  5050. */
  5051. readonly response: any;
  5052. /**
  5053. * Returns client's response url
  5054. */
  5055. readonly responseURL: string;
  5056. /**
  5057. * Returns client's response as text
  5058. */
  5059. readonly responseText: string;
  5060. /**
  5061. * Gets or sets the expected response type
  5062. */
  5063. responseType: XMLHttpRequestResponseType;
  5064. /** @hidden */
  5065. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5066. /** @hidden */
  5067. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5068. /**
  5069. * Cancels any network activity
  5070. */
  5071. abort(): void;
  5072. /**
  5073. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5074. * @param body defines an optional request body
  5075. */
  5076. send(body?: Document | BodyInit | null): void;
  5077. /**
  5078. * Sets the request method, request URL
  5079. * @param method defines the method to use (GET, POST, etc..)
  5080. * @param url defines the url to connect with
  5081. */
  5082. open(method: string, url: string): void;
  5083. }
  5084. }
  5085. declare module BABYLON {
  5086. /**
  5087. * Class used to evalaute queries containing `and` and `or` operators
  5088. */
  5089. export class AndOrNotEvaluator {
  5090. /**
  5091. * Evaluate a query
  5092. * @param query defines the query to evaluate
  5093. * @param evaluateCallback defines the callback used to filter result
  5094. * @returns true if the query matches
  5095. */
  5096. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5097. private static _HandleParenthesisContent;
  5098. private static _SimplifyNegation;
  5099. }
  5100. }
  5101. declare module BABYLON {
  5102. /**
  5103. * Class used to store custom tags
  5104. */
  5105. export class Tags {
  5106. /**
  5107. * Adds support for tags on the given object
  5108. * @param obj defines the object to use
  5109. */
  5110. static EnableFor(obj: any): void;
  5111. /**
  5112. * Removes tags support
  5113. * @param obj defines the object to use
  5114. */
  5115. static DisableFor(obj: any): void;
  5116. /**
  5117. * Gets a boolean indicating if the given object has tags
  5118. * @param obj defines the object to use
  5119. * @returns a boolean
  5120. */
  5121. static HasTags(obj: any): boolean;
  5122. /**
  5123. * Gets the tags available on a given object
  5124. * @param obj defines the object to use
  5125. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5126. * @returns the tags
  5127. */
  5128. static GetTags(obj: any, asString?: boolean): any;
  5129. /**
  5130. * Adds tags to an object
  5131. * @param obj defines the object to use
  5132. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5133. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5134. */
  5135. static AddTagsTo(obj: any, tagsString: string): void;
  5136. /**
  5137. * @hidden
  5138. */ private static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5148. /**
  5149. * Defines if tags hosted on an object match a given query
  5150. * @param obj defines the object to use
  5151. * @param tagsQuery defines the tag query
  5152. * @returns a boolean
  5153. */
  5154. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5155. }
  5156. }
  5157. declare module BABYLON {
  5158. /**
  5159. * Manages the defines for the Material
  5160. */
  5161. export class MaterialDefines {
  5162. /** @hidden */
  5163. protected _keys: string[];
  5164. private _isDirty;
  5165. /** @hidden */ private _renderId: number;
  5166. /** @hidden */ private _areLightsDirty: boolean;
  5167. /** @hidden */ private _areAttributesDirty: boolean;
  5168. /** @hidden */ private _areTexturesDirty: boolean;
  5169. /** @hidden */ private _areFresnelDirty: boolean;
  5170. /** @hidden */ private _areMiscDirty: boolean;
  5171. /** @hidden */ private _areImageProcessingDirty: boolean;
  5172. /** @hidden */ private _normals: boolean;
  5173. /** @hidden */ private _uvs: boolean;
  5174. /** @hidden */ private _needNormals: boolean;
  5175. /** @hidden */ private _needUVs: boolean;
  5176. [id: string]: any;
  5177. /**
  5178. * Specifies if the material needs to be re-calculated
  5179. */
  5180. readonly isDirty: boolean;
  5181. /**
  5182. * Marks the material to indicate that it has been re-calculated
  5183. */
  5184. markAsProcessed(): void;
  5185. /**
  5186. * Marks the material to indicate that it needs to be re-calculated
  5187. */
  5188. markAsUnprocessed(): void;
  5189. /**
  5190. * Marks the material to indicate all of its defines need to be re-calculated
  5191. */
  5192. markAllAsDirty(): void;
  5193. /**
  5194. * Marks the material to indicate that image processing needs to be re-calculated
  5195. */
  5196. markAsImageProcessingDirty(): void;
  5197. /**
  5198. * Marks the material to indicate the lights need to be re-calculated
  5199. */
  5200. markAsLightDirty(): void;
  5201. /**
  5202. * Marks the attribute state as changed
  5203. */
  5204. markAsAttributesDirty(): void;
  5205. /**
  5206. * Marks the texture state as changed
  5207. */
  5208. markAsTexturesDirty(): void;
  5209. /**
  5210. * Marks the fresnel state as changed
  5211. */
  5212. markAsFresnelDirty(): void;
  5213. /**
  5214. * Marks the misc state as changed
  5215. */
  5216. markAsMiscDirty(): void;
  5217. /**
  5218. * Rebuilds the material defines
  5219. */
  5220. rebuild(): void;
  5221. /**
  5222. * Specifies if two material defines are equal
  5223. * @param other - A material define instance to compare to
  5224. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5225. */
  5226. isEqual(other: MaterialDefines): boolean;
  5227. /**
  5228. * Clones this instance's defines to another instance
  5229. * @param other - material defines to clone values to
  5230. */
  5231. cloneTo(other: MaterialDefines): void;
  5232. /**
  5233. * Resets the material define values
  5234. */
  5235. reset(): void;
  5236. /**
  5237. * Converts the material define values to a string
  5238. * @returns - String of material define information
  5239. */
  5240. toString(): string;
  5241. }
  5242. }
  5243. declare module BABYLON {
  5244. /**
  5245. * Class used to store and describe the pipeline context associated with an effect
  5246. */
  5247. export interface IPipelineContext {
  5248. /**
  5249. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5250. */
  5251. isAsync: boolean;
  5252. /**
  5253. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5254. */
  5255. isReady: boolean;
  5256. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5257. }
  5258. }
  5259. declare module BABYLON {
  5260. /**
  5261. * Class used to store gfx data (like WebGLBuffer)
  5262. */
  5263. export class DataBuffer {
  5264. /**
  5265. * Gets or sets the number of objects referencing this buffer
  5266. */
  5267. references: number;
  5268. /** Gets or sets the size of the underlying buffer */
  5269. capacity: number;
  5270. /**
  5271. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5272. */
  5273. is32Bits: boolean;
  5274. /**
  5275. * Gets the underlying buffer
  5276. */
  5277. readonly underlyingResource: any;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /** @hidden */
  5282. export interface IShaderProcessor {
  5283. attributeProcessor?: (attribute: string) => string;
  5284. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5285. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5286. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5287. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5288. lineProcessor?: (line: string, isFragment: boolean) => string;
  5289. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5290. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /** @hidden */
  5295. export interface ProcessingOptions {
  5296. defines: string[];
  5297. indexParameters: any;
  5298. isFragment: boolean;
  5299. shouldUseHighPrecisionShader: boolean;
  5300. supportsUniformBuffers: boolean;
  5301. shadersRepository: string;
  5302. includesShadersStore: {
  5303. [key: string]: string;
  5304. };
  5305. processor?: IShaderProcessor;
  5306. version: string;
  5307. platformName: string;
  5308. lookForClosingBracketForUniformBuffer?: boolean;
  5309. }
  5310. }
  5311. declare module BABYLON {
  5312. /** @hidden */
  5313. export class ShaderCodeNode {
  5314. line: string;
  5315. children: ShaderCodeNode[];
  5316. additionalDefineKey?: string;
  5317. additionalDefineValue?: string;
  5318. isValid(preprocessors: {
  5319. [key: string]: string;
  5320. }): boolean;
  5321. process(preprocessors: {
  5322. [key: string]: string;
  5323. }, options: ProcessingOptions): string;
  5324. }
  5325. }
  5326. declare module BABYLON {
  5327. /** @hidden */
  5328. export class ShaderCodeCursor {
  5329. private _lines;
  5330. lineIndex: number;
  5331. readonly currentLine: string;
  5332. readonly canRead: boolean;
  5333. lines: string[];
  5334. }
  5335. }
  5336. declare module BABYLON {
  5337. /** @hidden */
  5338. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module BABYLON {
  5345. /** @hidden */
  5346. export class ShaderDefineExpression {
  5347. isTrue(preprocessors: {
  5348. [key: string]: string;
  5349. }): boolean;
  5350. }
  5351. }
  5352. declare module BABYLON {
  5353. /** @hidden */
  5354. export class ShaderCodeTestNode extends ShaderCodeNode {
  5355. testExpression: ShaderDefineExpression;
  5356. isValid(preprocessors: {
  5357. [key: string]: string;
  5358. }): boolean;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /** @hidden */
  5363. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5364. define: string;
  5365. not: boolean;
  5366. constructor(define: string, not?: boolean);
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /** @hidden */
  5374. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5375. leftOperand: ShaderDefineExpression;
  5376. rightOperand: ShaderDefineExpression;
  5377. isTrue(preprocessors: {
  5378. [key: string]: string;
  5379. }): boolean;
  5380. }
  5381. }
  5382. declare module BABYLON {
  5383. /** @hidden */
  5384. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5385. leftOperand: ShaderDefineExpression;
  5386. rightOperand: ShaderDefineExpression;
  5387. isTrue(preprocessors: {
  5388. [key: string]: string;
  5389. }): boolean;
  5390. }
  5391. }
  5392. declare module BABYLON {
  5393. /** @hidden */
  5394. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5395. define: string;
  5396. operand: string;
  5397. testValue: string;
  5398. constructor(define: string, operand: string, testValue: string);
  5399. isTrue(preprocessors: {
  5400. [key: string]: string;
  5401. }): boolean;
  5402. }
  5403. }
  5404. declare module BABYLON {
  5405. /** @hidden */
  5406. export class ShaderProcessor {
  5407. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5408. private static _ProcessPrecision;
  5409. private static _ExtractOperation;
  5410. private static _BuildSubExpression;
  5411. private static _BuildExpression;
  5412. private static _MoveCursorWithinIf;
  5413. private static _MoveCursor;
  5414. private static _EvaluatePreProcessors;
  5415. private static _PreparePreProcessors;
  5416. private static _ProcessShaderConversion;
  5417. private static _ProcessIncludes;
  5418. }
  5419. }
  5420. declare module BABYLON {
  5421. /**
  5422. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5423. */
  5424. export class PerformanceMonitor {
  5425. private _enabled;
  5426. private _rollingFrameTime;
  5427. private _lastFrameTimeMs;
  5428. /**
  5429. * constructor
  5430. * @param frameSampleSize The number of samples required to saturate the sliding window
  5431. */
  5432. constructor(frameSampleSize?: number);
  5433. /**
  5434. * Samples current frame
  5435. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5436. */
  5437. sampleFrame(timeMs?: number): void;
  5438. /**
  5439. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5440. */
  5441. readonly averageFrameTime: number;
  5442. /**
  5443. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5444. */
  5445. readonly averageFrameTimeVariance: number;
  5446. /**
  5447. * Returns the frame time of the most recent frame
  5448. */
  5449. readonly instantaneousFrameTime: number;
  5450. /**
  5451. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5452. */
  5453. readonly averageFPS: number;
  5454. /**
  5455. * Returns the average framerate in frames per second using the most recent frame time
  5456. */
  5457. readonly instantaneousFPS: number;
  5458. /**
  5459. * Returns true if enough samples have been taken to completely fill the sliding window
  5460. */
  5461. readonly isSaturated: boolean;
  5462. /**
  5463. * Enables contributions to the sliding window sample set
  5464. */
  5465. enable(): void;
  5466. /**
  5467. * Disables contributions to the sliding window sample set
  5468. * Samples will not be interpolated over the disabled period
  5469. */
  5470. disable(): void;
  5471. /**
  5472. * Returns true if sampling is enabled
  5473. */
  5474. readonly isEnabled: boolean;
  5475. /**
  5476. * Resets performance monitor
  5477. */
  5478. reset(): void;
  5479. }
  5480. /**
  5481. * RollingAverage
  5482. *
  5483. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5484. */
  5485. export class RollingAverage {
  5486. /**
  5487. * Current average
  5488. */
  5489. average: number;
  5490. /**
  5491. * Current variance
  5492. */
  5493. variance: number;
  5494. protected _samples: Array<number>;
  5495. protected _sampleCount: number;
  5496. protected _pos: number;
  5497. protected _m2: number;
  5498. /**
  5499. * constructor
  5500. * @param length The number of samples required to saturate the sliding window
  5501. */
  5502. constructor(length: number);
  5503. /**
  5504. * Adds a sample to the sample set
  5505. * @param v The sample value
  5506. */
  5507. add(v: number): void;
  5508. /**
  5509. * Returns previously added values or null if outside of history or outside the sliding window domain
  5510. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5511. * @return Value previously recorded with add() or null if outside of range
  5512. */
  5513. history(i: number): number;
  5514. /**
  5515. * Returns true if enough samples have been taken to completely fill the sliding window
  5516. * @return true if sample-set saturated
  5517. */
  5518. isSaturated(): boolean;
  5519. /**
  5520. * Resets the rolling average (equivalent to 0 samples taken so far)
  5521. */
  5522. reset(): void;
  5523. /**
  5524. * Wraps a value around the sample range boundaries
  5525. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5526. * @return Wrapped position in sample range
  5527. */
  5528. protected _wrapPosition(i: number): number;
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5534. * The underlying implementation relies on an associative array to ensure the best performances.
  5535. * The value can be anything including 'null' but except 'undefined'
  5536. */
  5537. export class StringDictionary<T> {
  5538. /**
  5539. * This will clear this dictionary and copy the content from the 'source' one.
  5540. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5541. * @param source the dictionary to take the content from and copy to this dictionary
  5542. */
  5543. copyFrom(source: StringDictionary<T>): void;
  5544. /**
  5545. * Get a value based from its key
  5546. * @param key the given key to get the matching value from
  5547. * @return the value if found, otherwise undefined is returned
  5548. */
  5549. get(key: string): T | undefined;
  5550. /**
  5551. * Get a value from its key or add it if it doesn't exist.
  5552. * This method will ensure you that a given key/data will be present in the dictionary.
  5553. * @param key the given key to get the matching value from
  5554. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5555. * The factory will only be invoked if there's no data for the given key.
  5556. * @return the value corresponding to the key.
  5557. */
  5558. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5559. /**
  5560. * Get a value from its key if present in the dictionary otherwise add it
  5561. * @param key the key to get the value from
  5562. * @param val if there's no such key/value pair in the dictionary add it with this value
  5563. * @return the value corresponding to the key
  5564. */
  5565. getOrAdd(key: string, val: T): T;
  5566. /**
  5567. * Check if there's a given key in the dictionary
  5568. * @param key the key to check for
  5569. * @return true if the key is present, false otherwise
  5570. */
  5571. contains(key: string): boolean;
  5572. /**
  5573. * Add a new key and its corresponding value
  5574. * @param key the key to add
  5575. * @param value the value corresponding to the key
  5576. * @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
  5577. */
  5578. add(key: string, value: T): boolean;
  5579. /**
  5580. * Update a specific value associated to a key
  5581. * @param key defines the key to use
  5582. * @param value defines the value to store
  5583. * @returns true if the value was updated (or false if the key was not found)
  5584. */
  5585. set(key: string, value: T): boolean;
  5586. /**
  5587. * Get the element of the given key and remove it from the dictionary
  5588. * @param key defines the key to search
  5589. * @returns the value associated with the key or null if not found
  5590. */
  5591. getAndRemove(key: string): Nullable<T>;
  5592. /**
  5593. * Remove a key/value from the dictionary.
  5594. * @param key the key to remove
  5595. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5596. */
  5597. remove(key: string): boolean;
  5598. /**
  5599. * Clear the whole content of the dictionary
  5600. */
  5601. clear(): void;
  5602. /**
  5603. * Gets the current count
  5604. */
  5605. readonly count: number;
  5606. /**
  5607. * Execute a callback on each key/val of the dictionary.
  5608. * Note that you can remove any element in this dictionary in the callback implementation
  5609. * @param callback the callback to execute on a given key/value pair
  5610. */
  5611. forEach(callback: (key: string, val: T) => void): void;
  5612. /**
  5613. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5614. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5615. * Note that you can remove any element in this dictionary in the callback implementation
  5616. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5617. * @returns the first item
  5618. */
  5619. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5620. private _count;
  5621. private _data;
  5622. }
  5623. }
  5624. declare module BABYLON {
  5625. /**
  5626. * Helper class that provides a small promise polyfill
  5627. */
  5628. export class PromisePolyfill {
  5629. /**
  5630. * Static function used to check if the polyfill is required
  5631. * If this is the case then the function will inject the polyfill to window.Promise
  5632. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5633. */
  5634. static Apply(force?: boolean): void;
  5635. }
  5636. }
  5637. declare module BABYLON {
  5638. /**
  5639. * Class used to store data that will be store in GPU memory
  5640. */
  5641. export class Buffer {
  5642. private _engine;
  5643. private _buffer;
  5644. /** @hidden */ private _data: Nullable<DataArray>;
  5645. private _updatable;
  5646. private _instanced;
  5647. /**
  5648. * Gets the byte stride.
  5649. */
  5650. readonly byteStride: number;
  5651. /**
  5652. * Constructor
  5653. * @param engine the engine
  5654. * @param data the data to use for this buffer
  5655. * @param updatable whether the data is updatable
  5656. * @param stride the stride (optional)
  5657. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5658. * @param instanced whether the buffer is instanced (optional)
  5659. * @param useBytes set to true if the stride in in bytes (optional)
  5660. */
  5661. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5662. /**
  5663. * Create a new VertexBuffer based on the current buffer
  5664. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5665. * @param offset defines offset in the buffer (0 by default)
  5666. * @param size defines the size in floats of attributes (position is 3 for instance)
  5667. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5668. * @param instanced defines if the vertex buffer contains indexed data
  5669. * @param useBytes defines if the offset and stride are in bytes
  5670. * @returns the new vertex buffer
  5671. */
  5672. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5673. /**
  5674. * Gets a boolean indicating if the Buffer is updatable?
  5675. * @returns true if the buffer is updatable
  5676. */
  5677. isUpdatable(): boolean;
  5678. /**
  5679. * Gets current buffer's data
  5680. * @returns a DataArray or null
  5681. */
  5682. getData(): Nullable<DataArray>;
  5683. /**
  5684. * Gets underlying native buffer
  5685. * @returns underlying native buffer
  5686. */
  5687. getBuffer(): Nullable<DataBuffer>;
  5688. /**
  5689. * Gets the stride in float32 units (i.e. byte stride / 4).
  5690. * May not be an integer if the byte stride is not divisible by 4.
  5691. * DEPRECATED. Use byteStride instead.
  5692. * @returns the stride in float32 units
  5693. */
  5694. getStrideSize(): number;
  5695. /**
  5696. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5697. * @param data defines the data to store
  5698. */
  5699. create(data?: Nullable<DataArray>): void;
  5700. /** @hidden */ private _rebuild(): void;
  5701. /**
  5702. * Update current buffer data
  5703. * @param data defines the data to store
  5704. */
  5705. update(data: DataArray): void;
  5706. /**
  5707. * Updates the data directly.
  5708. * @param data the new data
  5709. * @param offset the new offset
  5710. * @param vertexCount the vertex count (optional)
  5711. * @param useBytes set to true if the offset is in bytes
  5712. */
  5713. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5714. /**
  5715. * Release all resources
  5716. */
  5717. dispose(): void;
  5718. }
  5719. /**
  5720. * Specialized buffer used to store vertex data
  5721. */
  5722. export class VertexBuffer {
  5723. /** @hidden */ private _buffer: Buffer;
  5724. private _kind;
  5725. private _size;
  5726. private _ownsBuffer;
  5727. private _instanced;
  5728. private _instanceDivisor;
  5729. /**
  5730. * The byte type.
  5731. */
  5732. static readonly BYTE: number;
  5733. /**
  5734. * The unsigned byte type.
  5735. */
  5736. static readonly UNSIGNED_BYTE: number;
  5737. /**
  5738. * The short type.
  5739. */
  5740. static readonly SHORT: number;
  5741. /**
  5742. * The unsigned short type.
  5743. */
  5744. static readonly UNSIGNED_SHORT: number;
  5745. /**
  5746. * The integer type.
  5747. */
  5748. static readonly INT: number;
  5749. /**
  5750. * The unsigned integer type.
  5751. */
  5752. static readonly UNSIGNED_INT: number;
  5753. /**
  5754. * The float type.
  5755. */
  5756. static readonly FLOAT: number;
  5757. /**
  5758. * Gets or sets the instance divisor when in instanced mode
  5759. */
  5760. instanceDivisor: number;
  5761. /**
  5762. * Gets the byte stride.
  5763. */
  5764. readonly byteStride: number;
  5765. /**
  5766. * Gets the byte offset.
  5767. */
  5768. readonly byteOffset: number;
  5769. /**
  5770. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5771. */
  5772. readonly normalized: boolean;
  5773. /**
  5774. * Gets the data type of each component in the array.
  5775. */
  5776. readonly type: number;
  5777. /**
  5778. * Constructor
  5779. * @param engine the engine
  5780. * @param data the data to use for this vertex buffer
  5781. * @param kind the vertex buffer kind
  5782. * @param updatable whether the data is updatable
  5783. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5784. * @param stride the stride (optional)
  5785. * @param instanced whether the buffer is instanced (optional)
  5786. * @param offset the offset of the data (optional)
  5787. * @param size the number of components (optional)
  5788. * @param type the type of the component (optional)
  5789. * @param normalized whether the data contains normalized data (optional)
  5790. * @param useBytes set to true if stride and offset are in bytes (optional)
  5791. */
  5792. 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);
  5793. /** @hidden */ private _rebuild(): void;
  5794. /**
  5795. * Returns the kind of the VertexBuffer (string)
  5796. * @returns a string
  5797. */
  5798. getKind(): string;
  5799. /**
  5800. * Gets a boolean indicating if the VertexBuffer is updatable?
  5801. * @returns true if the buffer is updatable
  5802. */
  5803. isUpdatable(): boolean;
  5804. /**
  5805. * Gets current buffer's data
  5806. * @returns a DataArray or null
  5807. */
  5808. getData(): Nullable<DataArray>;
  5809. /**
  5810. * Gets underlying native buffer
  5811. * @returns underlying native buffer
  5812. */
  5813. getBuffer(): Nullable<DataBuffer>;
  5814. /**
  5815. * Gets the stride in float32 units (i.e. byte stride / 4).
  5816. * May not be an integer if the byte stride is not divisible by 4.
  5817. * DEPRECATED. Use byteStride instead.
  5818. * @returns the stride in float32 units
  5819. */
  5820. getStrideSize(): number;
  5821. /**
  5822. * Returns the offset as a multiple of the type byte length.
  5823. * DEPRECATED. Use byteOffset instead.
  5824. * @returns the offset in bytes
  5825. */
  5826. getOffset(): number;
  5827. /**
  5828. * Returns the number of components per vertex attribute (integer)
  5829. * @returns the size in float
  5830. */
  5831. getSize(): number;
  5832. /**
  5833. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5834. * @returns true if this buffer is instanced
  5835. */
  5836. getIsInstanced(): boolean;
  5837. /**
  5838. * Returns the instancing divisor, zero for non-instanced (integer).
  5839. * @returns a number
  5840. */
  5841. getInstanceDivisor(): number;
  5842. /**
  5843. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5844. * @param data defines the data to store
  5845. */
  5846. create(data?: DataArray): void;
  5847. /**
  5848. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5849. * This function will create a new buffer if the current one is not updatable
  5850. * @param data defines the data to store
  5851. */
  5852. update(data: DataArray): void;
  5853. /**
  5854. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5855. * Returns the directly updated WebGLBuffer.
  5856. * @param data the new data
  5857. * @param offset the new offset
  5858. * @param useBytes set to true if the offset is in bytes
  5859. */
  5860. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5861. /**
  5862. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5863. */
  5864. dispose(): void;
  5865. /**
  5866. * Enumerates each value of this vertex buffer as numbers.
  5867. * @param count the number of values to enumerate
  5868. * @param callback the callback function called for each value
  5869. */
  5870. forEach(count: number, callback: (value: number, index: number) => void): void;
  5871. /**
  5872. * Positions
  5873. */
  5874. static readonly PositionKind: string;
  5875. /**
  5876. * Normals
  5877. */
  5878. static readonly NormalKind: string;
  5879. /**
  5880. * Tangents
  5881. */
  5882. static readonly TangentKind: string;
  5883. /**
  5884. * Texture coordinates
  5885. */
  5886. static readonly UVKind: string;
  5887. /**
  5888. * Texture coordinates 2
  5889. */
  5890. static readonly UV2Kind: string;
  5891. /**
  5892. * Texture coordinates 3
  5893. */
  5894. static readonly UV3Kind: string;
  5895. /**
  5896. * Texture coordinates 4
  5897. */
  5898. static readonly UV4Kind: string;
  5899. /**
  5900. * Texture coordinates 5
  5901. */
  5902. static readonly UV5Kind: string;
  5903. /**
  5904. * Texture coordinates 6
  5905. */
  5906. static readonly UV6Kind: string;
  5907. /**
  5908. * Colors
  5909. */
  5910. static readonly ColorKind: string;
  5911. /**
  5912. * Matrix indices (for bones)
  5913. */
  5914. static readonly MatricesIndicesKind: string;
  5915. /**
  5916. * Matrix weights (for bones)
  5917. */
  5918. static readonly MatricesWeightsKind: string;
  5919. /**
  5920. * Additional matrix indices (for bones)
  5921. */
  5922. static readonly MatricesIndicesExtraKind: string;
  5923. /**
  5924. * Additional matrix weights (for bones)
  5925. */
  5926. static readonly MatricesWeightsExtraKind: string;
  5927. /**
  5928. * Deduces the stride given a kind.
  5929. * @param kind The kind string to deduce
  5930. * @returns The deduced stride
  5931. */
  5932. static DeduceStride(kind: string): number;
  5933. /**
  5934. * Gets the byte length of the given type.
  5935. * @param type the type
  5936. * @returns the number of bytes
  5937. */
  5938. static GetTypeByteLength(type: number): number;
  5939. /**
  5940. * Enumerates each value of the given parameters as numbers.
  5941. * @param data the data to enumerate
  5942. * @param byteOffset the byte offset of the data
  5943. * @param byteStride the byte stride of the data
  5944. * @param componentCount the number of components per element
  5945. * @param componentType the type of the component
  5946. * @param count the number of values to enumerate
  5947. * @param normalized whether the data is normalized
  5948. * @param callback the callback function called for each value
  5949. */
  5950. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5951. private static _GetFloatValue;
  5952. }
  5953. }
  5954. declare module BABYLON {
  5955. /**
  5956. * Class representing spherical harmonics coefficients to the 3rd degree
  5957. */
  5958. export class SphericalHarmonics {
  5959. /**
  5960. * Defines whether or not the harmonics have been prescaled for rendering.
  5961. */
  5962. preScaled: boolean;
  5963. /**
  5964. * The l0,0 coefficients of the spherical harmonics
  5965. */
  5966. l00: Vector3;
  5967. /**
  5968. * The l1,-1 coefficients of the spherical harmonics
  5969. */
  5970. l1_1: Vector3;
  5971. /**
  5972. * The l1,0 coefficients of the spherical harmonics
  5973. */
  5974. l10: Vector3;
  5975. /**
  5976. * The l1,1 coefficients of the spherical harmonics
  5977. */
  5978. l11: Vector3;
  5979. /**
  5980. * The l2,-2 coefficients of the spherical harmonics
  5981. */
  5982. l2_2: Vector3;
  5983. /**
  5984. * The l2,-1 coefficients of the spherical harmonics
  5985. */
  5986. l2_1: Vector3;
  5987. /**
  5988. * The l2,0 coefficients of the spherical harmonics
  5989. */
  5990. l20: Vector3;
  5991. /**
  5992. * The l2,1 coefficients of the spherical harmonics
  5993. */
  5994. l21: Vector3;
  5995. /**
  5996. * The l2,2 coefficients of the spherical harmonics
  5997. */
  5998. l22: Vector3;
  5999. /**
  6000. * Adds a light to the spherical harmonics
  6001. * @param direction the direction of the light
  6002. * @param color the color of the light
  6003. * @param deltaSolidAngle the delta solid angle of the light
  6004. */
  6005. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6006. /**
  6007. * Scales the spherical harmonics by the given amount
  6008. * @param scale the amount to scale
  6009. */
  6010. scaleInPlace(scale: number): void;
  6011. /**
  6012. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6013. *
  6014. * ```
  6015. * E_lm = A_l * L_lm
  6016. * ```
  6017. *
  6018. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6019. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6020. * the scaling factors are given in equation 9.
  6021. */
  6022. convertIncidentRadianceToIrradiance(): void;
  6023. /**
  6024. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6025. *
  6026. * ```
  6027. * L = (1/pi) * E * rho
  6028. * ```
  6029. *
  6030. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6031. */
  6032. convertIrradianceToLambertianRadiance(): void;
  6033. /**
  6034. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6035. * required operations at run time.
  6036. *
  6037. * This is simply done by scaling back the SH with Ylm constants parameter.
  6038. * The trigonometric part being applied by the shader at run time.
  6039. */
  6040. preScaleForRendering(): void;
  6041. /**
  6042. * Constructs a spherical harmonics from an array.
  6043. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6044. * @returns the spherical harmonics
  6045. */
  6046. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6047. /**
  6048. * Gets the spherical harmonics from polynomial
  6049. * @param polynomial the spherical polynomial
  6050. * @returns the spherical harmonics
  6051. */
  6052. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6053. }
  6054. /**
  6055. * Class representing spherical polynomial coefficients to the 3rd degree
  6056. */
  6057. export class SphericalPolynomial {
  6058. private _harmonics;
  6059. /**
  6060. * The spherical harmonics used to create the polynomials.
  6061. */
  6062. readonly preScaledHarmonics: SphericalHarmonics;
  6063. /**
  6064. * The x coefficients of the spherical polynomial
  6065. */
  6066. x: Vector3;
  6067. /**
  6068. * The y coefficients of the spherical polynomial
  6069. */
  6070. y: Vector3;
  6071. /**
  6072. * The z coefficients of the spherical polynomial
  6073. */
  6074. z: Vector3;
  6075. /**
  6076. * The xx coefficients of the spherical polynomial
  6077. */
  6078. xx: Vector3;
  6079. /**
  6080. * The yy coefficients of the spherical polynomial
  6081. */
  6082. yy: Vector3;
  6083. /**
  6084. * The zz coefficients of the spherical polynomial
  6085. */
  6086. zz: Vector3;
  6087. /**
  6088. * The xy coefficients of the spherical polynomial
  6089. */
  6090. xy: Vector3;
  6091. /**
  6092. * The yz coefficients of the spherical polynomial
  6093. */
  6094. yz: Vector3;
  6095. /**
  6096. * The zx coefficients of the spherical polynomial
  6097. */
  6098. zx: Vector3;
  6099. /**
  6100. * Adds an ambient color to the spherical polynomial
  6101. * @param color the color to add
  6102. */
  6103. addAmbient(color: Color3): void;
  6104. /**
  6105. * Scales the spherical polynomial by the given amount
  6106. * @param scale the amount to scale
  6107. */
  6108. scaleInPlace(scale: number): void;
  6109. /**
  6110. * Gets the spherical polynomial from harmonics
  6111. * @param harmonics the spherical harmonics
  6112. * @returns the spherical polynomial
  6113. */
  6114. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6115. /**
  6116. * Constructs a spherical polynomial from an array.
  6117. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6118. * @returns the spherical polynomial
  6119. */
  6120. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6126. */
  6127. export interface CubeMapInfo {
  6128. /**
  6129. * The pixel array for the front face.
  6130. * This is stored in format, left to right, up to down format.
  6131. */
  6132. front: Nullable<ArrayBufferView>;
  6133. /**
  6134. * The pixel array for the back face.
  6135. * This is stored in format, left to right, up to down format.
  6136. */
  6137. back: Nullable<ArrayBufferView>;
  6138. /**
  6139. * The pixel array for the left face.
  6140. * This is stored in format, left to right, up to down format.
  6141. */
  6142. left: Nullable<ArrayBufferView>;
  6143. /**
  6144. * The pixel array for the right face.
  6145. * This is stored in format, left to right, up to down format.
  6146. */
  6147. right: Nullable<ArrayBufferView>;
  6148. /**
  6149. * The pixel array for the up face.
  6150. * This is stored in format, left to right, up to down format.
  6151. */
  6152. up: Nullable<ArrayBufferView>;
  6153. /**
  6154. * The pixel array for the down face.
  6155. * This is stored in format, left to right, up to down format.
  6156. */
  6157. down: Nullable<ArrayBufferView>;
  6158. /**
  6159. * The size of the cubemap stored.
  6160. *
  6161. * Each faces will be size * size pixels.
  6162. */
  6163. size: number;
  6164. /**
  6165. * The format of the texture.
  6166. *
  6167. * RGBA, RGB.
  6168. */
  6169. format: number;
  6170. /**
  6171. * The type of the texture data.
  6172. *
  6173. * UNSIGNED_INT, FLOAT.
  6174. */
  6175. type: number;
  6176. /**
  6177. * Specifies whether the texture is in gamma space.
  6178. */
  6179. gammaSpace: boolean;
  6180. }
  6181. /**
  6182. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6183. */
  6184. export class PanoramaToCubeMapTools {
  6185. private static FACE_FRONT;
  6186. private static FACE_BACK;
  6187. private static FACE_RIGHT;
  6188. private static FACE_LEFT;
  6189. private static FACE_DOWN;
  6190. private static FACE_UP;
  6191. /**
  6192. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6193. *
  6194. * @param float32Array The source data.
  6195. * @param inputWidth The width of the input panorama.
  6196. * @param inputHeight The height of the input panorama.
  6197. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6198. * @return The cubemap data
  6199. */
  6200. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6201. private static CreateCubemapTexture;
  6202. private static CalcProjectionSpherical;
  6203. }
  6204. }
  6205. declare module BABYLON {
  6206. /**
  6207. * Helper class dealing with the extraction of spherical polynomial dataArray
  6208. * from a cube map.
  6209. */
  6210. export class CubeMapToSphericalPolynomialTools {
  6211. private static FileFaces;
  6212. /**
  6213. * Converts a texture to the according Spherical Polynomial data.
  6214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6215. *
  6216. * @param texture The texture to extract the information from.
  6217. * @return The Spherical Polynomial data.
  6218. */
  6219. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6220. /**
  6221. * Converts a cubemap to the according Spherical Polynomial data.
  6222. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6223. *
  6224. * @param cubeInfo The Cube map to extract the information from.
  6225. * @return The Spherical Polynomial data.
  6226. */
  6227. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6228. }
  6229. }
  6230. declare module BABYLON {
  6231. /**
  6232. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6233. * during the life time of the application.
  6234. */
  6235. export class EngineStore {
  6236. /** Gets the list of created engines */
  6237. static Instances: Engine[];
  6238. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  6239. /**
  6240. * Gets the latest created engine
  6241. */
  6242. static readonly LastCreatedEngine: Nullable<Engine>;
  6243. /**
  6244. * Gets the latest created scene
  6245. */
  6246. static readonly LastCreatedScene: Nullable<Scene>;
  6247. }
  6248. }
  6249. declare module BABYLON {
  6250. /**
  6251. * Define options used to create a render target texture
  6252. */
  6253. export class RenderTargetCreationOptions {
  6254. /**
  6255. * Specifies is mipmaps must be generated
  6256. */
  6257. generateMipMaps?: boolean;
  6258. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6259. generateDepthBuffer?: boolean;
  6260. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6261. generateStencilBuffer?: boolean;
  6262. /** Defines texture type (int by default) */
  6263. type?: number;
  6264. /** Defines sampling mode (trilinear by default) */
  6265. samplingMode?: number;
  6266. /** Defines format (RGBA by default) */
  6267. format?: number;
  6268. }
  6269. }
  6270. declare module BABYLON {
  6271. /**
  6272. * @hidden
  6273. **/
  6274. export class _AlphaState {
  6275. private _isAlphaBlendDirty;
  6276. private _isBlendFunctionParametersDirty;
  6277. private _isBlendEquationParametersDirty;
  6278. private _isBlendConstantsDirty;
  6279. private _alphaBlend;
  6280. private _blendFunctionParameters;
  6281. private _blendEquationParameters;
  6282. private _blendConstants;
  6283. /**
  6284. * Initializes the state.
  6285. */
  6286. constructor();
  6287. readonly isDirty: boolean;
  6288. alphaBlend: boolean;
  6289. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6290. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6291. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6292. reset(): void;
  6293. apply(gl: WebGLRenderingContext): void;
  6294. }
  6295. }
  6296. declare module BABYLON {
  6297. /**
  6298. * @hidden
  6299. **/
  6300. export class _DepthCullingState {
  6301. private _isDepthTestDirty;
  6302. private _isDepthMaskDirty;
  6303. private _isDepthFuncDirty;
  6304. private _isCullFaceDirty;
  6305. private _isCullDirty;
  6306. private _isZOffsetDirty;
  6307. private _isFrontFaceDirty;
  6308. private _depthTest;
  6309. private _depthMask;
  6310. private _depthFunc;
  6311. private _cull;
  6312. private _cullFace;
  6313. private _zOffset;
  6314. private _frontFace;
  6315. /**
  6316. * Initializes the state.
  6317. */
  6318. constructor();
  6319. readonly isDirty: boolean;
  6320. zOffset: number;
  6321. cullFace: Nullable<number>;
  6322. cull: Nullable<boolean>;
  6323. depthFunc: Nullable<number>;
  6324. depthMask: boolean;
  6325. depthTest: boolean;
  6326. frontFace: Nullable<number>;
  6327. reset(): void;
  6328. apply(gl: WebGLRenderingContext): void;
  6329. }
  6330. }
  6331. declare module BABYLON {
  6332. /**
  6333. * @hidden
  6334. **/
  6335. export class _StencilState {
  6336. /** 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 */
  6337. static readonly ALWAYS: number;
  6338. /** Passed to stencilOperation to specify that stencil value must be kept */
  6339. static readonly KEEP: number;
  6340. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6341. static readonly REPLACE: number;
  6342. private _isStencilTestDirty;
  6343. private _isStencilMaskDirty;
  6344. private _isStencilFuncDirty;
  6345. private _isStencilOpDirty;
  6346. private _stencilTest;
  6347. private _stencilMask;
  6348. private _stencilFunc;
  6349. private _stencilFuncRef;
  6350. private _stencilFuncMask;
  6351. private _stencilOpStencilFail;
  6352. private _stencilOpDepthFail;
  6353. private _stencilOpStencilDepthPass;
  6354. readonly isDirty: boolean;
  6355. stencilFunc: number;
  6356. stencilFuncRef: number;
  6357. stencilFuncMask: number;
  6358. stencilOpStencilFail: number;
  6359. stencilOpDepthFail: number;
  6360. stencilOpStencilDepthPass: number;
  6361. stencilMask: number;
  6362. stencilTest: boolean;
  6363. constructor();
  6364. reset(): void;
  6365. apply(gl: WebGLRenderingContext): void;
  6366. }
  6367. }
  6368. declare module BABYLON {
  6369. /**
  6370. * @hidden
  6371. **/
  6372. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  6373. }
  6374. }
  6375. declare module BABYLON {
  6376. /**
  6377. * Class used to store data associated with WebGL texture data for the engine
  6378. * This class should not be used directly
  6379. */
  6380. export class InternalTexture {
  6381. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6382. /**
  6383. * The source of the texture data is unknown
  6384. */
  6385. static DATASOURCE_UNKNOWN: number;
  6386. /**
  6387. * Texture data comes from an URL
  6388. */
  6389. static DATASOURCE_URL: number;
  6390. /**
  6391. * Texture data is only used for temporary storage
  6392. */
  6393. static DATASOURCE_TEMP: number;
  6394. /**
  6395. * Texture data comes from raw data (ArrayBuffer)
  6396. */
  6397. static DATASOURCE_RAW: number;
  6398. /**
  6399. * Texture content is dynamic (video or dynamic texture)
  6400. */
  6401. static DATASOURCE_DYNAMIC: number;
  6402. /**
  6403. * Texture content is generated by rendering to it
  6404. */
  6405. static DATASOURCE_RENDERTARGET: number;
  6406. /**
  6407. * Texture content is part of a multi render target process
  6408. */
  6409. static DATASOURCE_MULTIRENDERTARGET: number;
  6410. /**
  6411. * Texture data comes from a cube data file
  6412. */
  6413. static DATASOURCE_CUBE: number;
  6414. /**
  6415. * Texture data comes from a raw cube data
  6416. */
  6417. static DATASOURCE_CUBERAW: number;
  6418. /**
  6419. * Texture data come from a prefiltered cube data file
  6420. */
  6421. static DATASOURCE_CUBEPREFILTERED: number;
  6422. /**
  6423. * Texture content is raw 3D data
  6424. */
  6425. static DATASOURCE_RAW3D: number;
  6426. /**
  6427. * Texture content is a depth texture
  6428. */
  6429. static DATASOURCE_DEPTHTEXTURE: number;
  6430. /**
  6431. * Texture data comes from a raw cube data encoded with RGBD
  6432. */
  6433. static DATASOURCE_CUBERAW_RGBD: number;
  6434. /**
  6435. * Defines if the texture is ready
  6436. */
  6437. isReady: boolean;
  6438. /**
  6439. * Defines if the texture is a cube texture
  6440. */
  6441. isCube: boolean;
  6442. /**
  6443. * Defines if the texture contains 3D data
  6444. */
  6445. is3D: boolean;
  6446. /**
  6447. * Defines if the texture contains multiview data
  6448. */
  6449. isMultiview: boolean;
  6450. /**
  6451. * Gets the URL used to load this texture
  6452. */
  6453. url: string;
  6454. /**
  6455. * Gets the sampling mode of the texture
  6456. */
  6457. samplingMode: number;
  6458. /**
  6459. * Gets a boolean indicating if the texture needs mipmaps generation
  6460. */
  6461. generateMipMaps: boolean;
  6462. /**
  6463. * Gets the number of samples used by the texture (WebGL2+ only)
  6464. */
  6465. samples: number;
  6466. /**
  6467. * Gets the type of the texture (int, float...)
  6468. */
  6469. type: number;
  6470. /**
  6471. * Gets the format of the texture (RGB, RGBA...)
  6472. */
  6473. format: number;
  6474. /**
  6475. * Observable called when the texture is loaded
  6476. */
  6477. onLoadedObservable: Observable<InternalTexture>;
  6478. /**
  6479. * Gets the width of the texture
  6480. */
  6481. width: number;
  6482. /**
  6483. * Gets the height of the texture
  6484. */
  6485. height: number;
  6486. /**
  6487. * Gets the depth of the texture
  6488. */
  6489. depth: number;
  6490. /**
  6491. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6492. */
  6493. baseWidth: number;
  6494. /**
  6495. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6496. */
  6497. baseHeight: number;
  6498. /**
  6499. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6500. */
  6501. baseDepth: number;
  6502. /**
  6503. * Gets a boolean indicating if the texture is inverted on Y axis
  6504. */
  6505. invertY: boolean;
  6506. /** @hidden */ private _invertVScale: boolean;
  6507. /** @hidden */ private _associatedChannel: number;
  6508. /** @hidden */ private _dataSource: number;
  6509. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6510. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  6511. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  6512. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6513. /** @hidden */ private _size: number;
  6514. /** @hidden */ private _extension: string;
  6515. /** @hidden */ private _files: Nullable<string[]>;
  6516. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  6517. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  6518. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  6519. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6520. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6521. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6522. /** @hidden */ private _attachments: Nullable<number[]>;
  6523. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  6524. /** @hidden */ private _cachedWrapU: Nullable<number>;
  6525. /** @hidden */ private _cachedWrapV: Nullable<number>;
  6526. /** @hidden */ private _cachedWrapR: Nullable<number>;
  6527. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  6528. /** @hidden */ private _isDisabled: boolean;
  6529. /** @hidden */ private _compression: Nullable<string>;
  6530. /** @hidden */ private _generateStencilBuffer: boolean;
  6531. /** @hidden */ private _generateDepthBuffer: boolean;
  6532. /** @hidden */ private _comparisonFunction: number;
  6533. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6534. /** @hidden */ private _lodGenerationScale: number;
  6535. /** @hidden */ private _lodGenerationOffset: number;
  6536. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  6537. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  6538. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  6539. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  6540. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  6541. /** @hidden */ private _isRGBD: boolean;
  6542. /** @hidden */ private _linearSpecularLOD: boolean;
  6543. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  6544. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  6545. /** @hidden */ private _references: number;
  6546. private _engine;
  6547. /**
  6548. * Gets the Engine the texture belongs to.
  6549. * @returns The babylon engine
  6550. */
  6551. getEngine(): Engine;
  6552. /**
  6553. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6554. */
  6555. readonly dataSource: number;
  6556. /**
  6557. * Creates a new InternalTexture
  6558. * @param engine defines the engine to use
  6559. * @param dataSource defines the type of data that will be used
  6560. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6561. */
  6562. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6563. /**
  6564. * Increments the number of references (ie. the number of Texture that point to it)
  6565. */
  6566. incrementReferences(): void;
  6567. /**
  6568. * Change the size of the texture (not the size of the content)
  6569. * @param width defines the new width
  6570. * @param height defines the new height
  6571. * @param depth defines the new depth (1 by default)
  6572. */
  6573. updateSize(width: int, height: int, depth?: int): void;
  6574. /** @hidden */ private _rebuild(): void;
  6575. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  6576. /**
  6577. * Dispose the current allocated resources
  6578. */
  6579. dispose(): void;
  6580. }
  6581. }
  6582. declare module BABYLON {
  6583. /**
  6584. * This represents the main contract an easing function should follow.
  6585. * Easing functions are used throughout the animation system.
  6586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6587. */
  6588. export interface IEasingFunction {
  6589. /**
  6590. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6591. * of the easing function.
  6592. * The link below provides some of the most common examples of easing functions.
  6593. * @see https://easings.net/
  6594. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6595. * @returns the corresponding value on the curve defined by the easing function
  6596. */
  6597. ease(gradient: number): number;
  6598. }
  6599. /**
  6600. * Base class used for every default easing function.
  6601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6602. */
  6603. export class EasingFunction implements IEasingFunction {
  6604. /**
  6605. * Interpolation follows the mathematical formula associated with the easing function.
  6606. */
  6607. static readonly EASINGMODE_EASEIN: number;
  6608. /**
  6609. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6610. */
  6611. static readonly EASINGMODE_EASEOUT: number;
  6612. /**
  6613. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6614. */
  6615. static readonly EASINGMODE_EASEINOUT: number;
  6616. private _easingMode;
  6617. /**
  6618. * Sets the easing mode of the current function.
  6619. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6620. */
  6621. setEasingMode(easingMode: number): void;
  6622. /**
  6623. * Gets the current easing mode.
  6624. * @returns the easing mode
  6625. */
  6626. getEasingMode(): number;
  6627. /**
  6628. * @hidden
  6629. */
  6630. easeInCore(gradient: number): number;
  6631. /**
  6632. * Given an input gradient between 0 and 1, this returns the corresponding value
  6633. * of the easing function.
  6634. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6635. * @returns the corresponding value on the curve defined by the easing function
  6636. */
  6637. ease(gradient: number): number;
  6638. }
  6639. /**
  6640. * Easing function with a circle shape (see link below).
  6641. * @see https://easings.net/#easeInCirc
  6642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6643. */
  6644. export class CircleEase extends EasingFunction implements IEasingFunction {
  6645. /** @hidden */
  6646. easeInCore(gradient: number): number;
  6647. }
  6648. /**
  6649. * Easing function with a ease back shape (see link below).
  6650. * @see https://easings.net/#easeInBack
  6651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6652. */
  6653. export class BackEase extends EasingFunction implements IEasingFunction {
  6654. /** Defines the amplitude of the function */
  6655. amplitude: number;
  6656. /**
  6657. * Instantiates a back ease easing
  6658. * @see https://easings.net/#easeInBack
  6659. * @param amplitude Defines the amplitude of the function
  6660. */
  6661. constructor(
  6662. /** Defines the amplitude of the function */
  6663. amplitude?: number);
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a bouncing shape (see link below).
  6669. * @see https://easings.net/#easeInBounce
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class BounceEase extends EasingFunction implements IEasingFunction {
  6673. /** Defines the number of bounces */
  6674. bounces: number;
  6675. /** Defines the amplitude of the bounce */
  6676. bounciness: number;
  6677. /**
  6678. * Instantiates a bounce easing
  6679. * @see https://easings.net/#easeInBounce
  6680. * @param bounces Defines the number of bounces
  6681. * @param bounciness Defines the amplitude of the bounce
  6682. */
  6683. constructor(
  6684. /** Defines the number of bounces */
  6685. bounces?: number,
  6686. /** Defines the amplitude of the bounce */
  6687. bounciness?: number);
  6688. /** @hidden */
  6689. easeInCore(gradient: number): number;
  6690. }
  6691. /**
  6692. * Easing function with a power of 3 shape (see link below).
  6693. * @see https://easings.net/#easeInCubic
  6694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6695. */
  6696. export class CubicEase extends EasingFunction implements IEasingFunction {
  6697. /** @hidden */
  6698. easeInCore(gradient: number): number;
  6699. }
  6700. /**
  6701. * Easing function with an elastic shape (see link below).
  6702. * @see https://easings.net/#easeInElastic
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6706. /** Defines the number of oscillations*/
  6707. oscillations: number;
  6708. /** Defines the amplitude of the oscillations*/
  6709. springiness: number;
  6710. /**
  6711. * Instantiates an elastic easing function
  6712. * @see https://easings.net/#easeInElastic
  6713. * @param oscillations Defines the number of oscillations
  6714. * @param springiness Defines the amplitude of the oscillations
  6715. */
  6716. constructor(
  6717. /** Defines the number of oscillations*/
  6718. oscillations?: number,
  6719. /** Defines the amplitude of the oscillations*/
  6720. springiness?: number);
  6721. /** @hidden */
  6722. easeInCore(gradient: number): number;
  6723. }
  6724. /**
  6725. * Easing function with an exponential shape (see link below).
  6726. * @see https://easings.net/#easeInExpo
  6727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6728. */
  6729. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6730. /** Defines the exponent of the function */
  6731. exponent: number;
  6732. /**
  6733. * Instantiates an exponential easing function
  6734. * @see https://easings.net/#easeInExpo
  6735. * @param exponent Defines the exponent of the function
  6736. */
  6737. constructor(
  6738. /** Defines the exponent of the function */
  6739. exponent?: number);
  6740. /** @hidden */
  6741. easeInCore(gradient: number): number;
  6742. }
  6743. /**
  6744. * Easing function with a power shape (see link below).
  6745. * @see https://easings.net/#easeInQuad
  6746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6747. */
  6748. export class PowerEase extends EasingFunction implements IEasingFunction {
  6749. /** Defines the power of the function */
  6750. power: number;
  6751. /**
  6752. * Instantiates an power base easing function
  6753. * @see https://easings.net/#easeInQuad
  6754. * @param power Defines the power of the function
  6755. */
  6756. constructor(
  6757. /** Defines the power of the function */
  6758. power?: number);
  6759. /** @hidden */
  6760. easeInCore(gradient: number): number;
  6761. }
  6762. /**
  6763. * Easing function with a power of 2 shape (see link below).
  6764. * @see https://easings.net/#easeInQuad
  6765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6766. */
  6767. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6768. /** @hidden */
  6769. easeInCore(gradient: number): number;
  6770. }
  6771. /**
  6772. * Easing function with a power of 4 shape (see link below).
  6773. * @see https://easings.net/#easeInQuart
  6774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6775. */
  6776. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6777. /** @hidden */
  6778. easeInCore(gradient: number): number;
  6779. }
  6780. /**
  6781. * Easing function with a power of 5 shape (see link below).
  6782. * @see https://easings.net/#easeInQuint
  6783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6784. */
  6785. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6786. /** @hidden */
  6787. easeInCore(gradient: number): number;
  6788. }
  6789. /**
  6790. * Easing function with a sin shape (see link below).
  6791. * @see https://easings.net/#easeInSine
  6792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6793. */
  6794. export class SineEase extends EasingFunction implements IEasingFunction {
  6795. /** @hidden */
  6796. easeInCore(gradient: number): number;
  6797. }
  6798. /**
  6799. * Easing function with a bezier shape (see link below).
  6800. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6802. */
  6803. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6804. /** Defines the x component of the start tangent in the bezier curve */
  6805. x1: number;
  6806. /** Defines the y component of the start tangent in the bezier curve */
  6807. y1: number;
  6808. /** Defines the x component of the end tangent in the bezier curve */
  6809. x2: number;
  6810. /** Defines the y component of the end tangent in the bezier curve */
  6811. y2: number;
  6812. /**
  6813. * Instantiates a bezier function
  6814. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6815. * @param x1 Defines the x component of the start tangent in the bezier curve
  6816. * @param y1 Defines the y component of the start tangent in the bezier curve
  6817. * @param x2 Defines the x component of the end tangent in the bezier curve
  6818. * @param y2 Defines the y component of the end tangent in the bezier curve
  6819. */
  6820. constructor(
  6821. /** Defines the x component of the start tangent in the bezier curve */
  6822. x1?: number,
  6823. /** Defines the y component of the start tangent in the bezier curve */
  6824. y1?: number,
  6825. /** Defines the x component of the end tangent in the bezier curve */
  6826. x2?: number,
  6827. /** Defines the y component of the end tangent in the bezier curve */
  6828. y2?: number);
  6829. /** @hidden */
  6830. easeInCore(gradient: number): number;
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Defines an interface which represents an animation key frame
  6836. */
  6837. export interface IAnimationKey {
  6838. /**
  6839. * Frame of the key frame
  6840. */
  6841. frame: number;
  6842. /**
  6843. * Value at the specifies key frame
  6844. */
  6845. value: any;
  6846. /**
  6847. * The input tangent for the cubic hermite spline
  6848. */
  6849. inTangent?: any;
  6850. /**
  6851. * The output tangent for the cubic hermite spline
  6852. */
  6853. outTangent?: any;
  6854. /**
  6855. * The animation interpolation type
  6856. */
  6857. interpolation?: AnimationKeyInterpolation;
  6858. }
  6859. /**
  6860. * Enum for the animation key frame interpolation type
  6861. */
  6862. export enum AnimationKeyInterpolation {
  6863. /**
  6864. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6865. */
  6866. STEP = 1
  6867. }
  6868. }
  6869. declare module BABYLON {
  6870. /**
  6871. * Represents the range of an animation
  6872. */
  6873. export class AnimationRange {
  6874. /**The name of the animation range**/
  6875. name: string;
  6876. /**The starting frame of the animation */
  6877. from: number;
  6878. /**The ending frame of the animation*/
  6879. to: number;
  6880. /**
  6881. * Initializes the range of an animation
  6882. * @param name The name of the animation range
  6883. * @param from The starting frame of the animation
  6884. * @param to The ending frame of the animation
  6885. */
  6886. constructor(
  6887. /**The name of the animation range**/
  6888. name: string,
  6889. /**The starting frame of the animation */
  6890. from: number,
  6891. /**The ending frame of the animation*/
  6892. to: number);
  6893. /**
  6894. * Makes a copy of the animation range
  6895. * @returns A copy of the animation range
  6896. */
  6897. clone(): AnimationRange;
  6898. }
  6899. }
  6900. declare module BABYLON {
  6901. /**
  6902. * Composed of a frame, and an action function
  6903. */
  6904. export class AnimationEvent {
  6905. /** The frame for which the event is triggered **/
  6906. frame: number;
  6907. /** The event to perform when triggered **/
  6908. action: (currentFrame: number) => void;
  6909. /** Specifies if the event should be triggered only once**/
  6910. onlyOnce?: boolean | undefined;
  6911. /**
  6912. * Specifies if the animation event is done
  6913. */
  6914. isDone: boolean;
  6915. /**
  6916. * Initializes the animation event
  6917. * @param frame The frame for which the event is triggered
  6918. * @param action The event to perform when triggered
  6919. * @param onlyOnce Specifies if the event should be triggered only once
  6920. */
  6921. constructor(
  6922. /** The frame for which the event is triggered **/
  6923. frame: number,
  6924. /** The event to perform when triggered **/
  6925. action: (currentFrame: number) => void,
  6926. /** Specifies if the event should be triggered only once**/
  6927. onlyOnce?: boolean | undefined);
  6928. /** @hidden */ private _clone(): AnimationEvent;
  6929. }
  6930. }
  6931. declare module BABYLON {
  6932. /**
  6933. * Interface used to define a behavior
  6934. */
  6935. export interface Behavior<T> {
  6936. /** gets or sets behavior's name */
  6937. name: string;
  6938. /**
  6939. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6940. */
  6941. init(): void;
  6942. /**
  6943. * Called when the behavior is attached to a target
  6944. * @param target defines the target where the behavior is attached to
  6945. */
  6946. attach(target: T): void;
  6947. /**
  6948. * Called when the behavior is detached from its target
  6949. */
  6950. detach(): void;
  6951. }
  6952. /**
  6953. * Interface implemented by classes supporting behaviors
  6954. */
  6955. export interface IBehaviorAware<T> {
  6956. /**
  6957. * Attach a behavior
  6958. * @param behavior defines the behavior to attach
  6959. * @returns the current host
  6960. */
  6961. addBehavior(behavior: Behavior<T>): T;
  6962. /**
  6963. * Remove a behavior from the current object
  6964. * @param behavior defines the behavior to detach
  6965. * @returns the current host
  6966. */
  6967. removeBehavior(behavior: Behavior<T>): T;
  6968. /**
  6969. * Gets a behavior using its name to search
  6970. * @param name defines the name to search
  6971. * @returns the behavior or null if not found
  6972. */
  6973. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /**
  6978. * @hidden
  6979. */
  6980. export class IntersectionInfo {
  6981. bu: Nullable<number>;
  6982. bv: Nullable<number>;
  6983. distance: number;
  6984. faceId: number;
  6985. subMeshId: number;
  6986. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Class used to store bounding sphere information
  6992. */
  6993. export class BoundingSphere {
  6994. /**
  6995. * Gets the center of the bounding sphere in local space
  6996. */
  6997. readonly center: Vector3;
  6998. /**
  6999. * Radius of the bounding sphere in local space
  7000. */
  7001. radius: number;
  7002. /**
  7003. * Gets the center of the bounding sphere in world space
  7004. */
  7005. readonly centerWorld: Vector3;
  7006. /**
  7007. * Radius of the bounding sphere in world space
  7008. */
  7009. radiusWorld: number;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * Creates a new bounding sphere
  7022. * @param min defines the minimum vector (in local space)
  7023. * @param max defines the maximum vector (in local space)
  7024. * @param worldMatrix defines the new world matrix
  7025. */
  7026. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7027. /**
  7028. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7029. * @param min defines the new minimum vector (in local space)
  7030. * @param max defines the new maximum vector (in local space)
  7031. * @param worldMatrix defines the new world matrix
  7032. */
  7033. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7034. /**
  7035. * Scale the current bounding sphere by applying a scale factor
  7036. * @param factor defines the scale factor to apply
  7037. * @returns the current bounding box
  7038. */
  7039. scale(factor: number): BoundingSphere;
  7040. /**
  7041. * Gets the world matrix of the bounding box
  7042. * @returns a matrix
  7043. */
  7044. getWorldMatrix(): DeepImmutable<Matrix>;
  7045. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  7046. /**
  7047. * Tests if the bounding sphere is intersecting the frustum planes
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @returns true if there is an intersection
  7050. */
  7051. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if the bounding sphere center is in between the frustum planes.
  7054. * Used for optimistic fast inclusion.
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if the sphere center is in between the frustum planes
  7057. */
  7058. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if a point is inside the bounding sphere
  7061. * @param point defines the point to test
  7062. * @returns true if the point is inside the bounding sphere
  7063. */
  7064. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7065. /**
  7066. * Checks if two sphere intersct
  7067. * @param sphere0 sphere 0
  7068. * @param sphere1 sphere 1
  7069. * @returns true if the speres intersect
  7070. */
  7071. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7072. }
  7073. }
  7074. declare module BABYLON {
  7075. /**
  7076. * Class used to store bounding box information
  7077. */
  7078. export class BoundingBox implements ICullable {
  7079. /**
  7080. * Gets the 8 vectors representing the bounding box in local space
  7081. */
  7082. readonly vectors: Vector3[];
  7083. /**
  7084. * Gets the center of the bounding box in local space
  7085. */
  7086. readonly center: Vector3;
  7087. /**
  7088. * Gets the center of the bounding box in world space
  7089. */
  7090. readonly centerWorld: Vector3;
  7091. /**
  7092. * Gets the extend size in local space
  7093. */
  7094. readonly extendSize: Vector3;
  7095. /**
  7096. * Gets the extend size in world space
  7097. */
  7098. readonly extendSizeWorld: Vector3;
  7099. /**
  7100. * Gets the OBB (object bounding box) directions
  7101. */
  7102. readonly directions: Vector3[];
  7103. /**
  7104. * Gets the 8 vectors representing the bounding box in world space
  7105. */
  7106. readonly vectorsWorld: Vector3[];
  7107. /**
  7108. * Gets the minimum vector in world space
  7109. */
  7110. readonly minimumWorld: Vector3;
  7111. /**
  7112. * Gets the maximum vector in world space
  7113. */
  7114. readonly maximumWorld: Vector3;
  7115. /**
  7116. * Gets the minimum vector in local space
  7117. */
  7118. readonly minimum: Vector3;
  7119. /**
  7120. * Gets the maximum vector in local space
  7121. */
  7122. readonly maximum: Vector3;
  7123. private _worldMatrix;
  7124. private static readonly TmpVector3;
  7125. /**
  7126. * @hidden
  7127. */ private _tag: number;
  7128. /**
  7129. * Creates a new bounding box
  7130. * @param min defines the minimum vector (in local space)
  7131. * @param max defines the maximum vector (in local space)
  7132. * @param worldMatrix defines the new world matrix
  7133. */
  7134. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7135. /**
  7136. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7137. * @param min defines the new minimum vector (in local space)
  7138. * @param max defines the new maximum vector (in local space)
  7139. * @param worldMatrix defines the new world matrix
  7140. */
  7141. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7142. /**
  7143. * Scale the current bounding box by applying a scale factor
  7144. * @param factor defines the scale factor to apply
  7145. * @returns the current bounding box
  7146. */
  7147. scale(factor: number): BoundingBox;
  7148. /**
  7149. * Gets the world matrix of the bounding box
  7150. * @returns a matrix
  7151. */
  7152. getWorldMatrix(): DeepImmutable<Matrix>;
  7153. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding box is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding box is entirely inside the frustum planes
  7162. * @param frustumPlanes defines the frustum planes to test
  7163. * @returns true if there is an inclusion
  7164. */
  7165. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7166. /**
  7167. * Tests if a point is inside the bounding box
  7168. * @param point defines the point to test
  7169. * @returns true if the point is inside the bounding box
  7170. */
  7171. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7172. /**
  7173. * Tests if the bounding box intersects with a bounding sphere
  7174. * @param sphere defines the sphere to test
  7175. * @returns true if there is an intersection
  7176. */
  7177. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7178. /**
  7179. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7180. * @param min defines the min vector to use
  7181. * @param max defines the max vector to use
  7182. * @returns true if there is an intersection
  7183. */
  7184. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7185. /**
  7186. * Tests if two bounding boxes are intersections
  7187. * @param box0 defines the first box to test
  7188. * @param box1 defines the second box to test
  7189. * @returns true if there is an intersection
  7190. */
  7191. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7192. /**
  7193. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7194. * @param minPoint defines the minimum vector of the bounding box
  7195. * @param maxPoint defines the maximum vector of the bounding box
  7196. * @param sphereCenter defines the sphere center
  7197. * @param sphereRadius defines the sphere radius
  7198. * @returns true if there is an intersection
  7199. */
  7200. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7201. /**
  7202. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7203. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7204. * @param frustumPlanes defines the frustum planes to test
  7205. * @return true if there is an inclusion
  7206. */
  7207. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7208. /**
  7209. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7210. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7211. * @param frustumPlanes defines the frustum planes to test
  7212. * @return true if there is an intersection
  7213. */
  7214. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7215. }
  7216. }
  7217. declare module BABYLON {
  7218. /** @hidden */
  7219. export class Collider {
  7220. /** Define if a collision was found */
  7221. collisionFound: boolean;
  7222. /**
  7223. * Define last intersection point in local space
  7224. */
  7225. intersectionPoint: Vector3;
  7226. /**
  7227. * Define last collided mesh
  7228. */
  7229. collidedMesh: Nullable<AbstractMesh>;
  7230. private _collisionPoint;
  7231. private _planeIntersectionPoint;
  7232. private _tempVector;
  7233. private _tempVector2;
  7234. private _tempVector3;
  7235. private _tempVector4;
  7236. private _edge;
  7237. private _baseToVertex;
  7238. private _destinationPoint;
  7239. private _slidePlaneNormal;
  7240. private _displacementVector;
  7241. /** @hidden */ private _radius: Vector3;
  7242. /** @hidden */ private _retry: number;
  7243. private _velocity;
  7244. private _basePoint;
  7245. private _epsilon;
  7246. /** @hidden */ private _velocityWorldLength: number;
  7247. /** @hidden */ private _basePointWorld: Vector3;
  7248. private _velocityWorld;
  7249. private _normalizedVelocity;
  7250. /** @hidden */ private _initialVelocity: Vector3;
  7251. /** @hidden */ private _initialPosition: Vector3;
  7252. private _nearestDistance;
  7253. private _collisionMask;
  7254. collisionMask: number;
  7255. /**
  7256. * Gets the plane normal used to compute the sliding response (in local space)
  7257. */
  7258. readonly slidePlaneNormal: Vector3;
  7259. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7260. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7261. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7262. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7263. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7264. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7265. }
  7266. }
  7267. declare module BABYLON {
  7268. /**
  7269. * Interface for cullable objects
  7270. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7271. */
  7272. export interface ICullable {
  7273. /**
  7274. * Checks if the object or part of the object is in the frustum
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isInFrustum(frustumPlanes: Plane[]): boolean;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7286. }
  7287. /**
  7288. * Info for a bounding data of a mesh
  7289. */
  7290. export class BoundingInfo implements ICullable {
  7291. /**
  7292. * Bounding box for the mesh
  7293. */
  7294. readonly boundingBox: BoundingBox;
  7295. /**
  7296. * Bounding sphere for the mesh
  7297. */
  7298. readonly boundingSphere: BoundingSphere;
  7299. private _isLocked;
  7300. private static readonly TmpVector3;
  7301. /**
  7302. * Constructs bounding info
  7303. * @param minimum min vector of the bounding box/sphere
  7304. * @param maximum max vector of the bounding box/sphere
  7305. * @param worldMatrix defines the new world matrix
  7306. */
  7307. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7308. /**
  7309. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7310. * @param min defines the new minimum vector (in local space)
  7311. * @param max defines the new maximum vector (in local space)
  7312. * @param worldMatrix defines the new world matrix
  7313. */
  7314. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7315. /**
  7316. * min vector of the bounding box/sphere
  7317. */
  7318. readonly minimum: Vector3;
  7319. /**
  7320. * max vector of the bounding box/sphere
  7321. */
  7322. readonly maximum: Vector3;
  7323. /**
  7324. * If the info is locked and won't be updated to avoid perf overhead
  7325. */
  7326. isLocked: boolean;
  7327. /**
  7328. * Updates the bounding sphere and box
  7329. * @param world world matrix to be used to update
  7330. */
  7331. update(world: DeepImmutable<Matrix>): void;
  7332. /**
  7333. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7334. * @param center New center of the bounding info
  7335. * @param extend New extend of the bounding info
  7336. * @returns the current bounding info
  7337. */
  7338. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7339. /**
  7340. * Scale the current bounding info by applying a scale factor
  7341. * @param factor defines the scale factor to apply
  7342. * @returns the current bounding info
  7343. */
  7344. scale(factor: number): BoundingInfo;
  7345. /**
  7346. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7347. * @param frustumPlanes defines the frustum to test
  7348. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7349. * @returns true if the bounding info is in the frustum planes
  7350. */
  7351. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7352. /**
  7353. * Gets the world distance between the min and max points of the bounding box
  7354. */
  7355. readonly diagonalLength: number;
  7356. /**
  7357. * Checks if a cullable object (mesh...) is in the camera frustum
  7358. * Unlike isInFrustum this cheks the full bounding box
  7359. * @param frustumPlanes Camera near/planes
  7360. * @returns true if the object is in frustum otherwise false
  7361. */
  7362. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7363. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7364. /**
  7365. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7366. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7367. * @param point the point to check intersection with
  7368. * @returns if the point intersects
  7369. */
  7370. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7371. /**
  7372. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7373. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7374. * @param boundingInfo the bounding info to check intersection with
  7375. * @param precise if the intersection should be done using OBB
  7376. * @returns if the bounding info intersects
  7377. */
  7378. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7379. }
  7380. }
  7381. declare module BABYLON {
  7382. /**
  7383. * Defines an array and its length.
  7384. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7385. */
  7386. export interface ISmartArrayLike<T> {
  7387. /**
  7388. * The data of the array.
  7389. */
  7390. data: Array<T>;
  7391. /**
  7392. * The active length of the array.
  7393. */
  7394. length: number;
  7395. }
  7396. /**
  7397. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7398. */
  7399. export class SmartArray<T> implements ISmartArrayLike<T> {
  7400. /**
  7401. * The full set of data from the array.
  7402. */
  7403. data: Array<T>;
  7404. /**
  7405. * The active length of the array.
  7406. */
  7407. length: number;
  7408. protected _id: number;
  7409. /**
  7410. * Instantiates a Smart Array.
  7411. * @param capacity defines the default capacity of the array.
  7412. */
  7413. constructor(capacity: number);
  7414. /**
  7415. * Pushes a value at the end of the active data.
  7416. * @param value defines the object to push in the array.
  7417. */
  7418. push(value: T): void;
  7419. /**
  7420. * Iterates over the active data and apply the lambda to them.
  7421. * @param func defines the action to apply on each value.
  7422. */
  7423. forEach(func: (content: T) => void): void;
  7424. /**
  7425. * Sorts the full sets of data.
  7426. * @param compareFn defines the comparison function to apply.
  7427. */
  7428. sort(compareFn: (a: T, b: T) => number): void;
  7429. /**
  7430. * Resets the active data to an empty array.
  7431. */
  7432. reset(): void;
  7433. /**
  7434. * Releases all the data from the array as well as the array.
  7435. */
  7436. dispose(): void;
  7437. /**
  7438. * Concats the active data with a given array.
  7439. * @param array defines the data to concatenate with.
  7440. */
  7441. concat(array: any): void;
  7442. /**
  7443. * Returns the position of a value in the active data.
  7444. * @param value defines the value to find the index for
  7445. * @returns the index if found in the active data otherwise -1
  7446. */
  7447. indexOf(value: T): number;
  7448. /**
  7449. * Returns whether an element is part of the active data.
  7450. * @param value defines the value to look for
  7451. * @returns true if found in the active data otherwise false
  7452. */
  7453. contains(value: T): boolean;
  7454. private static _GlobalId;
  7455. }
  7456. /**
  7457. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7458. * The data in this array can only be present once
  7459. */
  7460. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7461. private _duplicateId;
  7462. /**
  7463. * Pushes a value at the end of the active data.
  7464. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7465. * @param value defines the object to push in the array.
  7466. */
  7467. push(value: T): void;
  7468. /**
  7469. * Pushes a value at the end of the active data.
  7470. * If the data is already present, it won t be added again
  7471. * @param value defines the object to push in the array.
  7472. * @returns true if added false if it was already present
  7473. */
  7474. pushNoDuplicate(value: T): boolean;
  7475. /**
  7476. * Resets the active data to an empty array.
  7477. */
  7478. reset(): void;
  7479. /**
  7480. * Concats the active data with a given array.
  7481. * This ensures no dupplicate will be present in the result.
  7482. * @param array defines the data to concatenate with.
  7483. */
  7484. concatWithNoDuplicate(array: any): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Enum that determines the text-wrapping mode to use.
  7490. */
  7491. export enum InspectableType {
  7492. /**
  7493. * Checkbox for booleans
  7494. */
  7495. Checkbox = 0,
  7496. /**
  7497. * Sliders for numbers
  7498. */
  7499. Slider = 1,
  7500. /**
  7501. * Vector3
  7502. */
  7503. Vector3 = 2,
  7504. /**
  7505. * Quaternions
  7506. */
  7507. Quaternion = 3,
  7508. /**
  7509. * Color3
  7510. */
  7511. Color3 = 4
  7512. }
  7513. /**
  7514. * Interface used to define custom inspectable properties.
  7515. * This interface is used by the inspector to display custom property grids
  7516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7517. */
  7518. export interface IInspectable {
  7519. /**
  7520. * Gets the label to display
  7521. */
  7522. label: string;
  7523. /**
  7524. * Gets the name of the property to edit
  7525. */
  7526. propertyName: string;
  7527. /**
  7528. * Gets the type of the editor to use
  7529. */
  7530. type: InspectableType;
  7531. /**
  7532. * Gets the minimum value of the property when using in "slider" mode
  7533. */
  7534. min?: number;
  7535. /**
  7536. * Gets the maximum value of the property when using in "slider" mode
  7537. */
  7538. max?: number;
  7539. /**
  7540. * Gets the setp to use when using in "slider" mode
  7541. */
  7542. step?: number;
  7543. }
  7544. }
  7545. declare module BABYLON {
  7546. /**
  7547. * This represents the required contract to create a new type of texture loader.
  7548. */
  7549. export interface IInternalTextureLoader {
  7550. /**
  7551. * Defines wether the loader supports cascade loading the different faces.
  7552. */
  7553. supportCascades: boolean;
  7554. /**
  7555. * This returns if the loader support the current file information.
  7556. * @param extension defines the file extension of the file being loaded
  7557. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7558. * @param fallback defines the fallback internal texture if any
  7559. * @param isBase64 defines whether the texture is encoded as a base64
  7560. * @param isBuffer defines whether the texture data are stored as a buffer
  7561. * @returns true if the loader can load the specified file
  7562. */
  7563. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7564. /**
  7565. * Transform the url before loading if required.
  7566. * @param rootUrl the url of the texture
  7567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7568. * @returns the transformed texture
  7569. */
  7570. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7571. /**
  7572. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7573. * @param rootUrl the url of the texture
  7574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7575. * @returns the fallback texture
  7576. */
  7577. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7578. /**
  7579. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7580. * @param data contains the texture data
  7581. * @param texture defines the BabylonJS internal texture
  7582. * @param createPolynomials will be true if polynomials have been requested
  7583. * @param onLoad defines the callback to trigger once the texture is ready
  7584. * @param onError defines the callback to trigger in case of error
  7585. */
  7586. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7587. /**
  7588. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7589. * @param data contains the texture data
  7590. * @param texture defines the BabylonJS internal texture
  7591. * @param callback defines the method to call once ready to upload
  7592. */
  7593. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7594. }
  7595. }
  7596. declare module BABYLON {
  7597. interface Engine {
  7598. /**
  7599. * Creates a depth stencil cube texture.
  7600. * This is only available in WebGL 2.
  7601. * @param size The size of face edge in the cube texture.
  7602. * @param options The options defining the cube texture.
  7603. * @returns The cube texture
  7604. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7605. /**
  7606. * Creates a cube texture
  7607. * @param rootUrl defines the url where the files to load is located
  7608. * @param scene defines the current scene
  7609. * @param files defines the list of files to load (1 per face)
  7610. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7611. * @param onLoad defines an optional callback raised when the texture is loaded
  7612. * @param onError defines an optional callback raised if there is an issue to load the texture
  7613. * @param format defines the format of the data
  7614. * @param forcedExtension defines the extension to use to pick the right loader
  7615. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7616. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7617. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7618. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7619. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7620. * @returns the cube texture as an InternalTexture
  7621. */
  7622. 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;
  7623. /**
  7624. * Creates a cube texture
  7625. * @param rootUrl defines the url where the files to load is located
  7626. * @param scene defines the current scene
  7627. * @param files defines the list of files to load (1 per face)
  7628. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7629. * @param onLoad defines an optional callback raised when the texture is loaded
  7630. * @param onError defines an optional callback raised if there is an issue to load the texture
  7631. * @param format defines the format of the data
  7632. * @param forcedExtension defines the extension to use to pick the right loader
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. 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;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @returns the cube texture as an InternalTexture
  7650. */
  7651. 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;
  7652. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7653. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7654. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7655. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7656. }
  7657. }
  7658. declare module BABYLON {
  7659. /**
  7660. * Class for creating a cube texture
  7661. */
  7662. export class CubeTexture extends BaseTexture {
  7663. private _delayedOnLoad;
  7664. /**
  7665. * The url of the texture
  7666. */
  7667. url: string;
  7668. /**
  7669. * Gets or sets the center of the bounding box associated with the cube texture.
  7670. * It must define where the camera used to render the texture was set
  7671. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7672. */
  7673. boundingBoxPosition: Vector3;
  7674. private _boundingBoxSize;
  7675. /**
  7676. * Gets or sets the size of the bounding box associated with the cube texture
  7677. * When defined, the cubemap will switch to local mode
  7678. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7679. * @example https://www.babylonjs-playground.com/#RNASML
  7680. */
  7681. /**
  7682. * Returns the bounding box size
  7683. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7684. */
  7685. boundingBoxSize: Vector3;
  7686. protected _rotationY: number;
  7687. /**
  7688. * Sets texture matrix rotation angle around Y axis in radians.
  7689. */
  7690. /**
  7691. * Gets texture matrix rotation angle around Y axis radians.
  7692. */
  7693. rotationY: number;
  7694. /**
  7695. * Are mip maps generated for this texture or not.
  7696. */
  7697. readonly noMipmap: boolean;
  7698. private _noMipmap;
  7699. private _files;
  7700. private _extensions;
  7701. private _textureMatrix;
  7702. private _format;
  7703. private _createPolynomials;
  7704. /** @hidden */ private _prefiltered: boolean;
  7705. /**
  7706. * Creates a cube texture from an array of image urls
  7707. * @param files defines an array of image urls
  7708. * @param scene defines the hosting scene
  7709. * @param noMipmap specifies if mip maps are not used
  7710. * @returns a cube texture
  7711. */
  7712. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7713. /**
  7714. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7715. * @param url defines the url of the prefiltered texture
  7716. * @param scene defines the scene the texture is attached to
  7717. * @param forcedExtension defines the extension of the file if different from the url
  7718. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7719. * @return the prefiltered texture
  7720. */
  7721. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7722. /**
  7723. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7724. * as prefiltered data.
  7725. * @param rootUrl defines the url of the texture or the root name of the six images
  7726. * @param scene defines the scene the texture is attached to
  7727. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7728. * @param noMipmap defines if mipmaps should be created or not
  7729. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7730. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7731. * @param onError defines a callback triggered in case of error during load
  7732. * @param format defines the internal format to use for the texture once loaded
  7733. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7734. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7735. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @return the cube texture
  7739. */
  7740. 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);
  7741. /**
  7742. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7743. */
  7744. readonly isPrefiltered: boolean;
  7745. /**
  7746. * Get the current class name of the texture useful for serialization or dynamic coding.
  7747. * @returns "CubeTexture"
  7748. */
  7749. getClassName(): string;
  7750. /**
  7751. * Update the url (and optional buffer) of this texture if url was null during construction.
  7752. * @param url the url of the texture
  7753. * @param forcedExtension defines the extension to use
  7754. * @param onLoad callback called when the texture is loaded (defaults to null)
  7755. */
  7756. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7757. /**
  7758. * Delays loading of the cube texture
  7759. * @param forcedExtension defines the extension to use
  7760. */
  7761. delayLoad(forcedExtension?: string): void;
  7762. /**
  7763. * Returns the reflection texture matrix
  7764. * @returns the reflection texture matrix
  7765. */
  7766. getReflectionTextureMatrix(): Matrix;
  7767. /**
  7768. * Sets the reflection texture matrix
  7769. * @param value Reflection texture matrix
  7770. */
  7771. setReflectionTextureMatrix(value: Matrix): void;
  7772. /**
  7773. * Parses text to create a cube texture
  7774. * @param parsedTexture define the serialized text to read from
  7775. * @param scene defines the hosting scene
  7776. * @param rootUrl defines the root url of the cube texture
  7777. * @returns a cube texture
  7778. */
  7779. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7780. /**
  7781. * Makes a clone, or deep copy, of the cube texture
  7782. * @returns a new cube texture
  7783. */
  7784. clone(): CubeTexture;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /** @hidden */
  7789. export var postprocessVertexShader: {
  7790. name: string;
  7791. shader: string;
  7792. };
  7793. }
  7794. declare module BABYLON {
  7795. /**
  7796. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7797. * This is the base of the follow, arc rotate cameras and Free camera
  7798. * @see http://doc.babylonjs.com/features/cameras
  7799. */
  7800. export class TargetCamera extends Camera {
  7801. private static _RigCamTransformMatrix;
  7802. private static _TargetTransformMatrix;
  7803. private static _TargetFocalPoint;
  7804. /**
  7805. * Define the current direction the camera is moving to
  7806. */
  7807. cameraDirection: Vector3;
  7808. /**
  7809. * Define the current rotation the camera is rotating to
  7810. */
  7811. cameraRotation: Vector2;
  7812. /**
  7813. * When set, the up vector of the camera will be updated by the rotation of the camera
  7814. */
  7815. updateUpVectorFromRotation: boolean;
  7816. private _tmpQuaternion;
  7817. /**
  7818. * Define the current rotation of the camera
  7819. */
  7820. rotation: Vector3;
  7821. /**
  7822. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7823. */
  7824. rotationQuaternion: Quaternion;
  7825. /**
  7826. * Define the current speed of the camera
  7827. */
  7828. speed: number;
  7829. /**
  7830. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7831. * around all axis.
  7832. */
  7833. noRotationConstraint: boolean;
  7834. /**
  7835. * Define the current target of the camera as an object or a position.
  7836. */
  7837. lockedTarget: any;
  7838. /** @hidden */ private _currentTarget: Vector3;
  7839. /** @hidden */ private _initialFocalDistance: number;
  7840. /** @hidden */ private _viewMatrix: Matrix;
  7841. /** @hidden */ private _camMatrix: Matrix;
  7842. /** @hidden */ private _cameraTransformMatrix: Matrix;
  7843. /** @hidden */ private _cameraRotationMatrix: Matrix;
  7844. /** @hidden */ private _referencePoint: Vector3;
  7845. /** @hidden */ private _transformedReferencePoint: Vector3;
  7846. protected _globalCurrentTarget: Vector3;
  7847. protected _globalCurrentUpVector: Vector3;
  7848. /** @hidden */ private _reset: () => void;
  7849. private _defaultUp;
  7850. /**
  7851. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7852. * This is the base of the follow, arc rotate cameras and Free camera
  7853. * @see http://doc.babylonjs.com/features/cameras
  7854. * @param name Defines the name of the camera in the scene
  7855. * @param position Defines the start position of the camera in the scene
  7856. * @param scene Defines the scene the camera belongs to
  7857. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7858. */
  7859. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7860. /**
  7861. * Gets the position in front of the camera at a given distance.
  7862. * @param distance The distance from the camera we want the position to be
  7863. * @returns the position
  7864. */
  7865. getFrontPosition(distance: number): Vector3;
  7866. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  7867. private _storedPosition;
  7868. private _storedRotation;
  7869. private _storedRotationQuaternion;
  7870. /**
  7871. * Store current camera state of the camera (fov, position, rotation, etc..)
  7872. * @returns the camera
  7873. */
  7874. storeState(): Camera;
  7875. /**
  7876. * Restored camera state. You must call storeState() first
  7877. * @returns whether it was successful or not
  7878. * @hidden
  7879. */ private _restoreStateValues(): boolean;
  7880. /** @hidden */ private _initCache(): void;
  7881. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  7882. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  7883. /** @hidden */ private _computeLocalCameraSpeed(): number;
  7884. /**
  7885. * Defines the target the camera should look at.
  7886. * @param target Defines the new target as a Vector or a mesh
  7887. */
  7888. setTarget(target: Vector3): void;
  7889. /**
  7890. * Return the current target position of the camera. This value is expressed in local space.
  7891. * @returns the target position
  7892. */
  7893. getTarget(): Vector3;
  7894. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  7895. /** @hidden */ private _updatePosition(): void;
  7896. /** @hidden */ private _checkInputs(): void;
  7897. protected _updateCameraRotationMatrix(): void;
  7898. /**
  7899. * 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)
  7900. * @returns the current camera
  7901. */
  7902. private _rotateUpVectorWithCameraRotationMatrix;
  7903. private _cachedRotationZ;
  7904. private _cachedQuaternionRotationZ;
  7905. /** @hidden */ private _getViewMatrix(): Matrix;
  7906. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7907. /**
  7908. * @hidden
  7909. */
  7910. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7911. /**
  7912. * @hidden
  7913. */ private _updateRigCameras(): void;
  7914. private _getRigCamPositionAndTarget;
  7915. /**
  7916. * Gets the current object class name.
  7917. * @return the class name
  7918. */
  7919. getClassName(): string;
  7920. }
  7921. }
  7922. declare module BABYLON {
  7923. /**
  7924. * @ignore
  7925. * This is a list of all the different input types that are available in the application.
  7926. * Fo instance: ArcRotateCameraGamepadInput...
  7927. */
  7928. export var CameraInputTypes: {};
  7929. /**
  7930. * This is the contract to implement in order to create a new input class.
  7931. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7932. */
  7933. export interface ICameraInput<TCamera extends Camera> {
  7934. /**
  7935. * Defines the camera the input is attached to.
  7936. */
  7937. camera: Nullable<TCamera>;
  7938. /**
  7939. * Gets the class name of the current intput.
  7940. * @returns the class name
  7941. */
  7942. getClassName(): string;
  7943. /**
  7944. * Get the friendly name associated with the input class.
  7945. * @returns the input friendly name
  7946. */
  7947. getSimpleName(): string;
  7948. /**
  7949. * Attach the input controls to a specific dom element to get the input from.
  7950. * @param element Defines the element the controls should be listened from
  7951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7952. */
  7953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7954. /**
  7955. * Detach the current controls from the specified dom element.
  7956. * @param element Defines the element to stop listening the inputs from
  7957. */
  7958. detachControl(element: Nullable<HTMLElement>): void;
  7959. /**
  7960. * Update the current camera state depending on the inputs that have been used this frame.
  7961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7962. */
  7963. checkInputs?: () => void;
  7964. }
  7965. /**
  7966. * Represents a map of input types to input instance or input index to input instance.
  7967. */
  7968. export interface CameraInputsMap<TCamera extends Camera> {
  7969. /**
  7970. * Accessor to the input by input type.
  7971. */
  7972. [name: string]: ICameraInput<TCamera>;
  7973. /**
  7974. * Accessor to the input by input index.
  7975. */
  7976. [idx: number]: ICameraInput<TCamera>;
  7977. }
  7978. /**
  7979. * This represents the input manager used within a camera.
  7980. * It helps dealing with all the different kind of input attached to a camera.
  7981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7982. */
  7983. export class CameraInputsManager<TCamera extends Camera> {
  7984. /**
  7985. * Defines the list of inputs attahed to the camera.
  7986. */
  7987. attached: CameraInputsMap<TCamera>;
  7988. /**
  7989. * Defines the dom element the camera is collecting inputs from.
  7990. * This is null if the controls have not been attached.
  7991. */
  7992. attachedElement: Nullable<HTMLElement>;
  7993. /**
  7994. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7995. */
  7996. noPreventDefault: boolean;
  7997. /**
  7998. * Defined the camera the input manager belongs to.
  7999. */
  8000. camera: TCamera;
  8001. /**
  8002. * Update the current camera state depending on the inputs that have been used this frame.
  8003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8004. */
  8005. checkInputs: () => void;
  8006. /**
  8007. * Instantiate a new Camera Input Manager.
  8008. * @param camera Defines the camera the input manager blongs to
  8009. */
  8010. constructor(camera: TCamera);
  8011. /**
  8012. * Add an input method to a camera
  8013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8014. * @param input camera input method
  8015. */
  8016. add(input: ICameraInput<TCamera>): void;
  8017. /**
  8018. * Remove a specific input method from a camera
  8019. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8020. * @param inputToRemove camera input method
  8021. */
  8022. remove(inputToRemove: ICameraInput<TCamera>): void;
  8023. /**
  8024. * Remove a specific input type from a camera
  8025. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8026. * @param inputType the type of the input to remove
  8027. */
  8028. removeByType(inputType: string): void;
  8029. private _addCheckInputs;
  8030. /**
  8031. * Attach the input controls to the currently attached dom element to listen the events from.
  8032. * @param input Defines the input to attach
  8033. */
  8034. attachInput(input: ICameraInput<TCamera>): void;
  8035. /**
  8036. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8037. * @param element Defines the dom element to collect the events from
  8038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8039. */
  8040. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8041. /**
  8042. * Detach the current manager inputs controls from a specific dom element.
  8043. * @param element Defines the dom element to collect the events from
  8044. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8045. */
  8046. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8047. /**
  8048. * Rebuild the dynamic inputCheck function from the current list of
  8049. * defined inputs in the manager.
  8050. */
  8051. rebuildInputCheck(): void;
  8052. /**
  8053. * Remove all attached input methods from a camera
  8054. */
  8055. clear(): void;
  8056. /**
  8057. * Serialize the current input manager attached to a camera.
  8058. * This ensures than once parsed,
  8059. * the input associated to the camera will be identical to the current ones
  8060. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8061. */
  8062. serialize(serializedCamera: any): void;
  8063. /**
  8064. * Parses an input manager serialized JSON to restore the previous list of inputs
  8065. * and states associated to a camera.
  8066. * @param parsedCamera Defines the JSON to parse
  8067. */
  8068. parse(parsedCamera: any): void;
  8069. }
  8070. }
  8071. declare module BABYLON {
  8072. /**
  8073. * Gather the list of keyboard event types as constants.
  8074. */
  8075. export class KeyboardEventTypes {
  8076. /**
  8077. * The keydown event is fired when a key becomes active (pressed).
  8078. */
  8079. static readonly KEYDOWN: number;
  8080. /**
  8081. * The keyup event is fired when a key has been released.
  8082. */
  8083. static readonly KEYUP: number;
  8084. }
  8085. /**
  8086. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8087. */
  8088. export class KeyboardInfo {
  8089. /**
  8090. * Defines the type of event (KeyboardEventTypes)
  8091. */
  8092. type: number;
  8093. /**
  8094. * Defines the related dom event
  8095. */
  8096. event: KeyboardEvent;
  8097. /**
  8098. * Instantiates a new keyboard info.
  8099. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8100. * @param type Defines the type of event (KeyboardEventTypes)
  8101. * @param event Defines the related dom event
  8102. */
  8103. constructor(
  8104. /**
  8105. * Defines the type of event (KeyboardEventTypes)
  8106. */
  8107. type: number,
  8108. /**
  8109. * Defines the related dom event
  8110. */
  8111. event: KeyboardEvent);
  8112. }
  8113. /**
  8114. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8115. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8116. */
  8117. export class KeyboardInfoPre extends KeyboardInfo {
  8118. /**
  8119. * Defines the type of event (KeyboardEventTypes)
  8120. */
  8121. type: number;
  8122. /**
  8123. * Defines the related dom event
  8124. */
  8125. event: KeyboardEvent;
  8126. /**
  8127. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8128. */
  8129. skipOnPointerObservable: boolean;
  8130. /**
  8131. * Instantiates a new keyboard pre info.
  8132. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8133. * @param type Defines the type of event (KeyboardEventTypes)
  8134. * @param event Defines the related dom event
  8135. */
  8136. constructor(
  8137. /**
  8138. * Defines the type of event (KeyboardEventTypes)
  8139. */
  8140. type: number,
  8141. /**
  8142. * Defines the related dom event
  8143. */
  8144. event: KeyboardEvent);
  8145. }
  8146. }
  8147. declare module BABYLON {
  8148. /**
  8149. * Manage the keyboard inputs to control the movement of a free camera.
  8150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8151. */
  8152. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8153. /**
  8154. * Defines the camera the input is attached to.
  8155. */
  8156. camera: FreeCamera;
  8157. /**
  8158. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8159. */
  8160. keysUp: number[];
  8161. /**
  8162. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8163. */
  8164. keysDown: number[];
  8165. /**
  8166. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8167. */
  8168. keysLeft: number[];
  8169. /**
  8170. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8171. */
  8172. keysRight: number[];
  8173. private _keys;
  8174. private _onCanvasBlurObserver;
  8175. private _onKeyboardObserver;
  8176. private _engine;
  8177. private _scene;
  8178. /**
  8179. * Attach the input controls to a specific dom element to get the input from.
  8180. * @param element Defines the element the controls should be listened from
  8181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8182. */
  8183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8184. /**
  8185. * Detach the current controls from the specified dom element.
  8186. * @param element Defines the element to stop listening the inputs from
  8187. */
  8188. detachControl(element: Nullable<HTMLElement>): void;
  8189. /**
  8190. * Update the current camera state depending on the inputs that have been used this frame.
  8191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8192. */
  8193. checkInputs(): void;
  8194. /**
  8195. * Gets the class name of the current intput.
  8196. * @returns the class name
  8197. */
  8198. getClassName(): string;
  8199. /** @hidden */ private _onLostFocus(): void;
  8200. /**
  8201. * Get the friendly name associated with the input class.
  8202. * @returns the input friendly name
  8203. */
  8204. getSimpleName(): string;
  8205. }
  8206. }
  8207. declare module BABYLON {
  8208. /**
  8209. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8210. * separate meshes. This can be use to improve performances.
  8211. * @see http://doc.babylonjs.com/how_to/multi_materials
  8212. */
  8213. export class MultiMaterial extends Material {
  8214. private _subMaterials;
  8215. /**
  8216. * Gets or Sets the list of Materials used within the multi material.
  8217. * They need to be ordered according to the submeshes order in the associated mesh
  8218. */
  8219. subMaterials: Nullable<Material>[];
  8220. /**
  8221. * Function used to align with Node.getChildren()
  8222. * @returns the list of Materials used within the multi material
  8223. */
  8224. getChildren(): Nullable<Material>[];
  8225. /**
  8226. * Instantiates a new Multi Material
  8227. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8228. * separate meshes. This can be use to improve performances.
  8229. * @see http://doc.babylonjs.com/how_to/multi_materials
  8230. * @param name Define the name in the scene
  8231. * @param scene Define the scene the material belongs to
  8232. */
  8233. constructor(name: string, scene: Scene);
  8234. private _hookArray;
  8235. /**
  8236. * Get one of the submaterial by its index in the submaterials array
  8237. * @param index The index to look the sub material at
  8238. * @returns The Material if the index has been defined
  8239. */
  8240. getSubMaterial(index: number): Nullable<Material>;
  8241. /**
  8242. * Get the list of active textures for the whole sub materials list.
  8243. * @returns All the textures that will be used during the rendering
  8244. */
  8245. getActiveTextures(): BaseTexture[];
  8246. /**
  8247. * Gets the current class name of the material e.g. "MultiMaterial"
  8248. * Mainly use in serialization.
  8249. * @returns the class name
  8250. */
  8251. getClassName(): string;
  8252. /**
  8253. * Checks if the material is ready to render the requested sub mesh
  8254. * @param mesh Define the mesh the submesh belongs to
  8255. * @param subMesh Define the sub mesh to look readyness for
  8256. * @param useInstances Define whether or not the material is used with instances
  8257. * @returns true if ready, otherwise false
  8258. */
  8259. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8260. /**
  8261. * Clones the current material and its related sub materials
  8262. * @param name Define the name of the newly cloned material
  8263. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8264. * @returns the cloned material
  8265. */
  8266. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8267. /**
  8268. * Serializes the materials into a JSON representation.
  8269. * @returns the JSON representation
  8270. */
  8271. serialize(): any;
  8272. /**
  8273. * Dispose the material and release its associated resources
  8274. * @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)
  8275. * @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)
  8276. * @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)
  8277. */
  8278. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8279. /**
  8280. * Creates a MultiMaterial from parsed MultiMaterial data.
  8281. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8282. * @param scene defines the hosting scene
  8283. * @returns a new MultiMaterial
  8284. */
  8285. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8286. }
  8287. }
  8288. declare module BABYLON {
  8289. /**
  8290. * Class used to represent data loading progression
  8291. */
  8292. export class SceneLoaderFlags {
  8293. private static _ForceFullSceneLoadingForIncremental;
  8294. private static _ShowLoadingScreen;
  8295. private static _CleanBoneMatrixWeights;
  8296. private static _loggingLevel;
  8297. /**
  8298. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8299. */
  8300. static ForceFullSceneLoadingForIncremental: boolean;
  8301. /**
  8302. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8303. */
  8304. static ShowLoadingScreen: boolean;
  8305. /**
  8306. * Defines the current logging level (while loading the scene)
  8307. * @ignorenaming
  8308. */
  8309. static loggingLevel: number;
  8310. /**
  8311. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8312. */
  8313. static CleanBoneMatrixWeights: boolean;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * 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.
  8319. * @see https://doc.babylonjs.com/how_to/transformnode
  8320. */
  8321. export class TransformNode extends Node {
  8322. /**
  8323. * Object will not rotate to face the camera
  8324. */
  8325. static BILLBOARDMODE_NONE: number;
  8326. /**
  8327. * Object will rotate to face the camera but only on the x axis
  8328. */
  8329. static BILLBOARDMODE_X: number;
  8330. /**
  8331. * Object will rotate to face the camera but only on the y axis
  8332. */
  8333. static BILLBOARDMODE_Y: number;
  8334. /**
  8335. * Object will rotate to face the camera but only on the z axis
  8336. */
  8337. static BILLBOARDMODE_Z: number;
  8338. /**
  8339. * Object will rotate to face the camera
  8340. */
  8341. static BILLBOARDMODE_ALL: number;
  8342. private _forward;
  8343. private _forwardInverted;
  8344. private _up;
  8345. private _right;
  8346. private _rightInverted;
  8347. private _position;
  8348. private _rotation;
  8349. private _rotationQuaternion;
  8350. protected _scaling: Vector3;
  8351. protected _isDirty: boolean;
  8352. private _transformToBoneReferal;
  8353. private _billboardMode;
  8354. /**
  8355. * Gets or sets the billboard mode. Default is 0.
  8356. *
  8357. * | Value | Type | Description |
  8358. * | --- | --- | --- |
  8359. * | 0 | BILLBOARDMODE_NONE | |
  8360. * | 1 | BILLBOARDMODE_X | |
  8361. * | 2 | BILLBOARDMODE_Y | |
  8362. * | 4 | BILLBOARDMODE_Z | |
  8363. * | 7 | BILLBOARDMODE_ALL | |
  8364. *
  8365. */
  8366. billboardMode: number;
  8367. private _preserveParentRotationForBillboard;
  8368. /**
  8369. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8370. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8371. */
  8372. preserveParentRotationForBillboard: boolean;
  8373. /**
  8374. * 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
  8375. */
  8376. scalingDeterminant: number;
  8377. private _infiniteDistance;
  8378. /**
  8379. * Gets or sets the distance of the object to max, often used by skybox
  8380. */
  8381. infiniteDistance: boolean;
  8382. /**
  8383. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8384. * By default the system will update normals to compensate
  8385. */
  8386. ignoreNonUniformScaling: boolean;
  8387. /**
  8388. * 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
  8389. */
  8390. reIntegrateRotationIntoRotationQuaternion: boolean;
  8391. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  8392. /** @hidden */ private _localMatrix: Matrix;
  8393. private _usePivotMatrix;
  8394. private _absolutePosition;
  8395. private _pivotMatrix;
  8396. private _pivotMatrixInverse;
  8397. protected _postMultiplyPivotMatrix: boolean;
  8398. protected _isWorldMatrixFrozen: boolean;
  8399. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  8400. /**
  8401. * An event triggered after the world matrix is updated
  8402. */
  8403. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8404. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8405. /**
  8406. * Gets a string identifying the name of the class
  8407. * @returns "TransformNode" string
  8408. */
  8409. getClassName(): string;
  8410. /**
  8411. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8412. */
  8413. position: Vector3;
  8414. /**
  8415. * 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)).
  8416. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8417. */
  8418. rotation: Vector3;
  8419. /**
  8420. * 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)).
  8421. */
  8422. scaling: Vector3;
  8423. /**
  8424. * 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).
  8425. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8426. */
  8427. rotationQuaternion: Nullable<Quaternion>;
  8428. /**
  8429. * The forward direction of that transform in world space.
  8430. */
  8431. readonly forward: Vector3;
  8432. /**
  8433. * The up direction of that transform in world space.
  8434. */
  8435. readonly up: Vector3;
  8436. /**
  8437. * The right direction of that transform in world space.
  8438. */
  8439. readonly right: Vector3;
  8440. /**
  8441. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8442. * @param matrix the matrix to copy the pose from
  8443. * @returns this TransformNode.
  8444. */
  8445. updatePoseMatrix(matrix: Matrix): TransformNode;
  8446. /**
  8447. * Returns the mesh Pose matrix.
  8448. * @returns the pose matrix
  8449. */
  8450. getPoseMatrix(): Matrix;
  8451. /** @hidden */ private _isSynchronized(): boolean;
  8452. /** @hidden */ private _initCache(): void;
  8453. /**
  8454. * Flag the transform node as dirty (Forcing it to update everything)
  8455. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8456. * @returns this transform node
  8457. */
  8458. markAsDirty(property: string): TransformNode;
  8459. /**
  8460. * Returns the current mesh absolute position.
  8461. * Returns a Vector3.
  8462. */
  8463. readonly absolutePosition: Vector3;
  8464. /**
  8465. * Sets a new matrix to apply before all other transformation
  8466. * @param matrix defines the transform matrix
  8467. * @returns the current TransformNode
  8468. */
  8469. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8470. /**
  8471. * Sets a new pivot matrix to the current node
  8472. * @param matrix defines the new pivot matrix to use
  8473. * @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
  8474. * @returns the current TransformNode
  8475. */
  8476. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8477. /**
  8478. * Returns the mesh pivot matrix.
  8479. * Default : Identity.
  8480. * @returns the matrix
  8481. */
  8482. getPivotMatrix(): Matrix;
  8483. /**
  8484. * Prevents the World matrix to be computed any longer.
  8485. * @returns the TransformNode.
  8486. */
  8487. freezeWorldMatrix(): TransformNode;
  8488. /**
  8489. * Allows back the World matrix computation.
  8490. * @returns the TransformNode.
  8491. */
  8492. unfreezeWorldMatrix(): this;
  8493. /**
  8494. * True if the World matrix has been frozen.
  8495. */
  8496. readonly isWorldMatrixFrozen: boolean;
  8497. /**
  8498. * Retuns the mesh absolute position in the World.
  8499. * @returns a Vector3.
  8500. */
  8501. getAbsolutePosition(): Vector3;
  8502. /**
  8503. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8504. * @param absolutePosition the absolute position to set
  8505. * @returns the TransformNode.
  8506. */
  8507. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8508. /**
  8509. * Sets the mesh position in its local space.
  8510. * @param vector3 the position to set in localspace
  8511. * @returns the TransformNode.
  8512. */
  8513. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8514. /**
  8515. * Returns the mesh position in the local space from the current World matrix values.
  8516. * @returns a new Vector3.
  8517. */
  8518. getPositionExpressedInLocalSpace(): Vector3;
  8519. /**
  8520. * Translates the mesh along the passed Vector3 in its local space.
  8521. * @param vector3 the distance to translate in localspace
  8522. * @returns the TransformNode.
  8523. */
  8524. locallyTranslate(vector3: Vector3): TransformNode;
  8525. private static _lookAtVectorCache;
  8526. /**
  8527. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8528. * @param targetPoint the position (must be in same space as current mesh) to look at
  8529. * @param yawCor optional yaw (y-axis) correction in radians
  8530. * @param pitchCor optional pitch (x-axis) correction in radians
  8531. * @param rollCor optional roll (z-axis) correction in radians
  8532. * @param space the choosen space of the target
  8533. * @returns the TransformNode.
  8534. */
  8535. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8536. /**
  8537. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8538. * This Vector3 is expressed in the World space.
  8539. * @param localAxis axis to rotate
  8540. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8541. */
  8542. getDirection(localAxis: Vector3): Vector3;
  8543. /**
  8544. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8545. * localAxis is expressed in the mesh local space.
  8546. * result is computed in the Wordl space from the mesh World matrix.
  8547. * @param localAxis axis to rotate
  8548. * @param result the resulting transformnode
  8549. * @returns this TransformNode.
  8550. */
  8551. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8552. /**
  8553. * Sets this transform node rotation to the given local axis.
  8554. * @param localAxis the axis in local space
  8555. * @param yawCor optional yaw (y-axis) correction in radians
  8556. * @param pitchCor optional pitch (x-axis) correction in radians
  8557. * @param rollCor optional roll (z-axis) correction in radians
  8558. * @returns this TransformNode
  8559. */
  8560. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8561. /**
  8562. * Sets a new pivot point to the current node
  8563. * @param point defines the new pivot point to use
  8564. * @param space defines if the point is in world or local space (local by default)
  8565. * @returns the current TransformNode
  8566. */
  8567. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8568. /**
  8569. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8570. * @returns the pivot point
  8571. */
  8572. getPivotPoint(): Vector3;
  8573. /**
  8574. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8575. * @param result the vector3 to store the result
  8576. * @returns this TransformNode.
  8577. */
  8578. getPivotPointToRef(result: Vector3): TransformNode;
  8579. /**
  8580. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8581. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8582. */
  8583. getAbsolutePivotPoint(): Vector3;
  8584. /**
  8585. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8586. * @param result vector3 to store the result
  8587. * @returns this TransformNode.
  8588. */
  8589. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8590. /**
  8591. * Defines the passed node as the parent of the current node.
  8592. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8593. * @see https://doc.babylonjs.com/how_to/parenting
  8594. * @param node the node ot set as the parent
  8595. * @returns this TransformNode.
  8596. */
  8597. setParent(node: Nullable<Node>): TransformNode;
  8598. private _nonUniformScaling;
  8599. /**
  8600. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8601. */
  8602. readonly nonUniformScaling: boolean;
  8603. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  8604. /**
  8605. * Attach the current TransformNode to another TransformNode associated with a bone
  8606. * @param bone Bone affecting the TransformNode
  8607. * @param affectedTransformNode TransformNode associated with the bone
  8608. * @returns this object
  8609. */
  8610. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8611. /**
  8612. * Detach the transform node if its associated with a bone
  8613. * @returns this object
  8614. */
  8615. detachFromBone(): TransformNode;
  8616. private static _rotationAxisCache;
  8617. /**
  8618. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8619. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8620. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8621. * The passed axis is also normalized.
  8622. * @param axis the axis to rotate around
  8623. * @param amount the amount to rotate in radians
  8624. * @param space Space to rotate in (Default: local)
  8625. * @returns the TransformNode.
  8626. */
  8627. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8628. /**
  8629. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8630. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8631. * The passed axis is also normalized. .
  8632. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8633. * @param point the point to rotate around
  8634. * @param axis the axis to rotate around
  8635. * @param amount the amount to rotate in radians
  8636. * @returns the TransformNode
  8637. */
  8638. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8639. /**
  8640. * Translates the mesh along the axis vector for the passed distance in the given space.
  8641. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8642. * @param axis the axis to translate in
  8643. * @param distance the distance to translate
  8644. * @param space Space to rotate in (Default: local)
  8645. * @returns the TransformNode.
  8646. */
  8647. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8648. /**
  8649. * Adds a rotation step to the mesh current rotation.
  8650. * x, y, z are Euler angles expressed in radians.
  8651. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8652. * This means this rotation is made in the mesh local space only.
  8653. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8654. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8655. * ```javascript
  8656. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8657. * ```
  8658. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8659. * 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.
  8660. * @param x Rotation to add
  8661. * @param y Rotation to add
  8662. * @param z Rotation to add
  8663. * @returns the TransformNode.
  8664. */
  8665. addRotation(x: number, y: number, z: number): TransformNode;
  8666. /**
  8667. * @hidden
  8668. */
  8669. protected _getEffectiveParent(): Nullable<Node>;
  8670. /**
  8671. * Computes the world matrix of the node
  8672. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8673. * @returns the world matrix
  8674. */
  8675. computeWorldMatrix(force?: boolean): Matrix;
  8676. protected _afterComputeWorldMatrix(): void;
  8677. /**
  8678. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8679. * @param func callback function to add
  8680. *
  8681. * @returns the TransformNode.
  8682. */
  8683. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8684. /**
  8685. * Removes a registered callback function.
  8686. * @param func callback function to remove
  8687. * @returns the TransformNode.
  8688. */
  8689. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8690. /**
  8691. * Gets the position of the current mesh in camera space
  8692. * @param camera defines the camera to use
  8693. * @returns a position
  8694. */
  8695. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8696. /**
  8697. * Returns the distance from the mesh to the active camera
  8698. * @param camera defines the camera to use
  8699. * @returns the distance
  8700. */
  8701. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8702. /**
  8703. * Clone the current transform node
  8704. * @param name Name of the new clone
  8705. * @param newParent New parent for the clone
  8706. * @param doNotCloneChildren Do not clone children hierarchy
  8707. * @returns the new transform node
  8708. */
  8709. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8710. /**
  8711. * Serializes the objects information.
  8712. * @param currentSerializationObject defines the object to serialize in
  8713. * @returns the serialized object
  8714. */
  8715. serialize(currentSerializationObject?: any): any;
  8716. /**
  8717. * Returns a new TransformNode object parsed from the source provided.
  8718. * @param parsedTransformNode is the source.
  8719. * @param scene the scne the object belongs to
  8720. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8721. * @returns a new TransformNode object parsed from the source provided.
  8722. */
  8723. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8724. /**
  8725. * Get all child-transformNodes of this node
  8726. * @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
  8727. * @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
  8728. * @returns an array of TransformNode
  8729. */
  8730. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8731. /**
  8732. * Releases resources associated with this transform node.
  8733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8735. */
  8736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8737. /**
  8738. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8739. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8740. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8741. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8742. * @returns the current mesh
  8743. */
  8744. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8745. }
  8746. }
  8747. declare module BABYLON {
  8748. /**
  8749. * Class used to override all child animations of a given target
  8750. */
  8751. export class AnimationPropertiesOverride {
  8752. /**
  8753. * Gets or sets a value indicating if animation blending must be used
  8754. */
  8755. enableBlending: boolean;
  8756. /**
  8757. * Gets or sets the blending speed to use when enableBlending is true
  8758. */
  8759. blendingSpeed: number;
  8760. /**
  8761. * Gets or sets the default loop mode to use
  8762. */
  8763. loopMode: number;
  8764. }
  8765. }
  8766. declare module BABYLON {
  8767. /**
  8768. * Class used to store bone information
  8769. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8770. */
  8771. export class Bone extends Node {
  8772. /**
  8773. * defines the bone name
  8774. */
  8775. name: string;
  8776. private static _tmpVecs;
  8777. private static _tmpQuat;
  8778. private static _tmpMats;
  8779. /**
  8780. * Gets the list of child bones
  8781. */
  8782. children: Bone[];
  8783. /** Gets the animations associated with this bone */
  8784. animations: Animation[];
  8785. /**
  8786. * Gets or sets bone length
  8787. */
  8788. length: number;
  8789. /**
  8790. * @hidden Internal only
  8791. * Set this value to map this bone to a different index in the transform matrices
  8792. * Set this value to -1 to exclude the bone from the transform matrices
  8793. */ private _index: Nullable<number>;
  8794. private _skeleton;
  8795. private _localMatrix;
  8796. private _restPose;
  8797. private _baseMatrix;
  8798. private _absoluteTransform;
  8799. private _invertedAbsoluteTransform;
  8800. private _parent;
  8801. private _scalingDeterminant;
  8802. private _worldTransform;
  8803. private _localScaling;
  8804. private _localRotation;
  8805. private _localPosition;
  8806. private _needToDecompose;
  8807. private _needToCompose;
  8808. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  8809. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  8810. /** @hidden */
  8811. /** @hidden */ private _matrix: Matrix;
  8812. /**
  8813. * Create a new bone
  8814. * @param name defines the bone name
  8815. * @param skeleton defines the parent skeleton
  8816. * @param parentBone defines the parent (can be null if the bone is the root)
  8817. * @param localMatrix defines the local matrix
  8818. * @param restPose defines the rest pose matrix
  8819. * @param baseMatrix defines the base matrix
  8820. * @param index defines index of the bone in the hiearchy
  8821. */
  8822. constructor(
  8823. /**
  8824. * defines the bone name
  8825. */
  8826. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8827. /**
  8828. * Gets the current object class name.
  8829. * @return the class name
  8830. */
  8831. getClassName(): string;
  8832. /**
  8833. * Gets the parent skeleton
  8834. * @returns a skeleton
  8835. */
  8836. getSkeleton(): Skeleton;
  8837. /**
  8838. * Gets parent bone
  8839. * @returns a bone or null if the bone is the root of the bone hierarchy
  8840. */
  8841. getParent(): Nullable<Bone>;
  8842. /**
  8843. * Returns an array containing the root bones
  8844. * @returns an array containing the root bones
  8845. */
  8846. getChildren(): Array<Bone>;
  8847. /**
  8848. * Sets the parent bone
  8849. * @param parent defines the parent (can be null if the bone is the root)
  8850. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8851. */
  8852. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8853. /**
  8854. * Gets the local matrix
  8855. * @returns a matrix
  8856. */
  8857. getLocalMatrix(): Matrix;
  8858. /**
  8859. * Gets the base matrix (initial matrix which remains unchanged)
  8860. * @returns a matrix
  8861. */
  8862. getBaseMatrix(): Matrix;
  8863. /**
  8864. * Gets the rest pose matrix
  8865. * @returns a matrix
  8866. */
  8867. getRestPose(): Matrix;
  8868. /**
  8869. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8870. */
  8871. getWorldMatrix(): Matrix;
  8872. /**
  8873. * Sets the local matrix to rest pose matrix
  8874. */
  8875. returnToRest(): void;
  8876. /**
  8877. * Gets the inverse of the absolute transform matrix.
  8878. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8879. * @returns a matrix
  8880. */
  8881. getInvertedAbsoluteTransform(): Matrix;
  8882. /**
  8883. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8884. * @returns a matrix
  8885. */
  8886. getAbsoluteTransform(): Matrix;
  8887. /**
  8888. * Links with the given transform node.
  8889. * The local matrix of this bone is copied from the transform node every frame.
  8890. * @param transformNode defines the transform node to link to
  8891. */
  8892. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8893. /** Gets or sets current position (in local space) */
  8894. position: Vector3;
  8895. /** Gets or sets current rotation (in local space) */
  8896. rotation: Vector3;
  8897. /** Gets or sets current rotation quaternion (in local space) */
  8898. rotationQuaternion: Quaternion;
  8899. /** Gets or sets current scaling (in local space) */
  8900. scaling: Vector3;
  8901. /**
  8902. * Gets the animation properties override
  8903. */
  8904. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8905. private _decompose;
  8906. private _compose;
  8907. /**
  8908. * Update the base and local matrices
  8909. * @param matrix defines the new base or local matrix
  8910. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8911. * @param updateLocalMatrix defines if the local matrix should be updated
  8912. */
  8913. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8914. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8915. /**
  8916. * Flag the bone as dirty (Forcing it to update everything)
  8917. */
  8918. markAsDirty(): void;
  8919. /** @hidden */ private _markAsDirtyAndCompose(): void;
  8920. private _markAsDirtyAndDecompose;
  8921. /**
  8922. * Translate the bone in local or world space
  8923. * @param vec The amount to translate the bone
  8924. * @param space The space that the translation is in
  8925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8926. */
  8927. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8928. /**
  8929. * Set the postion of the bone in local or world space
  8930. * @param position The position to set the bone
  8931. * @param space The space that the position is in
  8932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8933. */
  8934. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8935. /**
  8936. * Set the absolute position of the bone (world space)
  8937. * @param position The position to set the bone
  8938. * @param mesh The mesh that this bone is attached to
  8939. */
  8940. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8941. /**
  8942. * Scale the bone on the x, y and z axes (in local space)
  8943. * @param x The amount to scale the bone on the x axis
  8944. * @param y The amount to scale the bone on the y axis
  8945. * @param z The amount to scale the bone on the z axis
  8946. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8947. */
  8948. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8949. /**
  8950. * Set the bone scaling in local space
  8951. * @param scale defines the scaling vector
  8952. */
  8953. setScale(scale: Vector3): void;
  8954. /**
  8955. * Gets the current scaling in local space
  8956. * @returns the current scaling vector
  8957. */
  8958. getScale(): Vector3;
  8959. /**
  8960. * Gets the current scaling in local space and stores it in a target vector
  8961. * @param result defines the target vector
  8962. */
  8963. getScaleToRef(result: Vector3): void;
  8964. /**
  8965. * Set the yaw, pitch, and roll of the bone in local or world space
  8966. * @param yaw The rotation of the bone on the y axis
  8967. * @param pitch The rotation of the bone on the x axis
  8968. * @param roll The rotation of the bone on the z axis
  8969. * @param space The space that the axes of rotation are in
  8970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8971. */
  8972. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8973. /**
  8974. * Add a rotation to the bone on an axis in local or world space
  8975. * @param axis The axis to rotate the bone on
  8976. * @param amount The amount to rotate the bone
  8977. * @param space The space that the axis is in
  8978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8979. */
  8980. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8981. /**
  8982. * Set the rotation of the bone to a particular axis angle in local or world space
  8983. * @param axis The axis to rotate the bone on
  8984. * @param angle The angle that the bone should be rotated to
  8985. * @param space The space that the axis is in
  8986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8987. */
  8988. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8989. /**
  8990. * Set the euler rotation of the bone in local of world space
  8991. * @param rotation The euler rotation that the bone should be set to
  8992. * @param space The space that the rotation is in
  8993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8994. */
  8995. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8996. /**
  8997. * Set the quaternion rotation of the bone in local of world space
  8998. * @param quat The quaternion rotation that the bone should be set to
  8999. * @param space The space that the rotation is in
  9000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9001. */
  9002. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9003. /**
  9004. * Set the rotation matrix of the bone in local of world space
  9005. * @param rotMat The rotation matrix that the bone should be set to
  9006. * @param space The space that the rotation is in
  9007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9008. */
  9009. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9010. private _rotateWithMatrix;
  9011. private _getNegativeRotationToRef;
  9012. /**
  9013. * Get the position of the bone in local or world space
  9014. * @param space The space that the returned position is in
  9015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9016. * @returns The position of the bone
  9017. */
  9018. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9019. /**
  9020. * Copy the position of the bone to a vector3 in local or world space
  9021. * @param space The space that the returned position is in
  9022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9023. * @param result The vector3 to copy the position to
  9024. */
  9025. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9026. /**
  9027. * Get the absolute position of the bone (world space)
  9028. * @param mesh The mesh that this bone is attached to
  9029. * @returns The absolute position of the bone
  9030. */
  9031. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9032. /**
  9033. * Copy the absolute position of the bone (world space) to the result param
  9034. * @param mesh The mesh that this bone is attached to
  9035. * @param result The vector3 to copy the absolute position to
  9036. */
  9037. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9038. /**
  9039. * Compute the absolute transforms of this bone and its children
  9040. */
  9041. computeAbsoluteTransforms(): void;
  9042. /**
  9043. * Get the world direction from an axis that is in the local space of the bone
  9044. * @param localAxis The local direction that is used to compute the world direction
  9045. * @param mesh The mesh that this bone is attached to
  9046. * @returns The world direction
  9047. */
  9048. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9049. /**
  9050. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9051. * @param localAxis The local direction that is used to compute the world direction
  9052. * @param mesh The mesh that this bone is attached to
  9053. * @param result The vector3 that the world direction will be copied to
  9054. */
  9055. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9056. /**
  9057. * Get the euler rotation of the bone in local or world space
  9058. * @param space The space that the rotation should be in
  9059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9060. * @returns The euler rotation
  9061. */
  9062. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9063. /**
  9064. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9065. * @param space The space that the rotation should be in
  9066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9067. * @param result The vector3 that the rotation should be copied to
  9068. */
  9069. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9070. /**
  9071. * Get the quaternion rotation of the bone in either local or world space
  9072. * @param space The space that the rotation should be in
  9073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9074. * @returns The quaternion rotation
  9075. */
  9076. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9077. /**
  9078. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9079. * @param space The space that the rotation should be in
  9080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9081. * @param result The quaternion that the rotation should be copied to
  9082. */
  9083. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9084. /**
  9085. * Get the rotation matrix of the bone in local or world space
  9086. * @param space The space that the rotation should be in
  9087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9088. * @returns The rotation matrix
  9089. */
  9090. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9091. /**
  9092. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9093. * @param space The space that the rotation should be in
  9094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9095. * @param result The quaternion that the rotation should be copied to
  9096. */
  9097. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9098. /**
  9099. * Get the world position of a point that is in the local space of the bone
  9100. * @param position The local position
  9101. * @param mesh The mesh that this bone is attached to
  9102. * @returns The world position
  9103. */
  9104. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9105. /**
  9106. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9107. * @param position The local position
  9108. * @param mesh The mesh that this bone is attached to
  9109. * @param result The vector3 that the world position should be copied to
  9110. */
  9111. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9112. /**
  9113. * Get the local position of a point that is in world space
  9114. * @param position The world position
  9115. * @param mesh The mesh that this bone is attached to
  9116. * @returns The local position
  9117. */
  9118. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9119. /**
  9120. * Get the local position of a point that is in world space and copy it to the result param
  9121. * @param position The world position
  9122. * @param mesh The mesh that this bone is attached to
  9123. * @param result The vector3 that the local position should be copied to
  9124. */
  9125. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9126. }
  9127. }
  9128. declare module BABYLON {
  9129. interface Engine {
  9130. /**
  9131. * Creates a raw texture
  9132. * @param data defines the data to store in the texture
  9133. * @param width defines the width of the texture
  9134. * @param height defines the height of the texture
  9135. * @param format defines the format of the data
  9136. * @param generateMipMaps defines if the engine should generate the mip levels
  9137. * @param invertY defines if data must be stored with Y axis inverted
  9138. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9139. * @param compression defines the compression used (null by default)
  9140. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9141. * @returns the raw texture inside an InternalTexture
  9142. */
  9143. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9144. /**
  9145. * Update a raw texture
  9146. * @param texture defines the texture to update
  9147. * @param data defines the data to store in the texture
  9148. * @param format defines the format of the data
  9149. * @param invertY defines if data must be stored with Y axis inverted
  9150. */
  9151. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9152. /**
  9153. * Update a raw texture
  9154. * @param texture defines the texture to update
  9155. * @param data defines the data to store in the texture
  9156. * @param format defines the format of the data
  9157. * @param invertY defines if data must be stored with Y axis inverted
  9158. * @param compression defines the compression used (null by default)
  9159. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9160. */
  9161. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9162. /**
  9163. * Creates a new raw cube texture
  9164. * @param data defines the array of data to use to create each face
  9165. * @param size defines the size of the textures
  9166. * @param format defines the format of the data
  9167. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9168. * @param generateMipMaps defines if the engine should generate the mip levels
  9169. * @param invertY defines if data must be stored with Y axis inverted
  9170. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9171. * @param compression defines the compression used (null by default)
  9172. * @returns the cube texture as an InternalTexture
  9173. */
  9174. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9175. /**
  9176. * Update a raw cube texture
  9177. * @param texture defines the texture to udpdate
  9178. * @param data defines the data to store
  9179. * @param format defines the data format
  9180. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9181. * @param invertY defines if data must be stored with Y axis inverted
  9182. */
  9183. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9184. /**
  9185. * Update a raw cube texture
  9186. * @param texture defines the texture to udpdate
  9187. * @param data defines the data to store
  9188. * @param format defines the data format
  9189. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9190. * @param invertY defines if data must be stored with Y axis inverted
  9191. * @param compression defines the compression used (null by default)
  9192. */
  9193. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9194. /**
  9195. * Update a raw cube texture
  9196. * @param texture defines the texture to udpdate
  9197. * @param data defines the data to store
  9198. * @param format defines the data format
  9199. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9200. * @param invertY defines if data must be stored with Y axis inverted
  9201. * @param compression defines the compression used (null by default)
  9202. * @param level defines which level of the texture to update
  9203. */
  9204. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9205. /**
  9206. * Creates a new raw cube texture from a specified url
  9207. * @param url defines the url where the data is located
  9208. * @param scene defines the current scene
  9209. * @param size defines the size of the textures
  9210. * @param format defines the format of the data
  9211. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9212. * @param noMipmap defines if the engine should avoid generating the mip levels
  9213. * @param callback defines a callback used to extract texture data from loaded data
  9214. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9215. * @param onLoad defines a callback called when texture is loaded
  9216. * @param onError defines a callback called if there is an error
  9217. * @returns the cube texture as an InternalTexture
  9218. */
  9219. 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;
  9220. /**
  9221. * Creates a new raw cube texture from a specified url
  9222. * @param url defines the url where the data is located
  9223. * @param scene defines the current scene
  9224. * @param size defines the size of the textures
  9225. * @param format defines the format of the data
  9226. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9227. * @param noMipmap defines if the engine should avoid generating the mip levels
  9228. * @param callback defines a callback used to extract texture data from loaded data
  9229. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9230. * @param onLoad defines a callback called when texture is loaded
  9231. * @param onError defines a callback called if there is an error
  9232. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9233. * @param invertY defines if data must be stored with Y axis inverted
  9234. * @returns the cube texture as an InternalTexture
  9235. */
  9236. 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;
  9237. /**
  9238. * Creates a new raw 3D texture
  9239. * @param data defines the data used to create the texture
  9240. * @param width defines the width of the texture
  9241. * @param height defines the height of the texture
  9242. * @param depth defines the depth of the texture
  9243. * @param format defines the format of the texture
  9244. * @param generateMipMaps defines if the engine must generate mip levels
  9245. * @param invertY defines if data must be stored with Y axis inverted
  9246. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9247. * @param compression defines the compressed used (can be null)
  9248. * @param textureType defines the compressed used (can be null)
  9249. * @returns a new raw 3D texture (stored in an InternalTexture)
  9250. */
  9251. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9252. /**
  9253. * Update a raw 3D texture
  9254. * @param texture defines the texture to update
  9255. * @param data defines the data to store
  9256. * @param format defines the data format
  9257. * @param invertY defines if data must be stored with Y axis inverted
  9258. */
  9259. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9260. /**
  9261. * Update a raw 3D texture
  9262. * @param texture defines the texture to update
  9263. * @param data defines the data to store
  9264. * @param format defines the data format
  9265. * @param invertY defines if data must be stored with Y axis inverted
  9266. * @param compression defines the used compression (can be null)
  9267. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9268. */
  9269. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9270. }
  9271. }
  9272. declare module BABYLON {
  9273. /**
  9274. * Raw texture can help creating a texture directly from an array of data.
  9275. * This can be super useful if you either get the data from an uncompressed source or
  9276. * if you wish to create your texture pixel by pixel.
  9277. */
  9278. export class RawTexture extends Texture {
  9279. /**
  9280. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9281. */
  9282. format: number;
  9283. private _engine;
  9284. /**
  9285. * Instantiates a new RawTexture.
  9286. * Raw texture can help creating a texture directly from an array of data.
  9287. * This can be super useful if you either get the data from an uncompressed source or
  9288. * if you wish to create your texture pixel by pixel.
  9289. * @param data define the array of data to use to create the texture
  9290. * @param width define the width of the texture
  9291. * @param height define the height of the texture
  9292. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9293. * @param scene define the scene the texture belongs to
  9294. * @param generateMipMaps define whether mip maps should be generated or not
  9295. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9296. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9297. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9298. */
  9299. constructor(data: ArrayBufferView, width: number, height: number,
  9300. /**
  9301. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9302. */
  9303. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9304. /**
  9305. * Updates the texture underlying data.
  9306. * @param data Define the new data of the texture
  9307. */
  9308. update(data: ArrayBufferView): void;
  9309. /**
  9310. * Creates a luminance texture from some data.
  9311. * @param data Define the texture data
  9312. * @param width Define the width of the texture
  9313. * @param height Define the height of the texture
  9314. * @param scene Define the scene the texture belongs to
  9315. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9316. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9317. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9318. * @returns the luminance texture
  9319. */
  9320. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9321. /**
  9322. * Creates a luminance alpha texture from some data.
  9323. * @param data Define the texture data
  9324. * @param width Define the width of the texture
  9325. * @param height Define the height of the texture
  9326. * @param scene Define the scene the texture belongs to
  9327. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9328. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9329. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9330. * @returns the luminance alpha texture
  9331. */
  9332. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9333. /**
  9334. * Creates an alpha texture from some data.
  9335. * @param data Define the texture data
  9336. * @param width Define the width of the texture
  9337. * @param height Define the height of the texture
  9338. * @param scene Define the scene the texture belongs to
  9339. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9340. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9341. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9342. * @returns the alpha texture
  9343. */
  9344. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9345. /**
  9346. * Creates a RGB texture from some data.
  9347. * @param data Define the texture data
  9348. * @param width Define the width of the texture
  9349. * @param height Define the height of the texture
  9350. * @param scene Define the scene the texture belongs to
  9351. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9352. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9353. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9354. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9355. * @returns the RGB alpha texture
  9356. */
  9357. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9358. /**
  9359. * Creates a RGBA texture from some data.
  9360. * @param data Define the texture data
  9361. * @param width Define the width of the texture
  9362. * @param height Define the height of the texture
  9363. * @param scene Define the scene the texture belongs to
  9364. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9365. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9366. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9367. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9368. * @returns the RGBA texture
  9369. */
  9370. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9371. /**
  9372. * Creates a R texture from some data.
  9373. * @param data Define the texture data
  9374. * @param width Define the width of the texture
  9375. * @param height Define the height of the texture
  9376. * @param scene Define the scene the texture belongs to
  9377. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9378. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9379. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9380. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9381. * @returns the R texture
  9382. */
  9383. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9384. }
  9385. }
  9386. declare module BABYLON {
  9387. /**
  9388. * Defines a runtime animation
  9389. */
  9390. export class RuntimeAnimation {
  9391. private _events;
  9392. /**
  9393. * The current frame of the runtime animation
  9394. */
  9395. private _currentFrame;
  9396. /**
  9397. * The animation used by the runtime animation
  9398. */
  9399. private _animation;
  9400. /**
  9401. * The target of the runtime animation
  9402. */
  9403. private _target;
  9404. /**
  9405. * The initiating animatable
  9406. */
  9407. private _host;
  9408. /**
  9409. * The original value of the runtime animation
  9410. */
  9411. private _originalValue;
  9412. /**
  9413. * The original blend value of the runtime animation
  9414. */
  9415. private _originalBlendValue;
  9416. /**
  9417. * The offsets cache of the runtime animation
  9418. */
  9419. private _offsetsCache;
  9420. /**
  9421. * The high limits cache of the runtime animation
  9422. */
  9423. private _highLimitsCache;
  9424. /**
  9425. * Specifies if the runtime animation has been stopped
  9426. */
  9427. private _stopped;
  9428. /**
  9429. * The blending factor of the runtime animation
  9430. */
  9431. private _blendingFactor;
  9432. /**
  9433. * The BabylonJS scene
  9434. */
  9435. private _scene;
  9436. /**
  9437. * The current value of the runtime animation
  9438. */
  9439. private _currentValue;
  9440. /** @hidden */ private _animationState: _IAnimationState;
  9441. /**
  9442. * The active target of the runtime animation
  9443. */
  9444. private _activeTargets;
  9445. private _currentActiveTarget;
  9446. private _directTarget;
  9447. /**
  9448. * The target path of the runtime animation
  9449. */
  9450. private _targetPath;
  9451. /**
  9452. * The weight of the runtime animation
  9453. */
  9454. private _weight;
  9455. /**
  9456. * The ratio offset of the runtime animation
  9457. */
  9458. private _ratioOffset;
  9459. /**
  9460. * The previous delay of the runtime animation
  9461. */
  9462. private _previousDelay;
  9463. /**
  9464. * The previous ratio of the runtime animation
  9465. */
  9466. private _previousRatio;
  9467. private _enableBlending;
  9468. private _keys;
  9469. private _minFrame;
  9470. private _maxFrame;
  9471. private _minValue;
  9472. private _maxValue;
  9473. private _targetIsArray;
  9474. /**
  9475. * Gets the current frame of the runtime animation
  9476. */
  9477. readonly currentFrame: number;
  9478. /**
  9479. * Gets the weight of the runtime animation
  9480. */
  9481. readonly weight: number;
  9482. /**
  9483. * Gets the current value of the runtime animation
  9484. */
  9485. readonly currentValue: any;
  9486. /**
  9487. * Gets the target path of the runtime animation
  9488. */
  9489. readonly targetPath: string;
  9490. /**
  9491. * Gets the actual target of the runtime animation
  9492. */
  9493. readonly target: any;
  9494. /** @hidden */ private _onLoop: () => void;
  9495. /**
  9496. * Create a new RuntimeAnimation object
  9497. * @param target defines the target of the animation
  9498. * @param animation defines the source animation object
  9499. * @param scene defines the hosting scene
  9500. * @param host defines the initiating Animatable
  9501. */
  9502. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9503. private _preparePath;
  9504. /**
  9505. * Gets the animation from the runtime animation
  9506. */
  9507. readonly animation: Animation;
  9508. /**
  9509. * Resets the runtime animation to the beginning
  9510. * @param restoreOriginal defines whether to restore the target property to the original value
  9511. */
  9512. reset(restoreOriginal?: boolean): void;
  9513. /**
  9514. * Specifies if the runtime animation is stopped
  9515. * @returns Boolean specifying if the runtime animation is stopped
  9516. */
  9517. isStopped(): boolean;
  9518. /**
  9519. * Disposes of the runtime animation
  9520. */
  9521. dispose(): void;
  9522. /**
  9523. * Apply the interpolated value to the target
  9524. * @param currentValue defines the value computed by the animation
  9525. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9526. */
  9527. setValue(currentValue: any, weight: number): void;
  9528. private _getOriginalValues;
  9529. private _setValue;
  9530. /**
  9531. * Gets the loop pmode of the runtime animation
  9532. * @returns Loop Mode
  9533. */
  9534. private _getCorrectLoopMode;
  9535. /**
  9536. * Move the current animation to a given frame
  9537. * @param frame defines the frame to move to
  9538. */
  9539. goToFrame(frame: number): void;
  9540. /**
  9541. * @hidden Internal use only
  9542. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9543. /**
  9544. * Execute the current animation
  9545. * @param delay defines the delay to add to the current frame
  9546. * @param from defines the lower bound of the animation range
  9547. * @param to defines the upper bound of the animation range
  9548. * @param loop defines if the current animation must loop
  9549. * @param speedRatio defines the current speed ratio
  9550. * @param weight defines the weight of the animation (default is -1 so no weight)
  9551. * @param onLoop optional callback called when animation loops
  9552. * @returns a boolean indicating if the animation is running
  9553. */
  9554. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9555. }
  9556. }
  9557. declare module BABYLON {
  9558. /**
  9559. * Class used to store an actual running animation
  9560. */
  9561. export class Animatable {
  9562. /** defines the target object */
  9563. target: any;
  9564. /** defines the starting frame number (default is 0) */
  9565. fromFrame: number;
  9566. /** defines the ending frame number (default is 100) */
  9567. toFrame: number;
  9568. /** defines if the animation must loop (default is false) */
  9569. loopAnimation: boolean;
  9570. /** defines a callback to call when animation ends if it is not looping */
  9571. onAnimationEnd?: (() => void) | null | undefined;
  9572. /** defines a callback to call when animation loops */
  9573. onAnimationLoop?: (() => void) | null | undefined;
  9574. private _localDelayOffset;
  9575. private _pausedDelay;
  9576. private _runtimeAnimations;
  9577. private _paused;
  9578. private _scene;
  9579. private _speedRatio;
  9580. private _weight;
  9581. private _syncRoot;
  9582. /**
  9583. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9584. * This will only apply for non looping animation (default is true)
  9585. */
  9586. disposeOnEnd: boolean;
  9587. /**
  9588. * Gets a boolean indicating if the animation has started
  9589. */
  9590. animationStarted: boolean;
  9591. /**
  9592. * Observer raised when the animation ends
  9593. */
  9594. onAnimationEndObservable: Observable<Animatable>;
  9595. /**
  9596. * Observer raised when the animation loops
  9597. */
  9598. onAnimationLoopObservable: Observable<Animatable>;
  9599. /**
  9600. * Gets the root Animatable used to synchronize and normalize animations
  9601. */
  9602. readonly syncRoot: Nullable<Animatable>;
  9603. /**
  9604. * Gets the current frame of the first RuntimeAnimation
  9605. * Used to synchronize Animatables
  9606. */
  9607. readonly masterFrame: number;
  9608. /**
  9609. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9610. */
  9611. weight: number;
  9612. /**
  9613. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9614. */
  9615. speedRatio: number;
  9616. /**
  9617. * Creates a new Animatable
  9618. * @param scene defines the hosting scene
  9619. * @param target defines the target object
  9620. * @param fromFrame defines the starting frame number (default is 0)
  9621. * @param toFrame defines the ending frame number (default is 100)
  9622. * @param loopAnimation defines if the animation must loop (default is false)
  9623. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9624. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9625. * @param animations defines a group of animation to add to the new Animatable
  9626. * @param onAnimationLoop defines a callback to call when animation loops
  9627. */
  9628. constructor(scene: Scene,
  9629. /** defines the target object */
  9630. target: any,
  9631. /** defines the starting frame number (default is 0) */
  9632. fromFrame?: number,
  9633. /** defines the ending frame number (default is 100) */
  9634. toFrame?: number,
  9635. /** defines if the animation must loop (default is false) */
  9636. loopAnimation?: boolean, speedRatio?: number,
  9637. /** defines a callback to call when animation ends if it is not looping */
  9638. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9639. /** defines a callback to call when animation loops */
  9640. onAnimationLoop?: (() => void) | null | undefined);
  9641. /**
  9642. * Synchronize and normalize current Animatable with a source Animatable
  9643. * This is useful when using animation weights and when animations are not of the same length
  9644. * @param root defines the root Animatable to synchronize with
  9645. * @returns the current Animatable
  9646. */
  9647. syncWith(root: Animatable): Animatable;
  9648. /**
  9649. * Gets the list of runtime animations
  9650. * @returns an array of RuntimeAnimation
  9651. */
  9652. getAnimations(): RuntimeAnimation[];
  9653. /**
  9654. * Adds more animations to the current animatable
  9655. * @param target defines the target of the animations
  9656. * @param animations defines the new animations to add
  9657. */
  9658. appendAnimations(target: any, animations: Animation[]): void;
  9659. /**
  9660. * Gets the source animation for a specific property
  9661. * @param property defines the propertyu to look for
  9662. * @returns null or the source animation for the given property
  9663. */
  9664. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9665. /**
  9666. * Gets the runtime animation for a specific property
  9667. * @param property defines the propertyu to look for
  9668. * @returns null or the runtime animation for the given property
  9669. */
  9670. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9671. /**
  9672. * Resets the animatable to its original state
  9673. */
  9674. reset(): void;
  9675. /**
  9676. * Allows the animatable to blend with current running animations
  9677. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9678. * @param blendingSpeed defines the blending speed to use
  9679. */
  9680. enableBlending(blendingSpeed: number): void;
  9681. /**
  9682. * Disable animation blending
  9683. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9684. */
  9685. disableBlending(): void;
  9686. /**
  9687. * Jump directly to a given frame
  9688. * @param frame defines the frame to jump to
  9689. */
  9690. goToFrame(frame: number): void;
  9691. /**
  9692. * Pause the animation
  9693. */
  9694. pause(): void;
  9695. /**
  9696. * Restart the animation
  9697. */
  9698. restart(): void;
  9699. private _raiseOnAnimationEnd;
  9700. /**
  9701. * Stop and delete the current animation
  9702. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9703. * @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)
  9704. */
  9705. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9706. /**
  9707. * Wait asynchronously for the animation to end
  9708. * @returns a promise which will be fullfilled when the animation ends
  9709. */
  9710. waitAsync(): Promise<Animatable>;
  9711. /** @hidden */ private _animate(delay: number): boolean;
  9712. }
  9713. interface Scene {
  9714. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9715. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  9716. totalWeight: number;
  9717. animations: RuntimeAnimation[];
  9718. originalValue: Matrix;
  9719. }): any;
  9720. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  9721. totalWeight: number;
  9722. animations: RuntimeAnimation[];
  9723. originalValue: Quaternion;
  9724. }, refQuaternion: Quaternion): Quaternion;
  9725. /** @hidden */ private _processLateAnimationBindings(): void;
  9726. /**
  9727. * Will start the animation sequence of a given target
  9728. * @param target defines the target
  9729. * @param from defines from which frame should animation start
  9730. * @param to defines until which frame should animation run.
  9731. * @param weight defines the weight to apply to the animation (1.0 by default)
  9732. * @param loop defines if the animation loops
  9733. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9734. * @param onAnimationEnd defines the function to be executed when the animation ends
  9735. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9736. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9737. * @param onAnimationLoop defines the callback to call when an animation loops
  9738. * @returns the animatable object created for this animation
  9739. */
  9740. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9741. /**
  9742. * Will start the animation sequence of a given target
  9743. * @param target defines the target
  9744. * @param from defines from which frame should animation start
  9745. * @param to defines until which frame should animation run.
  9746. * @param loop defines if the animation loops
  9747. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9748. * @param onAnimationEnd defines the function to be executed when the animation ends
  9749. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9750. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9751. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9752. * @param onAnimationLoop defines the callback to call when an animation loops
  9753. * @returns the animatable object created for this animation
  9754. */
  9755. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9756. /**
  9757. * Will start the animation sequence of a given target and its hierarchy
  9758. * @param target defines the target
  9759. * @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.
  9760. * @param from defines from which frame should animation start
  9761. * @param to defines until which frame should animation run.
  9762. * @param loop defines if the animation loops
  9763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9764. * @param onAnimationEnd defines the function to be executed when the animation ends
  9765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9766. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9767. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9768. * @param onAnimationLoop defines the callback to call when an animation loops
  9769. * @returns the list of created animatables
  9770. */
  9771. 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[];
  9772. /**
  9773. * Begin a new animation on a given node
  9774. * @param target defines the target where the animation will take place
  9775. * @param animations defines the list of animations to start
  9776. * @param from defines the initial value
  9777. * @param to defines the final value
  9778. * @param loop defines if you want animation to loop (off by default)
  9779. * @param speedRatio defines the speed ratio to apply to all animations
  9780. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9781. * @param onAnimationLoop defines the callback to call when an animation loops
  9782. * @returns the list of created animatables
  9783. */
  9784. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9785. /**
  9786. * Begin a new animation on a given node and its hierarchy
  9787. * @param target defines the root node where the animation will take place
  9788. * @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.
  9789. * @param animations defines the list of animations to start
  9790. * @param from defines the initial value
  9791. * @param to defines the final value
  9792. * @param loop defines if you want animation to loop (off by default)
  9793. * @param speedRatio defines the speed ratio to apply to all animations
  9794. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9795. * @param onAnimationLoop defines the callback to call when an animation loops
  9796. * @returns the list of animatables created for all nodes
  9797. */
  9798. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9799. /**
  9800. * Gets the animatable associated with a specific target
  9801. * @param target defines the target of the animatable
  9802. * @returns the required animatable if found
  9803. */
  9804. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9805. /**
  9806. * Gets all animatables associated with a given target
  9807. * @param target defines the target to look animatables for
  9808. * @returns an array of Animatables
  9809. */
  9810. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9811. /**
  9812. * Stops and removes all animations that have been applied to the scene
  9813. */
  9814. stopAllAnimations(): void;
  9815. }
  9816. interface Bone {
  9817. /**
  9818. * Copy an animation range from another bone
  9819. * @param source defines the source bone
  9820. * @param rangeName defines the range name to copy
  9821. * @param frameOffset defines the frame offset
  9822. * @param rescaleAsRequired defines if rescaling must be applied if required
  9823. * @param skelDimensionsRatio defines the scaling ratio
  9824. * @returns true if operation was successful
  9825. */
  9826. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9827. }
  9828. }
  9829. declare module BABYLON {
  9830. /**
  9831. * Class used to handle skinning animations
  9832. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9833. */
  9834. export class Skeleton implements IAnimatable {
  9835. /** defines the skeleton name */
  9836. name: string;
  9837. /** defines the skeleton Id */
  9838. id: string;
  9839. /**
  9840. * Defines the list of child bones
  9841. */
  9842. bones: Bone[];
  9843. /**
  9844. * Defines an estimate of the dimension of the skeleton at rest
  9845. */
  9846. dimensionsAtRest: Vector3;
  9847. /**
  9848. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9849. */
  9850. needInitialSkinMatrix: boolean;
  9851. /**
  9852. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9853. */
  9854. overrideMesh: Nullable<AbstractMesh>;
  9855. /**
  9856. * Gets the list of animations attached to this skeleton
  9857. */
  9858. animations: Array<Animation>;
  9859. private _scene;
  9860. private _isDirty;
  9861. private _transformMatrices;
  9862. private _transformMatrixTexture;
  9863. private _meshesWithPoseMatrix;
  9864. private _animatables;
  9865. private _identity;
  9866. private _synchronizedWithMesh;
  9867. private _ranges;
  9868. private _lastAbsoluteTransformsUpdateId;
  9869. private _canUseTextureForBones;
  9870. private _uniqueId;
  9871. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  9872. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  9873. /**
  9874. * Specifies if the skeleton should be serialized
  9875. */
  9876. doNotSerialize: boolean;
  9877. private _useTextureToStoreBoneMatrices;
  9878. /**
  9879. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  9880. * Please note that this option is not available if the hardware does not support it
  9881. */
  9882. useTextureToStoreBoneMatrices: boolean;
  9883. private _animationPropertiesOverride;
  9884. /**
  9885. * Gets or sets the animation properties override
  9886. */
  9887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9888. /**
  9889. * List of inspectable custom properties (used by the Inspector)
  9890. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  9891. */
  9892. inspectableCustomProperties: IInspectable[];
  9893. /**
  9894. * An observable triggered before computing the skeleton's matrices
  9895. */
  9896. onBeforeComputeObservable: Observable<Skeleton>;
  9897. /**
  9898. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9899. */
  9900. readonly isUsingTextureForMatrices: boolean;
  9901. /**
  9902. * Gets the unique ID of this skeleton
  9903. */
  9904. readonly uniqueId: number;
  9905. /**
  9906. * Creates a new skeleton
  9907. * @param name defines the skeleton name
  9908. * @param id defines the skeleton Id
  9909. * @param scene defines the hosting scene
  9910. */
  9911. constructor(
  9912. /** defines the skeleton name */
  9913. name: string,
  9914. /** defines the skeleton Id */
  9915. id: string, scene: Scene);
  9916. /**
  9917. * Gets the current object class name.
  9918. * @return the class name
  9919. */
  9920. getClassName(): string;
  9921. /**
  9922. * Returns an array containing the root bones
  9923. * @returns an array containing the root bones
  9924. */
  9925. getChildren(): Array<Bone>;
  9926. /**
  9927. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9928. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9929. * @returns a Float32Array containing matrices data
  9930. */
  9931. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9932. /**
  9933. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9934. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9935. * @returns a raw texture containing the data
  9936. */
  9937. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  9938. /**
  9939. * Gets the current hosting scene
  9940. * @returns a scene object
  9941. */
  9942. getScene(): Scene;
  9943. /**
  9944. * Gets a string representing the current skeleton data
  9945. * @param fullDetails defines a boolean indicating if we want a verbose version
  9946. * @returns a string representing the current skeleton data
  9947. */
  9948. toString(fullDetails?: boolean): string;
  9949. /**
  9950. * Get bone's index searching by name
  9951. * @param name defines bone's name to search for
  9952. * @return the indice of the bone. Returns -1 if not found
  9953. */
  9954. getBoneIndexByName(name: string): number;
  9955. /**
  9956. * Creater a new animation range
  9957. * @param name defines the name of the range
  9958. * @param from defines the start key
  9959. * @param to defines the end key
  9960. */
  9961. createAnimationRange(name: string, from: number, to: number): void;
  9962. /**
  9963. * Delete a specific animation range
  9964. * @param name defines the name of the range
  9965. * @param deleteFrames defines if frames must be removed as well
  9966. */
  9967. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9968. /**
  9969. * Gets a specific animation range
  9970. * @param name defines the name of the range to look for
  9971. * @returns the requested animation range or null if not found
  9972. */
  9973. getAnimationRange(name: string): Nullable<AnimationRange>;
  9974. /**
  9975. * Gets the list of all animation ranges defined on this skeleton
  9976. * @returns an array
  9977. */
  9978. getAnimationRanges(): Nullable<AnimationRange>[];
  9979. /**
  9980. * Copy animation range from a source skeleton.
  9981. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9982. * @param source defines the source skeleton
  9983. * @param name defines the name of the range to copy
  9984. * @param rescaleAsRequired defines if rescaling must be applied if required
  9985. * @returns true if operation was successful
  9986. */
  9987. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9988. /**
  9989. * Forces the skeleton to go to rest pose
  9990. */
  9991. returnToRest(): void;
  9992. private _getHighestAnimationFrame;
  9993. /**
  9994. * Begin a specific animation range
  9995. * @param name defines the name of the range to start
  9996. * @param loop defines if looping must be turned on (false by default)
  9997. * @param speedRatio defines the speed ratio to apply (1 by default)
  9998. * @param onAnimationEnd defines a callback which will be called when animation will end
  9999. * @returns a new animatable
  10000. */
  10001. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10002. /** @hidden */ private _markAsDirty(): void;
  10003. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10004. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10005. private _computeTransformMatrices;
  10006. /**
  10007. * Build all resources required to render a skeleton
  10008. */
  10009. prepare(): void;
  10010. /**
  10011. * Gets the list of animatables currently running for this skeleton
  10012. * @returns an array of animatables
  10013. */
  10014. getAnimatables(): IAnimatable[];
  10015. /**
  10016. * Clone the current skeleton
  10017. * @param name defines the name of the new skeleton
  10018. * @param id defines the id of the new skeleton
  10019. * @returns the new skeleton
  10020. */
  10021. clone(name: string, id: string): Skeleton;
  10022. /**
  10023. * Enable animation blending for this skeleton
  10024. * @param blendingSpeed defines the blending speed to apply
  10025. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10026. */
  10027. enableBlending(blendingSpeed?: number): void;
  10028. /**
  10029. * Releases all resources associated with the current skeleton
  10030. */
  10031. dispose(): void;
  10032. /**
  10033. * Serialize the skeleton in a JSON object
  10034. * @returns a JSON object
  10035. */
  10036. serialize(): any;
  10037. /**
  10038. * Creates a new skeleton from serialized data
  10039. * @param parsedSkeleton defines the serialized data
  10040. * @param scene defines the hosting scene
  10041. * @returns a new skeleton
  10042. */
  10043. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10044. /**
  10045. * Compute all node absolute transforms
  10046. * @param forceUpdate defines if computation must be done even if cache is up to date
  10047. */
  10048. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10049. /**
  10050. * Gets the root pose matrix
  10051. * @returns a matrix
  10052. */
  10053. getPoseMatrix(): Nullable<Matrix>;
  10054. /**
  10055. * Sorts bones per internal index
  10056. */
  10057. sortBones(): void;
  10058. private _sortBones;
  10059. }
  10060. }
  10061. declare module BABYLON {
  10062. /**
  10063. * Defines a target to use with MorphTargetManager
  10064. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10065. */
  10066. export class MorphTarget implements IAnimatable {
  10067. /** defines the name of the target */
  10068. name: string;
  10069. /**
  10070. * Gets or sets the list of animations
  10071. */
  10072. animations: Animation[];
  10073. private _scene;
  10074. private _positions;
  10075. private _normals;
  10076. private _tangents;
  10077. private _uvs;
  10078. private _influence;
  10079. /**
  10080. * Observable raised when the influence changes
  10081. */
  10082. onInfluenceChanged: Observable<boolean>;
  10083. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  10084. /**
  10085. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10086. */
  10087. influence: number;
  10088. /**
  10089. * Gets or sets the id of the morph Target
  10090. */
  10091. id: string;
  10092. private _animationPropertiesOverride;
  10093. /**
  10094. * Gets or sets the animation properties override
  10095. */
  10096. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10097. /**
  10098. * Creates a new MorphTarget
  10099. * @param name defines the name of the target
  10100. * @param influence defines the influence to use
  10101. * @param scene defines the scene the morphtarget belongs to
  10102. */
  10103. constructor(
  10104. /** defines the name of the target */
  10105. name: string, influence?: number, scene?: Nullable<Scene>);
  10106. /**
  10107. * Gets a boolean defining if the target contains position data
  10108. */
  10109. readonly hasPositions: boolean;
  10110. /**
  10111. * Gets a boolean defining if the target contains normal data
  10112. */
  10113. readonly hasNormals: boolean;
  10114. /**
  10115. * Gets a boolean defining if the target contains tangent data
  10116. */
  10117. readonly hasTangents: boolean;
  10118. /**
  10119. * Gets a boolean defining if the target contains texture coordinates data
  10120. */
  10121. readonly hasUVs: boolean;
  10122. /**
  10123. * Affects position data to this target
  10124. * @param data defines the position data to use
  10125. */
  10126. setPositions(data: Nullable<FloatArray>): void;
  10127. /**
  10128. * Gets the position data stored in this target
  10129. * @returns a FloatArray containing the position data (or null if not present)
  10130. */
  10131. getPositions(): Nullable<FloatArray>;
  10132. /**
  10133. * Affects normal data to this target
  10134. * @param data defines the normal data to use
  10135. */
  10136. setNormals(data: Nullable<FloatArray>): void;
  10137. /**
  10138. * Gets the normal data stored in this target
  10139. * @returns a FloatArray containing the normal data (or null if not present)
  10140. */
  10141. getNormals(): Nullable<FloatArray>;
  10142. /**
  10143. * Affects tangent data to this target
  10144. * @param data defines the tangent data to use
  10145. */
  10146. setTangents(data: Nullable<FloatArray>): void;
  10147. /**
  10148. * Gets the tangent data stored in this target
  10149. * @returns a FloatArray containing the tangent data (or null if not present)
  10150. */
  10151. getTangents(): Nullable<FloatArray>;
  10152. /**
  10153. * Affects texture coordinates data to this target
  10154. * @param data defines the texture coordinates data to use
  10155. */
  10156. setUVs(data: Nullable<FloatArray>): void;
  10157. /**
  10158. * Gets the texture coordinates data stored in this target
  10159. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10160. */
  10161. getUVs(): Nullable<FloatArray>;
  10162. /**
  10163. * Serializes the current target into a Serialization object
  10164. * @returns the serialized object
  10165. */
  10166. serialize(): any;
  10167. /**
  10168. * Returns the string "MorphTarget"
  10169. * @returns "MorphTarget"
  10170. */
  10171. getClassName(): string;
  10172. /**
  10173. * Creates a new target from serialized data
  10174. * @param serializationObject defines the serialized data to use
  10175. * @returns a new MorphTarget
  10176. */
  10177. static Parse(serializationObject: any): MorphTarget;
  10178. /**
  10179. * Creates a MorphTarget from mesh data
  10180. * @param mesh defines the source mesh
  10181. * @param name defines the name to use for the new target
  10182. * @param influence defines the influence to attach to the target
  10183. * @returns a new MorphTarget
  10184. */
  10185. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10186. }
  10187. }
  10188. declare module BABYLON {
  10189. /**
  10190. * This class is used to deform meshes using morphing between different targets
  10191. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10192. */
  10193. export class MorphTargetManager {
  10194. private _targets;
  10195. private _targetInfluenceChangedObservers;
  10196. private _targetDataLayoutChangedObservers;
  10197. private _activeTargets;
  10198. private _scene;
  10199. private _influences;
  10200. private _supportsNormals;
  10201. private _supportsTangents;
  10202. private _supportsUVs;
  10203. private _vertexCount;
  10204. private _uniqueId;
  10205. private _tempInfluences;
  10206. /**
  10207. * Gets or sets a boolean indicating if normals must be morphed
  10208. */
  10209. enableNormalMorphing: boolean;
  10210. /**
  10211. * Gets or sets a boolean indicating if tangents must be morphed
  10212. */
  10213. enableTangentMorphing: boolean;
  10214. /**
  10215. * Gets or sets a boolean indicating if UV must be morphed
  10216. */
  10217. enableUVMorphing: boolean;
  10218. /**
  10219. * Creates a new MorphTargetManager
  10220. * @param scene defines the current scene
  10221. */
  10222. constructor(scene?: Nullable<Scene>);
  10223. /**
  10224. * Gets the unique ID of this manager
  10225. */
  10226. readonly uniqueId: number;
  10227. /**
  10228. * Gets the number of vertices handled by this manager
  10229. */
  10230. readonly vertexCount: number;
  10231. /**
  10232. * Gets a boolean indicating if this manager supports morphing of normals
  10233. */
  10234. readonly supportsNormals: boolean;
  10235. /**
  10236. * Gets a boolean indicating if this manager supports morphing of tangents
  10237. */
  10238. readonly supportsTangents: boolean;
  10239. /**
  10240. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10241. */
  10242. readonly supportsUVs: boolean;
  10243. /**
  10244. * Gets the number of targets stored in this manager
  10245. */
  10246. readonly numTargets: number;
  10247. /**
  10248. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10249. */
  10250. readonly numInfluencers: number;
  10251. /**
  10252. * Gets the list of influences (one per target)
  10253. */
  10254. readonly influences: Float32Array;
  10255. /**
  10256. * Gets the active target at specified index. An active target is a target with an influence > 0
  10257. * @param index defines the index to check
  10258. * @returns the requested target
  10259. */
  10260. getActiveTarget(index: number): MorphTarget;
  10261. /**
  10262. * Gets the target at specified index
  10263. * @param index defines the index to check
  10264. * @returns the requested target
  10265. */
  10266. getTarget(index: number): MorphTarget;
  10267. /**
  10268. * Add a new target to this manager
  10269. * @param target defines the target to add
  10270. */
  10271. addTarget(target: MorphTarget): void;
  10272. /**
  10273. * Removes a target from the manager
  10274. * @param target defines the target to remove
  10275. */
  10276. removeTarget(target: MorphTarget): void;
  10277. /**
  10278. * Serializes the current manager into a Serialization object
  10279. * @returns the serialized object
  10280. */
  10281. serialize(): any;
  10282. private _syncActiveTargets;
  10283. /**
  10284. * Syncrhonize the targets with all the meshes using this morph target manager
  10285. */
  10286. synchronize(): void;
  10287. /**
  10288. * Creates a new MorphTargetManager from serialized data
  10289. * @param serializationObject defines the serialized data
  10290. * @param scene defines the hosting scene
  10291. * @returns the new MorphTargetManager
  10292. */
  10293. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10294. }
  10295. }
  10296. declare module BABYLON {
  10297. /**
  10298. * Groups all the scene component constants in one place to ease maintenance.
  10299. * @hidden
  10300. */
  10301. export class SceneComponentConstants {
  10302. static readonly NAME_EFFECTLAYER: string;
  10303. static readonly NAME_LAYER: string;
  10304. static readonly NAME_LENSFLARESYSTEM: string;
  10305. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10306. static readonly NAME_PARTICLESYSTEM: string;
  10307. static readonly NAME_GAMEPAD: string;
  10308. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10309. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10310. static readonly NAME_DEPTHRENDERER: string;
  10311. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10312. static readonly NAME_SPRITE: string;
  10313. static readonly NAME_OUTLINERENDERER: string;
  10314. static readonly NAME_PROCEDURALTEXTURE: string;
  10315. static readonly NAME_SHADOWGENERATOR: string;
  10316. static readonly NAME_OCTREE: string;
  10317. static readonly NAME_PHYSICSENGINE: string;
  10318. static readonly NAME_AUDIO: string;
  10319. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10320. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10321. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10322. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10323. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10324. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10325. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10326. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10327. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10328. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10329. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10330. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10331. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10332. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10333. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10334. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10335. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10336. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10337. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10338. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10339. static readonly STEP_AFTERRENDER_AUDIO: number;
  10340. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10341. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10342. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10343. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10344. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10345. static readonly STEP_POINTERMOVE_SPRITE: number;
  10346. static readonly STEP_POINTERDOWN_SPRITE: number;
  10347. static readonly STEP_POINTERUP_SPRITE: number;
  10348. }
  10349. /**
  10350. * This represents a scene component.
  10351. *
  10352. * This is used to decouple the dependency the scene is having on the different workloads like
  10353. * layers, post processes...
  10354. */
  10355. export interface ISceneComponent {
  10356. /**
  10357. * The name of the component. Each component must have a unique name.
  10358. */
  10359. name: string;
  10360. /**
  10361. * The scene the component belongs to.
  10362. */
  10363. scene: Scene;
  10364. /**
  10365. * Register the component to one instance of a scene.
  10366. */
  10367. register(): void;
  10368. /**
  10369. * Rebuilds the elements related to this component in case of
  10370. * context lost for instance.
  10371. */
  10372. rebuild(): void;
  10373. /**
  10374. * Disposes the component and the associated ressources.
  10375. */
  10376. dispose(): void;
  10377. }
  10378. /**
  10379. * This represents a SERIALIZABLE scene component.
  10380. *
  10381. * This extends Scene Component to add Serialization methods on top.
  10382. */
  10383. export interface ISceneSerializableComponent extends ISceneComponent {
  10384. /**
  10385. * Adds all the elements from the container to the scene
  10386. * @param container the container holding the elements
  10387. */
  10388. addFromContainer(container: AbstractScene): void;
  10389. /**
  10390. * Removes all the elements in the container from the scene
  10391. * @param container contains the elements to remove
  10392. * @param dispose if the removed element should be disposed (default: false)
  10393. */
  10394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10395. /**
  10396. * Serializes the component data to the specified json object
  10397. * @param serializationObject The object to serialize to
  10398. */
  10399. serialize(serializationObject: any): void;
  10400. }
  10401. /**
  10402. * Strong typing of a Mesh related stage step action
  10403. */
  10404. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10405. /**
  10406. * Strong typing of a Evaluate Sub Mesh related stage step action
  10407. */
  10408. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10409. /**
  10410. * Strong typing of a Active Mesh related stage step action
  10411. */
  10412. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10413. /**
  10414. * Strong typing of a Camera related stage step action
  10415. */
  10416. export type CameraStageAction = (camera: Camera) => void;
  10417. /**
  10418. * Strong typing of a Camera Frame buffer related stage step action
  10419. */
  10420. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10421. /**
  10422. * Strong typing of a Render Target related stage step action
  10423. */
  10424. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10425. /**
  10426. * Strong typing of a RenderingGroup related stage step action
  10427. */
  10428. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10429. /**
  10430. * Strong typing of a Mesh Render related stage step action
  10431. */
  10432. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10433. /**
  10434. * Strong typing of a simple stage step action
  10435. */
  10436. export type SimpleStageAction = () => void;
  10437. /**
  10438. * Strong typing of a render target action.
  10439. */
  10440. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10441. /**
  10442. * Strong typing of a pointer move action.
  10443. */
  10444. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10445. /**
  10446. * Strong typing of a pointer up/down action.
  10447. */
  10448. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10449. /**
  10450. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10451. * @hidden
  10452. */
  10453. export class Stage<T extends Function> extends Array<{
  10454. index: number;
  10455. component: ISceneComponent;
  10456. action: T;
  10457. }> {
  10458. /**
  10459. * Hide ctor from the rest of the world.
  10460. * @param items The items to add.
  10461. */
  10462. private constructor();
  10463. /**
  10464. * Creates a new Stage.
  10465. * @returns A new instance of a Stage
  10466. */
  10467. static Create<T extends Function>(): Stage<T>;
  10468. /**
  10469. * Registers a step in an ordered way in the targeted stage.
  10470. * @param index Defines the position to register the step in
  10471. * @param component Defines the component attached to the step
  10472. * @param action Defines the action to launch during the step
  10473. */
  10474. registerStep(index: number, component: ISceneComponent, action: T): void;
  10475. /**
  10476. * Clears all the steps from the stage.
  10477. */
  10478. clear(): void;
  10479. }
  10480. }
  10481. declare module BABYLON {
  10482. /**
  10483. * Class used to represent a specific level of detail of a mesh
  10484. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10485. */
  10486. export class MeshLODLevel {
  10487. /** Defines the distance where this level should star being displayed */
  10488. distance: number;
  10489. /** Defines the mesh to use to render this level */
  10490. mesh: Nullable<Mesh>;
  10491. /**
  10492. * Creates a new LOD level
  10493. * @param distance defines the distance where this level should star being displayed
  10494. * @param mesh defines the mesh to use to render this level
  10495. */
  10496. constructor(
  10497. /** Defines the distance where this level should star being displayed */
  10498. distance: number,
  10499. /** Defines the mesh to use to render this level */
  10500. mesh: Nullable<Mesh>);
  10501. }
  10502. }
  10503. declare module BABYLON {
  10504. /**
  10505. * Interface describing all the common properties and methods a shadow light needs to implement.
  10506. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10507. * as well as binding the different shadow properties to the effects.
  10508. */
  10509. export interface IShadowLight extends Light {
  10510. /**
  10511. * The light id in the scene (used in scene.findLighById for instance)
  10512. */
  10513. id: string;
  10514. /**
  10515. * The position the shdow will be casted from.
  10516. */
  10517. position: Vector3;
  10518. /**
  10519. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10520. */
  10521. direction: Vector3;
  10522. /**
  10523. * The transformed position. Position of the light in world space taking parenting in account.
  10524. */
  10525. transformedPosition: Vector3;
  10526. /**
  10527. * The transformed direction. Direction of the light in world space taking parenting in account.
  10528. */
  10529. transformedDirection: Vector3;
  10530. /**
  10531. * The friendly name of the light in the scene.
  10532. */
  10533. name: string;
  10534. /**
  10535. * Defines the shadow projection clipping minimum z value.
  10536. */
  10537. shadowMinZ: number;
  10538. /**
  10539. * Defines the shadow projection clipping maximum z value.
  10540. */
  10541. shadowMaxZ: number;
  10542. /**
  10543. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10544. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10545. */
  10546. computeTransformedInformation(): boolean;
  10547. /**
  10548. * Gets the scene the light belongs to.
  10549. * @returns The scene
  10550. */
  10551. getScene(): Scene;
  10552. /**
  10553. * Callback defining a custom Projection Matrix Builder.
  10554. * This can be used to override the default projection matrix computation.
  10555. */
  10556. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10557. /**
  10558. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10559. * @param matrix The materix to updated with the projection information
  10560. * @param viewMatrix The transform matrix of the light
  10561. * @param renderList The list of mesh to render in the map
  10562. * @returns The current light
  10563. */
  10564. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10565. /**
  10566. * Gets the current depth scale used in ESM.
  10567. * @returns The scale
  10568. */
  10569. getDepthScale(): number;
  10570. /**
  10571. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10572. * @returns true if a cube texture needs to be use
  10573. */
  10574. needCube(): boolean;
  10575. /**
  10576. * Detects if the projection matrix requires to be recomputed this frame.
  10577. * @returns true if it requires to be recomputed otherwise, false.
  10578. */
  10579. needProjectionMatrixCompute(): boolean;
  10580. /**
  10581. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10582. */
  10583. forceProjectionMatrixCompute(): void;
  10584. /**
  10585. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10586. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10587. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10588. */
  10589. getShadowDirection(faceIndex?: number): Vector3;
  10590. /**
  10591. * Gets the minZ used for shadow according to both the scene and the light.
  10592. * @param activeCamera The camera we are returning the min for
  10593. * @returns the depth min z
  10594. */
  10595. getDepthMinZ(activeCamera: Camera): number;
  10596. /**
  10597. * Gets the maxZ used for shadow according to both the scene and the light.
  10598. * @param activeCamera The camera we are returning the max for
  10599. * @returns the depth max z
  10600. */
  10601. getDepthMaxZ(activeCamera: Camera): number;
  10602. }
  10603. /**
  10604. * Base implementation IShadowLight
  10605. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10606. */
  10607. export abstract class ShadowLight extends Light implements IShadowLight {
  10608. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10609. protected _position: Vector3;
  10610. protected _setPosition(value: Vector3): void;
  10611. /**
  10612. * Sets the position the shadow will be casted from. Also use as the light position for both
  10613. * point and spot lights.
  10614. */
  10615. /**
  10616. * Sets the position the shadow will be casted from. Also use as the light position for both
  10617. * point and spot lights.
  10618. */
  10619. position: Vector3;
  10620. protected _direction: Vector3;
  10621. protected _setDirection(value: Vector3): void;
  10622. /**
  10623. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10624. * Also use as the light direction on spot and directional lights.
  10625. */
  10626. /**
  10627. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10628. * Also use as the light direction on spot and directional lights.
  10629. */
  10630. direction: Vector3;
  10631. private _shadowMinZ;
  10632. /**
  10633. * Gets the shadow projection clipping minimum z value.
  10634. */
  10635. /**
  10636. * Sets the shadow projection clipping minimum z value.
  10637. */
  10638. shadowMinZ: number;
  10639. private _shadowMaxZ;
  10640. /**
  10641. * Sets the shadow projection clipping maximum z value.
  10642. */
  10643. /**
  10644. * Gets the shadow projection clipping maximum z value.
  10645. */
  10646. shadowMaxZ: number;
  10647. /**
  10648. * Callback defining a custom Projection Matrix Builder.
  10649. * This can be used to override the default projection matrix computation.
  10650. */
  10651. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10652. /**
  10653. * The transformed position. Position of the light in world space taking parenting in account.
  10654. */
  10655. transformedPosition: Vector3;
  10656. /**
  10657. * The transformed direction. Direction of the light in world space taking parenting in account.
  10658. */
  10659. transformedDirection: Vector3;
  10660. private _needProjectionMatrixCompute;
  10661. /**
  10662. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10663. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10664. */
  10665. computeTransformedInformation(): boolean;
  10666. /**
  10667. * Return the depth scale used for the shadow map.
  10668. * @returns the depth scale.
  10669. */
  10670. getDepthScale(): number;
  10671. /**
  10672. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10673. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10674. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10675. */
  10676. getShadowDirection(faceIndex?: number): Vector3;
  10677. /**
  10678. * Returns the ShadowLight absolute position in the World.
  10679. * @returns the position vector in world space
  10680. */
  10681. getAbsolutePosition(): Vector3;
  10682. /**
  10683. * Sets the ShadowLight direction toward the passed target.
  10684. * @param target The point to target in local space
  10685. * @returns the updated ShadowLight direction
  10686. */
  10687. setDirectionToTarget(target: Vector3): Vector3;
  10688. /**
  10689. * Returns the light rotation in euler definition.
  10690. * @returns the x y z rotation in local space.
  10691. */
  10692. getRotation(): Vector3;
  10693. /**
  10694. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10695. * @returns true if a cube texture needs to be use
  10696. */
  10697. needCube(): boolean;
  10698. /**
  10699. * Detects if the projection matrix requires to be recomputed this frame.
  10700. * @returns true if it requires to be recomputed otherwise, false.
  10701. */
  10702. needProjectionMatrixCompute(): boolean;
  10703. /**
  10704. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10705. */
  10706. forceProjectionMatrixCompute(): void;
  10707. /** @hidden */ private _initCache(): void;
  10708. /** @hidden */ private _isSynchronized(): boolean;
  10709. /**
  10710. * Computes the world matrix of the node
  10711. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10712. * @returns the world matrix
  10713. */
  10714. computeWorldMatrix(force?: boolean): Matrix;
  10715. /**
  10716. * Gets the minZ used for shadow according to both the scene and the light.
  10717. * @param activeCamera The camera we are returning the min for
  10718. * @returns the depth min z
  10719. */
  10720. getDepthMinZ(activeCamera: Camera): number;
  10721. /**
  10722. * Gets the maxZ used for shadow according to both the scene and the light.
  10723. * @param activeCamera The camera we are returning the max for
  10724. * @returns the depth max z
  10725. */
  10726. getDepthMaxZ(activeCamera: Camera): number;
  10727. /**
  10728. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10729. * @param matrix The materix to updated with the projection information
  10730. * @param viewMatrix The transform matrix of the light
  10731. * @param renderList The list of mesh to render in the map
  10732. * @returns The current light
  10733. */
  10734. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10735. }
  10736. }
  10737. declare module BABYLON {
  10738. /**
  10739. * "Static Class" containing the most commonly used helper while dealing with material for
  10740. * rendering purpose.
  10741. *
  10742. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10743. *
  10744. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10745. */
  10746. export class MaterialHelper {
  10747. /**
  10748. * Bind the current view position to an effect.
  10749. * @param effect The effect to be bound
  10750. * @param scene The scene the eyes position is used from
  10751. */
  10752. static BindEyePosition(effect: Effect, scene: Scene): void;
  10753. /**
  10754. * Helps preparing the defines values about the UVs in used in the effect.
  10755. * UVs are shared as much as we can accross channels in the shaders.
  10756. * @param texture The texture we are preparing the UVs for
  10757. * @param defines The defines to update
  10758. * @param key The channel key "diffuse", "specular"... used in the shader
  10759. */
  10760. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10761. /**
  10762. * Binds a texture matrix value to its corrsponding uniform
  10763. * @param texture The texture to bind the matrix for
  10764. * @param uniformBuffer The uniform buffer receivin the data
  10765. * @param key The channel key "diffuse", "specular"... used in the shader
  10766. */
  10767. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10768. /**
  10769. * Gets the current status of the fog (should it be enabled?)
  10770. * @param mesh defines the mesh to evaluate for fog support
  10771. * @param scene defines the hosting scene
  10772. * @returns true if fog must be enabled
  10773. */
  10774. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10775. /**
  10776. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10777. * @param mesh defines the current mesh
  10778. * @param scene defines the current scene
  10779. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10780. * @param pointsCloud defines if point cloud rendering has to be turned on
  10781. * @param fogEnabled defines if fog has to be turned on
  10782. * @param alphaTest defines if alpha testing has to be turned on
  10783. * @param defines defines the current list of defines
  10784. */
  10785. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10786. /**
  10787. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10788. * @param scene defines the current scene
  10789. * @param engine defines the current engine
  10790. * @param defines specifies the list of active defines
  10791. * @param useInstances defines if instances have to be turned on
  10792. * @param useClipPlane defines if clip plane have to be turned on
  10793. */
  10794. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10795. /**
  10796. * Prepares the defines for bones
  10797. * @param mesh The mesh containing the geometry data we will draw
  10798. * @param defines The defines to update
  10799. */
  10800. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10801. /**
  10802. * Prepares the defines for morph targets
  10803. * @param mesh The mesh containing the geometry data we will draw
  10804. * @param defines The defines to update
  10805. */
  10806. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10807. /**
  10808. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10809. * @param mesh The mesh containing the geometry data we will draw
  10810. * @param defines The defines to update
  10811. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10812. * @param useBones Precise whether bones should be used or not (override mesh info)
  10813. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10814. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10815. * @returns false if defines are considered not dirty and have not been checked
  10816. */
  10817. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10818. /**
  10819. * Prepares the defines related to multiview
  10820. * @param scene The scene we are intending to draw
  10821. * @param defines The defines to update
  10822. */
  10823. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10824. /**
  10825. * Prepares the defines related to the light information passed in parameter
  10826. * @param scene The scene we are intending to draw
  10827. * @param mesh The mesh the effect is compiling for
  10828. * @param light The light the effect is compiling for
  10829. * @param lightIndex The index of the light
  10830. * @param defines The defines to update
  10831. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10832. * @param state Defines the current state regarding what is needed (normals, etc...)
  10833. */
  10834. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10835. needNormals: boolean;
  10836. needRebuild: boolean;
  10837. shadowEnabled: boolean;
  10838. specularEnabled: boolean;
  10839. lightmapMode: boolean;
  10840. }): void;
  10841. /**
  10842. * Prepares the defines related to the light information passed in parameter
  10843. * @param scene The scene we are intending to draw
  10844. * @param mesh The mesh the effect is compiling for
  10845. * @param defines The defines to update
  10846. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10847. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10848. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10849. * @returns true if normals will be required for the rest of the effect
  10850. */
  10851. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10852. /**
  10853. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10854. * @param lightIndex defines the light index
  10855. * @param uniformsList The uniform list
  10856. * @param samplersList The sampler list
  10857. * @param projectedLightTexture defines if projected texture must be used
  10858. * @param uniformBuffersList defines an optional list of uniform buffers
  10859. */
  10860. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  10861. /**
  10862. * Prepares the uniforms and samplers list to be used in the effect
  10863. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10864. * @param samplersList The sampler list
  10865. * @param defines The defines helping in the list generation
  10866. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10867. */
  10868. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10869. /**
  10870. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10871. * @param defines The defines to update while falling back
  10872. * @param fallbacks The authorized effect fallbacks
  10873. * @param maxSimultaneousLights The maximum number of lights allowed
  10874. * @param rank the current rank of the Effect
  10875. * @returns The newly affected rank
  10876. */
  10877. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10878. private static _TmpMorphInfluencers;
  10879. /**
  10880. * Prepares the list of attributes required for morph targets according to the effect defines.
  10881. * @param attribs The current list of supported attribs
  10882. * @param mesh The mesh to prepare the morph targets attributes for
  10883. * @param influencers The number of influencers
  10884. */
  10885. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  10886. /**
  10887. * Prepares the list of attributes required for morph targets according to the effect defines.
  10888. * @param attribs The current list of supported attribs
  10889. * @param mesh The mesh to prepare the morph targets attributes for
  10890. * @param defines The current Defines of the effect
  10891. */
  10892. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10893. /**
  10894. * Prepares the list of attributes required for bones according to the effect defines.
  10895. * @param attribs The current list of supported attribs
  10896. * @param mesh The mesh to prepare the bones attributes for
  10897. * @param defines The current Defines of the effect
  10898. * @param fallbacks The current efffect fallback strategy
  10899. */
  10900. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10901. /**
  10902. * Check and prepare the list of attributes required for instances according to the effect defines.
  10903. * @param attribs The current list of supported attribs
  10904. * @param defines The current MaterialDefines of the effect
  10905. */
  10906. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  10907. /**
  10908. * Add the list of attributes required for instances to the attribs array.
  10909. * @param attribs The current list of supported attribs
  10910. */
  10911. static PushAttributesForInstances(attribs: string[]): void;
  10912. /**
  10913. * Binds the light shadow information to the effect for the given mesh.
  10914. * @param light The light containing the generator
  10915. * @param scene The scene the lights belongs to
  10916. * @param mesh The mesh we are binding the information to render
  10917. * @param lightIndex The light index in the effect used to render the mesh
  10918. * @param effect The effect we are binding the data to
  10919. */
  10920. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10921. /**
  10922. * Binds the light information to the effect.
  10923. * @param light The light containing the generator
  10924. * @param effect The effect we are binding the data to
  10925. * @param lightIndex The light index in the effect used to render
  10926. */
  10927. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10928. /**
  10929. * Binds the lights information from the scene to the effect for the given mesh.
  10930. * @param light Light to bind
  10931. * @param lightIndex Light index
  10932. * @param scene The scene where the light belongs to
  10933. * @param mesh The mesh we are binding the information to render
  10934. * @param effect The effect we are binding the data to
  10935. * @param useSpecular Defines if specular is supported
  10936. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10937. */
  10938. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  10939. /**
  10940. * Binds the lights information from the scene to the effect for the given mesh.
  10941. * @param scene The scene the lights belongs to
  10942. * @param mesh The mesh we are binding the information to render
  10943. * @param effect The effect we are binding the data to
  10944. * @param defines The generated defines for the effect
  10945. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10946. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10947. */
  10948. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10949. private static _tempFogColor;
  10950. /**
  10951. * Binds the fog information from the scene to the effect for the given mesh.
  10952. * @param scene The scene the lights belongs to
  10953. * @param mesh The mesh we are binding the information to render
  10954. * @param effect The effect we are binding the data to
  10955. * @param linearSpace Defines if the fog effect is applied in linear space
  10956. */
  10957. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10958. /**
  10959. * Binds the bones information from the mesh to the effect.
  10960. * @param mesh The mesh we are binding the information to render
  10961. * @param effect The effect we are binding the data to
  10962. */
  10963. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10964. /**
  10965. * Binds the morph targets information from the mesh to the effect.
  10966. * @param abstractMesh The mesh we are binding the information to render
  10967. * @param effect The effect we are binding the data to
  10968. */
  10969. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10970. /**
  10971. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10972. * @param defines The generated defines used in the effect
  10973. * @param effect The effect we are binding the data to
  10974. * @param scene The scene we are willing to render with logarithmic scale for
  10975. */
  10976. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10977. /**
  10978. * Binds the clip plane information from the scene to the effect.
  10979. * @param scene The scene the clip plane information are extracted from
  10980. * @param effect The effect we are binding the data to
  10981. */
  10982. static BindClipPlane(effect: Effect, scene: Scene): void;
  10983. }
  10984. }
  10985. declare module BABYLON {
  10986. /** @hidden */
  10987. export var shadowMapPixelShader: {
  10988. name: string;
  10989. shader: string;
  10990. };
  10991. }
  10992. declare module BABYLON {
  10993. /** @hidden */
  10994. export var bonesDeclaration: {
  10995. name: string;
  10996. shader: string;
  10997. };
  10998. }
  10999. declare module BABYLON {
  11000. /** @hidden */
  11001. export var morphTargetsVertexGlobalDeclaration: {
  11002. name: string;
  11003. shader: string;
  11004. };
  11005. }
  11006. declare module BABYLON {
  11007. /** @hidden */
  11008. export var morphTargetsVertexDeclaration: {
  11009. name: string;
  11010. shader: string;
  11011. };
  11012. }
  11013. declare module BABYLON {
  11014. /** @hidden */
  11015. export var instancesDeclaration: {
  11016. name: string;
  11017. shader: string;
  11018. };
  11019. }
  11020. declare module BABYLON {
  11021. /** @hidden */
  11022. export var helperFunctions: {
  11023. name: string;
  11024. shader: string;
  11025. };
  11026. }
  11027. declare module BABYLON {
  11028. /** @hidden */
  11029. export var morphTargetsVertex: {
  11030. name: string;
  11031. shader: string;
  11032. };
  11033. }
  11034. declare module BABYLON {
  11035. /** @hidden */
  11036. export var instancesVertex: {
  11037. name: string;
  11038. shader: string;
  11039. };
  11040. }
  11041. declare module BABYLON {
  11042. /** @hidden */
  11043. export var bonesVertex: {
  11044. name: string;
  11045. shader: string;
  11046. };
  11047. }
  11048. declare module BABYLON {
  11049. /** @hidden */
  11050. export var shadowMapVertexShader: {
  11051. name: string;
  11052. shader: string;
  11053. };
  11054. }
  11055. declare module BABYLON {
  11056. /** @hidden */
  11057. export var depthBoxBlurPixelShader: {
  11058. name: string;
  11059. shader: string;
  11060. };
  11061. }
  11062. declare module BABYLON {
  11063. /**
  11064. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11065. */
  11066. export interface ICustomShaderOptions {
  11067. /**
  11068. * Gets or sets the custom shader name to use
  11069. */
  11070. shaderName: string;
  11071. /**
  11072. * The list of attribute names used in the shader
  11073. */
  11074. attributes?: string[];
  11075. /**
  11076. * The list of unifrom names used in the shader
  11077. */
  11078. uniforms?: string[];
  11079. /**
  11080. * The list of sampler names used in the shader
  11081. */
  11082. samplers?: string[];
  11083. /**
  11084. * The list of defines used in the shader
  11085. */
  11086. defines?: string[];
  11087. }
  11088. /**
  11089. * Interface to implement to create a shadow generator compatible with BJS.
  11090. */
  11091. export interface IShadowGenerator {
  11092. /**
  11093. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11094. * @returns The render target texture if present otherwise, null
  11095. */
  11096. getShadowMap(): Nullable<RenderTargetTexture>;
  11097. /**
  11098. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11099. * @returns The render target texture if the shadow map is present otherwise, null
  11100. */
  11101. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11102. /**
  11103. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11104. * @param subMesh The submesh we want to render in the shadow map
  11105. * @param useInstances Defines wether will draw in the map using instances
  11106. * @returns true if ready otherwise, false
  11107. */
  11108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11109. /**
  11110. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11111. * @param defines Defines of the material we want to update
  11112. * @param lightIndex Index of the light in the enabled light list of the material
  11113. */
  11114. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11115. /**
  11116. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11117. * defined in the generator but impacting the effect).
  11118. * It implies the unifroms available on the materials are the standard BJS ones.
  11119. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11120. * @param effect The effect we are binfing the information for
  11121. */
  11122. bindShadowLight(lightIndex: string, effect: Effect): void;
  11123. /**
  11124. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11125. * (eq to shadow prjection matrix * light transform matrix)
  11126. * @returns The transform matrix used to create the shadow map
  11127. */
  11128. getTransformMatrix(): Matrix;
  11129. /**
  11130. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11131. * Cube and 2D textures for instance.
  11132. */
  11133. recreateShadowMap(): void;
  11134. /**
  11135. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11136. * @param onCompiled Callback triggered at the and of the effects compilation
  11137. * @param options Sets of optional options forcing the compilation with different modes
  11138. */
  11139. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11140. useInstances: boolean;
  11141. }>): void;
  11142. /**
  11143. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11144. * @param options Sets of optional options forcing the compilation with different modes
  11145. * @returns A promise that resolves when the compilation completes
  11146. */
  11147. forceCompilationAsync(options?: Partial<{
  11148. useInstances: boolean;
  11149. }>): Promise<void>;
  11150. /**
  11151. * Serializes the shadow generator setup to a json object.
  11152. * @returns The serialized JSON object
  11153. */
  11154. serialize(): any;
  11155. /**
  11156. * Disposes the Shadow map and related Textures and effects.
  11157. */
  11158. dispose(): void;
  11159. }
  11160. /**
  11161. * Default implementation IShadowGenerator.
  11162. * This is the main object responsible of generating shadows in the framework.
  11163. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11164. */
  11165. export class ShadowGenerator implements IShadowGenerator {
  11166. /**
  11167. * Shadow generator mode None: no filtering applied.
  11168. */
  11169. static readonly FILTER_NONE: number;
  11170. /**
  11171. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11172. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11173. */
  11174. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11175. /**
  11176. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11177. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11178. */
  11179. static readonly FILTER_POISSONSAMPLING: number;
  11180. /**
  11181. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11182. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11183. */
  11184. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11185. /**
  11186. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11187. * edge artifacts on steep falloff.
  11188. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11189. */
  11190. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11191. /**
  11192. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11193. * edge artifacts on steep falloff.
  11194. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11195. */
  11196. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11197. /**
  11198. * Shadow generator mode PCF: Percentage Closer Filtering
  11199. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11200. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11201. */
  11202. static readonly FILTER_PCF: number;
  11203. /**
  11204. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11205. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11206. * Contact Hardening
  11207. */
  11208. static readonly FILTER_PCSS: number;
  11209. /**
  11210. * Reserved for PCF and PCSS
  11211. * Highest Quality.
  11212. *
  11213. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11214. *
  11215. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11216. */
  11217. static readonly QUALITY_HIGH: number;
  11218. /**
  11219. * Reserved for PCF and PCSS
  11220. * Good tradeoff for quality/perf cross devices
  11221. *
  11222. * Execute PCF on a 3*3 kernel.
  11223. *
  11224. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11225. */
  11226. static readonly QUALITY_MEDIUM: number;
  11227. /**
  11228. * Reserved for PCF and PCSS
  11229. * The lowest quality but the fastest.
  11230. *
  11231. * Execute PCF on a 1*1 kernel.
  11232. *
  11233. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11234. */
  11235. static readonly QUALITY_LOW: number;
  11236. /** Gets or sets the custom shader name to use */
  11237. customShaderOptions: ICustomShaderOptions;
  11238. /**
  11239. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11240. */
  11241. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11242. /**
  11243. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11244. */
  11245. onAfterShadowMapRenderObservable: Observable<Effect>;
  11246. /**
  11247. * Observable triggered before a mesh is rendered in the shadow map.
  11248. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11249. */
  11250. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11251. /**
  11252. * Observable triggered after a mesh is rendered in the shadow map.
  11253. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11254. */
  11255. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11256. private _bias;
  11257. /**
  11258. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11259. */
  11260. /**
  11261. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11262. */
  11263. bias: number;
  11264. private _normalBias;
  11265. /**
  11266. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11267. */
  11268. /**
  11269. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11270. */
  11271. normalBias: number;
  11272. private _blurBoxOffset;
  11273. /**
  11274. * Gets the blur box offset: offset applied during the blur pass.
  11275. * Only useful if useKernelBlur = false
  11276. */
  11277. /**
  11278. * Sets the blur box offset: offset applied during the blur pass.
  11279. * Only useful if useKernelBlur = false
  11280. */
  11281. blurBoxOffset: number;
  11282. private _blurScale;
  11283. /**
  11284. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11285. * 2 means half of the size.
  11286. */
  11287. /**
  11288. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11289. * 2 means half of the size.
  11290. */
  11291. blurScale: number;
  11292. private _blurKernel;
  11293. /**
  11294. * Gets the blur kernel: kernel size of the blur pass.
  11295. * Only useful if useKernelBlur = true
  11296. */
  11297. /**
  11298. * Sets the blur kernel: kernel size of the blur pass.
  11299. * Only useful if useKernelBlur = true
  11300. */
  11301. blurKernel: number;
  11302. private _useKernelBlur;
  11303. /**
  11304. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11305. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11306. */
  11307. /**
  11308. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11309. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11310. */
  11311. useKernelBlur: boolean;
  11312. private _depthScale;
  11313. /**
  11314. * Gets the depth scale used in ESM mode.
  11315. */
  11316. /**
  11317. * Sets the depth scale used in ESM mode.
  11318. * This can override the scale stored on the light.
  11319. */
  11320. depthScale: number;
  11321. private _filter;
  11322. /**
  11323. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11324. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11325. */
  11326. /**
  11327. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11328. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11329. */
  11330. filter: number;
  11331. /**
  11332. * Gets if the current filter is set to Poisson Sampling.
  11333. */
  11334. /**
  11335. * Sets the current filter to Poisson Sampling.
  11336. */
  11337. usePoissonSampling: boolean;
  11338. /**
  11339. * Gets if the current filter is set to ESM.
  11340. */
  11341. /**
  11342. * Sets the current filter is to ESM.
  11343. */
  11344. useExponentialShadowMap: boolean;
  11345. /**
  11346. * Gets if the current filter is set to filtered ESM.
  11347. */
  11348. /**
  11349. * Gets if the current filter is set to filtered ESM.
  11350. */
  11351. useBlurExponentialShadowMap: boolean;
  11352. /**
  11353. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11354. * exponential to prevent steep falloff artifacts).
  11355. */
  11356. /**
  11357. * Sets the current filter to "close ESM" (using the inverse of the
  11358. * exponential to prevent steep falloff artifacts).
  11359. */
  11360. useCloseExponentialShadowMap: boolean;
  11361. /**
  11362. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11363. * exponential to prevent steep falloff artifacts).
  11364. */
  11365. /**
  11366. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11367. * exponential to prevent steep falloff artifacts).
  11368. */
  11369. useBlurCloseExponentialShadowMap: boolean;
  11370. /**
  11371. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11372. */
  11373. /**
  11374. * Sets the current filter to "PCF" (percentage closer filtering).
  11375. */
  11376. usePercentageCloserFiltering: boolean;
  11377. private _filteringQuality;
  11378. /**
  11379. * Gets the PCF or PCSS Quality.
  11380. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11381. */
  11382. /**
  11383. * Sets the PCF or PCSS Quality.
  11384. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11385. */
  11386. filteringQuality: number;
  11387. /**
  11388. * Gets if the current filter is set to "PCSS" (contact hardening).
  11389. */
  11390. /**
  11391. * Sets the current filter to "PCSS" (contact hardening).
  11392. */
  11393. useContactHardeningShadow: boolean;
  11394. private _contactHardeningLightSizeUVRatio;
  11395. /**
  11396. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11397. * Using a ratio helps keeping shape stability independently of the map size.
  11398. *
  11399. * It does not account for the light projection as it was having too much
  11400. * instability during the light setup or during light position changes.
  11401. *
  11402. * Only valid if useContactHardeningShadow is true.
  11403. */
  11404. /**
  11405. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11406. * Using a ratio helps keeping shape stability independently of the map size.
  11407. *
  11408. * It does not account for the light projection as it was having too much
  11409. * instability during the light setup or during light position changes.
  11410. *
  11411. * Only valid if useContactHardeningShadow is true.
  11412. */
  11413. contactHardeningLightSizeUVRatio: number;
  11414. private _darkness;
  11415. /** Gets or sets the actual darkness of a shadow */
  11416. darkness: number;
  11417. /**
  11418. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11419. * 0 means strongest and 1 would means no shadow.
  11420. * @returns the darkness.
  11421. */
  11422. getDarkness(): number;
  11423. /**
  11424. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11425. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11426. * @returns the shadow generator allowing fluent coding.
  11427. */
  11428. setDarkness(darkness: number): ShadowGenerator;
  11429. private _transparencyShadow;
  11430. /** Gets or sets the ability to have transparent shadow */
  11431. transparencyShadow: boolean;
  11432. /**
  11433. * Sets the ability to have transparent shadow (boolean).
  11434. * @param transparent True if transparent else False
  11435. * @returns the shadow generator allowing fluent coding
  11436. */
  11437. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11438. private _shadowMap;
  11439. private _shadowMap2;
  11440. /**
  11441. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11442. * @returns The render target texture if present otherwise, null
  11443. */
  11444. getShadowMap(): Nullable<RenderTargetTexture>;
  11445. /**
  11446. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11447. * @returns The render target texture if the shadow map is present otherwise, null
  11448. */
  11449. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11450. /**
  11451. * Gets the class name of that object
  11452. * @returns "ShadowGenerator"
  11453. */
  11454. getClassName(): string;
  11455. /**
  11456. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11457. * @param mesh Mesh to add
  11458. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11459. * @returns the Shadow Generator itself
  11460. */
  11461. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11462. /**
  11463. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11464. * @param mesh Mesh to remove
  11465. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11466. * @returns the Shadow Generator itself
  11467. */
  11468. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11469. /**
  11470. * Controls the extent to which the shadows fade out at the edge of the frustum
  11471. * Used only by directionals and spots
  11472. */
  11473. frustumEdgeFalloff: number;
  11474. private _light;
  11475. /**
  11476. * Returns the associated light object.
  11477. * @returns the light generating the shadow
  11478. */
  11479. getLight(): IShadowLight;
  11480. /**
  11481. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11482. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11483. * It might on the other hand introduce peter panning.
  11484. */
  11485. forceBackFacesOnly: boolean;
  11486. private _scene;
  11487. private _lightDirection;
  11488. private _effect;
  11489. private _viewMatrix;
  11490. private _projectionMatrix;
  11491. private _transformMatrix;
  11492. private _cachedPosition;
  11493. private _cachedDirection;
  11494. private _cachedDefines;
  11495. private _currentRenderID;
  11496. private _boxBlurPostprocess;
  11497. private _kernelBlurXPostprocess;
  11498. private _kernelBlurYPostprocess;
  11499. private _blurPostProcesses;
  11500. private _mapSize;
  11501. private _currentFaceIndex;
  11502. private _currentFaceIndexCache;
  11503. private _textureType;
  11504. private _defaultTextureMatrix;
  11505. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  11506. /**
  11507. * Creates a ShadowGenerator object.
  11508. * A ShadowGenerator is the required tool to use the shadows.
  11509. * Each light casting shadows needs to use its own ShadowGenerator.
  11510. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11511. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11512. * @param light The light object generating the shadows.
  11513. * @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.
  11514. */
  11515. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11516. private _initializeGenerator;
  11517. private _initializeShadowMap;
  11518. private _initializeBlurRTTAndPostProcesses;
  11519. private _renderForShadowMap;
  11520. private _renderSubMeshForShadowMap;
  11521. private _applyFilterValues;
  11522. /**
  11523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11524. * @param onCompiled Callback triggered at the and of the effects compilation
  11525. * @param options Sets of optional options forcing the compilation with different modes
  11526. */
  11527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11528. useInstances: boolean;
  11529. }>): void;
  11530. /**
  11531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11532. * @param options Sets of optional options forcing the compilation with different modes
  11533. * @returns A promise that resolves when the compilation completes
  11534. */
  11535. forceCompilationAsync(options?: Partial<{
  11536. useInstances: boolean;
  11537. }>): Promise<void>;
  11538. /**
  11539. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11540. * @param subMesh The submesh we want to render in the shadow map
  11541. * @param useInstances Defines wether will draw in the map using instances
  11542. * @returns true if ready otherwise, false
  11543. */
  11544. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11545. /**
  11546. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11547. * @param defines Defines of the material we want to update
  11548. * @param lightIndex Index of the light in the enabled light list of the material
  11549. */
  11550. prepareDefines(defines: any, lightIndex: number): void;
  11551. /**
  11552. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11553. * defined in the generator but impacting the effect).
  11554. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11555. * @param effect The effect we are binfing the information for
  11556. */
  11557. bindShadowLight(lightIndex: string, effect: Effect): void;
  11558. /**
  11559. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11560. * (eq to shadow prjection matrix * light transform matrix)
  11561. * @returns The transform matrix used to create the shadow map
  11562. */
  11563. getTransformMatrix(): Matrix;
  11564. /**
  11565. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11566. * Cube and 2D textures for instance.
  11567. */
  11568. recreateShadowMap(): void;
  11569. private _disposeBlurPostProcesses;
  11570. private _disposeRTTandPostProcesses;
  11571. /**
  11572. * Disposes the ShadowGenerator.
  11573. * Returns nothing.
  11574. */
  11575. dispose(): void;
  11576. /**
  11577. * Serializes the shadow generator setup to a json object.
  11578. * @returns The serialized JSON object
  11579. */
  11580. serialize(): any;
  11581. /**
  11582. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11583. * @param parsedShadowGenerator The JSON object to parse
  11584. * @param scene The scene to create the shadow map for
  11585. * @returns The parsed shadow generator
  11586. */
  11587. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11588. }
  11589. }
  11590. declare module BABYLON {
  11591. /**
  11592. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11593. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11594. * 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.
  11595. */
  11596. export abstract class Light extends Node {
  11597. /**
  11598. * Falloff Default: light is falling off following the material specification:
  11599. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11600. */
  11601. static readonly FALLOFF_DEFAULT: number;
  11602. /**
  11603. * Falloff Physical: light is falling off following the inverse squared distance law.
  11604. */
  11605. static readonly FALLOFF_PHYSICAL: number;
  11606. /**
  11607. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11608. * to enhance interoperability with other engines.
  11609. */
  11610. static readonly FALLOFF_GLTF: number;
  11611. /**
  11612. * Falloff Standard: light is falling off like in the standard material
  11613. * to enhance interoperability with other materials.
  11614. */
  11615. static readonly FALLOFF_STANDARD: number;
  11616. /**
  11617. * If every light affecting the material is in this lightmapMode,
  11618. * material.lightmapTexture adds or multiplies
  11619. * (depends on material.useLightmapAsShadowmap)
  11620. * after every other light calculations.
  11621. */
  11622. static readonly LIGHTMAP_DEFAULT: number;
  11623. /**
  11624. * material.lightmapTexture as only diffuse lighting from this light
  11625. * adds only specular lighting from this light
  11626. * adds dynamic shadows
  11627. */
  11628. static readonly LIGHTMAP_SPECULAR: number;
  11629. /**
  11630. * material.lightmapTexture as only lighting
  11631. * no light calculation from this light
  11632. * only adds dynamic shadows from this light
  11633. */
  11634. static readonly LIGHTMAP_SHADOWSONLY: number;
  11635. /**
  11636. * Each light type uses the default quantity according to its type:
  11637. * point/spot lights use luminous intensity
  11638. * directional lights use illuminance
  11639. */
  11640. static readonly INTENSITYMODE_AUTOMATIC: number;
  11641. /**
  11642. * lumen (lm)
  11643. */
  11644. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11645. /**
  11646. * candela (lm/sr)
  11647. */
  11648. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11649. /**
  11650. * lux (lm/m^2)
  11651. */
  11652. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11653. /**
  11654. * nit (cd/m^2)
  11655. */
  11656. static readonly INTENSITYMODE_LUMINANCE: number;
  11657. /**
  11658. * Light type const id of the point light.
  11659. */
  11660. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11661. /**
  11662. * Light type const id of the directional light.
  11663. */
  11664. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11665. /**
  11666. * Light type const id of the spot light.
  11667. */
  11668. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11669. /**
  11670. * Light type const id of the hemispheric light.
  11671. */
  11672. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11673. /**
  11674. * Diffuse gives the basic color to an object.
  11675. */
  11676. diffuse: Color3;
  11677. /**
  11678. * Specular produces a highlight color on an object.
  11679. * Note: This is note affecting PBR materials.
  11680. */
  11681. specular: Color3;
  11682. /**
  11683. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11684. * falling off base on range or angle.
  11685. * This can be set to any values in Light.FALLOFF_x.
  11686. *
  11687. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11688. * other types of materials.
  11689. */
  11690. falloffType: number;
  11691. /**
  11692. * Strength of the light.
  11693. * Note: By default it is define in the framework own unit.
  11694. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11695. */
  11696. intensity: number;
  11697. private _range;
  11698. protected _inverseSquaredRange: number;
  11699. /**
  11700. * Defines how far from the source the light is impacting in scene units.
  11701. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11702. */
  11703. /**
  11704. * Defines how far from the source the light is impacting in scene units.
  11705. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11706. */
  11707. range: number;
  11708. /**
  11709. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11710. * of light.
  11711. */
  11712. private _photometricScale;
  11713. private _intensityMode;
  11714. /**
  11715. * Gets the photometric scale used to interpret the intensity.
  11716. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11717. */
  11718. /**
  11719. * Sets the photometric scale used to interpret the intensity.
  11720. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11721. */
  11722. intensityMode: number;
  11723. private _radius;
  11724. /**
  11725. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11726. */
  11727. /**
  11728. * sets the light radius used by PBR Materials to simulate soft area lights.
  11729. */
  11730. radius: number;
  11731. private _renderPriority;
  11732. /**
  11733. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11734. * exceeding the number allowed of the materials.
  11735. */
  11736. renderPriority: number;
  11737. private _shadowEnabled;
  11738. /**
  11739. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11740. * the current shadow generator.
  11741. */
  11742. /**
  11743. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11744. * the current shadow generator.
  11745. */
  11746. shadowEnabled: boolean;
  11747. private _includedOnlyMeshes;
  11748. /**
  11749. * Gets the only meshes impacted by this light.
  11750. */
  11751. /**
  11752. * Sets the only meshes impacted by this light.
  11753. */
  11754. includedOnlyMeshes: AbstractMesh[];
  11755. private _excludedMeshes;
  11756. /**
  11757. * Gets the meshes not impacted by this light.
  11758. */
  11759. /**
  11760. * Sets the meshes not impacted by this light.
  11761. */
  11762. excludedMeshes: AbstractMesh[];
  11763. private _excludeWithLayerMask;
  11764. /**
  11765. * Gets the layer id use to find what meshes are not impacted by the light.
  11766. * Inactive if 0
  11767. */
  11768. /**
  11769. * Sets the layer id use to find what meshes are not impacted by the light.
  11770. * Inactive if 0
  11771. */
  11772. excludeWithLayerMask: number;
  11773. private _includeOnlyWithLayerMask;
  11774. /**
  11775. * Gets the layer id use to find what meshes are impacted by the light.
  11776. * Inactive if 0
  11777. */
  11778. /**
  11779. * Sets the layer id use to find what meshes are impacted by the light.
  11780. * Inactive if 0
  11781. */
  11782. includeOnlyWithLayerMask: number;
  11783. private _lightmapMode;
  11784. /**
  11785. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11786. */
  11787. /**
  11788. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11789. */
  11790. lightmapMode: number;
  11791. /**
  11792. * Shadow generator associted to the light.
  11793. * @hidden Internal use only.
  11794. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  11795. /**
  11796. * @hidden Internal use only.
  11797. */ private _excludedMeshesIds: string[];
  11798. /**
  11799. * @hidden Internal use only.
  11800. */ private _includedOnlyMeshesIds: string[];
  11801. /**
  11802. * The current light unifom buffer.
  11803. * @hidden Internal use only.
  11804. */ private _uniformBuffer: UniformBuffer;
  11805. /**
  11806. * Creates a Light object in the scene.
  11807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11808. * @param name The firendly name of the light
  11809. * @param scene The scene the light belongs too
  11810. */
  11811. constructor(name: string, scene: Scene);
  11812. protected abstract _buildUniformLayout(): void;
  11813. /**
  11814. * Sets the passed Effect "effect" with the Light information.
  11815. * @param effect The effect to update
  11816. * @param lightIndex The index of the light in the effect to update
  11817. * @returns The light
  11818. */
  11819. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11820. /**
  11821. * Returns the string "Light".
  11822. * @returns the class name
  11823. */
  11824. getClassName(): string;
  11825. /** @hidden */ protected readonly _isLight: boolean;
  11826. /**
  11827. * Converts the light information to a readable string for debug purpose.
  11828. * @param fullDetails Supports for multiple levels of logging within scene loading
  11829. * @returns the human readable light info
  11830. */
  11831. toString(fullDetails?: boolean): string;
  11832. /** @hidden */
  11833. protected _syncParentEnabledState(): void;
  11834. /**
  11835. * Set the enabled state of this node.
  11836. * @param value - the new enabled state
  11837. */
  11838. setEnabled(value: boolean): void;
  11839. /**
  11840. * Returns the Light associated shadow generator if any.
  11841. * @return the associated shadow generator.
  11842. */
  11843. getShadowGenerator(): Nullable<IShadowGenerator>;
  11844. /**
  11845. * Returns a Vector3, the absolute light position in the World.
  11846. * @returns the world space position of the light
  11847. */
  11848. getAbsolutePosition(): Vector3;
  11849. /**
  11850. * Specifies if the light will affect the passed mesh.
  11851. * @param mesh The mesh to test against the light
  11852. * @return true the mesh is affected otherwise, false.
  11853. */
  11854. canAffectMesh(mesh: AbstractMesh): boolean;
  11855. /**
  11856. * Sort function to order lights for rendering.
  11857. * @param a First Light object to compare to second.
  11858. * @param b Second Light object to compare first.
  11859. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11860. */
  11861. static CompareLightsPriority(a: Light, b: Light): number;
  11862. /**
  11863. * Releases resources associated with this node.
  11864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11866. */
  11867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11868. /**
  11869. * Returns the light type ID (integer).
  11870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11871. */
  11872. getTypeID(): number;
  11873. /**
  11874. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11875. * @returns the scaled intensity in intensity mode unit
  11876. */
  11877. getScaledIntensity(): number;
  11878. /**
  11879. * Returns a new Light object, named "name", from the current one.
  11880. * @param name The name of the cloned light
  11881. * @returns the new created light
  11882. */
  11883. clone(name: string): Nullable<Light>;
  11884. /**
  11885. * Serializes the current light into a Serialization object.
  11886. * @returns the serialized object.
  11887. */
  11888. serialize(): any;
  11889. /**
  11890. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11891. * This new light is named "name" and added to the passed scene.
  11892. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11893. * @param name The friendly name of the light
  11894. * @param scene The scene the new light will belong to
  11895. * @returns the constructor function
  11896. */
  11897. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11898. /**
  11899. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11900. * @param parsedLight The JSON representation of the light
  11901. * @param scene The scene to create the parsed light in
  11902. * @returns the created light after parsing
  11903. */
  11904. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11905. private _hookArrayForExcluded;
  11906. private _hookArrayForIncludedOnly;
  11907. private _resyncMeshes;
  11908. /**
  11909. * Forces the meshes to update their light related information in their rendering used effects
  11910. * @hidden Internal Use Only
  11911. */ private _markMeshesAsLightDirty(): void;
  11912. /**
  11913. * Recomputes the cached photometric scale if needed.
  11914. */
  11915. private _computePhotometricScale;
  11916. /**
  11917. * Returns the Photometric Scale according to the light type and intensity mode.
  11918. */
  11919. private _getPhotometricScale;
  11920. /**
  11921. * Reorder the light in the scene according to their defined priority.
  11922. * @hidden Internal Use Only
  11923. */ private _reorderLightsInScene(): void;
  11924. /**
  11925. * Prepares the list of defines specific to the light type.
  11926. * @param defines the list of defines
  11927. * @param lightIndex defines the index of the light for the effect
  11928. */
  11929. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11930. }
  11931. }
  11932. declare module BABYLON {
  11933. /**
  11934. * Creates an instance based on a source mesh.
  11935. */
  11936. export class InstancedMesh extends AbstractMesh {
  11937. private _sourceMesh;
  11938. private _currentLOD;
  11939. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  11940. constructor(name: string, source: Mesh);
  11941. /**
  11942. * Returns the string "InstancedMesh".
  11943. */
  11944. getClassName(): string;
  11945. /** Gets the list of lights affecting that mesh */
  11946. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  11947. /**
  11948. * If the source mesh receives shadows
  11949. */
  11950. readonly receiveShadows: boolean;
  11951. /**
  11952. * The material of the source mesh
  11953. */
  11954. readonly material: Nullable<Material>;
  11955. /**
  11956. * Visibility of the source mesh
  11957. */
  11958. readonly visibility: number;
  11959. /**
  11960. * Skeleton of the source mesh
  11961. */
  11962. readonly skeleton: Nullable<Skeleton>;
  11963. /**
  11964. * Rendering ground id of the source mesh
  11965. */
  11966. renderingGroupId: number;
  11967. /**
  11968. * Returns the total number of vertices (integer).
  11969. */
  11970. getTotalVertices(): number;
  11971. /**
  11972. * Returns a positive integer : the total number of indices in this mesh geometry.
  11973. * @returns the numner of indices or zero if the mesh has no geometry.
  11974. */
  11975. getTotalIndices(): number;
  11976. /**
  11977. * The source mesh of the instance
  11978. */
  11979. readonly sourceMesh: Mesh;
  11980. /**
  11981. * Is this node ready to be used/rendered
  11982. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  11983. * @return {boolean} is it ready
  11984. */
  11985. isReady(completeCheck?: boolean): boolean;
  11986. /**
  11987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  11988. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  11989. * @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.
  11990. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  11991. */
  11992. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  11993. /**
  11994. * Sets the vertex data of the mesh geometry for the requested `kind`.
  11995. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  11996. * The `data` are either a numeric array either a Float32Array.
  11997. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  11998. * 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).
  11999. * Note that a new underlying VertexBuffer object is created each call.
  12000. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12001. *
  12002. * Possible `kind` values :
  12003. * - VertexBuffer.PositionKind
  12004. * - VertexBuffer.UVKind
  12005. * - VertexBuffer.UV2Kind
  12006. * - VertexBuffer.UV3Kind
  12007. * - VertexBuffer.UV4Kind
  12008. * - VertexBuffer.UV5Kind
  12009. * - VertexBuffer.UV6Kind
  12010. * - VertexBuffer.ColorKind
  12011. * - VertexBuffer.MatricesIndicesKind
  12012. * - VertexBuffer.MatricesIndicesExtraKind
  12013. * - VertexBuffer.MatricesWeightsKind
  12014. * - VertexBuffer.MatricesWeightsExtraKind
  12015. *
  12016. * Returns the Mesh.
  12017. */
  12018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12019. /**
  12020. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12021. * If the mesh has no geometry, it is simply returned as it is.
  12022. * The `data` are either a numeric array either a Float32Array.
  12023. * No new underlying VertexBuffer object is created.
  12024. * 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.
  12025. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12026. *
  12027. * Possible `kind` values :
  12028. * - VertexBuffer.PositionKind
  12029. * - VertexBuffer.UVKind
  12030. * - VertexBuffer.UV2Kind
  12031. * - VertexBuffer.UV3Kind
  12032. * - VertexBuffer.UV4Kind
  12033. * - VertexBuffer.UV5Kind
  12034. * - VertexBuffer.UV6Kind
  12035. * - VertexBuffer.ColorKind
  12036. * - VertexBuffer.MatricesIndicesKind
  12037. * - VertexBuffer.MatricesIndicesExtraKind
  12038. * - VertexBuffer.MatricesWeightsKind
  12039. * - VertexBuffer.MatricesWeightsExtraKind
  12040. *
  12041. * Returns the Mesh.
  12042. */
  12043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12044. /**
  12045. * Sets the mesh indices.
  12046. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12047. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12048. * This method creates a new index buffer each call.
  12049. * Returns the Mesh.
  12050. */
  12051. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12052. /**
  12053. * Boolean : True if the mesh owns the requested kind of data.
  12054. */
  12055. isVerticesDataPresent(kind: string): boolean;
  12056. /**
  12057. * Returns an array of indices (IndicesArray).
  12058. */
  12059. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  12060. /**
  12061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12062. * This means the mesh underlying bounding box and sphere are recomputed.
  12063. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12064. * @returns the current mesh
  12065. */
  12066. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12067. /** @hidden */ private _preActivate(): InstancedMesh;
  12068. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  12069. /** @hidden */ private _postActivate(): void;
  12070. getWorldMatrix(): Matrix;
  12071. readonly isAnInstance: boolean;
  12072. /**
  12073. * Returns the current associated LOD AbstractMesh.
  12074. */
  12075. getLOD(camera: Camera): AbstractMesh;
  12076. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  12077. /** @hidden */ private _generatePointsArray(): boolean;
  12078. /**
  12079. * Creates a new InstancedMesh from the current mesh.
  12080. * - name (string) : the cloned mesh name
  12081. * - newParent (optional Node) : the optional Node to parent the clone to.
  12082. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12083. *
  12084. * Returns the clone.
  12085. */
  12086. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12087. /**
  12088. * Disposes the InstancedMesh.
  12089. * Returns nothing.
  12090. */
  12091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12092. }
  12093. }
  12094. declare module BABYLON {
  12095. /**
  12096. * Defines the options associated with the creation of a shader material.
  12097. */
  12098. export interface IShaderMaterialOptions {
  12099. /**
  12100. * Does the material work in alpha blend mode
  12101. */
  12102. needAlphaBlending: boolean;
  12103. /**
  12104. * Does the material work in alpha test mode
  12105. */
  12106. needAlphaTesting: boolean;
  12107. /**
  12108. * The list of attribute names used in the shader
  12109. */
  12110. attributes: string[];
  12111. /**
  12112. * The list of unifrom names used in the shader
  12113. */
  12114. uniforms: string[];
  12115. /**
  12116. * The list of UBO names used in the shader
  12117. */
  12118. uniformBuffers: string[];
  12119. /**
  12120. * The list of sampler names used in the shader
  12121. */
  12122. samplers: string[];
  12123. /**
  12124. * The list of defines used in the shader
  12125. */
  12126. defines: string[];
  12127. }
  12128. /**
  12129. * 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.
  12130. *
  12131. * This returned material effects how the mesh will look based on the code in the shaders.
  12132. *
  12133. * @see http://doc.babylonjs.com/how_to/shader_material
  12134. */
  12135. export class ShaderMaterial extends Material {
  12136. private _shaderPath;
  12137. private _options;
  12138. private _textures;
  12139. private _textureArrays;
  12140. private _floats;
  12141. private _ints;
  12142. private _floatsArrays;
  12143. private _colors3;
  12144. private _colors3Arrays;
  12145. private _colors4;
  12146. private _colors4Arrays;
  12147. private _vectors2;
  12148. private _vectors3;
  12149. private _vectors4;
  12150. private _matrices;
  12151. private _matrices3x3;
  12152. private _matrices2x2;
  12153. private _vectors2Arrays;
  12154. private _vectors3Arrays;
  12155. private _vectors4Arrays;
  12156. private _cachedWorldViewMatrix;
  12157. private _cachedWorldViewProjectionMatrix;
  12158. private _renderId;
  12159. /**
  12160. * Instantiate a new shader material.
  12161. * 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.
  12162. * This returned material effects how the mesh will look based on the code in the shaders.
  12163. * @see http://doc.babylonjs.com/how_to/shader_material
  12164. * @param name Define the name of the material in the scene
  12165. * @param scene Define the scene the material belongs to
  12166. * @param shaderPath Defines the route to the shader code in one of three ways:
  12167. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12168. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12169. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12170. * @param options Define the options used to create the shader
  12171. */
  12172. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12173. /**
  12174. * Gets the options used to compile the shader.
  12175. * They can be modified to trigger a new compilation
  12176. */
  12177. readonly options: IShaderMaterialOptions;
  12178. /**
  12179. * Gets the current class name of the material e.g. "ShaderMaterial"
  12180. * Mainly use in serialization.
  12181. * @returns the class name
  12182. */
  12183. getClassName(): string;
  12184. /**
  12185. * Specifies if the material will require alpha blending
  12186. * @returns a boolean specifying if alpha blending is needed
  12187. */
  12188. needAlphaBlending(): boolean;
  12189. /**
  12190. * Specifies if this material should be rendered in alpha test mode
  12191. * @returns a boolean specifying if an alpha test is needed.
  12192. */
  12193. needAlphaTesting(): boolean;
  12194. private _checkUniform;
  12195. /**
  12196. * Set a texture in the shader.
  12197. * @param name Define the name of the uniform samplers as defined in the shader
  12198. * @param texture Define the texture to bind to this sampler
  12199. * @return the material itself allowing "fluent" like uniform updates
  12200. */
  12201. setTexture(name: string, texture: Texture): ShaderMaterial;
  12202. /**
  12203. * Set a texture array in the shader.
  12204. * @param name Define the name of the uniform sampler array as defined in the shader
  12205. * @param textures Define the list of textures to bind to this sampler
  12206. * @return the material itself allowing "fluent" like uniform updates
  12207. */
  12208. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12209. /**
  12210. * Set a float in the shader.
  12211. * @param name Define the name of the uniform as defined in the shader
  12212. * @param value Define the value to give to the uniform
  12213. * @return the material itself allowing "fluent" like uniform updates
  12214. */
  12215. setFloat(name: string, value: number): ShaderMaterial;
  12216. /**
  12217. * Set a int in the shader.
  12218. * @param name Define the name of the uniform as defined in the shader
  12219. * @param value Define the value to give to the uniform
  12220. * @return the material itself allowing "fluent" like uniform updates
  12221. */
  12222. setInt(name: string, value: number): ShaderMaterial;
  12223. /**
  12224. * Set an array of floats in the shader.
  12225. * @param name Define the name of the uniform as defined in the shader
  12226. * @param value Define the value to give to the uniform
  12227. * @return the material itself allowing "fluent" like uniform updates
  12228. */
  12229. setFloats(name: string, value: number[]): ShaderMaterial;
  12230. /**
  12231. * Set a vec3 in the shader from a Color3.
  12232. * @param name Define the name of the uniform as defined in the shader
  12233. * @param value Define the value to give to the uniform
  12234. * @return the material itself allowing "fluent" like uniform updates
  12235. */
  12236. setColor3(name: string, value: Color3): ShaderMaterial;
  12237. /**
  12238. * Set a vec3 array in the shader from a Color3 array.
  12239. * @param name Define the name of the uniform as defined in the shader
  12240. * @param value Define the value to give to the uniform
  12241. * @return the material itself allowing "fluent" like uniform updates
  12242. */
  12243. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12244. /**
  12245. * Set a vec4 in the shader from a Color4.
  12246. * @param name Define the name of the uniform as defined in the shader
  12247. * @param value Define the value to give to the uniform
  12248. * @return the material itself allowing "fluent" like uniform updates
  12249. */
  12250. setColor4(name: string, value: Color4): ShaderMaterial;
  12251. /**
  12252. * Set a vec4 array in the shader from a Color4 array.
  12253. * @param name Define the name of the uniform as defined in the shader
  12254. * @param value Define the value to give to the uniform
  12255. * @return the material itself allowing "fluent" like uniform updates
  12256. */
  12257. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12258. /**
  12259. * Set a vec2 in the shader from a Vector2.
  12260. * @param name Define the name of the uniform as defined in the shader
  12261. * @param value Define the value to give to the uniform
  12262. * @return the material itself allowing "fluent" like uniform updates
  12263. */
  12264. setVector2(name: string, value: Vector2): ShaderMaterial;
  12265. /**
  12266. * Set a vec3 in the shader from a Vector3.
  12267. * @param name Define the name of the uniform as defined in the shader
  12268. * @param value Define the value to give to the uniform
  12269. * @return the material itself allowing "fluent" like uniform updates
  12270. */
  12271. setVector3(name: string, value: Vector3): ShaderMaterial;
  12272. /**
  12273. * Set a vec4 in the shader from a Vector4.
  12274. * @param name Define the name of the uniform as defined in the shader
  12275. * @param value Define the value to give to the uniform
  12276. * @return the material itself allowing "fluent" like uniform updates
  12277. */
  12278. setVector4(name: string, value: Vector4): ShaderMaterial;
  12279. /**
  12280. * Set a mat4 in the shader from a Matrix.
  12281. * @param name Define the name of the uniform as defined in the shader
  12282. * @param value Define the value to give to the uniform
  12283. * @return the material itself allowing "fluent" like uniform updates
  12284. */
  12285. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12286. /**
  12287. * Set a mat3 in the shader from a Float32Array.
  12288. * @param name Define the name of the uniform as defined in the shader
  12289. * @param value Define the value to give to the uniform
  12290. * @return the material itself allowing "fluent" like uniform updates
  12291. */
  12292. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12293. /**
  12294. * Set a mat2 in the shader from a Float32Array.
  12295. * @param name Define the name of the uniform as defined in the shader
  12296. * @param value Define the value to give to the uniform
  12297. * @return the material itself allowing "fluent" like uniform updates
  12298. */
  12299. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12300. /**
  12301. * Set a vec2 array in the shader from a number array.
  12302. * @param name Define the name of the uniform as defined in the shader
  12303. * @param value Define the value to give to the uniform
  12304. * @return the material itself allowing "fluent" like uniform updates
  12305. */
  12306. setArray2(name: string, value: number[]): ShaderMaterial;
  12307. /**
  12308. * Set a vec3 array in the shader from a number array.
  12309. * @param name Define the name of the uniform as defined in the shader
  12310. * @param value Define the value to give to the uniform
  12311. * @return the material itself allowing "fluent" like uniform updates
  12312. */
  12313. setArray3(name: string, value: number[]): ShaderMaterial;
  12314. /**
  12315. * Set a vec4 array in the shader from a number array.
  12316. * @param name Define the name of the uniform as defined in the shader
  12317. * @param value Define the value to give to the uniform
  12318. * @return the material itself allowing "fluent" like uniform updates
  12319. */
  12320. setArray4(name: string, value: number[]): ShaderMaterial;
  12321. private _checkCache;
  12322. /**
  12323. * Specifies that the submesh is ready to be used
  12324. * @param mesh defines the mesh to check
  12325. * @param subMesh defines which submesh to check
  12326. * @param useInstances specifies that instances should be used
  12327. * @returns a boolean indicating that the submesh is ready or not
  12328. */
  12329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12330. /**
  12331. * Checks if the material is ready to render the requested mesh
  12332. * @param mesh Define the mesh to render
  12333. * @param useInstances Define whether or not the material is used with instances
  12334. * @returns true if ready, otherwise false
  12335. */
  12336. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12337. /**
  12338. * Binds the world matrix to the material
  12339. * @param world defines the world transformation matrix
  12340. */
  12341. bindOnlyWorldMatrix(world: Matrix): void;
  12342. /**
  12343. * Binds the material to the mesh
  12344. * @param world defines the world transformation matrix
  12345. * @param mesh defines the mesh to bind the material to
  12346. */
  12347. bind(world: Matrix, mesh?: Mesh): void;
  12348. /**
  12349. * Gets the active textures from the material
  12350. * @returns an array of textures
  12351. */
  12352. getActiveTextures(): BaseTexture[];
  12353. /**
  12354. * Specifies if the material uses a texture
  12355. * @param texture defines the texture to check against the material
  12356. * @returns a boolean specifying if the material uses the texture
  12357. */
  12358. hasTexture(texture: BaseTexture): boolean;
  12359. /**
  12360. * Makes a duplicate of the material, and gives it a new name
  12361. * @param name defines the new name for the duplicated material
  12362. * @returns the cloned material
  12363. */
  12364. clone(name: string): ShaderMaterial;
  12365. /**
  12366. * Disposes the material
  12367. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12368. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12369. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12370. */
  12371. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12372. /**
  12373. * Serializes this material in a JSON representation
  12374. * @returns the serialized material object
  12375. */
  12376. serialize(): any;
  12377. /**
  12378. * Creates a shader material from parsed shader material data
  12379. * @param source defines the JSON represnetation of the material
  12380. * @param scene defines the hosting scene
  12381. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12382. * @returns a new material
  12383. */
  12384. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12385. }
  12386. }
  12387. declare module BABYLON {
  12388. /** @hidden */
  12389. export var clipPlaneFragmentDeclaration: {
  12390. name: string;
  12391. shader: string;
  12392. };
  12393. }
  12394. declare module BABYLON {
  12395. /** @hidden */
  12396. export var clipPlaneFragment: {
  12397. name: string;
  12398. shader: string;
  12399. };
  12400. }
  12401. declare module BABYLON {
  12402. /** @hidden */
  12403. export var colorPixelShader: {
  12404. name: string;
  12405. shader: string;
  12406. };
  12407. }
  12408. declare module BABYLON {
  12409. /** @hidden */
  12410. export var clipPlaneVertexDeclaration: {
  12411. name: string;
  12412. shader: string;
  12413. };
  12414. }
  12415. declare module BABYLON {
  12416. /** @hidden */
  12417. export var clipPlaneVertex: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module BABYLON {
  12423. /** @hidden */
  12424. export var colorVertexShader: {
  12425. name: string;
  12426. shader: string;
  12427. };
  12428. }
  12429. declare module BABYLON {
  12430. /**
  12431. * Line mesh
  12432. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12433. */
  12434. export class LinesMesh extends Mesh {
  12435. /**
  12436. * If vertex color should be applied to the mesh
  12437. */
  12438. readonly useVertexColor?: boolean | undefined;
  12439. /**
  12440. * If vertex alpha should be applied to the mesh
  12441. */
  12442. readonly useVertexAlpha?: boolean | undefined;
  12443. /**
  12444. * Color of the line (Default: White)
  12445. */
  12446. color: Color3;
  12447. /**
  12448. * Alpha of the line (Default: 1)
  12449. */
  12450. alpha: number;
  12451. /**
  12452. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12453. * This margin is expressed in world space coordinates, so its value may vary.
  12454. * Default value is 0.1
  12455. */
  12456. intersectionThreshold: number;
  12457. private _colorShader;
  12458. private color4;
  12459. /**
  12460. * Creates a new LinesMesh
  12461. * @param name defines the name
  12462. * @param scene defines the hosting scene
  12463. * @param parent defines the parent mesh if any
  12464. * @param source defines the optional source LinesMesh used to clone data from
  12465. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12466. * When false, achieved by calling a clone(), also passing False.
  12467. * This will make creation of children, recursive.
  12468. * @param useVertexColor defines if this LinesMesh supports vertex color
  12469. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12470. */
  12471. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12472. /**
  12473. * If vertex color should be applied to the mesh
  12474. */
  12475. useVertexColor?: boolean | undefined,
  12476. /**
  12477. * If vertex alpha should be applied to the mesh
  12478. */
  12479. useVertexAlpha?: boolean | undefined);
  12480. private _addClipPlaneDefine;
  12481. private _removeClipPlaneDefine;
  12482. isReady(): boolean;
  12483. /**
  12484. * Returns the string "LineMesh"
  12485. */
  12486. getClassName(): string;
  12487. /**
  12488. * @hidden
  12489. */
  12490. /**
  12491. * @hidden
  12492. */
  12493. material: Material;
  12494. /**
  12495. * @hidden
  12496. */
  12497. readonly checkCollisions: boolean;
  12498. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12499. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12500. /**
  12501. * Disposes of the line mesh
  12502. * @param doNotRecurse If children should be disposed
  12503. */
  12504. dispose(doNotRecurse?: boolean): void;
  12505. /**
  12506. * Returns a new LineMesh object cloned from the current one.
  12507. */
  12508. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12509. /**
  12510. * Creates a new InstancedLinesMesh object from the mesh model.
  12511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12512. * @param name defines the name of the new instance
  12513. * @returns a new InstancedLinesMesh
  12514. */
  12515. createInstance(name: string): InstancedLinesMesh;
  12516. }
  12517. /**
  12518. * Creates an instance based on a source LinesMesh
  12519. */
  12520. export class InstancedLinesMesh extends InstancedMesh {
  12521. /**
  12522. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12523. * This margin is expressed in world space coordinates, so its value may vary.
  12524. * Initilized with the intersectionThreshold value of the source LinesMesh
  12525. */
  12526. intersectionThreshold: number;
  12527. constructor(name: string, source: LinesMesh);
  12528. /**
  12529. * Returns the string "InstancedLinesMesh".
  12530. */
  12531. getClassName(): string;
  12532. }
  12533. }
  12534. declare module BABYLON {
  12535. /**
  12536. * Mesh representing the gorund
  12537. */
  12538. export class GroundMesh extends Mesh {
  12539. /** If octree should be generated */
  12540. generateOctree: boolean;
  12541. private _heightQuads;
  12542. /** @hidden */ private _subdivisionsX: number;
  12543. /** @hidden */ private _subdivisionsY: number;
  12544. /** @hidden */ private _width: number;
  12545. /** @hidden */ private _height: number;
  12546. /** @hidden */ private _minX: number;
  12547. /** @hidden */ private _maxX: number;
  12548. /** @hidden */ private _minZ: number;
  12549. /** @hidden */ private _maxZ: number;
  12550. constructor(name: string, scene: Scene);
  12551. /**
  12552. * "GroundMesh"
  12553. * @returns "GroundMesh"
  12554. */
  12555. getClassName(): string;
  12556. /**
  12557. * The minimum of x and y subdivisions
  12558. */
  12559. readonly subdivisions: number;
  12560. /**
  12561. * X subdivisions
  12562. */
  12563. readonly subdivisionsX: number;
  12564. /**
  12565. * Y subdivisions
  12566. */
  12567. readonly subdivisionsY: number;
  12568. /**
  12569. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12570. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12571. * @param chunksCount the number of subdivisions for x and y
  12572. * @param octreeBlocksSize (Default: 32)
  12573. */
  12574. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12575. /**
  12576. * Returns a height (y) value in the Worl system :
  12577. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12578. * @param x x coordinate
  12579. * @param z z coordinate
  12580. * @returns the ground y position if (x, z) are outside the ground surface.
  12581. */
  12582. getHeightAtCoordinates(x: number, z: number): number;
  12583. /**
  12584. * Returns a normalized vector (Vector3) orthogonal to the ground
  12585. * at the ground coordinates (x, z) expressed in the World system.
  12586. * @param x x coordinate
  12587. * @param z z coordinate
  12588. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12589. */
  12590. getNormalAtCoordinates(x: number, z: number): Vector3;
  12591. /**
  12592. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12593. * at the ground coordinates (x, z) expressed in the World system.
  12594. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12595. * @param x x coordinate
  12596. * @param z z coordinate
  12597. * @param ref vector to store the result
  12598. * @returns the GroundMesh.
  12599. */
  12600. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12601. /**
  12602. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12603. * if the ground has been updated.
  12604. * This can be used in the render loop.
  12605. * @returns the GroundMesh.
  12606. */
  12607. updateCoordinateHeights(): GroundMesh;
  12608. private _getFacetAt;
  12609. private _initHeightQuads;
  12610. private _computeHeightQuads;
  12611. /**
  12612. * Serializes this ground mesh
  12613. * @param serializationObject object to write serialization to
  12614. */
  12615. serialize(serializationObject: any): void;
  12616. /**
  12617. * Parses a serialized ground mesh
  12618. * @param parsedMesh the serialized mesh
  12619. * @param scene the scene to create the ground mesh in
  12620. * @returns the created ground mesh
  12621. */
  12622. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12623. }
  12624. }
  12625. declare module BABYLON {
  12626. /**
  12627. * Interface for Physics-Joint data
  12628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12629. */
  12630. export interface PhysicsJointData {
  12631. /**
  12632. * The main pivot of the joint
  12633. */
  12634. mainPivot?: Vector3;
  12635. /**
  12636. * The connected pivot of the joint
  12637. */
  12638. connectedPivot?: Vector3;
  12639. /**
  12640. * The main axis of the joint
  12641. */
  12642. mainAxis?: Vector3;
  12643. /**
  12644. * The connected axis of the joint
  12645. */
  12646. connectedAxis?: Vector3;
  12647. /**
  12648. * The collision of the joint
  12649. */
  12650. collision?: boolean;
  12651. /**
  12652. * Native Oimo/Cannon/Energy data
  12653. */
  12654. nativeParams?: any;
  12655. }
  12656. /**
  12657. * This is a holder class for the physics joint created by the physics plugin
  12658. * It holds a set of functions to control the underlying joint
  12659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12660. */
  12661. export class PhysicsJoint {
  12662. /**
  12663. * The type of the physics joint
  12664. */
  12665. type: number;
  12666. /**
  12667. * The data for the physics joint
  12668. */
  12669. jointData: PhysicsJointData;
  12670. private _physicsJoint;
  12671. protected _physicsPlugin: IPhysicsEnginePlugin;
  12672. /**
  12673. * Initializes the physics joint
  12674. * @param type The type of the physics joint
  12675. * @param jointData The data for the physics joint
  12676. */
  12677. constructor(
  12678. /**
  12679. * The type of the physics joint
  12680. */
  12681. type: number,
  12682. /**
  12683. * The data for the physics joint
  12684. */
  12685. jointData: PhysicsJointData);
  12686. /**
  12687. * Gets the physics joint
  12688. */
  12689. /**
  12690. * Sets the physics joint
  12691. */
  12692. physicsJoint: any;
  12693. /**
  12694. * Sets the physics plugin
  12695. */
  12696. physicsPlugin: IPhysicsEnginePlugin;
  12697. /**
  12698. * Execute a function that is physics-plugin specific.
  12699. * @param {Function} func the function that will be executed.
  12700. * It accepts two parameters: the physics world and the physics joint
  12701. */
  12702. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12703. /**
  12704. * Distance-Joint type
  12705. */
  12706. static DistanceJoint: number;
  12707. /**
  12708. * Hinge-Joint type
  12709. */
  12710. static HingeJoint: number;
  12711. /**
  12712. * Ball-and-Socket joint type
  12713. */
  12714. static BallAndSocketJoint: number;
  12715. /**
  12716. * Wheel-Joint type
  12717. */
  12718. static WheelJoint: number;
  12719. /**
  12720. * Slider-Joint type
  12721. */
  12722. static SliderJoint: number;
  12723. /**
  12724. * Prismatic-Joint type
  12725. */
  12726. static PrismaticJoint: number;
  12727. /**
  12728. * Universal-Joint type
  12729. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12730. */
  12731. static UniversalJoint: number;
  12732. /**
  12733. * Hinge-Joint 2 type
  12734. */
  12735. static Hinge2Joint: number;
  12736. /**
  12737. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12738. */
  12739. static PointToPointJoint: number;
  12740. /**
  12741. * Spring-Joint type
  12742. */
  12743. static SpringJoint: number;
  12744. /**
  12745. * Lock-Joint type
  12746. */
  12747. static LockJoint: number;
  12748. }
  12749. /**
  12750. * A class representing a physics distance joint
  12751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12752. */
  12753. export class DistanceJoint extends PhysicsJoint {
  12754. /**
  12755. *
  12756. * @param jointData The data for the Distance-Joint
  12757. */
  12758. constructor(jointData: DistanceJointData);
  12759. /**
  12760. * Update the predefined distance.
  12761. * @param maxDistance The maximum preferred distance
  12762. * @param minDistance The minimum preferred distance
  12763. */
  12764. updateDistance(maxDistance: number, minDistance?: number): void;
  12765. }
  12766. /**
  12767. * Represents a Motor-Enabled Joint
  12768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12769. */
  12770. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12771. /**
  12772. * Initializes the Motor-Enabled Joint
  12773. * @param type The type of the joint
  12774. * @param jointData The physica joint data for the joint
  12775. */
  12776. constructor(type: number, jointData: PhysicsJointData);
  12777. /**
  12778. * Set the motor values.
  12779. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12780. * @param force the force to apply
  12781. * @param maxForce max force for this motor.
  12782. */
  12783. setMotor(force?: number, maxForce?: number): void;
  12784. /**
  12785. * Set the motor's limits.
  12786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12787. * @param upperLimit The upper limit of the motor
  12788. * @param lowerLimit The lower limit of the motor
  12789. */
  12790. setLimit(upperLimit: number, lowerLimit?: number): void;
  12791. }
  12792. /**
  12793. * This class represents a single physics Hinge-Joint
  12794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12795. */
  12796. export class HingeJoint extends MotorEnabledJoint {
  12797. /**
  12798. * Initializes the Hinge-Joint
  12799. * @param jointData The joint data for the Hinge-Joint
  12800. */
  12801. constructor(jointData: PhysicsJointData);
  12802. /**
  12803. * Set the motor values.
  12804. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12805. * @param {number} force the force to apply
  12806. * @param {number} maxForce max force for this motor.
  12807. */
  12808. setMotor(force?: number, maxForce?: number): void;
  12809. /**
  12810. * Set the motor's limits.
  12811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12812. * @param upperLimit The upper limit of the motor
  12813. * @param lowerLimit The lower limit of the motor
  12814. */
  12815. setLimit(upperLimit: number, lowerLimit?: number): void;
  12816. }
  12817. /**
  12818. * This class represents a dual hinge physics joint (same as wheel joint)
  12819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12820. */
  12821. export class Hinge2Joint extends MotorEnabledJoint {
  12822. /**
  12823. * Initializes the Hinge2-Joint
  12824. * @param jointData The joint data for the Hinge2-Joint
  12825. */
  12826. constructor(jointData: PhysicsJointData);
  12827. /**
  12828. * Set the motor values.
  12829. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12830. * @param {number} targetSpeed the speed the motor is to reach
  12831. * @param {number} maxForce max force for this motor.
  12832. * @param {motorIndex} the motor's index, 0 or 1.
  12833. */
  12834. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12835. /**
  12836. * Set the motor limits.
  12837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12838. * @param {number} upperLimit the upper limit
  12839. * @param {number} lowerLimit lower limit
  12840. * @param {motorIndex} the motor's index, 0 or 1.
  12841. */
  12842. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12843. }
  12844. /**
  12845. * Interface for a motor enabled joint
  12846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12847. */
  12848. export interface IMotorEnabledJoint {
  12849. /**
  12850. * Physics joint
  12851. */
  12852. physicsJoint: any;
  12853. /**
  12854. * Sets the motor of the motor-enabled joint
  12855. * @param force The force of the motor
  12856. * @param maxForce The maximum force of the motor
  12857. * @param motorIndex The index of the motor
  12858. */
  12859. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  12860. /**
  12861. * Sets the limit of the motor
  12862. * @param upperLimit The upper limit of the motor
  12863. * @param lowerLimit The lower limit of the motor
  12864. * @param motorIndex The index of the motor
  12865. */
  12866. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12867. }
  12868. /**
  12869. * Joint data for a Distance-Joint
  12870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12871. */
  12872. export interface DistanceJointData extends PhysicsJointData {
  12873. /**
  12874. * Max distance the 2 joint objects can be apart
  12875. */
  12876. maxDistance: number;
  12877. }
  12878. /**
  12879. * Joint data from a spring joint
  12880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12881. */
  12882. export interface SpringJointData extends PhysicsJointData {
  12883. /**
  12884. * Length of the spring
  12885. */
  12886. length: number;
  12887. /**
  12888. * Stiffness of the spring
  12889. */
  12890. stiffness: number;
  12891. /**
  12892. * Damping of the spring
  12893. */
  12894. damping: number;
  12895. /** this callback will be called when applying the force to the impostors. */
  12896. forceApplicationCallback: () => void;
  12897. }
  12898. }
  12899. declare module BABYLON {
  12900. /**
  12901. * Holds the data for the raycast result
  12902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12903. */
  12904. export class PhysicsRaycastResult {
  12905. private _hasHit;
  12906. private _hitDistance;
  12907. private _hitNormalWorld;
  12908. private _hitPointWorld;
  12909. private _rayFromWorld;
  12910. private _rayToWorld;
  12911. /**
  12912. * Gets if there was a hit
  12913. */
  12914. readonly hasHit: boolean;
  12915. /**
  12916. * Gets the distance from the hit
  12917. */
  12918. readonly hitDistance: number;
  12919. /**
  12920. * Gets the hit normal/direction in the world
  12921. */
  12922. readonly hitNormalWorld: Vector3;
  12923. /**
  12924. * Gets the hit point in the world
  12925. */
  12926. readonly hitPointWorld: Vector3;
  12927. /**
  12928. * Gets the ray "start point" of the ray in the world
  12929. */
  12930. readonly rayFromWorld: Vector3;
  12931. /**
  12932. * Gets the ray "end point" of the ray in the world
  12933. */
  12934. readonly rayToWorld: Vector3;
  12935. /**
  12936. * Sets the hit data (normal & point in world space)
  12937. * @param hitNormalWorld defines the normal in world space
  12938. * @param hitPointWorld defines the point in world space
  12939. */
  12940. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  12941. /**
  12942. * Sets the distance from the start point to the hit point
  12943. * @param distance
  12944. */
  12945. setHitDistance(distance: number): void;
  12946. /**
  12947. * Calculates the distance manually
  12948. */
  12949. calculateHitDistance(): void;
  12950. /**
  12951. * Resets all the values to default
  12952. * @param from The from point on world space
  12953. * @param to The to point on world space
  12954. */
  12955. reset(from?: Vector3, to?: Vector3): void;
  12956. }
  12957. /**
  12958. * Interface for the size containing width and height
  12959. */
  12960. interface IXYZ {
  12961. /**
  12962. * X
  12963. */
  12964. x: number;
  12965. /**
  12966. * Y
  12967. */
  12968. y: number;
  12969. /**
  12970. * Z
  12971. */
  12972. z: number;
  12973. }
  12974. }
  12975. declare module BABYLON {
  12976. /**
  12977. * Interface used to describe a physics joint
  12978. */
  12979. export interface PhysicsImpostorJoint {
  12980. /** Defines the main impostor to which the joint is linked */
  12981. mainImpostor: PhysicsImpostor;
  12982. /** Defines the impostor that is connected to the main impostor using this joint */
  12983. connectedImpostor: PhysicsImpostor;
  12984. /** Defines the joint itself */
  12985. joint: PhysicsJoint;
  12986. }
  12987. /** @hidden */
  12988. export interface IPhysicsEnginePlugin {
  12989. world: any;
  12990. name: string;
  12991. setGravity(gravity: Vector3): void;
  12992. setTimeStep(timeStep: number): void;
  12993. getTimeStep(): number;
  12994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  12995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  12996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  12997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  12998. removePhysicsBody(impostor: PhysicsImpostor): void;
  12999. generateJoint(joint: PhysicsImpostorJoint): void;
  13000. removeJoint(joint: PhysicsImpostorJoint): void;
  13001. isSupported(): boolean;
  13002. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13003. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13004. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13005. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13006. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13007. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13008. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13009. getBodyMass(impostor: PhysicsImpostor): number;
  13010. getBodyFriction(impostor: PhysicsImpostor): number;
  13011. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13012. getBodyRestitution(impostor: PhysicsImpostor): number;
  13013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13014. getBodyPressure?(impostor: PhysicsImpostor): number;
  13015. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13016. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13017. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13018. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13019. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13020. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13021. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13022. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13023. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13024. sleepBody(impostor: PhysicsImpostor): void;
  13025. wakeUpBody(impostor: PhysicsImpostor): void;
  13026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13027. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13028. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13029. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13030. getRadius(impostor: PhysicsImpostor): number;
  13031. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13032. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13033. dispose(): void;
  13034. }
  13035. /**
  13036. * Interface used to define a physics engine
  13037. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13038. */
  13039. export interface IPhysicsEngine {
  13040. /**
  13041. * Gets the gravity vector used by the simulation
  13042. */
  13043. gravity: Vector3;
  13044. /**
  13045. * Sets the gravity vector used by the simulation
  13046. * @param gravity defines the gravity vector to use
  13047. */
  13048. setGravity(gravity: Vector3): void;
  13049. /**
  13050. * Set the time step of the physics engine.
  13051. * Default is 1/60.
  13052. * To slow it down, enter 1/600 for example.
  13053. * To speed it up, 1/30
  13054. * @param newTimeStep the new timestep to apply to this world.
  13055. */
  13056. setTimeStep(newTimeStep: number): void;
  13057. /**
  13058. * Get the time step of the physics engine.
  13059. * @returns the current time step
  13060. */
  13061. getTimeStep(): number;
  13062. /**
  13063. * Release all resources
  13064. */
  13065. dispose(): void;
  13066. /**
  13067. * Gets the name of the current physics plugin
  13068. * @returns the name of the plugin
  13069. */
  13070. getPhysicsPluginName(): string;
  13071. /**
  13072. * Adding a new impostor for the impostor tracking.
  13073. * This will be done by the impostor itself.
  13074. * @param impostor the impostor to add
  13075. */
  13076. addImpostor(impostor: PhysicsImpostor): void;
  13077. /**
  13078. * Remove an impostor from the engine.
  13079. * This impostor and its mesh will not longer be updated by the physics engine.
  13080. * @param impostor the impostor to remove
  13081. */
  13082. removeImpostor(impostor: PhysicsImpostor): void;
  13083. /**
  13084. * Add a joint to the physics engine
  13085. * @param mainImpostor defines the main impostor to which the joint is added.
  13086. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13087. * @param joint defines the joint that will connect both impostors.
  13088. */
  13089. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13090. /**
  13091. * Removes a joint from the simulation
  13092. * @param mainImpostor defines the impostor used with the joint
  13093. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13094. * @param joint defines the joint to remove
  13095. */
  13096. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13097. /**
  13098. * Gets the current plugin used to run the simulation
  13099. * @returns current plugin
  13100. */
  13101. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13102. /**
  13103. * Gets the list of physic impostors
  13104. * @returns an array of PhysicsImpostor
  13105. */
  13106. getImpostors(): Array<PhysicsImpostor>;
  13107. /**
  13108. * Gets the impostor for a physics enabled object
  13109. * @param object defines the object impersonated by the impostor
  13110. * @returns the PhysicsImpostor or null if not found
  13111. */
  13112. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13113. /**
  13114. * Gets the impostor for a physics body object
  13115. * @param body defines physics body used by the impostor
  13116. * @returns the PhysicsImpostor or null if not found
  13117. */
  13118. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13119. /**
  13120. * Does a raycast in the physics world
  13121. * @param from when should the ray start?
  13122. * @param to when should the ray end?
  13123. * @returns PhysicsRaycastResult
  13124. */
  13125. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13126. /**
  13127. * Called by the scene. No need to call it.
  13128. * @param delta defines the timespam between frames
  13129. */ private _step(delta: number): void;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. /**
  13134. * The interface for the physics imposter parameters
  13135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13136. */
  13137. export interface PhysicsImpostorParameters {
  13138. /**
  13139. * The mass of the physics imposter
  13140. */
  13141. mass: number;
  13142. /**
  13143. * The friction of the physics imposter
  13144. */
  13145. friction?: number;
  13146. /**
  13147. * The coefficient of restitution of the physics imposter
  13148. */
  13149. restitution?: number;
  13150. /**
  13151. * The native options of the physics imposter
  13152. */
  13153. nativeOptions?: any;
  13154. /**
  13155. * Specifies if the parent should be ignored
  13156. */
  13157. ignoreParent?: boolean;
  13158. /**
  13159. * Specifies if bi-directional transformations should be disabled
  13160. */
  13161. disableBidirectionalTransformation?: boolean;
  13162. /**
  13163. * The pressure inside the physics imposter, soft object only
  13164. */
  13165. pressure?: number;
  13166. /**
  13167. * The stiffness the physics imposter, soft object only
  13168. */
  13169. stiffness?: number;
  13170. /**
  13171. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13172. */
  13173. velocityIterations?: number;
  13174. /**
  13175. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13176. */
  13177. positionIterations?: number;
  13178. /**
  13179. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13180. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13181. * Add to fix multiple points
  13182. */
  13183. fixedPoints?: number;
  13184. /**
  13185. * The collision margin around a soft object
  13186. */
  13187. margin?: number;
  13188. /**
  13189. * The collision margin around a soft object
  13190. */
  13191. damping?: number;
  13192. /**
  13193. * The path for a rope based on an extrusion
  13194. */
  13195. path?: any;
  13196. /**
  13197. * The shape of an extrusion used for a rope based on an extrusion
  13198. */
  13199. shape?: any;
  13200. }
  13201. /**
  13202. * Interface for a physics-enabled object
  13203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13204. */
  13205. export interface IPhysicsEnabledObject {
  13206. /**
  13207. * The position of the physics-enabled object
  13208. */
  13209. position: Vector3;
  13210. /**
  13211. * The rotation of the physics-enabled object
  13212. */
  13213. rotationQuaternion: Nullable<Quaternion>;
  13214. /**
  13215. * The scale of the physics-enabled object
  13216. */
  13217. scaling: Vector3;
  13218. /**
  13219. * The rotation of the physics-enabled object
  13220. */
  13221. rotation?: Vector3;
  13222. /**
  13223. * The parent of the physics-enabled object
  13224. */
  13225. parent?: any;
  13226. /**
  13227. * The bounding info of the physics-enabled object
  13228. * @returns The bounding info of the physics-enabled object
  13229. */
  13230. getBoundingInfo(): BoundingInfo;
  13231. /**
  13232. * Computes the world matrix
  13233. * @param force Specifies if the world matrix should be computed by force
  13234. * @returns A world matrix
  13235. */
  13236. computeWorldMatrix(force: boolean): Matrix;
  13237. /**
  13238. * Gets the world matrix
  13239. * @returns A world matrix
  13240. */
  13241. getWorldMatrix?(): Matrix;
  13242. /**
  13243. * Gets the child meshes
  13244. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13245. * @returns An array of abstract meshes
  13246. */
  13247. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13248. /**
  13249. * Gets the vertex data
  13250. * @param kind The type of vertex data
  13251. * @returns A nullable array of numbers, or a float32 array
  13252. */
  13253. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13254. /**
  13255. * Gets the indices from the mesh
  13256. * @returns A nullable array of index arrays
  13257. */
  13258. getIndices?(): Nullable<IndicesArray>;
  13259. /**
  13260. * Gets the scene from the mesh
  13261. * @returns the indices array or null
  13262. */
  13263. getScene?(): Scene;
  13264. /**
  13265. * Gets the absolute position from the mesh
  13266. * @returns the absolute position
  13267. */
  13268. getAbsolutePosition(): Vector3;
  13269. /**
  13270. * Gets the absolute pivot point from the mesh
  13271. * @returns the absolute pivot point
  13272. */
  13273. getAbsolutePivotPoint(): Vector3;
  13274. /**
  13275. * Rotates the mesh
  13276. * @param axis The axis of rotation
  13277. * @param amount The amount of rotation
  13278. * @param space The space of the rotation
  13279. * @returns The rotation transform node
  13280. */
  13281. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13282. /**
  13283. * Translates the mesh
  13284. * @param axis The axis of translation
  13285. * @param distance The distance of translation
  13286. * @param space The space of the translation
  13287. * @returns The transform node
  13288. */
  13289. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13290. /**
  13291. * Sets the absolute position of the mesh
  13292. * @param absolutePosition The absolute position of the mesh
  13293. * @returns The transform node
  13294. */
  13295. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13296. /**
  13297. * Gets the class name of the mesh
  13298. * @returns The class name
  13299. */
  13300. getClassName(): string;
  13301. }
  13302. /**
  13303. * Represents a physics imposter
  13304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13305. */
  13306. export class PhysicsImpostor {
  13307. /**
  13308. * The physics-enabled object used as the physics imposter
  13309. */
  13310. object: IPhysicsEnabledObject;
  13311. /**
  13312. * The type of the physics imposter
  13313. */
  13314. type: number;
  13315. private _options;
  13316. private _scene?;
  13317. /**
  13318. * The default object size of the imposter
  13319. */
  13320. static DEFAULT_OBJECT_SIZE: Vector3;
  13321. /**
  13322. * The identity quaternion of the imposter
  13323. */
  13324. static IDENTITY_QUATERNION: Quaternion;
  13325. /** @hidden */ private _pluginData: any;
  13326. private _physicsEngine;
  13327. private _physicsBody;
  13328. private _bodyUpdateRequired;
  13329. private _onBeforePhysicsStepCallbacks;
  13330. private _onAfterPhysicsStepCallbacks;
  13331. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  13332. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13333. otherImpostors: Array<PhysicsImpostor>;
  13334. }>;
  13335. private _deltaPosition;
  13336. private _deltaRotation;
  13337. private _deltaRotationConjugated;
  13338. /** @hidden */ private _isFromLine: boolean;
  13339. private _parent;
  13340. private _isDisposed;
  13341. private static _tmpVecs;
  13342. private static _tmpQuat;
  13343. /**
  13344. * Specifies if the physics imposter is disposed
  13345. */
  13346. readonly isDisposed: boolean;
  13347. /**
  13348. * Gets the mass of the physics imposter
  13349. */
  13350. mass: number;
  13351. /**
  13352. * Gets the coefficient of friction
  13353. */
  13354. /**
  13355. * Sets the coefficient of friction
  13356. */
  13357. friction: number;
  13358. /**
  13359. * Gets the coefficient of restitution
  13360. */
  13361. /**
  13362. * Sets the coefficient of restitution
  13363. */
  13364. restitution: number;
  13365. /**
  13366. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13367. */
  13368. /**
  13369. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13370. */
  13371. pressure: number;
  13372. /**
  13373. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13374. */
  13375. /**
  13376. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13377. */
  13378. stiffness: number;
  13379. /**
  13380. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13381. */
  13382. /**
  13383. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13384. */
  13385. velocityIterations: number;
  13386. /**
  13387. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13388. */
  13389. /**
  13390. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13391. */
  13392. positionIterations: number;
  13393. /**
  13394. * The unique id of the physics imposter
  13395. * set by the physics engine when adding this impostor to the array
  13396. */
  13397. uniqueId: number;
  13398. /**
  13399. * @hidden
  13400. */
  13401. soft: boolean;
  13402. /**
  13403. * @hidden
  13404. */
  13405. segments: number;
  13406. private _joints;
  13407. /**
  13408. * Initializes the physics imposter
  13409. * @param object The physics-enabled object used as the physics imposter
  13410. * @param type The type of the physics imposter
  13411. * @param _options The options for the physics imposter
  13412. * @param _scene The Babylon scene
  13413. */
  13414. constructor(
  13415. /**
  13416. * The physics-enabled object used as the physics imposter
  13417. */
  13418. object: IPhysicsEnabledObject,
  13419. /**
  13420. * The type of the physics imposter
  13421. */
  13422. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13423. /**
  13424. * This function will completly initialize this impostor.
  13425. * It will create a new body - but only if this mesh has no parent.
  13426. * If it has, this impostor will not be used other than to define the impostor
  13427. * of the child mesh.
  13428. * @hidden
  13429. */ private _init(): void;
  13430. private _getPhysicsParent;
  13431. /**
  13432. * Should a new body be generated.
  13433. * @returns boolean specifying if body initialization is required
  13434. */
  13435. isBodyInitRequired(): boolean;
  13436. /**
  13437. * Sets the updated scaling
  13438. * @param updated Specifies if the scaling is updated
  13439. */
  13440. setScalingUpdated(): void;
  13441. /**
  13442. * Force a regeneration of this or the parent's impostor's body.
  13443. * Use under cautious - This will remove all joints already implemented.
  13444. */
  13445. forceUpdate(): void;
  13446. /**
  13447. * Gets the body that holds this impostor. Either its own, or its parent.
  13448. */
  13449. /**
  13450. * Set the physics body. Used mainly by the physics engine/plugin
  13451. */
  13452. physicsBody: any;
  13453. /**
  13454. * Get the parent of the physics imposter
  13455. * @returns Physics imposter or null
  13456. */
  13457. /**
  13458. * Sets the parent of the physics imposter
  13459. */
  13460. parent: Nullable<PhysicsImpostor>;
  13461. /**
  13462. * Resets the update flags
  13463. */
  13464. resetUpdateFlags(): void;
  13465. /**
  13466. * Gets the object extend size
  13467. * @returns the object extend size
  13468. */
  13469. getObjectExtendSize(): Vector3;
  13470. /**
  13471. * Gets the object center
  13472. * @returns The object center
  13473. */
  13474. getObjectCenter(): Vector3;
  13475. /**
  13476. * Get a specific parametes from the options parameter
  13477. * @param paramName The object parameter name
  13478. * @returns The object parameter
  13479. */
  13480. getParam(paramName: string): any;
  13481. /**
  13482. * Sets a specific parameter in the options given to the physics plugin
  13483. * @param paramName The parameter name
  13484. * @param value The value of the parameter
  13485. */
  13486. setParam(paramName: string, value: number): void;
  13487. /**
  13488. * Specifically change the body's mass option. Won't recreate the physics body object
  13489. * @param mass The mass of the physics imposter
  13490. */
  13491. setMass(mass: number): void;
  13492. /**
  13493. * Gets the linear velocity
  13494. * @returns linear velocity or null
  13495. */
  13496. getLinearVelocity(): Nullable<Vector3>;
  13497. /**
  13498. * Sets the linear velocity
  13499. * @param velocity linear velocity or null
  13500. */
  13501. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13502. /**
  13503. * Gets the angular velocity
  13504. * @returns angular velocity or null
  13505. */
  13506. getAngularVelocity(): Nullable<Vector3>;
  13507. /**
  13508. * Sets the angular velocity
  13509. * @param velocity The velocity or null
  13510. */
  13511. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13512. /**
  13513. * Execute a function with the physics plugin native code
  13514. * Provide a function the will have two variables - the world object and the physics body object
  13515. * @param func The function to execute with the physics plugin native code
  13516. */
  13517. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13518. /**
  13519. * Register a function that will be executed before the physics world is stepping forward
  13520. * @param func The function to execute before the physics world is stepped forward
  13521. */
  13522. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13523. /**
  13524. * Unregister a function that will be executed before the physics world is stepping forward
  13525. * @param func The function to execute before the physics world is stepped forward
  13526. */
  13527. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13528. /**
  13529. * Register a function that will be executed after the physics step
  13530. * @param func The function to execute after physics step
  13531. */
  13532. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13533. /**
  13534. * Unregisters a function that will be executed after the physics step
  13535. * @param func The function to execute after physics step
  13536. */
  13537. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13538. /**
  13539. * register a function that will be executed when this impostor collides against a different body
  13540. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13541. * @param func Callback that is executed on collision
  13542. */
  13543. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13544. /**
  13545. * Unregisters the physics imposter on contact
  13546. * @param collideAgainst The physics object to collide against
  13547. * @param func Callback to execute on collision
  13548. */
  13549. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13550. private _tmpQuat;
  13551. private _tmpQuat2;
  13552. /**
  13553. * Get the parent rotation
  13554. * @returns The parent rotation
  13555. */
  13556. getParentsRotation(): Quaternion;
  13557. /**
  13558. * this function is executed by the physics engine.
  13559. */
  13560. beforeStep: () => void;
  13561. /**
  13562. * this function is executed by the physics engine
  13563. */
  13564. afterStep: () => void;
  13565. /**
  13566. * Legacy collision detection event support
  13567. */
  13568. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13569. /**
  13570. * event and body object due to cannon's event-based architecture.
  13571. */
  13572. onCollide: (e: {
  13573. body: any;
  13574. }) => void;
  13575. /**
  13576. * Apply a force
  13577. * @param force The force to apply
  13578. * @param contactPoint The contact point for the force
  13579. * @returns The physics imposter
  13580. */
  13581. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13582. /**
  13583. * Apply an impulse
  13584. * @param force The impulse force
  13585. * @param contactPoint The contact point for the impulse force
  13586. * @returns The physics imposter
  13587. */
  13588. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13589. /**
  13590. * A help function to create a joint
  13591. * @param otherImpostor A physics imposter used to create a joint
  13592. * @param jointType The type of joint
  13593. * @param jointData The data for the joint
  13594. * @returns The physics imposter
  13595. */
  13596. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13597. /**
  13598. * Add a joint to this impostor with a different impostor
  13599. * @param otherImpostor A physics imposter used to add a joint
  13600. * @param joint The joint to add
  13601. * @returns The physics imposter
  13602. */
  13603. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13604. /**
  13605. * Add an anchor to a cloth impostor
  13606. * @param otherImpostor rigid impostor to anchor to
  13607. * @param width ratio across width from 0 to 1
  13608. * @param height ratio up height from 0 to 1
  13609. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13610. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13611. * @returns impostor the soft imposter
  13612. */
  13613. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13614. /**
  13615. * Add a hook to a rope impostor
  13616. * @param otherImpostor rigid impostor to anchor to
  13617. * @param length ratio across rope from 0 to 1
  13618. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13619. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13620. * @returns impostor the rope imposter
  13621. */
  13622. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13623. /**
  13624. * Will keep this body still, in a sleep mode.
  13625. * @returns the physics imposter
  13626. */
  13627. sleep(): PhysicsImpostor;
  13628. /**
  13629. * Wake the body up.
  13630. * @returns The physics imposter
  13631. */
  13632. wakeUp(): PhysicsImpostor;
  13633. /**
  13634. * Clones the physics imposter
  13635. * @param newObject The physics imposter clones to this physics-enabled object
  13636. * @returns A nullable physics imposter
  13637. */
  13638. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13639. /**
  13640. * Disposes the physics imposter
  13641. */
  13642. dispose(): void;
  13643. /**
  13644. * Sets the delta position
  13645. * @param position The delta position amount
  13646. */
  13647. setDeltaPosition(position: Vector3): void;
  13648. /**
  13649. * Sets the delta rotation
  13650. * @param rotation The delta rotation amount
  13651. */
  13652. setDeltaRotation(rotation: Quaternion): void;
  13653. /**
  13654. * Gets the box size of the physics imposter and stores the result in the input parameter
  13655. * @param result Stores the box size
  13656. * @returns The physics imposter
  13657. */
  13658. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13659. /**
  13660. * Gets the radius of the physics imposter
  13661. * @returns Radius of the physics imposter
  13662. */
  13663. getRadius(): number;
  13664. /**
  13665. * Sync a bone with this impostor
  13666. * @param bone The bone to sync to the impostor.
  13667. * @param boneMesh The mesh that the bone is influencing.
  13668. * @param jointPivot The pivot of the joint / bone in local space.
  13669. * @param distToJoint Optional distance from the impostor to the joint.
  13670. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13671. */
  13672. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13673. /**
  13674. * Sync impostor to a bone
  13675. * @param bone The bone that the impostor will be synced to.
  13676. * @param boneMesh The mesh that the bone is influencing.
  13677. * @param jointPivot The pivot of the joint / bone in local space.
  13678. * @param distToJoint Optional distance from the impostor to the joint.
  13679. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13680. * @param boneAxis Optional vector3 axis the bone is aligned with
  13681. */
  13682. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13683. /**
  13684. * No-Imposter type
  13685. */
  13686. static NoImpostor: number;
  13687. /**
  13688. * Sphere-Imposter type
  13689. */
  13690. static SphereImpostor: number;
  13691. /**
  13692. * Box-Imposter type
  13693. */
  13694. static BoxImpostor: number;
  13695. /**
  13696. * Plane-Imposter type
  13697. */
  13698. static PlaneImpostor: number;
  13699. /**
  13700. * Mesh-imposter type
  13701. */
  13702. static MeshImpostor: number;
  13703. /**
  13704. * Capsule-Impostor type (Ammo.js plugin only)
  13705. */
  13706. static CapsuleImpostor: number;
  13707. /**
  13708. * Cylinder-Imposter type
  13709. */
  13710. static CylinderImpostor: number;
  13711. /**
  13712. * Particle-Imposter type
  13713. */
  13714. static ParticleImpostor: number;
  13715. /**
  13716. * Heightmap-Imposter type
  13717. */
  13718. static HeightmapImpostor: number;
  13719. /**
  13720. * ConvexHull-Impostor type (Ammo.js plugin only)
  13721. */
  13722. static ConvexHullImpostor: number;
  13723. /**
  13724. * Rope-Imposter type
  13725. */
  13726. static RopeImpostor: number;
  13727. /**
  13728. * Cloth-Imposter type
  13729. */
  13730. static ClothImpostor: number;
  13731. /**
  13732. * Softbody-Imposter type
  13733. */
  13734. static SoftbodyImpostor: number;
  13735. }
  13736. }
  13737. declare module BABYLON {
  13738. /**
  13739. * @hidden
  13740. **/
  13741. export class _CreationDataStorage {
  13742. closePath?: boolean;
  13743. closeArray?: boolean;
  13744. idx: number[];
  13745. dashSize: number;
  13746. gapSize: number;
  13747. path3D: Path3D;
  13748. pathArray: Vector3[][];
  13749. arc: number;
  13750. radius: number;
  13751. cap: number;
  13752. tessellation: number;
  13753. }
  13754. /**
  13755. * @hidden
  13756. **/ private class _InstanceDataStorage {
  13757. visibleInstances: any;
  13758. batchCache: _InstancesBatch;
  13759. instancesBufferSize: number;
  13760. instancesBuffer: Nullable<Buffer>;
  13761. instancesData: Float32Array;
  13762. overridenInstanceCount: number;
  13763. isFrozen: boolean;
  13764. previousBatch: Nullable<_InstancesBatch>;
  13765. hardwareInstancedRendering: boolean;
  13766. sideOrientation: number;
  13767. }
  13768. /**
  13769. * @hidden
  13770. **/
  13771. export class _InstancesBatch {
  13772. mustReturn: boolean;
  13773. visibleInstances: Nullable<InstancedMesh[]>[];
  13774. renderSelf: boolean[];
  13775. hardwareInstancedRendering: boolean[];
  13776. }
  13777. /**
  13778. * Class used to represent renderable models
  13779. */
  13780. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13781. /**
  13782. * Mesh side orientation : usually the external or front surface
  13783. */
  13784. static readonly FRONTSIDE: number;
  13785. /**
  13786. * Mesh side orientation : usually the internal or back surface
  13787. */
  13788. static readonly BACKSIDE: number;
  13789. /**
  13790. * Mesh side orientation : both internal and external or front and back surfaces
  13791. */
  13792. static readonly DOUBLESIDE: number;
  13793. /**
  13794. * Mesh side orientation : by default, `FRONTSIDE`
  13795. */
  13796. static readonly DEFAULTSIDE: number;
  13797. /**
  13798. * Mesh cap setting : no cap
  13799. */
  13800. static readonly NO_CAP: number;
  13801. /**
  13802. * Mesh cap setting : one cap at the beginning of the mesh
  13803. */
  13804. static readonly CAP_START: number;
  13805. /**
  13806. * Mesh cap setting : one cap at the end of the mesh
  13807. */
  13808. static readonly CAP_END: number;
  13809. /**
  13810. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13811. */
  13812. static readonly CAP_ALL: number;
  13813. /**
  13814. * Mesh pattern setting : no flip or rotate
  13815. */
  13816. static readonly NO_FLIP: number;
  13817. /**
  13818. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13819. */
  13820. static readonly FLIP_TILE: number;
  13821. /**
  13822. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13823. */
  13824. static readonly ROTATE_TILE: number;
  13825. /**
  13826. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13827. */
  13828. static readonly FLIP_ROW: number;
  13829. /**
  13830. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13831. */
  13832. static readonly ROTATE_ROW: number;
  13833. /**
  13834. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13835. */
  13836. static readonly FLIP_N_ROTATE_TILE: number;
  13837. /**
  13838. * Mesh pattern setting : rotate pattern and rotate
  13839. */
  13840. static readonly FLIP_N_ROTATE_ROW: number;
  13841. /**
  13842. * Mesh tile positioning : part tiles same on left/right or top/bottom
  13843. */
  13844. static readonly CENTER: number;
  13845. /**
  13846. * Mesh tile positioning : part tiles on left
  13847. */
  13848. static readonly LEFT: number;
  13849. /**
  13850. * Mesh tile positioning : part tiles on right
  13851. */
  13852. static readonly RIGHT: number;
  13853. /**
  13854. * Mesh tile positioning : part tiles on top
  13855. */
  13856. static readonly TOP: number;
  13857. /**
  13858. * Mesh tile positioning : part tiles on bottom
  13859. */
  13860. static readonly BOTTOM: number;
  13861. /**
  13862. * Gets the default side orientation.
  13863. * @param orientation the orientation to value to attempt to get
  13864. * @returns the default orientation
  13865. * @hidden
  13866. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  13867. private _internalMeshDataInfo;
  13868. /**
  13869. * An event triggered before rendering the mesh
  13870. */
  13871. readonly onBeforeRenderObservable: Observable<Mesh>;
  13872. /**
  13873. * An event triggered before binding the mesh
  13874. */
  13875. readonly onBeforeBindObservable: Observable<Mesh>;
  13876. /**
  13877. * An event triggered after rendering the mesh
  13878. */
  13879. readonly onAfterRenderObservable: Observable<Mesh>;
  13880. /**
  13881. * An event triggered before drawing the mesh
  13882. */
  13883. readonly onBeforeDrawObservable: Observable<Mesh>;
  13884. private _onBeforeDrawObserver;
  13885. /**
  13886. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  13887. */
  13888. onBeforeDraw: () => void;
  13889. /**
  13890. * Gets the delay loading state of the mesh (when delay loading is turned on)
  13891. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  13892. */
  13893. delayLoadState: number;
  13894. /**
  13895. * Gets the list of instances created from this mesh
  13896. * it is not supposed to be modified manually.
  13897. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  13898. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  13899. */
  13900. instances: InstancedMesh[];
  13901. /**
  13902. * Gets the file containing delay loading data for this mesh
  13903. */
  13904. delayLoadingFile: string;
  13905. /** @hidden */ private _binaryInfo: any;
  13906. /**
  13907. * User defined function used to change how LOD level selection is done
  13908. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  13909. */
  13910. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  13911. /**
  13912. * Gets or sets the morph target manager
  13913. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  13914. */
  13915. morphTargetManager: Nullable<MorphTargetManager>;
  13916. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  13917. /** @hidden */ private _geometry: Nullable<Geometry>;
  13918. /** @hidden */ private _delayInfo: Array<string>;
  13919. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  13920. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  13921. private _effectiveMaterial;
  13922. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  13923. /** @hidden */ private _originalBuilderSideOrientation: number;
  13924. /**
  13925. * Use this property to change the original side orientation defined at construction time
  13926. */
  13927. overrideMaterialSideOrientation: Nullable<number>;
  13928. /**
  13929. * Gets the source mesh (the one used to clone this one from)
  13930. */
  13931. readonly source: Nullable<Mesh>;
  13932. /**
  13933. * Gets or sets a boolean indicating that this mesh does not use index buffer
  13934. */
  13935. isUnIndexed: boolean;
  13936. /**
  13937. * @constructor
  13938. * @param name The value used by scene.getMeshByName() to do a lookup.
  13939. * @param scene The scene to add this mesh to.
  13940. * @param parent The parent of this mesh, if it has one
  13941. * @param source An optional Mesh from which geometry is shared, cloned.
  13942. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  13943. * When false, achieved by calling a clone(), also passing False.
  13944. * This will make creation of children, recursive.
  13945. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  13946. */
  13947. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  13948. /**
  13949. * Gets the class name
  13950. * @returns the string "Mesh".
  13951. */
  13952. getClassName(): string;
  13953. /** @hidden */ protected readonly _isMesh: boolean;
  13954. /**
  13955. * Returns a description of this mesh
  13956. * @param fullDetails define if full details about this mesh must be used
  13957. * @returns a descriptive string representing this mesh
  13958. */
  13959. toString(fullDetails?: boolean): string;
  13960. /** @hidden */ private _unBindEffect(): void;
  13961. /**
  13962. * Gets a boolean indicating if this mesh has LOD
  13963. */
  13964. readonly hasLODLevels: boolean;
  13965. /**
  13966. * Gets the list of MeshLODLevel associated with the current mesh
  13967. * @returns an array of MeshLODLevel
  13968. */
  13969. getLODLevels(): MeshLODLevel[];
  13970. private _sortLODLevels;
  13971. /**
  13972. * Add a mesh as LOD level triggered at the given distance.
  13973. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13974. * @param distance The distance from the center of the object to show this level
  13975. * @param mesh The mesh to be added as LOD level (can be null)
  13976. * @return This mesh (for chaining)
  13977. */
  13978. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  13979. /**
  13980. * Returns the LOD level mesh at the passed distance or null if not found.
  13981. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13982. * @param distance The distance from the center of the object to show this level
  13983. * @returns a Mesh or `null`
  13984. */
  13985. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  13986. /**
  13987. * Remove a mesh from the LOD array
  13988. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13989. * @param mesh defines the mesh to be removed
  13990. * @return This mesh (for chaining)
  13991. */
  13992. removeLODLevel(mesh: Mesh): Mesh;
  13993. /**
  13994. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  13995. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13996. * @param camera defines the camera to use to compute distance
  13997. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  13998. * @return This mesh (for chaining)
  13999. */
  14000. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14001. /**
  14002. * Gets the mesh internal Geometry object
  14003. */
  14004. readonly geometry: Nullable<Geometry>;
  14005. /**
  14006. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14007. * @returns the total number of vertices
  14008. */
  14009. getTotalVertices(): number;
  14010. /**
  14011. * Returns the content of an associated vertex buffer
  14012. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14013. * - VertexBuffer.PositionKind
  14014. * - VertexBuffer.UVKind
  14015. * - VertexBuffer.UV2Kind
  14016. * - VertexBuffer.UV3Kind
  14017. * - VertexBuffer.UV4Kind
  14018. * - VertexBuffer.UV5Kind
  14019. * - VertexBuffer.UV6Kind
  14020. * - VertexBuffer.ColorKind
  14021. * - VertexBuffer.MatricesIndicesKind
  14022. * - VertexBuffer.MatricesIndicesExtraKind
  14023. * - VertexBuffer.MatricesWeightsKind
  14024. * - VertexBuffer.MatricesWeightsExtraKind
  14025. * @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
  14026. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14027. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14028. */
  14029. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14030. /**
  14031. * Returns the mesh VertexBuffer object from the requested `kind`
  14032. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14033. * - VertexBuffer.PositionKind
  14034. * - VertexBuffer.NormalKind
  14035. * - VertexBuffer.UVKind
  14036. * - VertexBuffer.UV2Kind
  14037. * - VertexBuffer.UV3Kind
  14038. * - VertexBuffer.UV4Kind
  14039. * - VertexBuffer.UV5Kind
  14040. * - VertexBuffer.UV6Kind
  14041. * - VertexBuffer.ColorKind
  14042. * - VertexBuffer.MatricesIndicesKind
  14043. * - VertexBuffer.MatricesIndicesExtraKind
  14044. * - VertexBuffer.MatricesWeightsKind
  14045. * - VertexBuffer.MatricesWeightsExtraKind
  14046. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14047. */
  14048. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14049. /**
  14050. * Tests if a specific vertex buffer is associated with this mesh
  14051. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14052. * - VertexBuffer.PositionKind
  14053. * - VertexBuffer.NormalKind
  14054. * - VertexBuffer.UVKind
  14055. * - VertexBuffer.UV2Kind
  14056. * - VertexBuffer.UV3Kind
  14057. * - VertexBuffer.UV4Kind
  14058. * - VertexBuffer.UV5Kind
  14059. * - VertexBuffer.UV6Kind
  14060. * - VertexBuffer.ColorKind
  14061. * - VertexBuffer.MatricesIndicesKind
  14062. * - VertexBuffer.MatricesIndicesExtraKind
  14063. * - VertexBuffer.MatricesWeightsKind
  14064. * - VertexBuffer.MatricesWeightsExtraKind
  14065. * @returns a boolean
  14066. */
  14067. isVerticesDataPresent(kind: string): boolean;
  14068. /**
  14069. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14070. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14071. * - VertexBuffer.PositionKind
  14072. * - VertexBuffer.UVKind
  14073. * - VertexBuffer.UV2Kind
  14074. * - VertexBuffer.UV3Kind
  14075. * - VertexBuffer.UV4Kind
  14076. * - VertexBuffer.UV5Kind
  14077. * - VertexBuffer.UV6Kind
  14078. * - VertexBuffer.ColorKind
  14079. * - VertexBuffer.MatricesIndicesKind
  14080. * - VertexBuffer.MatricesIndicesExtraKind
  14081. * - VertexBuffer.MatricesWeightsKind
  14082. * - VertexBuffer.MatricesWeightsExtraKind
  14083. * @returns a boolean
  14084. */
  14085. isVertexBufferUpdatable(kind: string): boolean;
  14086. /**
  14087. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14089. * - VertexBuffer.PositionKind
  14090. * - VertexBuffer.NormalKind
  14091. * - VertexBuffer.UVKind
  14092. * - VertexBuffer.UV2Kind
  14093. * - VertexBuffer.UV3Kind
  14094. * - VertexBuffer.UV4Kind
  14095. * - VertexBuffer.UV5Kind
  14096. * - VertexBuffer.UV6Kind
  14097. * - VertexBuffer.ColorKind
  14098. * - VertexBuffer.MatricesIndicesKind
  14099. * - VertexBuffer.MatricesIndicesExtraKind
  14100. * - VertexBuffer.MatricesWeightsKind
  14101. * - VertexBuffer.MatricesWeightsExtraKind
  14102. * @returns an array of strings
  14103. */
  14104. getVerticesDataKinds(): string[];
  14105. /**
  14106. * Returns a positive integer : the total number of indices in this mesh geometry.
  14107. * @returns the numner of indices or zero if the mesh has no geometry.
  14108. */
  14109. getTotalIndices(): number;
  14110. /**
  14111. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14112. * @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.
  14113. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14114. * @returns the indices array or an empty array if the mesh has no geometry
  14115. */
  14116. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14117. readonly isBlocked: boolean;
  14118. /**
  14119. * Determine if the current mesh is ready to be rendered
  14120. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14121. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14122. * @returns true if all associated assets are ready (material, textures, shaders)
  14123. */
  14124. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14125. /**
  14126. * 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.
  14127. */
  14128. readonly areNormalsFrozen: boolean;
  14129. /**
  14130. * 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.
  14131. * @returns the current mesh
  14132. */
  14133. freezeNormals(): Mesh;
  14134. /**
  14135. * 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
  14136. * @returns the current mesh
  14137. */
  14138. unfreezeNormals(): Mesh;
  14139. /**
  14140. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14141. */
  14142. overridenInstanceCount: number;
  14143. /** @hidden */ private _preActivate(): Mesh;
  14144. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  14145. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14146. /**
  14147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14148. * This means the mesh underlying bounding box and sphere are recomputed.
  14149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14150. * @returns the current mesh
  14151. */
  14152. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14153. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14154. /**
  14155. * This function will subdivide the mesh into multiple submeshes
  14156. * @param count defines the expected number of submeshes
  14157. */
  14158. subdivide(count: number): void;
  14159. /**
  14160. * Copy a FloatArray into a specific associated vertex buffer
  14161. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14162. * - VertexBuffer.PositionKind
  14163. * - VertexBuffer.UVKind
  14164. * - VertexBuffer.UV2Kind
  14165. * - VertexBuffer.UV3Kind
  14166. * - VertexBuffer.UV4Kind
  14167. * - VertexBuffer.UV5Kind
  14168. * - VertexBuffer.UV6Kind
  14169. * - VertexBuffer.ColorKind
  14170. * - VertexBuffer.MatricesIndicesKind
  14171. * - VertexBuffer.MatricesIndicesExtraKind
  14172. * - VertexBuffer.MatricesWeightsKind
  14173. * - VertexBuffer.MatricesWeightsExtraKind
  14174. * @param data defines the data source
  14175. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14176. * @param stride defines the data stride size (can be null)
  14177. * @returns the current mesh
  14178. */
  14179. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14180. /**
  14181. * Flags an associated vertex buffer as updatable
  14182. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14183. * - VertexBuffer.PositionKind
  14184. * - VertexBuffer.UVKind
  14185. * - VertexBuffer.UV2Kind
  14186. * - VertexBuffer.UV3Kind
  14187. * - VertexBuffer.UV4Kind
  14188. * - VertexBuffer.UV5Kind
  14189. * - VertexBuffer.UV6Kind
  14190. * - VertexBuffer.ColorKind
  14191. * - VertexBuffer.MatricesIndicesKind
  14192. * - VertexBuffer.MatricesIndicesExtraKind
  14193. * - VertexBuffer.MatricesWeightsKind
  14194. * - VertexBuffer.MatricesWeightsExtraKind
  14195. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14196. */
  14197. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14198. /**
  14199. * Sets the mesh global Vertex Buffer
  14200. * @param buffer defines the buffer to use
  14201. * @returns the current mesh
  14202. */
  14203. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14204. /**
  14205. * Update a specific associated vertex buffer
  14206. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14207. * - VertexBuffer.PositionKind
  14208. * - VertexBuffer.UVKind
  14209. * - VertexBuffer.UV2Kind
  14210. * - VertexBuffer.UV3Kind
  14211. * - VertexBuffer.UV4Kind
  14212. * - VertexBuffer.UV5Kind
  14213. * - VertexBuffer.UV6Kind
  14214. * - VertexBuffer.ColorKind
  14215. * - VertexBuffer.MatricesIndicesKind
  14216. * - VertexBuffer.MatricesIndicesExtraKind
  14217. * - VertexBuffer.MatricesWeightsKind
  14218. * - VertexBuffer.MatricesWeightsExtraKind
  14219. * @param data defines the data source
  14220. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14221. * @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)
  14222. * @returns the current mesh
  14223. */
  14224. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14225. /**
  14226. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14227. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14228. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14229. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14230. * @returns the current mesh
  14231. */
  14232. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14233. /**
  14234. * Creates a un-shared specific occurence of the geometry for the mesh.
  14235. * @returns the current mesh
  14236. */
  14237. makeGeometryUnique(): Mesh;
  14238. /**
  14239. * Set the index buffer of this mesh
  14240. * @param indices defines the source data
  14241. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14242. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14243. * @returns the current mesh
  14244. */
  14245. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14246. /**
  14247. * Update the current index buffer
  14248. * @param indices defines the source data
  14249. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14250. * @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)
  14251. * @returns the current mesh
  14252. */
  14253. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14254. /**
  14255. * Invert the geometry to move from a right handed system to a left handed one.
  14256. * @returns the current mesh
  14257. */
  14258. toLeftHanded(): Mesh;
  14259. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14260. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14261. /**
  14262. * Registers for this mesh a javascript function called just before the rendering process
  14263. * @param func defines the function to call before rendering this mesh
  14264. * @returns the current mesh
  14265. */
  14266. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14267. /**
  14268. * Disposes a previously registered javascript function called before the rendering
  14269. * @param func defines the function to remove
  14270. * @returns the current mesh
  14271. */
  14272. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14273. /**
  14274. * Registers for this mesh a javascript function called just after the rendering is complete
  14275. * @param func defines the function to call after rendering this mesh
  14276. * @returns the current mesh
  14277. */
  14278. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14279. /**
  14280. * Disposes a previously registered javascript function called after the rendering.
  14281. * @param func defines the function to remove
  14282. * @returns the current mesh
  14283. */
  14284. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14285. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14286. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14287. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14288. /** @hidden */ private _rebuild(): void;
  14289. /** @hidden */ private _freeze(): void;
  14290. /** @hidden */ private _unFreeze(): void;
  14291. /**
  14292. * 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
  14293. * @param subMesh defines the subMesh to render
  14294. * @param enableAlphaMode defines if alpha mode can be changed
  14295. * @returns the current mesh
  14296. */
  14297. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14298. private _onBeforeDraw;
  14299. /**
  14300. * Renormalize the mesh and patch it up if there are no weights
  14301. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14302. * However in the case of zero weights then we set just a single influence to 1.
  14303. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14304. */
  14305. cleanMatrixWeights(): void;
  14306. private normalizeSkinFourWeights;
  14307. private normalizeSkinWeightsAndExtra;
  14308. /**
  14309. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14310. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14311. * the user know there was an issue with importing the mesh
  14312. * @returns a validation object with skinned, valid and report string
  14313. */
  14314. validateSkinning(): {
  14315. skinned: boolean;
  14316. valid: boolean;
  14317. report: string;
  14318. };
  14319. /** @hidden */ private _checkDelayState(): Mesh;
  14320. private _queueLoad;
  14321. /**
  14322. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14323. * A mesh is in the frustum if its bounding box intersects the frustum
  14324. * @param frustumPlanes defines the frustum to test
  14325. * @returns true if the mesh is in the frustum planes
  14326. */
  14327. isInFrustum(frustumPlanes: Plane[]): boolean;
  14328. /**
  14329. * Sets the mesh material by the material or multiMaterial `id` property
  14330. * @param id is a string identifying the material or the multiMaterial
  14331. * @returns the current mesh
  14332. */
  14333. setMaterialByID(id: string): Mesh;
  14334. /**
  14335. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14336. * @returns an array of IAnimatable
  14337. */
  14338. getAnimatables(): IAnimatable[];
  14339. /**
  14340. * Modifies the mesh geometry according to the passed transformation matrix.
  14341. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14342. * The mesh normals are modified using the same transformation.
  14343. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14344. * @param transform defines the transform matrix to use
  14345. * @see http://doc.babylonjs.com/resources/baking_transformations
  14346. * @returns the current mesh
  14347. */
  14348. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14349. /**
  14350. * Modifies the mesh geometry according to its own current World Matrix.
  14351. * The mesh World Matrix is then reset.
  14352. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14353. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14354. * @see http://doc.babylonjs.com/resources/baking_transformations
  14355. * @returns the current mesh
  14356. */
  14357. bakeCurrentTransformIntoVertices(): Mesh;
  14358. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  14359. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  14360. /** @hidden */ private _generatePointsArray(): boolean;
  14361. /**
  14362. * Returns a new Mesh object generated from the current mesh properties.
  14363. * This method must not get confused with createInstance()
  14364. * @param name is a string, the name given to the new mesh
  14365. * @param newParent can be any Node object (default `null`)
  14366. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14367. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14368. * @returns a new mesh
  14369. */
  14370. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14371. /**
  14372. * Releases resources associated with this mesh.
  14373. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14374. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14375. */
  14376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14377. /**
  14378. * Modifies the mesh geometry according to a displacement map.
  14379. * 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.
  14380. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14381. * @param url is a string, the URL from the image file is to be downloaded.
  14382. * @param minHeight is the lower limit of the displacement.
  14383. * @param maxHeight is the upper limit of the displacement.
  14384. * @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.
  14385. * @param uvOffset is an optional vector2 used to offset UV.
  14386. * @param uvScale is an optional vector2 used to scale UV.
  14387. * @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.
  14388. * @returns the Mesh.
  14389. */
  14390. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14391. /**
  14392. * Modifies the mesh geometry according to a displacementMap buffer.
  14393. * 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.
  14394. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14395. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14396. * @param heightMapWidth is the width of the buffer image.
  14397. * @param heightMapHeight is the height of the buffer image.
  14398. * @param minHeight is the lower limit of the displacement.
  14399. * @param maxHeight is the upper limit of the displacement.
  14400. * @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.
  14401. * @param uvOffset is an optional vector2 used to offset UV.
  14402. * @param uvScale is an optional vector2 used to scale UV.
  14403. * @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.
  14404. * @returns the Mesh.
  14405. */
  14406. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14407. /**
  14408. * Modify the mesh to get a flat shading rendering.
  14409. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14410. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14411. * @returns current mesh
  14412. */
  14413. convertToFlatShadedMesh(): Mesh;
  14414. /**
  14415. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14416. * In other words, more vertices, no more indices and a single bigger VBO.
  14417. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14418. * @returns current mesh
  14419. */
  14420. convertToUnIndexedMesh(): Mesh;
  14421. /**
  14422. * Inverses facet orientations.
  14423. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14424. * @param flipNormals will also inverts the normals
  14425. * @returns current mesh
  14426. */
  14427. flipFaces(flipNormals?: boolean): Mesh;
  14428. /**
  14429. * Increase the number of facets and hence vertices in a mesh
  14430. * Vertex normals are interpolated from existing vertex normals
  14431. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14432. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14433. */
  14434. increaseVertices(numberPerEdge: number): void;
  14435. /**
  14436. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14437. * This will undo any application of covertToFlatShadedMesh
  14438. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14439. */
  14440. forceSharedVertices(): void;
  14441. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14442. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14443. /**
  14444. * Creates a new InstancedMesh object from the mesh model.
  14445. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14446. * @param name defines the name of the new instance
  14447. * @returns a new InstancedMesh
  14448. */
  14449. createInstance(name: string): InstancedMesh;
  14450. /**
  14451. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14452. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14453. * @returns the current mesh
  14454. */
  14455. synchronizeInstances(): Mesh;
  14456. /**
  14457. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14458. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14459. * This should be used together with the simplification to avoid disappearing triangles.
  14460. * @param successCallback an optional success callback to be called after the optimization finished.
  14461. * @returns the current mesh
  14462. */
  14463. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14464. /**
  14465. * Serialize current mesh
  14466. * @param serializationObject defines the object which will receive the serialization data
  14467. */
  14468. serialize(serializationObject: any): void;
  14469. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  14470. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14471. /**
  14472. * Returns a new Mesh object parsed from the source provided.
  14473. * @param parsedMesh is the source
  14474. * @param scene defines the hosting scene
  14475. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14476. * @returns a new Mesh
  14477. */
  14478. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14479. /**
  14480. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14481. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14482. * @param name defines the name of the mesh to create
  14483. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14484. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14485. * @param closePath creates a seam between the first and the last points of each path of the path array
  14486. * @param offset is taken in account only if the `pathArray` is containing a single path
  14487. * @param scene defines the hosting scene
  14488. * @param updatable defines if the mesh must be flagged as updatable
  14489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14490. * @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)
  14491. * @returns a new Mesh
  14492. */
  14493. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14494. /**
  14495. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14496. * @param name defines the name of the mesh to create
  14497. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14498. * @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
  14499. * @param scene defines the hosting scene
  14500. * @param updatable defines if the mesh must be flagged as updatable
  14501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14502. * @returns a new Mesh
  14503. */
  14504. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14505. /**
  14506. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14507. * @param name defines the name of the mesh to create
  14508. * @param size sets the size (float) of each box side (default 1)
  14509. * @param scene defines the hosting scene
  14510. * @param updatable defines if the mesh must be flagged as updatable
  14511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14512. * @returns a new Mesh
  14513. */
  14514. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14515. /**
  14516. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14517. * @param name defines the name of the mesh to create
  14518. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14519. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14520. * @param scene defines the hosting scene
  14521. * @param updatable defines if the mesh must be flagged as updatable
  14522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14523. * @returns a new Mesh
  14524. */
  14525. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14526. /**
  14527. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14528. * @param name defines the name of the mesh to create
  14529. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14530. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14531. * @param scene defines the hosting scene
  14532. * @returns a new Mesh
  14533. */
  14534. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14535. /**
  14536. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14537. * @param name defines the name of the mesh to create
  14538. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14539. * @param diameterTop set the top cap diameter (floats, default 1)
  14540. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14541. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14542. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14543. * @param scene defines the hosting scene
  14544. * @param updatable defines if the mesh must be flagged as updatable
  14545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14546. * @returns a new Mesh
  14547. */
  14548. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14549. /**
  14550. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14551. * @param name defines the name of the mesh to create
  14552. * @param diameter sets the diameter size (float) of the torus (default 1)
  14553. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14554. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14555. * @param scene defines the hosting scene
  14556. * @param updatable defines if the mesh must be flagged as updatable
  14557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14558. * @returns a new Mesh
  14559. */
  14560. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14561. /**
  14562. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14563. * @param name defines the name of the mesh to create
  14564. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14565. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14566. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14567. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14568. * @param p the number of windings on X axis (positive integers, default 2)
  14569. * @param q the number of windings on Y axis (positive integers, default 3)
  14570. * @param scene defines the hosting scene
  14571. * @param updatable defines if the mesh must be flagged as updatable
  14572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14573. * @returns a new Mesh
  14574. */
  14575. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14576. /**
  14577. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14578. * @param name defines the name of the mesh to create
  14579. * @param points is an array successive Vector3
  14580. * @param scene defines the hosting scene
  14581. * @param updatable defines if the mesh must be flagged as updatable
  14582. * @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).
  14583. * @returns a new Mesh
  14584. */
  14585. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14586. /**
  14587. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14588. * @param name defines the name of the mesh to create
  14589. * @param points is an array successive Vector3
  14590. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14591. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14592. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14593. * @param scene defines the hosting scene
  14594. * @param updatable defines if the mesh must be flagged as updatable
  14595. * @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)
  14596. * @returns a new Mesh
  14597. */
  14598. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14599. /**
  14600. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14601. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14602. * 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.
  14603. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14604. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14605. * Remember you can only change the shape positions, not their number when updating a polygon.
  14606. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14607. * @param name defines the name of the mesh to create
  14608. * @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
  14609. * @param scene defines the hosting scene
  14610. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14611. * @param updatable defines if the mesh must be flagged as updatable
  14612. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14613. * @param earcutInjection can be used to inject your own earcut reference
  14614. * @returns a new Mesh
  14615. */
  14616. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14617. /**
  14618. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14619. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14620. * @param name defines the name of the mesh to create
  14621. * @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
  14622. * @param depth defines the height of extrusion
  14623. * @param scene defines the hosting scene
  14624. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14625. * @param updatable defines if the mesh must be flagged as updatable
  14626. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14627. * @param earcutInjection can be used to inject your own earcut reference
  14628. * @returns a new Mesh
  14629. */
  14630. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14631. /**
  14632. * Creates an extruded shape mesh.
  14633. * 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
  14634. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14635. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14636. * @param name defines the name of the mesh to create
  14637. * @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
  14638. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14639. * @param scale is the value to scale the shape
  14640. * @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
  14641. * @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
  14642. * @param scene defines the hosting scene
  14643. * @param updatable defines if the mesh must be flagged as updatable
  14644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14645. * @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)
  14646. * @returns a new Mesh
  14647. */
  14648. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14649. /**
  14650. * Creates an custom extruded shape mesh.
  14651. * The custom extrusion is a parametric shape.
  14652. * It has no predefined shape. Its final shape will depend on the input parameters.
  14653. * Please consider using the same method from the MeshBuilder class instead
  14654. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14655. * @param name defines the name of the mesh to create
  14656. * @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
  14657. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14658. * @param scaleFunction is a custom Javascript function called on each path point
  14659. * @param rotationFunction is a custom Javascript function called on each path point
  14660. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14661. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14662. * @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
  14663. * @param scene defines the hosting scene
  14664. * @param updatable defines if the mesh must be flagged as updatable
  14665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14666. * @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)
  14667. * @returns a new Mesh
  14668. */
  14669. 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;
  14670. /**
  14671. * Creates lathe mesh.
  14672. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14673. * Please consider using the same method from the MeshBuilder class instead
  14674. * @param name defines the name of the mesh to create
  14675. * @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
  14676. * @param radius is the radius value of the lathe
  14677. * @param tessellation is the side number of the lathe.
  14678. * @param scene defines the hosting scene
  14679. * @param updatable defines if the mesh must be flagged as updatable
  14680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14681. * @returns a new Mesh
  14682. */
  14683. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14684. /**
  14685. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14686. * @param name defines the name of the mesh to create
  14687. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14688. * @param scene defines the hosting scene
  14689. * @param updatable defines if the mesh must be flagged as updatable
  14690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14691. * @returns a new Mesh
  14692. */
  14693. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14694. /**
  14695. * Creates a ground mesh.
  14696. * Please consider using the same method from the MeshBuilder class instead
  14697. * @param name defines the name of the mesh to create
  14698. * @param width set the width of the ground
  14699. * @param height set the height of the ground
  14700. * @param subdivisions sets the number of subdivisions per side
  14701. * @param scene defines the hosting scene
  14702. * @param updatable defines if the mesh must be flagged as updatable
  14703. * @returns a new Mesh
  14704. */
  14705. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14706. /**
  14707. * Creates a tiled ground mesh.
  14708. * Please consider using the same method from the MeshBuilder class instead
  14709. * @param name defines the name of the mesh to create
  14710. * @param xmin set the ground minimum X coordinate
  14711. * @param zmin set the ground minimum Y coordinate
  14712. * @param xmax set the ground maximum X coordinate
  14713. * @param zmax set the ground maximum Z coordinate
  14714. * @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
  14715. * @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
  14716. * @param scene defines the hosting scene
  14717. * @param updatable defines if the mesh must be flagged as updatable
  14718. * @returns a new Mesh
  14719. */
  14720. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14721. w: number;
  14722. h: number;
  14723. }, precision: {
  14724. w: number;
  14725. h: number;
  14726. }, scene: Scene, updatable?: boolean): Mesh;
  14727. /**
  14728. * Creates a ground mesh from a height map.
  14729. * Please consider using the same method from the MeshBuilder class instead
  14730. * @see http://doc.babylonjs.com/babylon101/height_map
  14731. * @param name defines the name of the mesh to create
  14732. * @param url sets the URL of the height map image resource
  14733. * @param width set the ground width size
  14734. * @param height set the ground height size
  14735. * @param subdivisions sets the number of subdivision per side
  14736. * @param minHeight is the minimum altitude on the ground
  14737. * @param maxHeight is the maximum altitude on the ground
  14738. * @param scene defines the hosting scene
  14739. * @param updatable defines if the mesh must be flagged as updatable
  14740. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14741. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14742. * @returns a new Mesh
  14743. */
  14744. 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;
  14745. /**
  14746. * Creates a tube mesh.
  14747. * The tube is a parametric shape.
  14748. * It has no predefined shape. Its final shape will depend on the input parameters.
  14749. * Please consider using the same method from the MeshBuilder class instead
  14750. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14751. * @param name defines the name of the mesh to create
  14752. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14753. * @param radius sets the tube radius size
  14754. * @param tessellation is the number of sides on the tubular surface
  14755. * @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
  14756. * @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
  14757. * @param scene defines the hosting scene
  14758. * @param updatable defines if the mesh must be flagged as updatable
  14759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14760. * @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)
  14761. * @returns a new Mesh
  14762. */
  14763. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14764. (i: number, distance: number): number;
  14765. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14766. /**
  14767. * Creates a polyhedron mesh.
  14768. * Please consider using the same method from the MeshBuilder class instead.
  14769. * * 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
  14770. * * The parameter `size` (positive float, default 1) sets the polygon size
  14771. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14772. * * 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`
  14773. * * 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
  14774. * * 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)`)
  14775. * * 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
  14776. * * 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
  14777. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14778. * * 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
  14779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14780. * @param name defines the name of the mesh to create
  14781. * @param options defines the options used to create the mesh
  14782. * @param scene defines the hosting scene
  14783. * @returns a new Mesh
  14784. */
  14785. static CreatePolyhedron(name: string, options: {
  14786. type?: number;
  14787. size?: number;
  14788. sizeX?: number;
  14789. sizeY?: number;
  14790. sizeZ?: number;
  14791. custom?: any;
  14792. faceUV?: Vector4[];
  14793. faceColors?: Color4[];
  14794. updatable?: boolean;
  14795. sideOrientation?: number;
  14796. }, scene: Scene): Mesh;
  14797. /**
  14798. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14799. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14800. * * 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`)
  14801. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14802. * * 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
  14803. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14804. * * 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
  14805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14806. * @param name defines the name of the mesh
  14807. * @param options defines the options used to create the mesh
  14808. * @param scene defines the hosting scene
  14809. * @returns a new Mesh
  14810. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  14811. */
  14812. static CreateIcoSphere(name: string, options: {
  14813. radius?: number;
  14814. flat?: boolean;
  14815. subdivisions?: number;
  14816. sideOrientation?: number;
  14817. updatable?: boolean;
  14818. }, scene: Scene): Mesh;
  14819. /**
  14820. * Creates a decal mesh.
  14821. * Please consider using the same method from the MeshBuilder class instead.
  14822. * A decal is a mesh usually applied as a model onto the surface of another mesh
  14823. * @param name defines the name of the mesh
  14824. * @param sourceMesh defines the mesh receiving the decal
  14825. * @param position sets the position of the decal in world coordinates
  14826. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  14827. * @param size sets the decal scaling
  14828. * @param angle sets the angle to rotate the decal
  14829. * @returns a new Mesh
  14830. */
  14831. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  14832. /**
  14833. * Prepare internal position array for software CPU skinning
  14834. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  14835. */
  14836. setPositionsForCPUSkinning(): Float32Array;
  14837. /**
  14838. * Prepare internal normal array for software CPU skinning
  14839. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  14840. */
  14841. setNormalsForCPUSkinning(): Float32Array;
  14842. /**
  14843. * Updates the vertex buffer by applying transformation from the bones
  14844. * @param skeleton defines the skeleton to apply to current mesh
  14845. * @returns the current mesh
  14846. */
  14847. applySkeleton(skeleton: Skeleton): Mesh;
  14848. /**
  14849. * 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
  14850. * @param meshes defines the list of meshes to scan
  14851. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  14852. */
  14853. static MinMax(meshes: AbstractMesh[]): {
  14854. min: Vector3;
  14855. max: Vector3;
  14856. };
  14857. /**
  14858. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  14859. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  14860. * @returns a vector3
  14861. */
  14862. static Center(meshesOrMinMaxVector: {
  14863. min: Vector3;
  14864. max: Vector3;
  14865. } | AbstractMesh[]): Vector3;
  14866. /**
  14867. * Merge the array of meshes into a single mesh for performance reasons.
  14868. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  14869. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  14870. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  14871. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  14872. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  14873. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  14874. * @returns a new mesh
  14875. */
  14876. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  14877. /** @hidden */
  14878. addInstance(instance: InstancedMesh): void;
  14879. /** @hidden */
  14880. removeInstance(instance: InstancedMesh): void;
  14881. }
  14882. }
  14883. declare module BABYLON {
  14884. /**
  14885. * Interface used to define Action
  14886. */
  14887. export interface IAction {
  14888. /**
  14889. * Trigger for the action
  14890. */
  14891. trigger: number;
  14892. /** Options of the trigger */
  14893. triggerOptions: any;
  14894. /**
  14895. * Gets the trigger parameters
  14896. * @returns the trigger parameters
  14897. */
  14898. getTriggerParameter(): any;
  14899. /**
  14900. * Internal only - executes current action event
  14901. * @hidden
  14902. */ private _executeCurrent(evt?: ActionEvent): void;
  14903. /**
  14904. * Serialize placeholder for child classes
  14905. * @param parent of child
  14906. * @returns the serialized object
  14907. */
  14908. serialize(parent: any): any;
  14909. /**
  14910. * Internal only
  14911. * @hidden
  14912. */ private _prepare(): void;
  14913. /**
  14914. * Internal only - manager for action
  14915. * @hidden
  14916. */ private _actionManager: AbstractActionManager;
  14917. /**
  14918. * Adds action to chain of actions, may be a DoNothingAction
  14919. * @param action defines the next action to execute
  14920. * @returns The action passed in
  14921. * @see https://www.babylonjs-playground.com/#1T30HR#0
  14922. */
  14923. then(action: IAction): IAction;
  14924. }
  14925. /**
  14926. * The action to be carried out following a trigger
  14927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  14928. */
  14929. export class Action implements IAction {
  14930. /** the trigger, with or without parameters, for the action */
  14931. triggerOptions: any;
  14932. /**
  14933. * Trigger for the action
  14934. */
  14935. trigger: number;
  14936. /**
  14937. * Internal only - manager for action
  14938. * @hidden
  14939. */ private _actionManager: ActionManager;
  14940. private _nextActiveAction;
  14941. private _child;
  14942. private _condition?;
  14943. private _triggerParameter;
  14944. /**
  14945. * An event triggered prior to action being executed.
  14946. */
  14947. onBeforeExecuteObservable: Observable<Action>;
  14948. /**
  14949. * Creates a new Action
  14950. * @param triggerOptions the trigger, with or without parameters, for the action
  14951. * @param condition an optional determinant of action
  14952. */
  14953. constructor(
  14954. /** the trigger, with or without parameters, for the action */
  14955. triggerOptions: any, condition?: Condition);
  14956. /**
  14957. * Internal only
  14958. * @hidden
  14959. */ private _prepare(): void;
  14960. /**
  14961. * Gets the trigger parameters
  14962. * @returns the trigger parameters
  14963. */
  14964. getTriggerParameter(): any;
  14965. /**
  14966. * Internal only - executes current action event
  14967. * @hidden
  14968. */ private _executeCurrent(evt?: ActionEvent): void;
  14969. /**
  14970. * Execute placeholder for child classes
  14971. * @param evt optional action event
  14972. */
  14973. execute(evt?: ActionEvent): void;
  14974. /**
  14975. * Skips to next active action
  14976. */
  14977. skipToNextActiveAction(): void;
  14978. /**
  14979. * Adds action to chain of actions, may be a DoNothingAction
  14980. * @param action defines the next action to execute
  14981. * @returns The action passed in
  14982. * @see https://www.babylonjs-playground.com/#1T30HR#0
  14983. */
  14984. then(action: Action): Action;
  14985. /**
  14986. * Internal only
  14987. * @hidden
  14988. */ private _getProperty(propertyPath: string): string;
  14989. /**
  14990. * Internal only
  14991. * @hidden
  14992. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  14993. /**
  14994. * Serialize placeholder for child classes
  14995. * @param parent of child
  14996. * @returns the serialized object
  14997. */
  14998. serialize(parent: any): any;
  14999. /**
  15000. * Internal only called by serialize
  15001. * @hidden
  15002. */
  15003. protected _serialize(serializedAction: any, parent?: any): any;
  15004. /**
  15005. * Internal only
  15006. * @hidden
  15007. */ private static _SerializeValueAsString: (value: any) => string;
  15008. /**
  15009. * Internal only
  15010. * @hidden
  15011. */ private static _GetTargetProperty: (target: Scene | Node) => {
  15012. name: string;
  15013. targetType: string;
  15014. value: string;
  15015. };
  15016. }
  15017. }
  15018. declare module BABYLON {
  15019. /**
  15020. * A Condition applied to an Action
  15021. */
  15022. export class Condition {
  15023. /**
  15024. * Internal only - manager for action
  15025. * @hidden
  15026. */ private _actionManager: ActionManager;
  15027. /**
  15028. * Internal only
  15029. * @hidden
  15030. */ private _evaluationId: number;
  15031. /**
  15032. * Internal only
  15033. * @hidden
  15034. */ private _currentResult: boolean;
  15035. /**
  15036. * Creates a new Condition
  15037. * @param actionManager the manager of the action the condition is applied to
  15038. */
  15039. constructor(actionManager: ActionManager);
  15040. /**
  15041. * Check if the current condition is valid
  15042. * @returns a boolean
  15043. */
  15044. isValid(): boolean;
  15045. /**
  15046. * Internal only
  15047. * @hidden
  15048. */ private _getProperty(propertyPath: string): string;
  15049. /**
  15050. * Internal only
  15051. * @hidden
  15052. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  15053. /**
  15054. * Serialize placeholder for child classes
  15055. * @returns the serialized object
  15056. */
  15057. serialize(): any;
  15058. /**
  15059. * Internal only
  15060. * @hidden
  15061. */
  15062. protected _serialize(serializedCondition: any): any;
  15063. }
  15064. /**
  15065. * Defines specific conditional operators as extensions of Condition
  15066. */
  15067. export class ValueCondition extends Condition {
  15068. /** path to specify the property of the target the conditional operator uses */
  15069. propertyPath: string;
  15070. /** the value compared by the conditional operator against the current value of the property */
  15071. value: any;
  15072. /** the conditional operator, default ValueCondition.IsEqual */
  15073. operator: number;
  15074. /**
  15075. * Internal only
  15076. * @hidden
  15077. */
  15078. private static _IsEqual;
  15079. /**
  15080. * Internal only
  15081. * @hidden
  15082. */
  15083. private static _IsDifferent;
  15084. /**
  15085. * Internal only
  15086. * @hidden
  15087. */
  15088. private static _IsGreater;
  15089. /**
  15090. * Internal only
  15091. * @hidden
  15092. */
  15093. private static _IsLesser;
  15094. /**
  15095. * returns the number for IsEqual
  15096. */
  15097. static readonly IsEqual: number;
  15098. /**
  15099. * Returns the number for IsDifferent
  15100. */
  15101. static readonly IsDifferent: number;
  15102. /**
  15103. * Returns the number for IsGreater
  15104. */
  15105. static readonly IsGreater: number;
  15106. /**
  15107. * Returns the number for IsLesser
  15108. */
  15109. static readonly IsLesser: number;
  15110. /**
  15111. * Internal only The action manager for the condition
  15112. * @hidden
  15113. */ private _actionManager: ActionManager;
  15114. /**
  15115. * Internal only
  15116. * @hidden
  15117. */
  15118. private _target;
  15119. /**
  15120. * Internal only
  15121. * @hidden
  15122. */
  15123. private _effectiveTarget;
  15124. /**
  15125. * Internal only
  15126. * @hidden
  15127. */
  15128. private _property;
  15129. /**
  15130. * Creates a new ValueCondition
  15131. * @param actionManager manager for the action the condition applies to
  15132. * @param target for the action
  15133. * @param propertyPath path to specify the property of the target the conditional operator uses
  15134. * @param value the value compared by the conditional operator against the current value of the property
  15135. * @param operator the conditional operator, default ValueCondition.IsEqual
  15136. */
  15137. constructor(actionManager: ActionManager, target: any,
  15138. /** path to specify the property of the target the conditional operator uses */
  15139. propertyPath: string,
  15140. /** the value compared by the conditional operator against the current value of the property */
  15141. value: any,
  15142. /** the conditional operator, default ValueCondition.IsEqual */
  15143. operator?: number);
  15144. /**
  15145. * Compares the given value with the property value for the specified conditional operator
  15146. * @returns the result of the comparison
  15147. */
  15148. isValid(): boolean;
  15149. /**
  15150. * Serialize the ValueCondition into a JSON compatible object
  15151. * @returns serialization object
  15152. */
  15153. serialize(): any;
  15154. /**
  15155. * Gets the name of the conditional operator for the ValueCondition
  15156. * @param operator the conditional operator
  15157. * @returns the name
  15158. */
  15159. static GetOperatorName(operator: number): string;
  15160. }
  15161. /**
  15162. * Defines a predicate condition as an extension of Condition
  15163. */
  15164. export class PredicateCondition extends Condition {
  15165. /** defines the predicate function used to validate the condition */
  15166. predicate: () => boolean;
  15167. /**
  15168. * Internal only - manager for action
  15169. * @hidden
  15170. */ private _actionManager: ActionManager;
  15171. /**
  15172. * Creates a new PredicateCondition
  15173. * @param actionManager manager for the action the condition applies to
  15174. * @param predicate defines the predicate function used to validate the condition
  15175. */
  15176. constructor(actionManager: ActionManager,
  15177. /** defines the predicate function used to validate the condition */
  15178. predicate: () => boolean);
  15179. /**
  15180. * @returns the validity of the predicate condition
  15181. */
  15182. isValid(): boolean;
  15183. }
  15184. /**
  15185. * Defines a state condition as an extension of Condition
  15186. */
  15187. export class StateCondition extends Condition {
  15188. /** Value to compare with target state */
  15189. value: string;
  15190. /**
  15191. * Internal only - manager for action
  15192. * @hidden
  15193. */ private _actionManager: ActionManager;
  15194. /**
  15195. * Internal only
  15196. * @hidden
  15197. */
  15198. private _target;
  15199. /**
  15200. * Creates a new StateCondition
  15201. * @param actionManager manager for the action the condition applies to
  15202. * @param target of the condition
  15203. * @param value to compare with target state
  15204. */
  15205. constructor(actionManager: ActionManager, target: any,
  15206. /** Value to compare with target state */
  15207. value: string);
  15208. /**
  15209. * Gets a boolean indicating if the current condition is met
  15210. * @returns the validity of the state
  15211. */
  15212. isValid(): boolean;
  15213. /**
  15214. * Serialize the StateCondition into a JSON compatible object
  15215. * @returns serialization object
  15216. */
  15217. serialize(): any;
  15218. }
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * This defines an action responsible to toggle a boolean once triggered.
  15223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15224. */
  15225. export class SwitchBooleanAction extends Action {
  15226. /**
  15227. * The path to the boolean property in the target object
  15228. */
  15229. propertyPath: string;
  15230. private _target;
  15231. private _effectiveTarget;
  15232. private _property;
  15233. /**
  15234. * Instantiate the action
  15235. * @param triggerOptions defines the trigger options
  15236. * @param target defines the object containing the boolean
  15237. * @param propertyPath defines the path to the boolean property in the target object
  15238. * @param condition defines the trigger related conditions
  15239. */
  15240. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15241. /** @hidden */ private _prepare(): void;
  15242. /**
  15243. * Execute the action toggle the boolean value.
  15244. */
  15245. execute(): void;
  15246. /**
  15247. * Serializes the actions and its related information.
  15248. * @param parent defines the object to serialize in
  15249. * @returns the serialized object
  15250. */
  15251. serialize(parent: any): any;
  15252. }
  15253. /**
  15254. * This defines an action responsible to set a the state field of the target
  15255. * to a desired value once triggered.
  15256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15257. */
  15258. export class SetStateAction extends Action {
  15259. /**
  15260. * The value to store in the state field.
  15261. */
  15262. value: string;
  15263. private _target;
  15264. /**
  15265. * Instantiate the action
  15266. * @param triggerOptions defines the trigger options
  15267. * @param target defines the object containing the state property
  15268. * @param value defines the value to store in the state field
  15269. * @param condition defines the trigger related conditions
  15270. */
  15271. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15272. /**
  15273. * Execute the action and store the value on the target state property.
  15274. */
  15275. execute(): void;
  15276. /**
  15277. * Serializes the actions and its related information.
  15278. * @param parent defines the object to serialize in
  15279. * @returns the serialized object
  15280. */
  15281. serialize(parent: any): any;
  15282. }
  15283. /**
  15284. * This defines an action responsible to set a property of the target
  15285. * to a desired value once triggered.
  15286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15287. */
  15288. export class SetValueAction extends Action {
  15289. /**
  15290. * The path of the property to set in the target.
  15291. */
  15292. propertyPath: string;
  15293. /**
  15294. * The value to set in the property
  15295. */
  15296. value: any;
  15297. private _target;
  15298. private _effectiveTarget;
  15299. private _property;
  15300. /**
  15301. * Instantiate the action
  15302. * @param triggerOptions defines the trigger options
  15303. * @param target defines the object containing the property
  15304. * @param propertyPath defines the path of the property to set in the target
  15305. * @param value defines the value to set in the property
  15306. * @param condition defines the trigger related conditions
  15307. */
  15308. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15309. /** @hidden */ private _prepare(): void;
  15310. /**
  15311. * Execute the action and set the targetted property to the desired value.
  15312. */
  15313. execute(): void;
  15314. /**
  15315. * Serializes the actions and its related information.
  15316. * @param parent defines the object to serialize in
  15317. * @returns the serialized object
  15318. */
  15319. serialize(parent: any): any;
  15320. }
  15321. /**
  15322. * This defines an action responsible to increment the target value
  15323. * to a desired value once triggered.
  15324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15325. */
  15326. export class IncrementValueAction extends Action {
  15327. /**
  15328. * The path of the property to increment in the target.
  15329. */
  15330. propertyPath: string;
  15331. /**
  15332. * The value we should increment the property by.
  15333. */
  15334. value: any;
  15335. private _target;
  15336. private _effectiveTarget;
  15337. private _property;
  15338. /**
  15339. * Instantiate the action
  15340. * @param triggerOptions defines the trigger options
  15341. * @param target defines the object containing the property
  15342. * @param propertyPath defines the path of the property to increment in the target
  15343. * @param value defines the value value we should increment the property by
  15344. * @param condition defines the trigger related conditions
  15345. */
  15346. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15347. /** @hidden */ private _prepare(): void;
  15348. /**
  15349. * Execute the action and increment the target of the value amount.
  15350. */
  15351. execute(): void;
  15352. /**
  15353. * Serializes the actions and its related information.
  15354. * @param parent defines the object to serialize in
  15355. * @returns the serialized object
  15356. */
  15357. serialize(parent: any): any;
  15358. }
  15359. /**
  15360. * This defines an action responsible to start an animation once triggered.
  15361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15362. */
  15363. export class PlayAnimationAction extends Action {
  15364. /**
  15365. * Where the animation should start (animation frame)
  15366. */
  15367. from: number;
  15368. /**
  15369. * Where the animation should stop (animation frame)
  15370. */
  15371. to: number;
  15372. /**
  15373. * Define if the animation should loop or stop after the first play.
  15374. */
  15375. loop?: boolean;
  15376. private _target;
  15377. /**
  15378. * Instantiate the action
  15379. * @param triggerOptions defines the trigger options
  15380. * @param target defines the target animation or animation name
  15381. * @param from defines from where the animation should start (animation frame)
  15382. * @param end defines where the animation should stop (animation frame)
  15383. * @param loop defines if the animation should loop or stop after the first play
  15384. * @param condition defines the trigger related conditions
  15385. */
  15386. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15387. /** @hidden */ private _prepare(): void;
  15388. /**
  15389. * Execute the action and play the animation.
  15390. */
  15391. execute(): void;
  15392. /**
  15393. * Serializes the actions and its related information.
  15394. * @param parent defines the object to serialize in
  15395. * @returns the serialized object
  15396. */
  15397. serialize(parent: any): any;
  15398. }
  15399. /**
  15400. * This defines an action responsible to stop an animation once triggered.
  15401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15402. */
  15403. export class StopAnimationAction extends Action {
  15404. private _target;
  15405. /**
  15406. * Instantiate the action
  15407. * @param triggerOptions defines the trigger options
  15408. * @param target defines the target animation or animation name
  15409. * @param condition defines the trigger related conditions
  15410. */
  15411. constructor(triggerOptions: any, target: any, condition?: Condition);
  15412. /** @hidden */ private _prepare(): void;
  15413. /**
  15414. * Execute the action and stop the animation.
  15415. */
  15416. execute(): void;
  15417. /**
  15418. * Serializes the actions and its related information.
  15419. * @param parent defines the object to serialize in
  15420. * @returns the serialized object
  15421. */
  15422. serialize(parent: any): any;
  15423. }
  15424. /**
  15425. * This defines an action responsible that does nothing once triggered.
  15426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15427. */
  15428. export class DoNothingAction extends Action {
  15429. /**
  15430. * Instantiate the action
  15431. * @param triggerOptions defines the trigger options
  15432. * @param condition defines the trigger related conditions
  15433. */
  15434. constructor(triggerOptions?: any, condition?: Condition);
  15435. /**
  15436. * Execute the action and do nothing.
  15437. */
  15438. execute(): void;
  15439. /**
  15440. * Serializes the actions and its related information.
  15441. * @param parent defines the object to serialize in
  15442. * @returns the serialized object
  15443. */
  15444. serialize(parent: any): any;
  15445. }
  15446. /**
  15447. * This defines an action responsible to trigger several actions once triggered.
  15448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15449. */
  15450. export class CombineAction extends Action {
  15451. /**
  15452. * The list of aggregated animations to run.
  15453. */
  15454. children: Action[];
  15455. /**
  15456. * Instantiate the action
  15457. * @param triggerOptions defines the trigger options
  15458. * @param children defines the list of aggregated animations to run
  15459. * @param condition defines the trigger related conditions
  15460. */
  15461. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15462. /** @hidden */ private _prepare(): void;
  15463. /**
  15464. * Execute the action and executes all the aggregated actions.
  15465. */
  15466. execute(evt: ActionEvent): void;
  15467. /**
  15468. * Serializes the actions and its related information.
  15469. * @param parent defines the object to serialize in
  15470. * @returns the serialized object
  15471. */
  15472. serialize(parent: any): any;
  15473. }
  15474. /**
  15475. * This defines an action responsible to run code (external event) once triggered.
  15476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15477. */
  15478. export class ExecuteCodeAction extends Action {
  15479. /**
  15480. * The callback function to run.
  15481. */
  15482. func: (evt: ActionEvent) => void;
  15483. /**
  15484. * Instantiate the action
  15485. * @param triggerOptions defines the trigger options
  15486. * @param func defines the callback function to run
  15487. * @param condition defines the trigger related conditions
  15488. */
  15489. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15490. /**
  15491. * Execute the action and run the attached code.
  15492. */
  15493. execute(evt: ActionEvent): void;
  15494. }
  15495. /**
  15496. * This defines an action responsible to set the parent property of the target once triggered.
  15497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15498. */
  15499. export class SetParentAction extends Action {
  15500. private _parent;
  15501. private _target;
  15502. /**
  15503. * Instantiate the action
  15504. * @param triggerOptions defines the trigger options
  15505. * @param target defines the target containing the parent property
  15506. * @param parent defines from where the animation should start (animation frame)
  15507. * @param condition defines the trigger related conditions
  15508. */
  15509. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15510. /** @hidden */ private _prepare(): void;
  15511. /**
  15512. * Execute the action and set the parent property.
  15513. */
  15514. execute(): void;
  15515. /**
  15516. * Serializes the actions and its related information.
  15517. * @param parent defines the object to serialize in
  15518. * @returns the serialized object
  15519. */
  15520. serialize(parent: any): any;
  15521. }
  15522. }
  15523. declare module BABYLON {
  15524. /**
  15525. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15526. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15528. */
  15529. export class ActionManager extends AbstractActionManager {
  15530. /**
  15531. * Nothing
  15532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15533. */
  15534. static readonly NothingTrigger: number;
  15535. /**
  15536. * On pick
  15537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15538. */
  15539. static readonly OnPickTrigger: number;
  15540. /**
  15541. * On left pick
  15542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15543. */
  15544. static readonly OnLeftPickTrigger: number;
  15545. /**
  15546. * On right pick
  15547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15548. */
  15549. static readonly OnRightPickTrigger: number;
  15550. /**
  15551. * On center pick
  15552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15553. */
  15554. static readonly OnCenterPickTrigger: number;
  15555. /**
  15556. * On pick down
  15557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15558. */
  15559. static readonly OnPickDownTrigger: number;
  15560. /**
  15561. * On double pick
  15562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15563. */
  15564. static readonly OnDoublePickTrigger: number;
  15565. /**
  15566. * On pick up
  15567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15568. */
  15569. static readonly OnPickUpTrigger: number;
  15570. /**
  15571. * On pick out.
  15572. * This trigger will only be raised if you also declared a OnPickDown
  15573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15574. */
  15575. static readonly OnPickOutTrigger: number;
  15576. /**
  15577. * On long press
  15578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15579. */
  15580. static readonly OnLongPressTrigger: number;
  15581. /**
  15582. * On pointer over
  15583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15584. */
  15585. static readonly OnPointerOverTrigger: number;
  15586. /**
  15587. * On pointer out
  15588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15589. */
  15590. static readonly OnPointerOutTrigger: number;
  15591. /**
  15592. * On every frame
  15593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15594. */
  15595. static readonly OnEveryFrameTrigger: number;
  15596. /**
  15597. * On intersection enter
  15598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15599. */
  15600. static readonly OnIntersectionEnterTrigger: number;
  15601. /**
  15602. * On intersection exit
  15603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15604. */
  15605. static readonly OnIntersectionExitTrigger: number;
  15606. /**
  15607. * On key down
  15608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15609. */
  15610. static readonly OnKeyDownTrigger: number;
  15611. /**
  15612. * On key up
  15613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15614. */
  15615. static readonly OnKeyUpTrigger: number;
  15616. private _scene;
  15617. /**
  15618. * Creates a new action manager
  15619. * @param scene defines the hosting scene
  15620. */
  15621. constructor(scene: Scene);
  15622. /**
  15623. * Releases all associated resources
  15624. */
  15625. dispose(): void;
  15626. /**
  15627. * Gets hosting scene
  15628. * @returns the hosting scene
  15629. */
  15630. getScene(): Scene;
  15631. /**
  15632. * Does this action manager handles actions of any of the given triggers
  15633. * @param triggers defines the triggers to be tested
  15634. * @return a boolean indicating whether one (or more) of the triggers is handled
  15635. */
  15636. hasSpecificTriggers(triggers: number[]): boolean;
  15637. /**
  15638. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15639. * speed.
  15640. * @param triggerA defines the trigger to be tested
  15641. * @param triggerB defines the trigger to be tested
  15642. * @return a boolean indicating whether one (or more) of the triggers is handled
  15643. */
  15644. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15645. /**
  15646. * Does this action manager handles actions of a given trigger
  15647. * @param trigger defines the trigger to be tested
  15648. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15649. * @return whether the trigger is handled
  15650. */
  15651. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15652. /**
  15653. * Does this action manager has pointer triggers
  15654. */
  15655. readonly hasPointerTriggers: boolean;
  15656. /**
  15657. * Does this action manager has pick triggers
  15658. */
  15659. readonly hasPickTriggers: boolean;
  15660. /**
  15661. * Registers an action to this action manager
  15662. * @param action defines the action to be registered
  15663. * @return the action amended (prepared) after registration
  15664. */
  15665. registerAction(action: IAction): Nullable<IAction>;
  15666. /**
  15667. * Unregisters an action to this action manager
  15668. * @param action defines the action to be unregistered
  15669. * @return a boolean indicating whether the action has been unregistered
  15670. */
  15671. unregisterAction(action: IAction): Boolean;
  15672. /**
  15673. * Process a specific trigger
  15674. * @param trigger defines the trigger to process
  15675. * @param evt defines the event details to be processed
  15676. */
  15677. processTrigger(trigger: number, evt?: IActionEvent): void;
  15678. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  15679. /** @hidden */ private _getProperty(propertyPath: string): string;
  15680. /**
  15681. * Serialize this manager to a JSON object
  15682. * @param name defines the property name to store this manager
  15683. * @returns a JSON representation of this manager
  15684. */
  15685. serialize(name: string): any;
  15686. /**
  15687. * Creates a new ActionManager from a JSON data
  15688. * @param parsedActions defines the JSON data to read from
  15689. * @param object defines the hosting mesh
  15690. * @param scene defines the hosting scene
  15691. */
  15692. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15693. /**
  15694. * Get a trigger name by index
  15695. * @param trigger defines the trigger index
  15696. * @returns a trigger name
  15697. */
  15698. static GetTriggerName(trigger: number): string;
  15699. }
  15700. }
  15701. declare module BABYLON {
  15702. /**
  15703. * Class representing a ray with position and direction
  15704. */
  15705. export class Ray {
  15706. /** origin point */
  15707. origin: Vector3;
  15708. /** direction */
  15709. direction: Vector3;
  15710. /** length of the ray */
  15711. length: number;
  15712. private static readonly TmpVector3;
  15713. private _tmpRay;
  15714. /**
  15715. * Creates a new ray
  15716. * @param origin origin point
  15717. * @param direction direction
  15718. * @param length length of the ray
  15719. */
  15720. constructor(
  15721. /** origin point */
  15722. origin: Vector3,
  15723. /** direction */
  15724. direction: Vector3,
  15725. /** length of the ray */
  15726. length?: number);
  15727. /**
  15728. * Checks if the ray intersects a box
  15729. * @param minimum bound of the box
  15730. * @param maximum bound of the box
  15731. * @param intersectionTreshold extra extend to be added to the box in all direction
  15732. * @returns if the box was hit
  15733. */
  15734. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15735. /**
  15736. * Checks if the ray intersects a box
  15737. * @param box the bounding box to check
  15738. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15739. * @returns if the box was hit
  15740. */
  15741. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15742. /**
  15743. * If the ray hits a sphere
  15744. * @param sphere the bounding sphere to check
  15745. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15746. * @returns true if it hits the sphere
  15747. */
  15748. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15749. /**
  15750. * If the ray hits a triange
  15751. * @param vertex0 triangle vertex
  15752. * @param vertex1 triangle vertex
  15753. * @param vertex2 triangle vertex
  15754. * @returns intersection information if hit
  15755. */
  15756. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15757. /**
  15758. * Checks if ray intersects a plane
  15759. * @param plane the plane to check
  15760. * @returns the distance away it was hit
  15761. */
  15762. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15763. /**
  15764. * Checks if ray intersects a mesh
  15765. * @param mesh the mesh to check
  15766. * @param fastCheck if only the bounding box should checked
  15767. * @returns picking info of the intersecton
  15768. */
  15769. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15770. /**
  15771. * Checks if ray intersects a mesh
  15772. * @param meshes the meshes to check
  15773. * @param fastCheck if only the bounding box should checked
  15774. * @param results array to store result in
  15775. * @returns Array of picking infos
  15776. */
  15777. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15778. private _comparePickingInfo;
  15779. private static smallnum;
  15780. private static rayl;
  15781. /**
  15782. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  15783. * @param sega the first point of the segment to test the intersection against
  15784. * @param segb the second point of the segment to test the intersection against
  15785. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  15786. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  15787. */
  15788. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  15789. /**
  15790. * Update the ray from viewport position
  15791. * @param x position
  15792. * @param y y position
  15793. * @param viewportWidth viewport width
  15794. * @param viewportHeight viewport height
  15795. * @param world world matrix
  15796. * @param view view matrix
  15797. * @param projection projection matrix
  15798. * @returns this ray updated
  15799. */
  15800. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15801. /**
  15802. * Creates a ray with origin and direction of 0,0,0
  15803. * @returns the new ray
  15804. */
  15805. static Zero(): Ray;
  15806. /**
  15807. * Creates a new ray from screen space and viewport
  15808. * @param x position
  15809. * @param y y position
  15810. * @param viewportWidth viewport width
  15811. * @param viewportHeight viewport height
  15812. * @param world world matrix
  15813. * @param view view matrix
  15814. * @param projection projection matrix
  15815. * @returns new ray
  15816. */
  15817. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15818. /**
  15819. * 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
  15820. * transformed to the given world matrix.
  15821. * @param origin The origin point
  15822. * @param end The end point
  15823. * @param world a matrix to transform the ray to. Default is the identity matrix.
  15824. * @returns the new ray
  15825. */
  15826. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  15827. /**
  15828. * Transforms a ray by a matrix
  15829. * @param ray ray to transform
  15830. * @param matrix matrix to apply
  15831. * @returns the resulting new ray
  15832. */
  15833. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  15834. /**
  15835. * Transforms a ray by a matrix
  15836. * @param ray ray to transform
  15837. * @param matrix matrix to apply
  15838. * @param result ray to store result in
  15839. */
  15840. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  15841. /**
  15842. * Unproject a ray from screen space to object space
  15843. * @param sourceX defines the screen space x coordinate to use
  15844. * @param sourceY defines the screen space y coordinate to use
  15845. * @param viewportWidth defines the current width of the viewport
  15846. * @param viewportHeight defines the current height of the viewport
  15847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15848. * @param view defines the view matrix to use
  15849. * @param projection defines the projection matrix to use
  15850. */
  15851. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  15852. }
  15853. /**
  15854. * Type used to define predicate used to select faces when a mesh intersection is detected
  15855. */
  15856. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  15857. interface Scene {
  15858. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  15859. /** @hidden */ private _cachedRayForTransform: Ray;
  15860. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  15861. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  15862. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  15863. }
  15864. }
  15865. declare module BABYLON {
  15866. interface Scene {
  15867. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  15868. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  15869. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  15870. /**
  15871. * All of the sprite managers added to this scene
  15872. * @see http://doc.babylonjs.com/babylon101/sprites
  15873. */
  15874. spriteManagers: Array<ISpriteManager>;
  15875. /**
  15876. * An event triggered when sprites rendering is about to start
  15877. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  15878. */
  15879. onBeforeSpritesRenderingObservable: Observable<Scene>;
  15880. /**
  15881. * An event triggered when sprites rendering is done
  15882. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  15883. */
  15884. onAfterSpritesRenderingObservable: Observable<Scene>;
  15885. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15886. /** Launch a ray to try to pick a sprite in the scene
  15887. * @param x position on screen
  15888. * @param y position on screen
  15889. * @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
  15890. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  15891. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  15892. * @returns a PickingInfo
  15893. */
  15894. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15895. /** Use the given ray to pick a sprite in the scene
  15896. * @param ray The ray (in world space) to use to pick meshes
  15897. * @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
  15898. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  15899. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  15900. * @returns a PickingInfo
  15901. */
  15902. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15903. /**
  15904. * Force the sprite under the pointer
  15905. * @param sprite defines the sprite to use
  15906. */
  15907. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  15908. /**
  15909. * Gets the sprite under the pointer
  15910. * @returns a Sprite or null if no sprite is under the pointer
  15911. */
  15912. getPointerOverSprite(): Nullable<Sprite>;
  15913. }
  15914. /**
  15915. * Defines the sprite scene component responsible to manage sprites
  15916. * in a given scene.
  15917. */
  15918. export class SpriteSceneComponent implements ISceneComponent {
  15919. /**
  15920. * The component name helpfull to identify the component in the list of scene components.
  15921. */
  15922. readonly name: string;
  15923. /**
  15924. * The scene the component belongs to.
  15925. */
  15926. scene: Scene;
  15927. /** @hidden */
  15928. private _spritePredicate;
  15929. /**
  15930. * Creates a new instance of the component for the given scene
  15931. * @param scene Defines the scene to register the component in
  15932. */
  15933. constructor(scene: Scene);
  15934. /**
  15935. * Registers the component in a given scene
  15936. */
  15937. register(): void;
  15938. /**
  15939. * Rebuilds the elements related to this component in case of
  15940. * context lost for instance.
  15941. */
  15942. rebuild(): void;
  15943. /**
  15944. * Disposes the component and the associated ressources.
  15945. */
  15946. dispose(): void;
  15947. private _pickSpriteButKeepRay;
  15948. private _pointerMove;
  15949. private _pointerDown;
  15950. private _pointerUp;
  15951. }
  15952. }
  15953. declare module BABYLON {
  15954. /** @hidden */
  15955. export var fogFragmentDeclaration: {
  15956. name: string;
  15957. shader: string;
  15958. };
  15959. }
  15960. declare module BABYLON {
  15961. /** @hidden */
  15962. export var fogFragment: {
  15963. name: string;
  15964. shader: string;
  15965. };
  15966. }
  15967. declare module BABYLON {
  15968. /** @hidden */
  15969. export var spritesPixelShader: {
  15970. name: string;
  15971. shader: string;
  15972. };
  15973. }
  15974. declare module BABYLON {
  15975. /** @hidden */
  15976. export var fogVertexDeclaration: {
  15977. name: string;
  15978. shader: string;
  15979. };
  15980. }
  15981. declare module BABYLON {
  15982. /** @hidden */
  15983. export var spritesVertexShader: {
  15984. name: string;
  15985. shader: string;
  15986. };
  15987. }
  15988. declare module BABYLON {
  15989. /**
  15990. * Defines the minimum interface to fullfil in order to be a sprite manager.
  15991. */
  15992. export interface ISpriteManager extends IDisposable {
  15993. /**
  15994. * Restricts the camera to viewing objects with the same layerMask.
  15995. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  15996. */
  15997. layerMask: number;
  15998. /**
  15999. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16000. */
  16001. isPickable: boolean;
  16002. /**
  16003. * Specifies the rendering group id for this mesh (0 by default)
  16004. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16005. */
  16006. renderingGroupId: number;
  16007. /**
  16008. * Defines the list of sprites managed by the manager.
  16009. */
  16010. sprites: Array<Sprite>;
  16011. /**
  16012. * Tests the intersection of a sprite with a specific ray.
  16013. * @param ray The ray we are sending to test the collision
  16014. * @param camera The camera space we are sending rays in
  16015. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16016. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16017. * @returns picking info or null.
  16018. */
  16019. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16020. /**
  16021. * Renders the list of sprites on screen.
  16022. */
  16023. render(): void;
  16024. }
  16025. /**
  16026. * Class used to manage multiple sprites on the same spritesheet
  16027. * @see http://doc.babylonjs.com/babylon101/sprites
  16028. */
  16029. export class SpriteManager implements ISpriteManager {
  16030. /** defines the manager's name */
  16031. name: string;
  16032. /** Gets the list of sprites */
  16033. sprites: Sprite[];
  16034. /** Gets or sets the rendering group id (0 by default) */
  16035. renderingGroupId: number;
  16036. /** Gets or sets camera layer mask */
  16037. layerMask: number;
  16038. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16039. fogEnabled: boolean;
  16040. /** Gets or sets a boolean indicating if the sprites are pickable */
  16041. isPickable: boolean;
  16042. /** Defines the default width of a cell in the spritesheet */
  16043. cellWidth: number;
  16044. /** Defines the default height of a cell in the spritesheet */
  16045. cellHeight: number;
  16046. /**
  16047. * An event triggered when the manager is disposed.
  16048. */
  16049. onDisposeObservable: Observable<SpriteManager>;
  16050. private _onDisposeObserver;
  16051. /**
  16052. * Callback called when the manager is disposed
  16053. */
  16054. onDispose: () => void;
  16055. private _capacity;
  16056. private _spriteTexture;
  16057. private _epsilon;
  16058. private _scene;
  16059. private _vertexData;
  16060. private _buffer;
  16061. private _vertexBuffers;
  16062. private _indexBuffer;
  16063. private _effectBase;
  16064. private _effectFog;
  16065. /**
  16066. * Gets or sets the spritesheet texture
  16067. */
  16068. texture: Texture;
  16069. /**
  16070. * Creates a new sprite manager
  16071. * @param name defines the manager's name
  16072. * @param imgUrl defines the sprite sheet url
  16073. * @param capacity defines the maximum allowed number of sprites
  16074. * @param cellSize defines the size of a sprite cell
  16075. * @param scene defines the hosting scene
  16076. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16077. * @param samplingMode defines the smapling mode to use with spritesheet
  16078. */
  16079. constructor(
  16080. /** defines the manager's name */
  16081. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16082. private _appendSpriteVertex;
  16083. /**
  16084. * Intersects the sprites with a ray
  16085. * @param ray defines the ray to intersect with
  16086. * @param camera defines the current active camera
  16087. * @param predicate defines a predicate used to select candidate sprites
  16088. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16089. * @returns null if no hit or a PickingInfo
  16090. */
  16091. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16092. /**
  16093. * Render all child sprites
  16094. */
  16095. render(): void;
  16096. /**
  16097. * Release associated resources
  16098. */
  16099. dispose(): void;
  16100. }
  16101. }
  16102. declare module BABYLON {
  16103. /**
  16104. * Class used to represent a sprite
  16105. * @see http://doc.babylonjs.com/babylon101/sprites
  16106. */
  16107. export class Sprite {
  16108. /** defines the name */
  16109. name: string;
  16110. /** Gets or sets the current world position */
  16111. position: Vector3;
  16112. /** Gets or sets the main color */
  16113. color: Color4;
  16114. /** Gets or sets the width */
  16115. width: number;
  16116. /** Gets or sets the height */
  16117. height: number;
  16118. /** Gets or sets rotation angle */
  16119. angle: number;
  16120. /** Gets or sets the cell index in the sprite sheet */
  16121. cellIndex: number;
  16122. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16123. invertU: number;
  16124. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16125. invertV: number;
  16126. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16127. disposeWhenFinishedAnimating: boolean;
  16128. /** Gets the list of attached animations */
  16129. animations: Animation[];
  16130. /** Gets or sets a boolean indicating if the sprite can be picked */
  16131. isPickable: boolean;
  16132. /**
  16133. * Gets or sets the associated action manager
  16134. */
  16135. actionManager: Nullable<ActionManager>;
  16136. private _animationStarted;
  16137. private _loopAnimation;
  16138. private _fromIndex;
  16139. private _toIndex;
  16140. private _delay;
  16141. private _direction;
  16142. private _manager;
  16143. private _time;
  16144. private _onAnimationEnd;
  16145. /**
  16146. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16147. */
  16148. isVisible: boolean;
  16149. /**
  16150. * Gets or sets the sprite size
  16151. */
  16152. size: number;
  16153. /**
  16154. * Creates a new Sprite
  16155. * @param name defines the name
  16156. * @param manager defines the manager
  16157. */
  16158. constructor(
  16159. /** defines the name */
  16160. name: string, manager: ISpriteManager);
  16161. /**
  16162. * Starts an animation
  16163. * @param from defines the initial key
  16164. * @param to defines the end key
  16165. * @param loop defines if the animation must loop
  16166. * @param delay defines the start delay (in ms)
  16167. * @param onAnimationEnd defines a callback to call when animation ends
  16168. */
  16169. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16170. /** Stops current animation (if any) */
  16171. stopAnimation(): void;
  16172. /** @hidden */ private _animate(deltaTime: number): void;
  16173. /** Release associated resources */
  16174. dispose(): void;
  16175. }
  16176. }
  16177. declare module BABYLON {
  16178. /**
  16179. * Information about the result of picking within a scene
  16180. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16181. */
  16182. export class PickingInfo {
  16183. /** @hidden */ private _pickingUnavailable: boolean;
  16184. /**
  16185. * If the pick collided with an object
  16186. */
  16187. hit: boolean;
  16188. /**
  16189. * Distance away where the pick collided
  16190. */
  16191. distance: number;
  16192. /**
  16193. * The location of pick collision
  16194. */
  16195. pickedPoint: Nullable<Vector3>;
  16196. /**
  16197. * The mesh corresponding the the pick collision
  16198. */
  16199. pickedMesh: Nullable<AbstractMesh>;
  16200. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16201. bu: number;
  16202. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16203. bv: number;
  16204. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16205. faceId: number;
  16206. /** Id of the the submesh that was picked */
  16207. subMeshId: number;
  16208. /** If a sprite was picked, this will be the sprite the pick collided with */
  16209. pickedSprite: Nullable<Sprite>;
  16210. /**
  16211. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16212. */
  16213. originMesh: Nullable<AbstractMesh>;
  16214. /**
  16215. * The ray that was used to perform the picking.
  16216. */
  16217. ray: Nullable<Ray>;
  16218. /**
  16219. * Gets the normal correspodning to the face the pick collided with
  16220. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16221. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16222. * @returns The normal correspodning to the face the pick collided with
  16223. */
  16224. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16225. /**
  16226. * Gets the texture coordinates of where the pick occured
  16227. * @returns the vector containing the coordnates of the texture
  16228. */
  16229. getTextureCoordinates(): Nullable<Vector2>;
  16230. }
  16231. }
  16232. declare module BABYLON {
  16233. /**
  16234. * Gather the list of pointer event types as constants.
  16235. */
  16236. export class PointerEventTypes {
  16237. /**
  16238. * 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.
  16239. */
  16240. static readonly POINTERDOWN: number;
  16241. /**
  16242. * The pointerup event is fired when a pointer is no longer active.
  16243. */
  16244. static readonly POINTERUP: number;
  16245. /**
  16246. * The pointermove event is fired when a pointer changes coordinates.
  16247. */
  16248. static readonly POINTERMOVE: number;
  16249. /**
  16250. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16251. */
  16252. static readonly POINTERWHEEL: number;
  16253. /**
  16254. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16255. */
  16256. static readonly POINTERPICK: number;
  16257. /**
  16258. * The pointertap event is fired when a the object has been touched and released without drag.
  16259. */
  16260. static readonly POINTERTAP: number;
  16261. /**
  16262. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16263. */
  16264. static readonly POINTERDOUBLETAP: number;
  16265. }
  16266. /**
  16267. * Base class of pointer info types.
  16268. */
  16269. export class PointerInfoBase {
  16270. /**
  16271. * Defines the type of event (PointerEventTypes)
  16272. */
  16273. type: number;
  16274. /**
  16275. * Defines the related dom event
  16276. */
  16277. event: PointerEvent | MouseWheelEvent;
  16278. /**
  16279. * Instantiates the base class of pointers info.
  16280. * @param type Defines the type of event (PointerEventTypes)
  16281. * @param event Defines the related dom event
  16282. */
  16283. constructor(
  16284. /**
  16285. * Defines the type of event (PointerEventTypes)
  16286. */
  16287. type: number,
  16288. /**
  16289. * Defines the related dom event
  16290. */
  16291. event: PointerEvent | MouseWheelEvent);
  16292. }
  16293. /**
  16294. * This class is used to store pointer related info for the onPrePointerObservable event.
  16295. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16296. */
  16297. export class PointerInfoPre extends PointerInfoBase {
  16298. /**
  16299. * Ray from a pointer if availible (eg. 6dof controller)
  16300. */
  16301. ray: Nullable<Ray>;
  16302. /**
  16303. * Defines the local position of the pointer on the canvas.
  16304. */
  16305. localPosition: Vector2;
  16306. /**
  16307. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16308. */
  16309. skipOnPointerObservable: boolean;
  16310. /**
  16311. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16312. * @param type Defines the type of event (PointerEventTypes)
  16313. * @param event Defines the related dom event
  16314. * @param localX Defines the local x coordinates of the pointer when the event occured
  16315. * @param localY Defines the local y coordinates of the pointer when the event occured
  16316. */
  16317. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16318. }
  16319. /**
  16320. * This type contains all the data related to a pointer event in Babylon.js.
  16321. * 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.
  16322. */
  16323. export class PointerInfo extends PointerInfoBase {
  16324. /**
  16325. * Defines the picking info associated to the info (if any)\
  16326. */
  16327. pickInfo: Nullable<PickingInfo>;
  16328. /**
  16329. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16330. * @param type Defines the type of event (PointerEventTypes)
  16331. * @param event Defines the related dom event
  16332. * @param pickInfo Defines the picking info associated to the info (if any)\
  16333. */
  16334. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16335. /**
  16336. * Defines the picking info associated to the info (if any)\
  16337. */
  16338. pickInfo: Nullable<PickingInfo>);
  16339. }
  16340. /**
  16341. * Data relating to a touch event on the screen.
  16342. */
  16343. export interface PointerTouch {
  16344. /**
  16345. * X coordinate of touch.
  16346. */
  16347. x: number;
  16348. /**
  16349. * Y coordinate of touch.
  16350. */
  16351. y: number;
  16352. /**
  16353. * Id of touch. Unique for each finger.
  16354. */
  16355. pointerId: number;
  16356. /**
  16357. * Event type passed from DOM.
  16358. */
  16359. type: any;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. /**
  16364. * Manage the mouse inputs to control the movement of a free camera.
  16365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16366. */
  16367. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16368. /**
  16369. * Define if touch is enabled in the mouse input
  16370. */
  16371. touchEnabled: boolean;
  16372. /**
  16373. * Defines the camera the input is attached to.
  16374. */
  16375. camera: FreeCamera;
  16376. /**
  16377. * Defines the buttons associated with the input to handle camera move.
  16378. */
  16379. buttons: number[];
  16380. /**
  16381. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16382. */
  16383. angularSensibility: number;
  16384. private _pointerInput;
  16385. private _onMouseMove;
  16386. private _observer;
  16387. private previousPosition;
  16388. /**
  16389. * Observable for when a pointer move event occurs containing the move offset
  16390. */
  16391. onPointerMovedObservable: Observable<{
  16392. offsetX: number;
  16393. offsetY: number;
  16394. }>;
  16395. /**
  16396. * @hidden
  16397. * If the camera should be rotated automatically based on pointer movement
  16398. */ private _allowCameraRotation: boolean;
  16399. /**
  16400. * Manage the mouse inputs to control the movement of a free camera.
  16401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16402. * @param touchEnabled Defines if touch is enabled or not
  16403. */
  16404. constructor(
  16405. /**
  16406. * Define if touch is enabled in the mouse input
  16407. */
  16408. touchEnabled?: boolean);
  16409. /**
  16410. * Attach the input controls to a specific dom element to get the input from.
  16411. * @param element Defines the element the controls should be listened from
  16412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16413. */
  16414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16415. /**
  16416. * Called on JS contextmenu event.
  16417. * Override this method to provide functionality.
  16418. */
  16419. protected onContextMenu(evt: PointerEvent): void;
  16420. /**
  16421. * Detach the current controls from the specified dom element.
  16422. * @param element Defines the element to stop listening the inputs from
  16423. */
  16424. detachControl(element: Nullable<HTMLElement>): void;
  16425. /**
  16426. * Gets the class name of the current intput.
  16427. * @returns the class name
  16428. */
  16429. getClassName(): string;
  16430. /**
  16431. * Get the friendly name associated with the input class.
  16432. * @returns the input friendly name
  16433. */
  16434. getSimpleName(): string;
  16435. }
  16436. }
  16437. declare module BABYLON {
  16438. /**
  16439. * Manage the touch inputs to control the movement of a free camera.
  16440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16441. */
  16442. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16443. /**
  16444. * Defines the camera the input is attached to.
  16445. */
  16446. camera: FreeCamera;
  16447. /**
  16448. * Defines the touch sensibility for rotation.
  16449. * The higher the faster.
  16450. */
  16451. touchAngularSensibility: number;
  16452. /**
  16453. * Defines the touch sensibility for move.
  16454. * The higher the faster.
  16455. */
  16456. touchMoveSensibility: number;
  16457. private _offsetX;
  16458. private _offsetY;
  16459. private _pointerPressed;
  16460. private _pointerInput;
  16461. private _observer;
  16462. private _onLostFocus;
  16463. /**
  16464. * Attach the input controls to a specific dom element to get the input from.
  16465. * @param element Defines the element the controls should be listened from
  16466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16467. */
  16468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16469. /**
  16470. * Detach the current controls from the specified dom element.
  16471. * @param element Defines the element to stop listening the inputs from
  16472. */
  16473. detachControl(element: Nullable<HTMLElement>): void;
  16474. /**
  16475. * Update the current camera state depending on the inputs that have been used this frame.
  16476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16477. */
  16478. checkInputs(): void;
  16479. /**
  16480. * Gets the class name of the current intput.
  16481. * @returns the class name
  16482. */
  16483. getClassName(): string;
  16484. /**
  16485. * Get the friendly name associated with the input class.
  16486. * @returns the input friendly name
  16487. */
  16488. getSimpleName(): string;
  16489. }
  16490. }
  16491. declare module BABYLON {
  16492. /**
  16493. * Default Inputs manager for the FreeCamera.
  16494. * It groups all the default supported inputs for ease of use.
  16495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16496. */
  16497. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16498. /**
  16499. * @hidden
  16500. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  16501. /**
  16502. * Instantiates a new FreeCameraInputsManager.
  16503. * @param camera Defines the camera the inputs belong to
  16504. */
  16505. constructor(camera: FreeCamera);
  16506. /**
  16507. * Add keyboard input support to the input manager.
  16508. * @returns the current input manager
  16509. */
  16510. addKeyboard(): FreeCameraInputsManager;
  16511. /**
  16512. * Add mouse input support to the input manager.
  16513. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16514. * @returns the current input manager
  16515. */
  16516. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16517. /**
  16518. * Removes the mouse input support from the manager
  16519. * @returns the current input manager
  16520. */
  16521. removeMouse(): FreeCameraInputsManager;
  16522. /**
  16523. * Add touch input support to the input manager.
  16524. * @returns the current input manager
  16525. */
  16526. addTouch(): FreeCameraInputsManager;
  16527. /**
  16528. * Remove all attached input methods from a camera
  16529. */
  16530. clear(): void;
  16531. }
  16532. }
  16533. declare module BABYLON {
  16534. /**
  16535. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16536. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16537. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16538. */
  16539. export class FreeCamera extends TargetCamera {
  16540. /**
  16541. * Define the collision ellipsoid of the camera.
  16542. * This is helpful to simulate a camera body like the player body around the camera
  16543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16544. */
  16545. ellipsoid: Vector3;
  16546. /**
  16547. * Define an offset for the position of the ellipsoid around the camera.
  16548. * This can be helpful to determine the center of the body near the gravity center of the body
  16549. * instead of its head.
  16550. */
  16551. ellipsoidOffset: Vector3;
  16552. /**
  16553. * Enable or disable collisions of the camera with the rest of the scene objects.
  16554. */
  16555. checkCollisions: boolean;
  16556. /**
  16557. * Enable or disable gravity on the camera.
  16558. */
  16559. applyGravity: boolean;
  16560. /**
  16561. * Define the input manager associated to the camera.
  16562. */
  16563. inputs: FreeCameraInputsManager;
  16564. /**
  16565. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16566. * Higher values reduce sensitivity.
  16567. */
  16568. /**
  16569. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16570. * Higher values reduce sensitivity.
  16571. */
  16572. angularSensibility: number;
  16573. /**
  16574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16575. */
  16576. keysUp: number[];
  16577. /**
  16578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16579. */
  16580. keysDown: number[];
  16581. /**
  16582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16583. */
  16584. keysLeft: number[];
  16585. /**
  16586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16587. */
  16588. keysRight: number[];
  16589. /**
  16590. * Event raised when the camera collide with a mesh in the scene.
  16591. */
  16592. onCollide: (collidedMesh: AbstractMesh) => void;
  16593. private _collider;
  16594. private _needMoveForGravity;
  16595. private _oldPosition;
  16596. private _diffPosition;
  16597. private _newPosition;
  16598. /** @hidden */ private _localDirection: Vector3;
  16599. /** @hidden */ private _transformedDirection: Vector3;
  16600. /**
  16601. * Instantiates a Free Camera.
  16602. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16603. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16605. * @param name Define the name of the camera in the scene
  16606. * @param position Define the start position of the camera in the scene
  16607. * @param scene Define the scene the camera belongs to
  16608. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16609. */
  16610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16611. /**
  16612. * Attached controls to the current camera.
  16613. * @param element Defines the element the controls should be listened from
  16614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16615. */
  16616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16617. /**
  16618. * Detach the current controls from the camera.
  16619. * The camera will stop reacting to inputs.
  16620. * @param element Defines the element to stop listening the inputs from
  16621. */
  16622. detachControl(element: HTMLElement): void;
  16623. private _collisionMask;
  16624. /**
  16625. * Define a collision mask to limit the list of object the camera can collide with
  16626. */
  16627. collisionMask: number;
  16628. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  16629. private _onCollisionPositionChange;
  16630. /** @hidden */ private _checkInputs(): void;
  16631. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  16632. /** @hidden */ private _updatePosition(): void;
  16633. /**
  16634. * Destroy the camera and release the current resources hold by it.
  16635. */
  16636. dispose(): void;
  16637. /**
  16638. * Gets the current object class name.
  16639. * @return the class name
  16640. */
  16641. getClassName(): string;
  16642. }
  16643. }
  16644. declare module BABYLON {
  16645. /**
  16646. * Represents a gamepad control stick position
  16647. */
  16648. export class StickValues {
  16649. /**
  16650. * The x component of the control stick
  16651. */
  16652. x: number;
  16653. /**
  16654. * The y component of the control stick
  16655. */
  16656. y: number;
  16657. /**
  16658. * Initializes the gamepad x and y control stick values
  16659. * @param x The x component of the gamepad control stick value
  16660. * @param y The y component of the gamepad control stick value
  16661. */
  16662. constructor(
  16663. /**
  16664. * The x component of the control stick
  16665. */
  16666. x: number,
  16667. /**
  16668. * The y component of the control stick
  16669. */
  16670. y: number);
  16671. }
  16672. /**
  16673. * An interface which manages callbacks for gamepad button changes
  16674. */
  16675. export interface GamepadButtonChanges {
  16676. /**
  16677. * Called when a gamepad has been changed
  16678. */
  16679. changed: boolean;
  16680. /**
  16681. * Called when a gamepad press event has been triggered
  16682. */
  16683. pressChanged: boolean;
  16684. /**
  16685. * Called when a touch event has been triggered
  16686. */
  16687. touchChanged: boolean;
  16688. /**
  16689. * Called when a value has changed
  16690. */
  16691. valueChanged: boolean;
  16692. }
  16693. /**
  16694. * Represents a gamepad
  16695. */
  16696. export class Gamepad {
  16697. /**
  16698. * The id of the gamepad
  16699. */
  16700. id: string;
  16701. /**
  16702. * The index of the gamepad
  16703. */
  16704. index: number;
  16705. /**
  16706. * The browser gamepad
  16707. */
  16708. browserGamepad: any;
  16709. /**
  16710. * Specifies what type of gamepad this represents
  16711. */
  16712. type: number;
  16713. private _leftStick;
  16714. private _rightStick;
  16715. /** @hidden */ private _isConnected: boolean;
  16716. private _leftStickAxisX;
  16717. private _leftStickAxisY;
  16718. private _rightStickAxisX;
  16719. private _rightStickAxisY;
  16720. /**
  16721. * Triggered when the left control stick has been changed
  16722. */
  16723. private _onleftstickchanged;
  16724. /**
  16725. * Triggered when the right control stick has been changed
  16726. */
  16727. private _onrightstickchanged;
  16728. /**
  16729. * Represents a gamepad controller
  16730. */
  16731. static GAMEPAD: number;
  16732. /**
  16733. * Represents a generic controller
  16734. */
  16735. static GENERIC: number;
  16736. /**
  16737. * Represents an XBox controller
  16738. */
  16739. static XBOX: number;
  16740. /**
  16741. * Represents a pose-enabled controller
  16742. */
  16743. static POSE_ENABLED: number;
  16744. /**
  16745. * Specifies whether the left control stick should be Y-inverted
  16746. */
  16747. protected _invertLeftStickY: boolean;
  16748. /**
  16749. * Specifies if the gamepad has been connected
  16750. */
  16751. readonly isConnected: boolean;
  16752. /**
  16753. * Initializes the gamepad
  16754. * @param id The id of the gamepad
  16755. * @param index The index of the gamepad
  16756. * @param browserGamepad The browser gamepad
  16757. * @param leftStickX The x component of the left joystick
  16758. * @param leftStickY The y component of the left joystick
  16759. * @param rightStickX The x component of the right joystick
  16760. * @param rightStickY The y component of the right joystick
  16761. */
  16762. constructor(
  16763. /**
  16764. * The id of the gamepad
  16765. */
  16766. id: string,
  16767. /**
  16768. * The index of the gamepad
  16769. */
  16770. index: number,
  16771. /**
  16772. * The browser gamepad
  16773. */
  16774. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  16775. /**
  16776. * Callback triggered when the left joystick has changed
  16777. * @param callback
  16778. */
  16779. onleftstickchanged(callback: (values: StickValues) => void): void;
  16780. /**
  16781. * Callback triggered when the right joystick has changed
  16782. * @param callback
  16783. */
  16784. onrightstickchanged(callback: (values: StickValues) => void): void;
  16785. /**
  16786. * Gets the left joystick
  16787. */
  16788. /**
  16789. * Sets the left joystick values
  16790. */
  16791. leftStick: StickValues;
  16792. /**
  16793. * Gets the right joystick
  16794. */
  16795. /**
  16796. * Sets the right joystick value
  16797. */
  16798. rightStick: StickValues;
  16799. /**
  16800. * Updates the gamepad joystick positions
  16801. */
  16802. update(): void;
  16803. /**
  16804. * Disposes the gamepad
  16805. */
  16806. dispose(): void;
  16807. }
  16808. /**
  16809. * Represents a generic gamepad
  16810. */
  16811. export class GenericPad extends Gamepad {
  16812. private _buttons;
  16813. private _onbuttondown;
  16814. private _onbuttonup;
  16815. /**
  16816. * Observable triggered when a button has been pressed
  16817. */
  16818. onButtonDownObservable: Observable<number>;
  16819. /**
  16820. * Observable triggered when a button has been released
  16821. */
  16822. onButtonUpObservable: Observable<number>;
  16823. /**
  16824. * Callback triggered when a button has been pressed
  16825. * @param callback Called when a button has been pressed
  16826. */
  16827. onbuttondown(callback: (buttonPressed: number) => void): void;
  16828. /**
  16829. * Callback triggered when a button has been released
  16830. * @param callback Called when a button has been released
  16831. */
  16832. onbuttonup(callback: (buttonReleased: number) => void): void;
  16833. /**
  16834. * Initializes the generic gamepad
  16835. * @param id The id of the generic gamepad
  16836. * @param index The index of the generic gamepad
  16837. * @param browserGamepad The browser gamepad
  16838. */
  16839. constructor(id: string, index: number, browserGamepad: any);
  16840. private _setButtonValue;
  16841. /**
  16842. * Updates the generic gamepad
  16843. */
  16844. update(): void;
  16845. /**
  16846. * Disposes the generic gamepad
  16847. */
  16848. dispose(): void;
  16849. }
  16850. }
  16851. declare module BABYLON {
  16852. /**
  16853. * Defines the types of pose enabled controllers that are supported
  16854. */
  16855. export enum PoseEnabledControllerType {
  16856. /**
  16857. * HTC Vive
  16858. */
  16859. VIVE = 0,
  16860. /**
  16861. * Oculus Rift
  16862. */
  16863. OCULUS = 1,
  16864. /**
  16865. * Windows mixed reality
  16866. */
  16867. WINDOWS = 2,
  16868. /**
  16869. * Samsung gear VR
  16870. */
  16871. GEAR_VR = 3,
  16872. /**
  16873. * Google Daydream
  16874. */
  16875. DAYDREAM = 4,
  16876. /**
  16877. * Generic
  16878. */
  16879. GENERIC = 5
  16880. }
  16881. /**
  16882. * Defines the MutableGamepadButton interface for the state of a gamepad button
  16883. */
  16884. export interface MutableGamepadButton {
  16885. /**
  16886. * Value of the button/trigger
  16887. */
  16888. value: number;
  16889. /**
  16890. * If the button/trigger is currently touched
  16891. */
  16892. touched: boolean;
  16893. /**
  16894. * If the button/trigger is currently pressed
  16895. */
  16896. pressed: boolean;
  16897. }
  16898. /**
  16899. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  16900. * @hidden
  16901. */
  16902. export interface ExtendedGamepadButton extends GamepadButton {
  16903. /**
  16904. * If the button/trigger is currently pressed
  16905. */
  16906. readonly pressed: boolean;
  16907. /**
  16908. * If the button/trigger is currently touched
  16909. */
  16910. readonly touched: boolean;
  16911. /**
  16912. * Value of the button/trigger
  16913. */
  16914. readonly value: number;
  16915. }
  16916. /** @hidden */
  16917. export interface _GamePadFactory {
  16918. /**
  16919. * Returns wether or not the current gamepad can be created for this type of controller.
  16920. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  16921. * @returns true if it can be created, otherwise false
  16922. */
  16923. canCreate(gamepadInfo: any): boolean;
  16924. /**
  16925. * Creates a new instance of the Gamepad.
  16926. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  16927. * @returns the new gamepad instance
  16928. */
  16929. create(gamepadInfo: any): Gamepad;
  16930. }
  16931. /**
  16932. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  16933. */
  16934. export class PoseEnabledControllerHelper {
  16935. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  16936. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  16937. /**
  16938. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  16939. * @param vrGamepad the gamepad to initialized
  16940. * @returns a vr controller of the type the gamepad identified as
  16941. */
  16942. static InitiateController(vrGamepad: any): Gamepad;
  16943. }
  16944. /**
  16945. * Defines the PoseEnabledController object that contains state of a vr capable controller
  16946. */
  16947. export class PoseEnabledController extends Gamepad implements PoseControlled {
  16948. private _deviceRoomPosition;
  16949. private _deviceRoomRotationQuaternion;
  16950. /**
  16951. * The device position in babylon space
  16952. */
  16953. devicePosition: Vector3;
  16954. /**
  16955. * The device rotation in babylon space
  16956. */
  16957. deviceRotationQuaternion: Quaternion;
  16958. /**
  16959. * The scale factor of the device in babylon space
  16960. */
  16961. deviceScaleFactor: number;
  16962. /**
  16963. * (Likely devicePosition should be used instead) The device position in its room space
  16964. */
  16965. position: Vector3;
  16966. /**
  16967. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  16968. */
  16969. rotationQuaternion: Quaternion;
  16970. /**
  16971. * The type of controller (Eg. Windows mixed reality)
  16972. */
  16973. controllerType: PoseEnabledControllerType;
  16974. protected _calculatedPosition: Vector3;
  16975. private _calculatedRotation;
  16976. /**
  16977. * The raw pose from the device
  16978. */
  16979. rawPose: DevicePose;
  16980. private _trackPosition;
  16981. private _maxRotationDistFromHeadset;
  16982. private _draggedRoomRotation;
  16983. /**
  16984. * @hidden
  16985. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  16986. /**
  16987. * Internal, the mesh attached to the controller
  16988. * @hidden
  16989. */ private _mesh: Nullable<AbstractMesh>;
  16990. private _poseControlledCamera;
  16991. private _leftHandSystemQuaternion;
  16992. /**
  16993. * Internal, matrix used to convert room space to babylon space
  16994. * @hidden
  16995. */ private _deviceToWorld: Matrix;
  16996. /**
  16997. * Node to be used when casting a ray from the controller
  16998. * @hidden
  16999. */ private _pointingPoseNode: Nullable<TransformNode>;
  17000. /**
  17001. * Name of the child mesh that can be used to cast a ray from the controller
  17002. */
  17003. static readonly POINTING_POSE: string;
  17004. /**
  17005. * Creates a new PoseEnabledController from a gamepad
  17006. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17007. */
  17008. constructor(browserGamepad: any);
  17009. private _workingMatrix;
  17010. /**
  17011. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17012. */
  17013. update(): void;
  17014. /**
  17015. * Updates only the pose device and mesh without doing any button event checking
  17016. */
  17017. protected _updatePoseAndMesh(): void;
  17018. /**
  17019. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17020. * @param poseData raw pose fromthe device
  17021. */
  17022. updateFromDevice(poseData: DevicePose): void;
  17023. /**
  17024. * @hidden
  17025. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  17026. /**
  17027. * Attaches a mesh to the controller
  17028. * @param mesh the mesh to be attached
  17029. */
  17030. attachToMesh(mesh: AbstractMesh): void;
  17031. /**
  17032. * Attaches the controllers mesh to a camera
  17033. * @param camera the camera the mesh should be attached to
  17034. */
  17035. attachToPoseControlledCamera(camera: TargetCamera): void;
  17036. /**
  17037. * Disposes of the controller
  17038. */
  17039. dispose(): void;
  17040. /**
  17041. * The mesh that is attached to the controller
  17042. */
  17043. readonly mesh: Nullable<AbstractMesh>;
  17044. /**
  17045. * Gets the ray of the controller in the direction the controller is pointing
  17046. * @param length the length the resulting ray should be
  17047. * @returns a ray in the direction the controller is pointing
  17048. */
  17049. getForwardRay(length?: number): Ray;
  17050. }
  17051. }
  17052. declare module BABYLON {
  17053. /**
  17054. * Defines the WebVRController object that represents controllers tracked in 3D space
  17055. */
  17056. export abstract class WebVRController extends PoseEnabledController {
  17057. /**
  17058. * Internal, the default controller model for the controller
  17059. */
  17060. protected _defaultModel: AbstractMesh;
  17061. /**
  17062. * Fired when the trigger state has changed
  17063. */
  17064. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17065. /**
  17066. * Fired when the main button state has changed
  17067. */
  17068. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17069. /**
  17070. * Fired when the secondary button state has changed
  17071. */
  17072. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17073. /**
  17074. * Fired when the pad state has changed
  17075. */
  17076. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17077. /**
  17078. * Fired when controllers stick values have changed
  17079. */
  17080. onPadValuesChangedObservable: Observable<StickValues>;
  17081. /**
  17082. * Array of button availible on the controller
  17083. */
  17084. protected _buttons: Array<MutableGamepadButton>;
  17085. private _onButtonStateChange;
  17086. /**
  17087. * Fired when a controller button's state has changed
  17088. * @param callback the callback containing the button that was modified
  17089. */
  17090. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17091. /**
  17092. * X and Y axis corresponding to the controllers joystick
  17093. */
  17094. pad: StickValues;
  17095. /**
  17096. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17097. */
  17098. hand: string;
  17099. /**
  17100. * The default controller model for the controller
  17101. */
  17102. readonly defaultModel: AbstractMesh;
  17103. /**
  17104. * Creates a new WebVRController from a gamepad
  17105. * @param vrGamepad the gamepad that the WebVRController should be created from
  17106. */
  17107. constructor(vrGamepad: any);
  17108. /**
  17109. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17110. */
  17111. update(): void;
  17112. /**
  17113. * Function to be called when a button is modified
  17114. */
  17115. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17116. /**
  17117. * Loads a mesh and attaches it to the controller
  17118. * @param scene the scene the mesh should be added to
  17119. * @param meshLoaded callback for when the mesh has been loaded
  17120. */
  17121. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17122. private _setButtonValue;
  17123. private _changes;
  17124. private _checkChanges;
  17125. /**
  17126. * Disposes of th webVRCOntroller
  17127. */
  17128. dispose(): void;
  17129. }
  17130. }
  17131. declare module BABYLON {
  17132. /**
  17133. * The HemisphericLight simulates the ambient environment light,
  17134. * so the passed direction is the light reflection direction, not the incoming direction.
  17135. */
  17136. export class HemisphericLight extends Light {
  17137. /**
  17138. * The groundColor is the light in the opposite direction to the one specified during creation.
  17139. * 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.
  17140. */
  17141. groundColor: Color3;
  17142. /**
  17143. * The light reflection direction, not the incoming direction.
  17144. */
  17145. direction: Vector3;
  17146. /**
  17147. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17148. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17149. * The HemisphericLight can't cast shadows.
  17150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17151. * @param name The friendly name of the light
  17152. * @param direction The direction of the light reflection
  17153. * @param scene The scene the light belongs to
  17154. */
  17155. constructor(name: string, direction: Vector3, scene: Scene);
  17156. protected _buildUniformLayout(): void;
  17157. /**
  17158. * Returns the string "HemisphericLight".
  17159. * @return The class name
  17160. */
  17161. getClassName(): string;
  17162. /**
  17163. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17164. * Returns the updated direction.
  17165. * @param target The target the direction should point to
  17166. * @return The computed direction
  17167. */
  17168. setDirectionToTarget(target: Vector3): Vector3;
  17169. /**
  17170. * Returns the shadow generator associated to the light.
  17171. * @returns Always null for hemispheric lights because it does not support shadows.
  17172. */
  17173. getShadowGenerator(): Nullable<IShadowGenerator>;
  17174. /**
  17175. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17176. * @param effect The effect to update
  17177. * @param lightIndex The index of the light in the effect to update
  17178. * @returns The hemispheric light
  17179. */
  17180. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17181. /**
  17182. * Computes the world matrix of the node
  17183. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17184. * @param useWasUpdatedFlag defines a reserved property
  17185. * @returns the world matrix
  17186. */
  17187. computeWorldMatrix(): Matrix;
  17188. /**
  17189. * Returns the integer 3.
  17190. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17191. */
  17192. getTypeID(): number;
  17193. /**
  17194. * Prepares the list of defines specific to the light type.
  17195. * @param defines the list of defines
  17196. * @param lightIndex defines the index of the light for the effect
  17197. */
  17198. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17199. }
  17200. }
  17201. declare module BABYLON {
  17202. /** @hidden */
  17203. export var vrMultiviewToSingleviewPixelShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module BABYLON {
  17209. /**
  17210. * Renders to multiple views with a single draw call
  17211. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17212. */
  17213. export class MultiviewRenderTarget extends RenderTargetTexture {
  17214. /**
  17215. * Creates a multiview render target
  17216. * @param scene scene used with the render target
  17217. * @param size the size of the render target (used for each view)
  17218. */
  17219. constructor(scene: Scene, size?: number | {
  17220. width: number;
  17221. height: number;
  17222. } | {
  17223. ratio: number;
  17224. });
  17225. /**
  17226. * @hidden
  17227. * @param faceIndex the face index, if its a cube texture
  17228. */ private _bindFrameBuffer(faceIndex?: number): void;
  17229. /**
  17230. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17231. * @returns the view count
  17232. */
  17233. getViewCount(): number;
  17234. }
  17235. }
  17236. declare module BABYLON {
  17237. interface Engine {
  17238. /**
  17239. * Creates a new multiview render target
  17240. * @param width defines the width of the texture
  17241. * @param height defines the height of the texture
  17242. * @returns the created multiview texture
  17243. */
  17244. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17245. /**
  17246. * Binds a multiview framebuffer to be drawn to
  17247. * @param multiviewTexture texture to bind
  17248. */
  17249. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17250. }
  17251. interface Camera {
  17252. /**
  17253. * @hidden
  17254. * 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)
  17255. */ private _useMultiviewToSingleView: boolean;
  17256. /**
  17257. * @hidden
  17258. * 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)
  17259. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  17260. /**
  17261. * @hidden
  17262. * ensures the multiview texture of the camera exists and has the specified width/height
  17263. * @param width height to set on the multiview texture
  17264. * @param height width to set on the multiview texture
  17265. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17266. }
  17267. interface Scene {
  17268. /** @hidden */ private _transformMatrixR: Matrix;
  17269. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  17270. /** @hidden */ private _createMultiviewUbo(): void;
  17271. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17272. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  17273. }
  17274. }
  17275. declare module BABYLON {
  17276. /**
  17277. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17278. * This will not be used for webXR as it supports displaying texture arrays directly
  17279. */
  17280. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17281. /**
  17282. * Initializes a VRMultiviewToSingleview
  17283. * @param name name of the post process
  17284. * @param camera camera to be applied to
  17285. * @param scaleFactor scaling factor to the size of the output texture
  17286. */
  17287. constructor(name: string, camera: Camera, scaleFactor: number);
  17288. }
  17289. }
  17290. declare module BABYLON {
  17291. interface Engine {
  17292. /** @hidden */ private _vrDisplay: any;
  17293. /** @hidden */ private _vrSupported: boolean;
  17294. /** @hidden */ private _oldSize: Size;
  17295. /** @hidden */ private _oldHardwareScaleFactor: number;
  17296. /** @hidden */ private _vrExclusivePointerMode: boolean;
  17297. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17298. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  17299. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  17300. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  17301. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  17302. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  17303. /**
  17304. * Observable signaled when VR display mode changes
  17305. */
  17306. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17307. /**
  17308. * Observable signaled when VR request present is complete
  17309. */
  17310. onVRRequestPresentComplete: Observable<boolean>;
  17311. /**
  17312. * Observable signaled when VR request present starts
  17313. */
  17314. onVRRequestPresentStart: Observable<Engine>;
  17315. /**
  17316. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17317. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17318. */
  17319. isInVRExclusivePointerMode: boolean;
  17320. /**
  17321. * Gets a boolean indicating if a webVR device was detected
  17322. * @returns true if a webVR device was detected
  17323. */
  17324. isVRDevicePresent(): boolean;
  17325. /**
  17326. * Gets the current webVR device
  17327. * @returns the current webVR device (or null)
  17328. */
  17329. getVRDevice(): any;
  17330. /**
  17331. * Initializes a webVR display and starts listening to display change events
  17332. * The onVRDisplayChangedObservable will be notified upon these changes
  17333. * @returns A promise containing a VRDisplay and if vr is supported
  17334. */
  17335. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17336. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17337. /**
  17338. * Call this function to switch to webVR mode
  17339. * Will do nothing if webVR is not supported or if there is no webVR device
  17340. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17341. */
  17342. enableVR(): void;
  17343. /** @hidden */ private _onVRFullScreenTriggered(): void;
  17344. }
  17345. }
  17346. declare module BABYLON {
  17347. /**
  17348. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17349. * IMPORTANT!! The data is right-hand data.
  17350. * @export
  17351. * @interface DevicePose
  17352. */
  17353. export interface DevicePose {
  17354. /**
  17355. * The position of the device, values in array are [x,y,z].
  17356. */
  17357. readonly position: Nullable<Float32Array>;
  17358. /**
  17359. * The linearVelocity of the device, values in array are [x,y,z].
  17360. */
  17361. readonly linearVelocity: Nullable<Float32Array>;
  17362. /**
  17363. * The linearAcceleration of the device, values in array are [x,y,z].
  17364. */
  17365. readonly linearAcceleration: Nullable<Float32Array>;
  17366. /**
  17367. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17368. */
  17369. readonly orientation: Nullable<Float32Array>;
  17370. /**
  17371. * The angularVelocity of the device, values in array are [x,y,z].
  17372. */
  17373. readonly angularVelocity: Nullable<Float32Array>;
  17374. /**
  17375. * The angularAcceleration of the device, values in array are [x,y,z].
  17376. */
  17377. readonly angularAcceleration: Nullable<Float32Array>;
  17378. }
  17379. /**
  17380. * Interface representing a pose controlled object in Babylon.
  17381. * A pose controlled object has both regular pose values as well as pose values
  17382. * from an external device such as a VR head mounted display
  17383. */
  17384. export interface PoseControlled {
  17385. /**
  17386. * The position of the object in babylon space.
  17387. */
  17388. position: Vector3;
  17389. /**
  17390. * The rotation quaternion of the object in babylon space.
  17391. */
  17392. rotationQuaternion: Quaternion;
  17393. /**
  17394. * The position of the device in babylon space.
  17395. */
  17396. devicePosition?: Vector3;
  17397. /**
  17398. * The rotation quaternion of the device in babylon space.
  17399. */
  17400. deviceRotationQuaternion: Quaternion;
  17401. /**
  17402. * The raw pose coming from the device.
  17403. */
  17404. rawPose: Nullable<DevicePose>;
  17405. /**
  17406. * The scale of the device to be used when translating from device space to babylon space.
  17407. */
  17408. deviceScaleFactor: number;
  17409. /**
  17410. * Updates the poseControlled values based on the input device pose.
  17411. * @param poseData the pose data to update the object with
  17412. */
  17413. updateFromDevice(poseData: DevicePose): void;
  17414. }
  17415. /**
  17416. * Set of options to customize the webVRCamera
  17417. */
  17418. export interface WebVROptions {
  17419. /**
  17420. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17421. */
  17422. trackPosition?: boolean;
  17423. /**
  17424. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17425. */
  17426. positionScale?: number;
  17427. /**
  17428. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17429. */
  17430. displayName?: string;
  17431. /**
  17432. * Should the native controller meshes be initialized. (default: true)
  17433. */
  17434. controllerMeshes?: boolean;
  17435. /**
  17436. * Creating a default HemiLight only on controllers. (default: true)
  17437. */
  17438. defaultLightingOnControllers?: boolean;
  17439. /**
  17440. * If you don't want to use the default VR button of the helper. (default: false)
  17441. */
  17442. useCustomVRButton?: boolean;
  17443. /**
  17444. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17445. */
  17446. customVRButton?: HTMLButtonElement;
  17447. /**
  17448. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17449. */
  17450. rayLength?: number;
  17451. /**
  17452. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17453. */
  17454. defaultHeight?: number;
  17455. /**
  17456. * If multiview should be used if availible (default: false)
  17457. */
  17458. useMultiview?: boolean;
  17459. }
  17460. /**
  17461. * This represents a WebVR camera.
  17462. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17463. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17464. */
  17465. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17466. private webVROptions;
  17467. /**
  17468. * @hidden
  17469. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17470. */ private _vrDevice: any;
  17471. /**
  17472. * The rawPose of the vrDevice.
  17473. */
  17474. rawPose: Nullable<DevicePose>;
  17475. private _onVREnabled;
  17476. private _specsVersion;
  17477. private _attached;
  17478. private _frameData;
  17479. protected _descendants: Array<Node>;
  17480. private _deviceRoomPosition;
  17481. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  17482. private _standingMatrix;
  17483. /**
  17484. * Represents device position in babylon space.
  17485. */
  17486. devicePosition: Vector3;
  17487. /**
  17488. * Represents device rotation in babylon space.
  17489. */
  17490. deviceRotationQuaternion: Quaternion;
  17491. /**
  17492. * The scale of the device to be used when translating from device space to babylon space.
  17493. */
  17494. deviceScaleFactor: number;
  17495. private _deviceToWorld;
  17496. private _worldToDevice;
  17497. /**
  17498. * References to the webVR controllers for the vrDevice.
  17499. */
  17500. controllers: Array<WebVRController>;
  17501. /**
  17502. * Emits an event when a controller is attached.
  17503. */
  17504. onControllersAttachedObservable: Observable<WebVRController[]>;
  17505. /**
  17506. * Emits an event when a controller's mesh has been loaded;
  17507. */
  17508. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17509. /**
  17510. * Emits an event when the HMD's pose has been updated.
  17511. */
  17512. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17513. private _poseSet;
  17514. /**
  17515. * If the rig cameras be used as parent instead of this camera.
  17516. */
  17517. rigParenting: boolean;
  17518. private _lightOnControllers;
  17519. private _defaultHeight?;
  17520. /**
  17521. * Instantiates a WebVRFreeCamera.
  17522. * @param name The name of the WebVRFreeCamera
  17523. * @param position The starting anchor position for the camera
  17524. * @param scene The scene the camera belongs to
  17525. * @param webVROptions a set of customizable options for the webVRCamera
  17526. */
  17527. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17528. /**
  17529. * Gets the device distance from the ground in meters.
  17530. * @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.
  17531. */
  17532. deviceDistanceToRoomGround(): number;
  17533. /**
  17534. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17535. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17536. */
  17537. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17538. /**
  17539. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17540. * @returns A promise with a boolean set to if the standing matrix is supported.
  17541. */
  17542. useStandingMatrixAsync(): Promise<boolean>;
  17543. /**
  17544. * Disposes the camera
  17545. */
  17546. dispose(): void;
  17547. /**
  17548. * Gets a vrController by name.
  17549. * @param name The name of the controller to retreive
  17550. * @returns the controller matching the name specified or null if not found
  17551. */
  17552. getControllerByName(name: string): Nullable<WebVRController>;
  17553. private _leftController;
  17554. /**
  17555. * The controller corresponding to the users left hand.
  17556. */
  17557. readonly leftController: Nullable<WebVRController>;
  17558. private _rightController;
  17559. /**
  17560. * The controller corresponding to the users right hand.
  17561. */
  17562. readonly rightController: Nullable<WebVRController>;
  17563. /**
  17564. * Casts a ray forward from the vrCamera's gaze.
  17565. * @param length Length of the ray (default: 100)
  17566. * @returns the ray corresponding to the gaze
  17567. */
  17568. getForwardRay(length?: number): Ray;
  17569. /**
  17570. * @hidden
  17571. * Updates the camera based on device's frame data
  17572. */ private _checkInputs(): void;
  17573. /**
  17574. * Updates the poseControlled values based on the input device pose.
  17575. * @param poseData Pose coming from the device
  17576. */
  17577. updateFromDevice(poseData: DevicePose): void;
  17578. private _htmlElementAttached;
  17579. private _detachIfAttached;
  17580. /**
  17581. * WebVR's attach control will start broadcasting frames to the device.
  17582. * Note that in certain browsers (chrome for example) this function must be called
  17583. * within a user-interaction callback. Example:
  17584. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17585. *
  17586. * @param element html element to attach the vrDevice to
  17587. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17588. */
  17589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17590. /**
  17591. * Detaches the camera from the html element and disables VR
  17592. *
  17593. * @param element html element to detach from
  17594. */
  17595. detachControl(element: HTMLElement): void;
  17596. /**
  17597. * @returns the name of this class
  17598. */
  17599. getClassName(): string;
  17600. /**
  17601. * Calls resetPose on the vrDisplay
  17602. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17603. */
  17604. resetToCurrentRotation(): void;
  17605. /**
  17606. * @hidden
  17607. * Updates the rig cameras (left and right eye)
  17608. */ private _updateRigCameras(): void;
  17609. private _workingVector;
  17610. private _oneVector;
  17611. private _workingMatrix;
  17612. private updateCacheCalled;
  17613. private _correctPositionIfNotTrackPosition;
  17614. /**
  17615. * @hidden
  17616. * Updates the cached values of the camera
  17617. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17618. */ private _updateCache(ignoreParentClass?: boolean): void;
  17619. /**
  17620. * @hidden
  17621. * Get current device position in babylon world
  17622. */ private _computeDevicePosition(): void;
  17623. /**
  17624. * Updates the current device position and rotation in the babylon world
  17625. */
  17626. update(): void;
  17627. /**
  17628. * @hidden
  17629. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17630. * @returns an identity matrix
  17631. */ private _getViewMatrix(): Matrix;
  17632. private _tmpMatrix;
  17633. /**
  17634. * This function is called by the two RIG cameras.
  17635. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17636. * @hidden
  17637. */ private _getWebVRViewMatrix(): Matrix;
  17638. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  17639. private _onGamepadConnectedObserver;
  17640. private _onGamepadDisconnectedObserver;
  17641. private _updateCacheWhenTrackingDisabledObserver;
  17642. /**
  17643. * Initializes the controllers and their meshes
  17644. */
  17645. initControllers(): void;
  17646. }
  17647. }
  17648. declare module BABYLON {
  17649. /**
  17650. * Size options for a post process
  17651. */
  17652. export type PostProcessOptions = {
  17653. width: number;
  17654. height: number;
  17655. };
  17656. /**
  17657. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17658. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17659. */
  17660. export class PostProcess {
  17661. /** Name of the PostProcess. */
  17662. name: string;
  17663. /**
  17664. * Gets or sets the unique id of the post process
  17665. */
  17666. uniqueId: number;
  17667. /**
  17668. * Width of the texture to apply the post process on
  17669. */
  17670. width: number;
  17671. /**
  17672. * Height of the texture to apply the post process on
  17673. */
  17674. height: number;
  17675. /**
  17676. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17677. * @hidden
  17678. */ private _outputTexture: Nullable<InternalTexture>;
  17679. /**
  17680. * Sampling mode used by the shader
  17681. * See https://doc.babylonjs.com/classes/3.1/texture
  17682. */
  17683. renderTargetSamplingMode: number;
  17684. /**
  17685. * Clear color to use when screen clearing
  17686. */
  17687. clearColor: Color4;
  17688. /**
  17689. * If the buffer needs to be cleared before applying the post process. (default: true)
  17690. * Should be set to false if shader will overwrite all previous pixels.
  17691. */
  17692. autoClear: boolean;
  17693. /**
  17694. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17695. */
  17696. alphaMode: number;
  17697. /**
  17698. * Sets the setAlphaBlendConstants of the babylon engine
  17699. */
  17700. alphaConstants: Color4;
  17701. /**
  17702. * Animations to be used for the post processing
  17703. */
  17704. animations: Animation[];
  17705. /**
  17706. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17707. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17708. */
  17709. enablePixelPerfectMode: boolean;
  17710. /**
  17711. * Force the postprocess to be applied without taking in account viewport
  17712. */
  17713. forceFullscreenViewport: boolean;
  17714. /**
  17715. * List of inspectable custom properties (used by the Inspector)
  17716. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17717. */
  17718. inspectableCustomProperties: IInspectable[];
  17719. /**
  17720. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17721. *
  17722. * | Value | Type | Description |
  17723. * | ----- | ----------------------------------- | ----------- |
  17724. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  17725. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  17726. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  17727. *
  17728. */
  17729. scaleMode: number;
  17730. /**
  17731. * Force textures to be a power of two (default: false)
  17732. */
  17733. alwaysForcePOT: boolean;
  17734. private _samples;
  17735. /**
  17736. * Number of sample textures (default: 1)
  17737. */
  17738. samples: number;
  17739. /**
  17740. * Modify the scale of the post process to be the same as the viewport (default: false)
  17741. */
  17742. adaptScaleToCurrentViewport: boolean;
  17743. private _camera;
  17744. private _scene;
  17745. private _engine;
  17746. private _options;
  17747. private _reusable;
  17748. private _textureType;
  17749. /**
  17750. * Smart array of input and output textures for the post process.
  17751. * @hidden
  17752. */ private _textures: SmartArray<InternalTexture>;
  17753. /**
  17754. * The index in _textures that corresponds to the output texture.
  17755. * @hidden
  17756. */ private _currentRenderTextureInd: number;
  17757. private _effect;
  17758. private _samplers;
  17759. private _fragmentUrl;
  17760. private _vertexUrl;
  17761. private _parameters;
  17762. private _scaleRatio;
  17763. protected _indexParameters: any;
  17764. private _shareOutputWithPostProcess;
  17765. private _texelSize;
  17766. private _forcedOutputTexture;
  17767. /**
  17768. * Returns the fragment url or shader name used in the post process.
  17769. * @returns the fragment url or name in the shader store.
  17770. */
  17771. getEffectName(): string;
  17772. /**
  17773. * An event triggered when the postprocess is activated.
  17774. */
  17775. onActivateObservable: Observable<Camera>;
  17776. private _onActivateObserver;
  17777. /**
  17778. * A function that is added to the onActivateObservable
  17779. */
  17780. onActivate: Nullable<(camera: Camera) => void>;
  17781. /**
  17782. * An event triggered when the postprocess changes its size.
  17783. */
  17784. onSizeChangedObservable: Observable<PostProcess>;
  17785. private _onSizeChangedObserver;
  17786. /**
  17787. * A function that is added to the onSizeChangedObservable
  17788. */
  17789. onSizeChanged: (postProcess: PostProcess) => void;
  17790. /**
  17791. * An event triggered when the postprocess applies its effect.
  17792. */
  17793. onApplyObservable: Observable<Effect>;
  17794. private _onApplyObserver;
  17795. /**
  17796. * A function that is added to the onApplyObservable
  17797. */
  17798. onApply: (effect: Effect) => void;
  17799. /**
  17800. * An event triggered before rendering the postprocess
  17801. */
  17802. onBeforeRenderObservable: Observable<Effect>;
  17803. private _onBeforeRenderObserver;
  17804. /**
  17805. * A function that is added to the onBeforeRenderObservable
  17806. */
  17807. onBeforeRender: (effect: Effect) => void;
  17808. /**
  17809. * An event triggered after rendering the postprocess
  17810. */
  17811. onAfterRenderObservable: Observable<Effect>;
  17812. private _onAfterRenderObserver;
  17813. /**
  17814. * A function that is added to the onAfterRenderObservable
  17815. */
  17816. onAfterRender: (efect: Effect) => void;
  17817. /**
  17818. * 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
  17819. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  17820. */
  17821. inputTexture: InternalTexture;
  17822. /**
  17823. * Gets the camera which post process is applied to.
  17824. * @returns The camera the post process is applied to.
  17825. */
  17826. getCamera(): Camera;
  17827. /**
  17828. * Gets the texel size of the postprocess.
  17829. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  17830. */
  17831. readonly texelSize: Vector2;
  17832. /**
  17833. * Creates a new instance PostProcess
  17834. * @param name The name of the PostProcess.
  17835. * @param fragmentUrl The url of the fragment shader to be used.
  17836. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  17837. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  17838. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17839. * @param camera The camera to apply the render pass to.
  17840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17841. * @param engine The engine which the post process will be applied. (default: current engine)
  17842. * @param reusable If the post process can be reused on the same frame. (default: false)
  17843. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  17844. * @param textureType Type of textures used when performing the post process. (default: 0)
  17845. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  17846. * @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
  17847. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  17848. */
  17849. constructor(
  17850. /** Name of the PostProcess. */
  17851. 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);
  17852. /**
  17853. * Gets a string idenfifying the name of the class
  17854. * @returns "PostProcess" string
  17855. */
  17856. getClassName(): string;
  17857. /**
  17858. * Gets the engine which this post process belongs to.
  17859. * @returns The engine the post process was enabled with.
  17860. */
  17861. getEngine(): Engine;
  17862. /**
  17863. * The effect that is created when initializing the post process.
  17864. * @returns The created effect corresponding the the postprocess.
  17865. */
  17866. getEffect(): Effect;
  17867. /**
  17868. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  17869. * @param postProcess The post process to share the output with.
  17870. * @returns This post process.
  17871. */
  17872. shareOutputWith(postProcess: PostProcess): PostProcess;
  17873. /**
  17874. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  17875. * This should be called if the post process that shares output with this post process is disabled/disposed.
  17876. */
  17877. useOwnOutput(): void;
  17878. /**
  17879. * Updates the effect with the current post process compile time values and recompiles the shader.
  17880. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  17881. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  17882. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  17883. * @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
  17884. * @param onCompiled Called when the shader has been compiled.
  17885. * @param onError Called if there is an error when compiling a shader.
  17886. */
  17887. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17888. /**
  17889. * The post process is reusable if it can be used multiple times within one frame.
  17890. * @returns If the post process is reusable
  17891. */
  17892. isReusable(): boolean;
  17893. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  17894. markTextureDirty(): void;
  17895. /**
  17896. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  17897. * 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.
  17898. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  17899. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  17900. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  17901. * @returns The target texture that was bound to be written to.
  17902. */
  17903. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  17904. /**
  17905. * If the post process is supported.
  17906. */
  17907. readonly isSupported: boolean;
  17908. /**
  17909. * The aspect ratio of the output texture.
  17910. */
  17911. readonly aspectRatio: number;
  17912. /**
  17913. * Get a value indicating if the post-process is ready to be used
  17914. * @returns true if the post-process is ready (shader is compiled)
  17915. */
  17916. isReady(): boolean;
  17917. /**
  17918. * Binds all textures and uniforms to the shader, this will be run on every pass.
  17919. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  17920. */
  17921. apply(): Nullable<Effect>;
  17922. private _disposeTextures;
  17923. /**
  17924. * Disposes the post process.
  17925. * @param camera The camera to dispose the post process on.
  17926. */
  17927. dispose(camera?: Camera): void;
  17928. }
  17929. }
  17930. declare module BABYLON {
  17931. /** @hidden */
  17932. export var kernelBlurVaryingDeclaration: {
  17933. name: string;
  17934. shader: string;
  17935. };
  17936. }
  17937. declare module BABYLON {
  17938. /** @hidden */
  17939. export var kernelBlurFragment: {
  17940. name: string;
  17941. shader: string;
  17942. };
  17943. }
  17944. declare module BABYLON {
  17945. /** @hidden */
  17946. export var kernelBlurFragment2: {
  17947. name: string;
  17948. shader: string;
  17949. };
  17950. }
  17951. declare module BABYLON {
  17952. /** @hidden */
  17953. export var kernelBlurPixelShader: {
  17954. name: string;
  17955. shader: string;
  17956. };
  17957. }
  17958. declare module BABYLON {
  17959. /** @hidden */
  17960. export var kernelBlurVertex: {
  17961. name: string;
  17962. shader: string;
  17963. };
  17964. }
  17965. declare module BABYLON {
  17966. /** @hidden */
  17967. export var kernelBlurVertexShader: {
  17968. name: string;
  17969. shader: string;
  17970. };
  17971. }
  17972. declare module BABYLON {
  17973. /**
  17974. * The Blur Post Process which blurs an image based on a kernel and direction.
  17975. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  17976. */
  17977. export class BlurPostProcess extends PostProcess {
  17978. /** The direction in which to blur the image. */
  17979. direction: Vector2;
  17980. private blockCompilation;
  17981. protected _kernel: number;
  17982. protected _idealKernel: number;
  17983. protected _packedFloat: boolean;
  17984. private _staticDefines;
  17985. /**
  17986. * Sets the length in pixels of the blur sample region
  17987. */
  17988. /**
  17989. * Gets the length in pixels of the blur sample region
  17990. */
  17991. kernel: number;
  17992. /**
  17993. * Sets wether or not the blur needs to unpack/repack floats
  17994. */
  17995. /**
  17996. * Gets wether or not the blur is unpacking/repacking floats
  17997. */
  17998. packedFloat: boolean;
  17999. /**
  18000. * Creates a new instance BlurPostProcess
  18001. * @param name The name of the effect.
  18002. * @param direction The direction in which to blur the image.
  18003. * @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.
  18004. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18005. * @param camera The camera to apply the render pass to.
  18006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18007. * @param engine The engine which the post process will be applied. (default: current engine)
  18008. * @param reusable If the post process can be reused on the same frame. (default: false)
  18009. * @param textureType Type of textures used when performing the post process. (default: 0)
  18010. * @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)
  18011. */
  18012. constructor(name: string,
  18013. /** The direction in which to blur the image. */
  18014. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18015. /**
  18016. * Updates the effect with the current post process compile time values and recompiles the shader.
  18017. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18018. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18019. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18020. * @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
  18021. * @param onCompiled Called when the shader has been compiled.
  18022. * @param onError Called if there is an error when compiling a shader.
  18023. */
  18024. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18025. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18026. /**
  18027. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18028. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18029. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18030. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18031. * The gaps between physical kernels are compensated for in the weighting of the samples
  18032. * @param idealKernel Ideal blur kernel.
  18033. * @return Nearest best kernel.
  18034. */
  18035. protected _nearestBestKernel(idealKernel: number): number;
  18036. /**
  18037. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18038. * @param x The point on the Gaussian distribution to sample.
  18039. * @return the value of the Gaussian function at x.
  18040. */
  18041. protected _gaussianWeight(x: number): number;
  18042. /**
  18043. * Generates a string that can be used as a floating point number in GLSL.
  18044. * @param x Value to print.
  18045. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18046. * @return GLSL float string.
  18047. */
  18048. protected _glslFloat(x: number, decimalFigures?: number): string;
  18049. }
  18050. }
  18051. declare module BABYLON {
  18052. /**
  18053. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18054. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18055. * You can then easily use it as a reflectionTexture on a flat surface.
  18056. * In case the surface is not a plane, please consider relying on reflection probes.
  18057. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18058. */
  18059. export class MirrorTexture extends RenderTargetTexture {
  18060. private scene;
  18061. /**
  18062. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18063. * 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.
  18064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18065. */
  18066. mirrorPlane: Plane;
  18067. /**
  18068. * Define the blur ratio used to blur the reflection if needed.
  18069. */
  18070. blurRatio: number;
  18071. /**
  18072. * Define the adaptive blur kernel used to blur the reflection if needed.
  18073. * This will autocompute the closest best match for the `blurKernel`
  18074. */
  18075. adaptiveBlurKernel: number;
  18076. /**
  18077. * Define the blur kernel used to blur the reflection if needed.
  18078. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18079. */
  18080. blurKernel: number;
  18081. /**
  18082. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18083. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18084. */
  18085. blurKernelX: number;
  18086. /**
  18087. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18088. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18089. */
  18090. blurKernelY: number;
  18091. private _autoComputeBlurKernel;
  18092. protected _onRatioRescale(): void;
  18093. private _updateGammaSpace;
  18094. private _imageProcessingConfigChangeObserver;
  18095. private _transformMatrix;
  18096. private _mirrorMatrix;
  18097. private _savedViewMatrix;
  18098. private _blurX;
  18099. private _blurY;
  18100. private _adaptiveBlurKernel;
  18101. private _blurKernelX;
  18102. private _blurKernelY;
  18103. private _blurRatio;
  18104. /**
  18105. * Instantiates a Mirror Texture.
  18106. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18107. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18108. * You can then easily use it as a reflectionTexture on a flat surface.
  18109. * In case the surface is not a plane, please consider relying on reflection probes.
  18110. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18111. * @param name
  18112. * @param size
  18113. * @param scene
  18114. * @param generateMipMaps
  18115. * @param type
  18116. * @param samplingMode
  18117. * @param generateDepthBuffer
  18118. */
  18119. constructor(name: string, size: number | {
  18120. width: number;
  18121. height: number;
  18122. } | {
  18123. ratio: number;
  18124. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18125. private _preparePostProcesses;
  18126. /**
  18127. * Clone the mirror texture.
  18128. * @returns the cloned texture
  18129. */
  18130. clone(): MirrorTexture;
  18131. /**
  18132. * Serialize the texture to a JSON representation you could use in Parse later on
  18133. * @returns the serialized JSON representation
  18134. */
  18135. serialize(): any;
  18136. /**
  18137. * Dispose the texture and release its associated resources.
  18138. */
  18139. dispose(): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18145. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18146. */
  18147. export class Texture extends BaseTexture {
  18148. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18149. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18150. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18151. /** nearest is mag = nearest and min = nearest and mip = linear */
  18152. static readonly NEAREST_SAMPLINGMODE: number;
  18153. /** nearest is mag = nearest and min = nearest and mip = linear */
  18154. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18155. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18156. static readonly BILINEAR_SAMPLINGMODE: number;
  18157. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18158. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18159. /** Trilinear is mag = linear and min = linear and mip = linear */
  18160. static readonly TRILINEAR_SAMPLINGMODE: number;
  18161. /** Trilinear is mag = linear and min = linear and mip = linear */
  18162. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18163. /** mag = nearest and min = nearest and mip = nearest */
  18164. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18165. /** mag = nearest and min = linear and mip = nearest */
  18166. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18167. /** mag = nearest and min = linear and mip = linear */
  18168. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18169. /** mag = nearest and min = linear and mip = none */
  18170. static readonly NEAREST_LINEAR: number;
  18171. /** mag = nearest and min = nearest and mip = none */
  18172. static readonly NEAREST_NEAREST: number;
  18173. /** mag = linear and min = nearest and mip = nearest */
  18174. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18175. /** mag = linear and min = nearest and mip = linear */
  18176. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18177. /** mag = linear and min = linear and mip = none */
  18178. static readonly LINEAR_LINEAR: number;
  18179. /** mag = linear and min = nearest and mip = none */
  18180. static readonly LINEAR_NEAREST: number;
  18181. /** Explicit coordinates mode */
  18182. static readonly EXPLICIT_MODE: number;
  18183. /** Spherical coordinates mode */
  18184. static readonly SPHERICAL_MODE: number;
  18185. /** Planar coordinates mode */
  18186. static readonly PLANAR_MODE: number;
  18187. /** Cubic coordinates mode */
  18188. static readonly CUBIC_MODE: number;
  18189. /** Projection coordinates mode */
  18190. static readonly PROJECTION_MODE: number;
  18191. /** Inverse Cubic coordinates mode */
  18192. static readonly SKYBOX_MODE: number;
  18193. /** Inverse Cubic coordinates mode */
  18194. static readonly INVCUBIC_MODE: number;
  18195. /** Equirectangular coordinates mode */
  18196. static readonly EQUIRECTANGULAR_MODE: number;
  18197. /** Equirectangular Fixed coordinates mode */
  18198. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18199. /** Equirectangular Fixed Mirrored coordinates mode */
  18200. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18201. /** Texture is not repeating outside of 0..1 UVs */
  18202. static readonly CLAMP_ADDRESSMODE: number;
  18203. /** Texture is repeating outside of 0..1 UVs */
  18204. static readonly WRAP_ADDRESSMODE: number;
  18205. /** Texture is repeating and mirrored */
  18206. static readonly MIRROR_ADDRESSMODE: number;
  18207. /**
  18208. * 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
  18209. */
  18210. static UseSerializedUrlIfAny: boolean;
  18211. /**
  18212. * Define the url of the texture.
  18213. */
  18214. url: Nullable<string>;
  18215. /**
  18216. * Define an offset on the texture to offset the u coordinates of the UVs
  18217. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18218. */
  18219. uOffset: number;
  18220. /**
  18221. * Define an offset on the texture to offset the v coordinates of the UVs
  18222. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18223. */
  18224. vOffset: number;
  18225. /**
  18226. * Define an offset on the texture to scale the u coordinates of the UVs
  18227. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18228. */
  18229. uScale: number;
  18230. /**
  18231. * Define an offset on the texture to scale the v coordinates of the UVs
  18232. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18233. */
  18234. vScale: number;
  18235. /**
  18236. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18237. * @see http://doc.babylonjs.com/how_to/more_materials
  18238. */
  18239. uAng: number;
  18240. /**
  18241. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18242. * @see http://doc.babylonjs.com/how_to/more_materials
  18243. */
  18244. vAng: number;
  18245. /**
  18246. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18247. * @see http://doc.babylonjs.com/how_to/more_materials
  18248. */
  18249. wAng: number;
  18250. /**
  18251. * Defines the center of rotation (U)
  18252. */
  18253. uRotationCenter: number;
  18254. /**
  18255. * Defines the center of rotation (V)
  18256. */
  18257. vRotationCenter: number;
  18258. /**
  18259. * Defines the center of rotation (W)
  18260. */
  18261. wRotationCenter: number;
  18262. /**
  18263. * Are mip maps generated for this texture or not.
  18264. */
  18265. readonly noMipmap: boolean;
  18266. /**
  18267. * List of inspectable custom properties (used by the Inspector)
  18268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18269. */
  18270. inspectableCustomProperties: Nullable<IInspectable[]>;
  18271. private _noMipmap;
  18272. /** @hidden */ private _invertY: boolean;
  18273. private _rowGenerationMatrix;
  18274. private _cachedTextureMatrix;
  18275. private _projectionModeMatrix;
  18276. private _t0;
  18277. private _t1;
  18278. private _t2;
  18279. private _cachedUOffset;
  18280. private _cachedVOffset;
  18281. private _cachedUScale;
  18282. private _cachedVScale;
  18283. private _cachedUAng;
  18284. private _cachedVAng;
  18285. private _cachedWAng;
  18286. private _cachedProjectionMatrixId;
  18287. private _cachedCoordinatesMode;
  18288. /** @hidden */
  18289. protected _initialSamplingMode: number;
  18290. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18291. private _deleteBuffer;
  18292. protected _format: Nullable<number>;
  18293. private _delayedOnLoad;
  18294. private _delayedOnError;
  18295. /**
  18296. * Observable triggered once the texture has been loaded.
  18297. */
  18298. onLoadObservable: Observable<Texture>;
  18299. protected _isBlocking: boolean;
  18300. /**
  18301. * Is the texture preventing material to render while loading.
  18302. * If false, a default texture will be used instead of the loading one during the preparation step.
  18303. */
  18304. isBlocking: boolean;
  18305. /**
  18306. * Get the current sampling mode associated with the texture.
  18307. */
  18308. readonly samplingMode: number;
  18309. /**
  18310. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18311. */
  18312. readonly invertY: boolean;
  18313. /**
  18314. * Instantiates a new texture.
  18315. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18316. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18317. * @param url define the url of the picture to load as a texture
  18318. * @param scene define the scene the texture will belong to
  18319. * @param noMipmap define if the texture will require mip maps or not
  18320. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18321. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18322. * @param onLoad define a callback triggered when the texture has been loaded
  18323. * @param onError define a callback triggered when an error occurred during the loading session
  18324. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18325. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18326. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18327. */
  18328. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18329. /**
  18330. * Update the url (and optional buffer) of this texture if url was null during construction.
  18331. * @param url the url of the texture
  18332. * @param buffer the buffer of the texture (defaults to null)
  18333. * @param onLoad callback called when the texture is loaded (defaults to null)
  18334. */
  18335. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18336. /**
  18337. * Finish the loading sequence of a texture flagged as delayed load.
  18338. * @hidden
  18339. */
  18340. delayLoad(): void;
  18341. private _prepareRowForTextureGeneration;
  18342. /**
  18343. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18344. * @returns the transform matrix of the texture.
  18345. */
  18346. getTextureMatrix(): Matrix;
  18347. /**
  18348. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18349. * @returns The reflection texture transform
  18350. */
  18351. getReflectionTextureMatrix(): Matrix;
  18352. /**
  18353. * Clones the texture.
  18354. * @returns the cloned texture
  18355. */
  18356. clone(): Texture;
  18357. /**
  18358. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18359. * @returns The JSON representation of the texture
  18360. */
  18361. serialize(): any;
  18362. /**
  18363. * Get the current class name of the texture useful for serialization or dynamic coding.
  18364. * @returns "Texture"
  18365. */
  18366. getClassName(): string;
  18367. /**
  18368. * Dispose the texture and release its associated resources.
  18369. */
  18370. dispose(): void;
  18371. /**
  18372. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18373. * @param parsedTexture Define the JSON representation of the texture
  18374. * @param scene Define the scene the parsed texture should be instantiated in
  18375. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18376. * @returns The parsed texture if successful
  18377. */
  18378. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18379. /**
  18380. * Creates a texture from its base 64 representation.
  18381. * @param data Define the base64 payload without the data: prefix
  18382. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18383. * @param scene Define the scene the texture should belong to
  18384. * @param noMipmap Forces the texture to not create mip map information if true
  18385. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18386. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18387. * @param onLoad define a callback triggered when the texture has been loaded
  18388. * @param onError define a callback triggered when an error occurred during the loading session
  18389. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18390. * @returns the created texture
  18391. */
  18392. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18393. /**
  18394. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18395. * @param data Define the base64 payload without the data: prefix
  18396. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18397. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18398. * @param scene Define the scene the texture should belong to
  18399. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18400. * @param noMipmap Forces the texture to not create mip map information if true
  18401. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18402. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18403. * @param onLoad define a callback triggered when the texture has been loaded
  18404. * @param onError define a callback triggered when an error occurred during the loading session
  18405. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18406. * @returns the created texture
  18407. */
  18408. 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;
  18409. }
  18410. }
  18411. declare module BABYLON {
  18412. /**
  18413. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18414. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18415. */
  18416. export class PostProcessManager {
  18417. private _scene;
  18418. private _indexBuffer;
  18419. private _vertexBuffers;
  18420. /**
  18421. * Creates a new instance PostProcess
  18422. * @param scene The scene that the post process is associated with.
  18423. */
  18424. constructor(scene: Scene);
  18425. private _prepareBuffers;
  18426. private _buildIndexBuffer;
  18427. /**
  18428. * Rebuilds the vertex buffers of the manager.
  18429. * @hidden
  18430. */ private _rebuild(): void;
  18431. /**
  18432. * Prepares a frame to be run through a post process.
  18433. * @param sourceTexture The input texture to the post procesess. (default: null)
  18434. * @param postProcesses An array of post processes to be run. (default: null)
  18435. * @returns True if the post processes were able to be run.
  18436. * @hidden
  18437. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18438. /**
  18439. * Manually render a set of post processes to a texture.
  18440. * @param postProcesses An array of post processes to be run.
  18441. * @param targetTexture The target texture to render to.
  18442. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18443. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18444. * @param lodLevel defines which lod of the texture to render to
  18445. */
  18446. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18447. /**
  18448. * Finalize the result of the output of the postprocesses.
  18449. * @param doNotPresent If true the result will not be displayed to the screen.
  18450. * @param targetTexture The target texture to render to.
  18451. * @param faceIndex The index of the face to bind the target texture to.
  18452. * @param postProcesses The array of post processes to render.
  18453. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18454. * @hidden
  18455. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18456. /**
  18457. * Disposes of the post process manager.
  18458. */
  18459. dispose(): void;
  18460. }
  18461. }
  18462. declare module BABYLON {
  18463. interface AbstractScene {
  18464. /**
  18465. * The list of procedural textures added to the scene
  18466. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18467. */
  18468. proceduralTextures: Array<ProceduralTexture>;
  18469. }
  18470. /**
  18471. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18472. * in a given scene.
  18473. */
  18474. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18475. /**
  18476. * The component name helpfull to identify the component in the list of scene components.
  18477. */
  18478. readonly name: string;
  18479. /**
  18480. * The scene the component belongs to.
  18481. */
  18482. scene: Scene;
  18483. /**
  18484. * Creates a new instance of the component for the given scene
  18485. * @param scene Defines the scene to register the component in
  18486. */
  18487. constructor(scene: Scene);
  18488. /**
  18489. * Registers the component in a given scene
  18490. */
  18491. register(): void;
  18492. /**
  18493. * Rebuilds the elements related to this component in case of
  18494. * context lost for instance.
  18495. */
  18496. rebuild(): void;
  18497. /**
  18498. * Disposes the component and the associated ressources.
  18499. */
  18500. dispose(): void;
  18501. private _beforeClear;
  18502. }
  18503. }
  18504. declare module BABYLON {
  18505. interface Engine {
  18506. /**
  18507. * Creates a new render target cube texture
  18508. * @param size defines the size of the texture
  18509. * @param options defines the options used to create the texture
  18510. * @returns a new render target cube texture stored in an InternalTexture
  18511. */
  18512. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18513. }
  18514. }
  18515. declare module BABYLON {
  18516. /** @hidden */
  18517. export var proceduralVertexShader: {
  18518. name: string;
  18519. shader: string;
  18520. };
  18521. }
  18522. declare module BABYLON {
  18523. /**
  18524. * 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.
  18525. * This is the base class of any Procedural texture and contains most of the shareable code.
  18526. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18527. */
  18528. export class ProceduralTexture extends Texture {
  18529. isCube: boolean;
  18530. /**
  18531. * Define if the texture is enabled or not (disabled texture will not render)
  18532. */
  18533. isEnabled: boolean;
  18534. /**
  18535. * Define if the texture must be cleared before rendering (default is true)
  18536. */
  18537. autoClear: boolean;
  18538. /**
  18539. * Callback called when the texture is generated
  18540. */
  18541. onGenerated: () => void;
  18542. /**
  18543. * Event raised when the texture is generated
  18544. */
  18545. onGeneratedObservable: Observable<ProceduralTexture>;
  18546. /** @hidden */ private _generateMipMaps: boolean;
  18547. /** @hidden **/ private _effect: Effect;
  18548. /** @hidden */ private _textures: {
  18549. [key: string]: Texture;
  18550. };
  18551. private _size;
  18552. private _currentRefreshId;
  18553. private _refreshRate;
  18554. private _vertexBuffers;
  18555. private _indexBuffer;
  18556. private _uniforms;
  18557. private _samplers;
  18558. private _fragment;
  18559. private _floats;
  18560. private _ints;
  18561. private _floatsArrays;
  18562. private _colors3;
  18563. private _colors4;
  18564. private _vectors2;
  18565. private _vectors3;
  18566. private _matrices;
  18567. private _fallbackTexture;
  18568. private _fallbackTextureUsed;
  18569. private _engine;
  18570. private _cachedDefines;
  18571. private _contentUpdateId;
  18572. private _contentData;
  18573. /**
  18574. * Instantiates a new procedural texture.
  18575. * 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.
  18576. * This is the base class of any Procedural texture and contains most of the shareable code.
  18577. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18578. * @param name Define the name of the texture
  18579. * @param size Define the size of the texture to create
  18580. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18581. * @param scene Define the scene the texture belongs to
  18582. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18583. * @param generateMipMaps Define if the texture should creates mip maps or not
  18584. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18585. */
  18586. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18587. /**
  18588. * The effect that is created when initializing the post process.
  18589. * @returns The created effect corresponding the the postprocess.
  18590. */
  18591. getEffect(): Effect;
  18592. /**
  18593. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18594. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18595. */
  18596. getContent(): Nullable<ArrayBufferView>;
  18597. private _createIndexBuffer;
  18598. /** @hidden */ private _rebuild(): void;
  18599. /**
  18600. * Resets the texture in order to recreate its associated resources.
  18601. * This can be called in case of context loss
  18602. */
  18603. reset(): void;
  18604. protected _getDefines(): string;
  18605. /**
  18606. * Is the texture ready to be used ? (rendered at least once)
  18607. * @returns true if ready, otherwise, false.
  18608. */
  18609. isReady(): boolean;
  18610. /**
  18611. * Resets the refresh counter of the texture and start bak from scratch.
  18612. * Could be useful to regenerate the texture if it is setup to render only once.
  18613. */
  18614. resetRefreshCounter(): void;
  18615. /**
  18616. * Set the fragment shader to use in order to render the texture.
  18617. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18618. */
  18619. setFragment(fragment: any): void;
  18620. /**
  18621. * Define the refresh rate of the texture or the rendering frequency.
  18622. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18623. */
  18624. refreshRate: number;
  18625. /** @hidden */ private _shouldRender(): boolean;
  18626. /**
  18627. * Get the size the texture is rendering at.
  18628. * @returns the size (texture is always squared)
  18629. */
  18630. getRenderSize(): number;
  18631. /**
  18632. * Resize the texture to new value.
  18633. * @param size Define the new size the texture should have
  18634. * @param generateMipMaps Define whether the new texture should create mip maps
  18635. */
  18636. resize(size: number, generateMipMaps: boolean): void;
  18637. private _checkUniform;
  18638. /**
  18639. * Set a texture in the shader program used to render.
  18640. * @param name Define the name of the uniform samplers as defined in the shader
  18641. * @param texture Define the texture to bind to this sampler
  18642. * @return the texture itself allowing "fluent" like uniform updates
  18643. */
  18644. setTexture(name: string, texture: Texture): ProceduralTexture;
  18645. /**
  18646. * Set a float in the shader.
  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 texture itself allowing "fluent" like uniform updates
  18650. */
  18651. setFloat(name: string, value: number): ProceduralTexture;
  18652. /**
  18653. * Set a int in the shader.
  18654. * @param name Define the name of the uniform as defined in the shader
  18655. * @param value Define the value to give to the uniform
  18656. * @return the texture itself allowing "fluent" like uniform updates
  18657. */
  18658. setInt(name: string, value: number): ProceduralTexture;
  18659. /**
  18660. * Set an array of floats in the shader.
  18661. * @param name Define the name of the uniform as defined in the shader
  18662. * @param value Define the value to give to the uniform
  18663. * @return the texture itself allowing "fluent" like uniform updates
  18664. */
  18665. setFloats(name: string, value: number[]): ProceduralTexture;
  18666. /**
  18667. * Set a vec3 in the shader from a Color3.
  18668. * @param name Define the name of the uniform as defined in the shader
  18669. * @param value Define the value to give to the uniform
  18670. * @return the texture itself allowing "fluent" like uniform updates
  18671. */
  18672. setColor3(name: string, value: Color3): ProceduralTexture;
  18673. /**
  18674. * Set a vec4 in the shader from a Color4.
  18675. * @param name Define the name of the uniform as defined in the shader
  18676. * @param value Define the value to give to the uniform
  18677. * @return the texture itself allowing "fluent" like uniform updates
  18678. */
  18679. setColor4(name: string, value: Color4): ProceduralTexture;
  18680. /**
  18681. * Set a vec2 in the shader from a Vector2.
  18682. * @param name Define the name of the uniform as defined in the shader
  18683. * @param value Define the value to give to the uniform
  18684. * @return the texture itself allowing "fluent" like uniform updates
  18685. */
  18686. setVector2(name: string, value: Vector2): ProceduralTexture;
  18687. /**
  18688. * Set a vec3 in the shader from a Vector3.
  18689. * @param name Define the name of the uniform as defined in the shader
  18690. * @param value Define the value to give to the uniform
  18691. * @return the texture itself allowing "fluent" like uniform updates
  18692. */
  18693. setVector3(name: string, value: Vector3): ProceduralTexture;
  18694. /**
  18695. * Set a mat4 in the shader from a MAtrix.
  18696. * @param name Define the name of the uniform as defined in the shader
  18697. * @param value Define the value to give to the uniform
  18698. * @return the texture itself allowing "fluent" like uniform updates
  18699. */
  18700. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18701. /**
  18702. * Render the texture to its associated render target.
  18703. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18704. */
  18705. render(useCameraPostProcess?: boolean): void;
  18706. /**
  18707. * Clone the texture.
  18708. * @returns the cloned texture
  18709. */
  18710. clone(): ProceduralTexture;
  18711. /**
  18712. * Dispose the texture and release its asoociated resources.
  18713. */
  18714. dispose(): void;
  18715. }
  18716. }
  18717. declare module BABYLON {
  18718. /**
  18719. * This represents the base class for particle system in Babylon.
  18720. * 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.
  18721. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18722. * @example https://doc.babylonjs.com/babylon101/particles
  18723. */
  18724. export class BaseParticleSystem {
  18725. /**
  18726. * Source color is added to the destination color without alpha affecting the result
  18727. */
  18728. static BLENDMODE_ONEONE: number;
  18729. /**
  18730. * Blend current color and particle color using particle’s alpha
  18731. */
  18732. static BLENDMODE_STANDARD: number;
  18733. /**
  18734. * Add current color and particle color multiplied by particle’s alpha
  18735. */
  18736. static BLENDMODE_ADD: number;
  18737. /**
  18738. * Multiply current color with particle color
  18739. */
  18740. static BLENDMODE_MULTIPLY: number;
  18741. /**
  18742. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  18743. */
  18744. static BLENDMODE_MULTIPLYADD: number;
  18745. /**
  18746. * List of animations used by the particle system.
  18747. */
  18748. animations: Animation[];
  18749. /**
  18750. * The id of the Particle system.
  18751. */
  18752. id: string;
  18753. /**
  18754. * The friendly name of the Particle system.
  18755. */
  18756. name: string;
  18757. /**
  18758. * The rendering group used by the Particle system to chose when to render.
  18759. */
  18760. renderingGroupId: number;
  18761. /**
  18762. * The emitter represents the Mesh or position we are attaching the particle system to.
  18763. */
  18764. emitter: Nullable<AbstractMesh | Vector3>;
  18765. /**
  18766. * The maximum number of particles to emit per frame
  18767. */
  18768. emitRate: number;
  18769. /**
  18770. * If you want to launch only a few particles at once, that can be done, as well.
  18771. */
  18772. manualEmitCount: number;
  18773. /**
  18774. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18775. */
  18776. updateSpeed: number;
  18777. /**
  18778. * The amount of time the particle system is running (depends of the overall update speed).
  18779. */
  18780. targetStopDuration: number;
  18781. /**
  18782. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18783. */
  18784. disposeOnStop: boolean;
  18785. /**
  18786. * Minimum power of emitting particles.
  18787. */
  18788. minEmitPower: number;
  18789. /**
  18790. * Maximum power of emitting particles.
  18791. */
  18792. maxEmitPower: number;
  18793. /**
  18794. * Minimum life time of emitting particles.
  18795. */
  18796. minLifeTime: number;
  18797. /**
  18798. * Maximum life time of emitting particles.
  18799. */
  18800. maxLifeTime: number;
  18801. /**
  18802. * Minimum Size of emitting particles.
  18803. */
  18804. minSize: number;
  18805. /**
  18806. * Maximum Size of emitting particles.
  18807. */
  18808. maxSize: number;
  18809. /**
  18810. * Minimum scale of emitting particles on X axis.
  18811. */
  18812. minScaleX: number;
  18813. /**
  18814. * Maximum scale of emitting particles on X axis.
  18815. */
  18816. maxScaleX: number;
  18817. /**
  18818. * Minimum scale of emitting particles on Y axis.
  18819. */
  18820. minScaleY: number;
  18821. /**
  18822. * Maximum scale of emitting particles on Y axis.
  18823. */
  18824. maxScaleY: number;
  18825. /**
  18826. * Gets or sets the minimal initial rotation in radians.
  18827. */
  18828. minInitialRotation: number;
  18829. /**
  18830. * Gets or sets the maximal initial rotation in radians.
  18831. */
  18832. maxInitialRotation: number;
  18833. /**
  18834. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18835. */
  18836. minAngularSpeed: number;
  18837. /**
  18838. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18839. */
  18840. maxAngularSpeed: number;
  18841. /**
  18842. * The texture used to render each particle. (this can be a spritesheet)
  18843. */
  18844. particleTexture: Nullable<Texture>;
  18845. /**
  18846. * The layer mask we are rendering the particles through.
  18847. */
  18848. layerMask: number;
  18849. /**
  18850. * This can help using your own shader to render the particle system.
  18851. * The according effect will be created
  18852. */
  18853. customShader: any;
  18854. /**
  18855. * By default particle system starts as soon as they are created. This prevents the
  18856. * automatic start to happen and let you decide when to start emitting particles.
  18857. */
  18858. preventAutoStart: boolean;
  18859. private _noiseTexture;
  18860. /**
  18861. * Gets or sets a texture used to add random noise to particle positions
  18862. */
  18863. noiseTexture: Nullable<ProceduralTexture>;
  18864. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18865. noiseStrength: Vector3;
  18866. /**
  18867. * Callback triggered when the particle animation is ending.
  18868. */
  18869. onAnimationEnd: Nullable<() => void>;
  18870. /**
  18871. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18872. */
  18873. blendMode: number;
  18874. /**
  18875. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18876. * to override the particles.
  18877. */
  18878. forceDepthWrite: boolean;
  18879. /** 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 */
  18880. preWarmCycles: number;
  18881. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  18882. preWarmStepOffset: number;
  18883. /**
  18884. * 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)
  18885. */
  18886. spriteCellChangeSpeed: number;
  18887. /**
  18888. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18889. */
  18890. startSpriteCellID: number;
  18891. /**
  18892. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18893. */
  18894. endSpriteCellID: number;
  18895. /**
  18896. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18897. */
  18898. spriteCellWidth: number;
  18899. /**
  18900. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18901. */
  18902. spriteCellHeight: number;
  18903. /**
  18904. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18905. */
  18906. spriteRandomStartCell: boolean;
  18907. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18908. translationPivot: Vector2;
  18909. /** @hidden */
  18910. protected _isAnimationSheetEnabled: boolean;
  18911. /**
  18912. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18913. */
  18914. beginAnimationOnStart: boolean;
  18915. /**
  18916. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18917. */
  18918. beginAnimationFrom: number;
  18919. /**
  18920. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18921. */
  18922. beginAnimationTo: number;
  18923. /**
  18924. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18925. */
  18926. beginAnimationLoop: boolean;
  18927. /**
  18928. * Gets or sets a world offset applied to all particles
  18929. */
  18930. worldOffset: Vector3;
  18931. /**
  18932. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  18933. */
  18934. isAnimationSheetEnabled: boolean;
  18935. /**
  18936. * Get hosting scene
  18937. * @returns the scene
  18938. */
  18939. getScene(): Scene;
  18940. /**
  18941. * You can use gravity if you want to give an orientation to your particles.
  18942. */
  18943. gravity: Vector3;
  18944. protected _colorGradients: Nullable<Array<ColorGradient>>;
  18945. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  18946. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  18947. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  18948. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  18949. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  18950. protected _dragGradients: Nullable<Array<FactorGradient>>;
  18951. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  18952. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  18953. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  18954. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  18955. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  18956. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  18957. /**
  18958. * Defines the delay in milliseconds before starting the system (0 by default)
  18959. */
  18960. startDelay: number;
  18961. /**
  18962. * Gets the current list of drag gradients.
  18963. * You must use addDragGradient and removeDragGradient to udpate this list
  18964. * @returns the list of drag gradients
  18965. */
  18966. getDragGradients(): Nullable<Array<FactorGradient>>;
  18967. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18968. limitVelocityDamping: number;
  18969. /**
  18970. * Gets the current list of limit velocity gradients.
  18971. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18972. * @returns the list of limit velocity gradients
  18973. */
  18974. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of color gradients.
  18977. * You must use addColorGradient and removeColorGradient to udpate this list
  18978. * @returns the list of color gradients
  18979. */
  18980. getColorGradients(): Nullable<Array<ColorGradient>>;
  18981. /**
  18982. * Gets the current list of size gradients.
  18983. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18984. * @returns the list of size gradients
  18985. */
  18986. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18987. /**
  18988. * Gets the current list of color remap gradients.
  18989. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18990. * @returns the list of color remap gradients
  18991. */
  18992. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18993. /**
  18994. * Gets the current list of alpha remap gradients.
  18995. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18996. * @returns the list of alpha remap gradients
  18997. */
  18998. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18999. /**
  19000. * Gets the current list of life time gradients.
  19001. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19002. * @returns the list of life time gradients
  19003. */
  19004. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Gets the current list of angular speed gradients.
  19007. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19008. * @returns the list of angular speed gradients
  19009. */
  19010. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19011. /**
  19012. * Gets the current list of velocity gradients.
  19013. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19014. * @returns the list of velocity gradients
  19015. */
  19016. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19017. /**
  19018. * Gets the current list of start size gradients.
  19019. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19020. * @returns the list of start size gradients
  19021. */
  19022. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19023. /**
  19024. * Gets the current list of emit rate gradients.
  19025. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19026. * @returns the list of emit rate gradients
  19027. */
  19028. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19031. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19032. */
  19033. direction1: Vector3;
  19034. /**
  19035. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19036. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19037. */
  19038. direction2: Vector3;
  19039. /**
  19040. * 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.
  19041. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19042. */
  19043. minEmitBox: Vector3;
  19044. /**
  19045. * 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.
  19046. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19047. */
  19048. maxEmitBox: Vector3;
  19049. /**
  19050. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19051. */
  19052. color1: Color4;
  19053. /**
  19054. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19055. */
  19056. color2: Color4;
  19057. /**
  19058. * Color the particle will have at the end of its lifetime
  19059. */
  19060. colorDead: Color4;
  19061. /**
  19062. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19063. */
  19064. textureMask: Color4;
  19065. /**
  19066. * The particle emitter type defines the emitter used by the particle system.
  19067. * It can be for example box, sphere, or cone...
  19068. */
  19069. particleEmitterType: IParticleEmitterType;
  19070. /** @hidden */ private _isSubEmitter: boolean;
  19071. /**
  19072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19074. */
  19075. billboardMode: number;
  19076. protected _isBillboardBased: boolean;
  19077. /**
  19078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19079. */
  19080. isBillboardBased: boolean;
  19081. /**
  19082. * The scene the particle system belongs to.
  19083. */
  19084. protected _scene: Scene;
  19085. /**
  19086. * Local cache of defines for image processing.
  19087. */
  19088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19089. /**
  19090. * Default configuration related to image processing available in the standard Material.
  19091. */
  19092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19093. /**
  19094. * Gets the image processing configuration used either in this material.
  19095. */
  19096. /**
  19097. * Sets the Default image processing configuration used either in the this material.
  19098. *
  19099. * If sets to null, the scene one is in use.
  19100. */
  19101. imageProcessingConfiguration: ImageProcessingConfiguration;
  19102. /**
  19103. * Attaches a new image processing configuration to the Standard Material.
  19104. * @param configuration
  19105. */
  19106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19107. /** @hidden */
  19108. protected _reset(): void;
  19109. /** @hidden */
  19110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19111. /**
  19112. * Instantiates a particle system.
  19113. * 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.
  19114. * @param name The name of the particle system
  19115. */
  19116. constructor(name: string);
  19117. /**
  19118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19121. * @returns the emitter
  19122. */
  19123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19124. /**
  19125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19126. * @param radius The radius of the hemisphere to emit from
  19127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19128. * @returns the emitter
  19129. */
  19130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19131. /**
  19132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19133. * @param radius The radius of the sphere to emit from
  19134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19135. * @returns the emitter
  19136. */
  19137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19138. /**
  19139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the sphere to emit from
  19141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19143. * @returns the emitter
  19144. */
  19145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19146. /**
  19147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19148. * @param radius The radius of the emission cylinder
  19149. * @param height The height of the emission cylinder
  19150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19152. * @returns the emitter
  19153. */
  19154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19155. /**
  19156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19157. * @param radius The radius of the cylinder to emit from
  19158. * @param height The height of the emission cylinder
  19159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19162. * @returns the emitter
  19163. */
  19164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19165. /**
  19166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19167. * @param radius The radius of the cone to emit from
  19168. * @param angle The base angle of the cone
  19169. * @returns the emitter
  19170. */
  19171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19172. /**
  19173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19178. * @returns the emitter
  19179. */
  19180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19181. }
  19182. }
  19183. declare module BABYLON {
  19184. /**
  19185. * Type of sub emitter
  19186. */
  19187. export enum SubEmitterType {
  19188. /**
  19189. * Attached to the particle over it's lifetime
  19190. */
  19191. ATTACHED = 0,
  19192. /**
  19193. * Created when the particle dies
  19194. */
  19195. END = 1
  19196. }
  19197. /**
  19198. * Sub emitter class used to emit particles from an existing particle
  19199. */
  19200. export class SubEmitter {
  19201. /**
  19202. * the particle system to be used by the sub emitter
  19203. */
  19204. particleSystem: ParticleSystem;
  19205. /**
  19206. * Type of the submitter (Default: END)
  19207. */
  19208. type: SubEmitterType;
  19209. /**
  19210. * 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)
  19211. * Note: This only is supported when using an emitter of type Mesh
  19212. */
  19213. inheritDirection: boolean;
  19214. /**
  19215. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19216. */
  19217. inheritedVelocityAmount: number;
  19218. /**
  19219. * Creates a sub emitter
  19220. * @param particleSystem the particle system to be used by the sub emitter
  19221. */
  19222. constructor(
  19223. /**
  19224. * the particle system to be used by the sub emitter
  19225. */
  19226. particleSystem: ParticleSystem);
  19227. /**
  19228. * Clones the sub emitter
  19229. * @returns the cloned sub emitter
  19230. */
  19231. clone(): SubEmitter;
  19232. /**
  19233. * Serialize current object to a JSON object
  19234. * @returns the serialized object
  19235. */
  19236. serialize(): any;
  19237. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19238. /**
  19239. * Creates a new SubEmitter from a serialized JSON version
  19240. * @param serializationObject defines the JSON object to read from
  19241. * @param scene defines the hosting scene
  19242. * @param rootUrl defines the rootUrl for data loading
  19243. * @returns a new SubEmitter
  19244. */
  19245. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19246. /** Release associated resources */
  19247. dispose(): void;
  19248. }
  19249. }
  19250. declare module BABYLON {
  19251. /** @hidden */
  19252. export var imageProcessingDeclaration: {
  19253. name: string;
  19254. shader: string;
  19255. };
  19256. }
  19257. declare module BABYLON {
  19258. /** @hidden */
  19259. export var imageProcessingFunctions: {
  19260. name: string;
  19261. shader: string;
  19262. };
  19263. }
  19264. declare module BABYLON {
  19265. /** @hidden */
  19266. export var particlesPixelShader: {
  19267. name: string;
  19268. shader: string;
  19269. };
  19270. }
  19271. declare module BABYLON {
  19272. /** @hidden */
  19273. export var particlesVertexShader: {
  19274. name: string;
  19275. shader: string;
  19276. };
  19277. }
  19278. declare module BABYLON {
  19279. /**
  19280. * This represents a particle system in Babylon.
  19281. * 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.
  19282. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19283. * @example https://doc.babylonjs.com/babylon101/particles
  19284. */
  19285. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19286. /**
  19287. * Billboard mode will only apply to Y axis
  19288. */
  19289. static readonly BILLBOARDMODE_Y: number;
  19290. /**
  19291. * Billboard mode will apply to all axes
  19292. */
  19293. static readonly BILLBOARDMODE_ALL: number;
  19294. /**
  19295. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19296. */
  19297. static readonly BILLBOARDMODE_STRETCHED: number;
  19298. /**
  19299. * This function can be defined to provide custom update for active particles.
  19300. * This function will be called instead of regular update (age, position, color, etc.).
  19301. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19302. */
  19303. updateFunction: (particles: Particle[]) => void;
  19304. private _emitterWorldMatrix;
  19305. /**
  19306. * This function can be defined to specify initial direction for every new particle.
  19307. * It by default use the emitterType defined function
  19308. */
  19309. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19310. /**
  19311. * This function can be defined to specify initial position for every new particle.
  19312. * It by default use the emitterType defined function
  19313. */
  19314. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19315. /**
  19316. * @hidden
  19317. */ private _inheritedVelocityOffset: Vector3;
  19318. /**
  19319. * An event triggered when the system is disposed
  19320. */
  19321. onDisposeObservable: Observable<ParticleSystem>;
  19322. private _onDisposeObserver;
  19323. /**
  19324. * Sets a callback that will be triggered when the system is disposed
  19325. */
  19326. onDispose: () => void;
  19327. private _particles;
  19328. private _epsilon;
  19329. private _capacity;
  19330. private _stockParticles;
  19331. private _newPartsExcess;
  19332. private _vertexData;
  19333. private _vertexBuffer;
  19334. private _vertexBuffers;
  19335. private _spriteBuffer;
  19336. private _indexBuffer;
  19337. private _effect;
  19338. private _customEffect;
  19339. private _cachedDefines;
  19340. private _scaledColorStep;
  19341. private _colorDiff;
  19342. private _scaledDirection;
  19343. private _scaledGravity;
  19344. private _currentRenderId;
  19345. private _alive;
  19346. private _useInstancing;
  19347. private _started;
  19348. private _stopped;
  19349. private _actualFrame;
  19350. private _scaledUpdateSpeed;
  19351. private _vertexBufferSize;
  19352. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  19353. /** @hidden */ private _currentEmitRate1: number;
  19354. /** @hidden */ private _currentEmitRate2: number;
  19355. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  19356. /** @hidden */ private _currentStartSize1: number;
  19357. /** @hidden */ private _currentStartSize2: number;
  19358. private readonly _rawTextureWidth;
  19359. private _rampGradientsTexture;
  19360. private _useRampGradients;
  19361. /** Gets or sets a boolean indicating that ramp gradients must be used
  19362. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19363. */
  19364. useRampGradients: boolean;
  19365. /**
  19366. * 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.
  19367. * 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: [])
  19368. */
  19369. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19370. private _subEmitters;
  19371. /**
  19372. * @hidden
  19373. * If the particle systems emitter should be disposed when the particle system is disposed
  19374. */ private _disposeEmitterOnDispose: boolean;
  19375. /**
  19376. * The current active Sub-systems, this property is used by the root particle system only.
  19377. */
  19378. activeSubSystems: Array<ParticleSystem>;
  19379. private _rootParticleSystem;
  19380. /**
  19381. * Gets the current list of active particles
  19382. */
  19383. readonly particles: Particle[];
  19384. /**
  19385. * Returns the string "ParticleSystem"
  19386. * @returns a string containing the class name
  19387. */
  19388. getClassName(): string;
  19389. /**
  19390. * Instantiates a particle system.
  19391. * 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.
  19392. * @param name The name of the particle system
  19393. * @param capacity The max number of particles alive at the same time
  19394. * @param scene The scene the particle system belongs to
  19395. * @param customEffect a custom effect used to change the way particles are rendered by default
  19396. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19397. * @param epsilon Offset used to render the particles
  19398. */
  19399. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19400. private _addFactorGradient;
  19401. private _removeFactorGradient;
  19402. /**
  19403. * Adds a new life time gradient
  19404. * @param gradient defines the gradient to use (between 0 and 1)
  19405. * @param factor defines the life time factor to affect to the specified gradient
  19406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19407. * @returns the current particle system
  19408. */
  19409. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19410. /**
  19411. * Remove a specific life time gradient
  19412. * @param gradient defines the gradient to remove
  19413. * @returns the current particle system
  19414. */
  19415. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19416. /**
  19417. * Adds a new size gradient
  19418. * @param gradient defines the gradient to use (between 0 and 1)
  19419. * @param factor defines the size factor to affect to the specified gradient
  19420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19421. * @returns the current particle system
  19422. */
  19423. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19424. /**
  19425. * Remove a specific size gradient
  19426. * @param gradient defines the gradient to remove
  19427. * @returns the current particle system
  19428. */
  19429. removeSizeGradient(gradient: number): IParticleSystem;
  19430. /**
  19431. * Adds a new color remap gradient
  19432. * @param gradient defines the gradient to use (between 0 and 1)
  19433. * @param min defines the color remap minimal range
  19434. * @param max defines the color remap maximal range
  19435. * @returns the current particle system
  19436. */
  19437. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19438. /**
  19439. * Remove a specific color remap gradient
  19440. * @param gradient defines the gradient to remove
  19441. * @returns the current particle system
  19442. */
  19443. removeColorRemapGradient(gradient: number): IParticleSystem;
  19444. /**
  19445. * Adds a new alpha remap gradient
  19446. * @param gradient defines the gradient to use (between 0 and 1)
  19447. * @param min defines the alpha remap minimal range
  19448. * @param max defines the alpha remap maximal range
  19449. * @returns the current particle system
  19450. */
  19451. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19452. /**
  19453. * Remove a specific alpha remap gradient
  19454. * @param gradient defines the gradient to remove
  19455. * @returns the current particle system
  19456. */
  19457. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19458. /**
  19459. * Adds a new angular speed gradient
  19460. * @param gradient defines the gradient to use (between 0 and 1)
  19461. * @param factor defines the angular speed to affect to the specified gradient
  19462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19463. * @returns the current particle system
  19464. */
  19465. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19466. /**
  19467. * Remove a specific angular speed gradient
  19468. * @param gradient defines the gradient to remove
  19469. * @returns the current particle system
  19470. */
  19471. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19472. /**
  19473. * Adds a new velocity gradient
  19474. * @param gradient defines the gradient to use (between 0 and 1)
  19475. * @param factor defines the velocity to affect to the specified gradient
  19476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19477. * @returns the current particle system
  19478. */
  19479. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19480. /**
  19481. * Remove a specific velocity gradient
  19482. * @param gradient defines the gradient to remove
  19483. * @returns the current particle system
  19484. */
  19485. removeVelocityGradient(gradient: number): IParticleSystem;
  19486. /**
  19487. * Adds a new limit velocity gradient
  19488. * @param gradient defines the gradient to use (between 0 and 1)
  19489. * @param factor defines the limit velocity value to affect to the specified gradient
  19490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19491. * @returns the current particle system
  19492. */
  19493. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19494. /**
  19495. * Remove a specific limit velocity gradient
  19496. * @param gradient defines the gradient to remove
  19497. * @returns the current particle system
  19498. */
  19499. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19500. /**
  19501. * Adds a new drag gradient
  19502. * @param gradient defines the gradient to use (between 0 and 1)
  19503. * @param factor defines the drag value to affect to the specified gradient
  19504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19505. * @returns the current particle system
  19506. */
  19507. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19508. /**
  19509. * Remove a specific drag gradient
  19510. * @param gradient defines the gradient to remove
  19511. * @returns the current particle system
  19512. */
  19513. removeDragGradient(gradient: number): IParticleSystem;
  19514. /**
  19515. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19516. * @param gradient defines the gradient to use (between 0 and 1)
  19517. * @param factor defines the emit rate value to affect to the specified gradient
  19518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19519. * @returns the current particle system
  19520. */
  19521. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19522. /**
  19523. * Remove a specific emit rate gradient
  19524. * @param gradient defines the gradient to remove
  19525. * @returns the current particle system
  19526. */
  19527. removeEmitRateGradient(gradient: number): IParticleSystem;
  19528. /**
  19529. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19530. * @param gradient defines the gradient to use (between 0 and 1)
  19531. * @param factor defines the start size value to affect to the specified gradient
  19532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19533. * @returns the current particle system
  19534. */
  19535. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19536. /**
  19537. * Remove a specific start size gradient
  19538. * @param gradient defines the gradient to remove
  19539. * @returns the current particle system
  19540. */
  19541. removeStartSizeGradient(gradient: number): IParticleSystem;
  19542. private _createRampGradientTexture;
  19543. /**
  19544. * Gets the current list of ramp gradients.
  19545. * You must use addRampGradient and removeRampGradient to udpate this list
  19546. * @returns the list of ramp gradients
  19547. */
  19548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19549. /**
  19550. * Adds a new ramp gradient used to remap particle colors
  19551. * @param gradient defines the gradient to use (between 0 and 1)
  19552. * @param color defines the color to affect to the specified gradient
  19553. * @returns the current particle system
  19554. */
  19555. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19556. /**
  19557. * Remove a specific ramp gradient
  19558. * @param gradient defines the gradient to remove
  19559. * @returns the current particle system
  19560. */
  19561. removeRampGradient(gradient: number): ParticleSystem;
  19562. /**
  19563. * Adds a new color gradient
  19564. * @param gradient defines the gradient to use (between 0 and 1)
  19565. * @param color1 defines the color to affect to the specified gradient
  19566. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19567. * @returns this particle system
  19568. */
  19569. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19570. /**
  19571. * Remove a specific color gradient
  19572. * @param gradient defines the gradient to remove
  19573. * @returns this particle system
  19574. */
  19575. removeColorGradient(gradient: number): IParticleSystem;
  19576. private _fetchR;
  19577. protected _reset(): void;
  19578. private _resetEffect;
  19579. private _createVertexBuffers;
  19580. private _createIndexBuffer;
  19581. /**
  19582. * Gets the maximum number of particles active at the same time.
  19583. * @returns The max number of active particles.
  19584. */
  19585. getCapacity(): number;
  19586. /**
  19587. * Gets whether there are still active particles in the system.
  19588. * @returns True if it is alive, otherwise false.
  19589. */
  19590. isAlive(): boolean;
  19591. /**
  19592. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19593. * @returns True if it has been started, otherwise false.
  19594. */
  19595. isStarted(): boolean;
  19596. private _prepareSubEmitterInternalArray;
  19597. /**
  19598. * Starts the particle system and begins to emit
  19599. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19600. */
  19601. start(delay?: number): void;
  19602. /**
  19603. * Stops the particle system.
  19604. * @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.
  19605. */
  19606. stop(stopSubEmitters?: boolean): void;
  19607. /**
  19608. * Remove all active particles
  19609. */
  19610. reset(): void;
  19611. /**
  19612. * @hidden (for internal use only)
  19613. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19614. /**
  19615. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19616. * Its lifetime will start back at 0.
  19617. */
  19618. recycleParticle: (particle: Particle) => void;
  19619. private _stopSubEmitters;
  19620. private _createParticle;
  19621. private _removeFromRoot;
  19622. private _emitFromParticle;
  19623. private _update;
  19624. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19625. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19626. /** @hidden */
  19627. private _getEffect;
  19628. /**
  19629. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19630. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19631. */
  19632. animate(preWarmOnly?: boolean): void;
  19633. private _appendParticleVertices;
  19634. /**
  19635. * Rebuilds the particle system.
  19636. */
  19637. rebuild(): void;
  19638. /**
  19639. * Is this system ready to be used/rendered
  19640. * @return true if the system is ready
  19641. */
  19642. isReady(): boolean;
  19643. private _render;
  19644. /**
  19645. * Renders the particle system in its current state.
  19646. * @returns the current number of particles
  19647. */
  19648. render(): number;
  19649. /**
  19650. * Disposes the particle system and free the associated resources
  19651. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19652. */
  19653. dispose(disposeTexture?: boolean): void;
  19654. /**
  19655. * Clones the particle system.
  19656. * @param name The name of the cloned object
  19657. * @param newEmitter The new emitter to use
  19658. * @returns the cloned particle system
  19659. */
  19660. clone(name: string, newEmitter: any): ParticleSystem;
  19661. /**
  19662. * Serializes the particle system to a JSON object.
  19663. * @returns the JSON object
  19664. */
  19665. serialize(): any;
  19666. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19667. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19668. /**
  19669. * Parses a JSON object to create a particle system.
  19670. * @param parsedParticleSystem The JSON object to parse
  19671. * @param scene The scene to create the particle system in
  19672. * @param rootUrl The root url to use to load external dependencies like texture
  19673. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19674. * @returns the Parsed particle system
  19675. */
  19676. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19677. }
  19678. }
  19679. declare module BABYLON {
  19680. /**
  19681. * A particle represents one of the element emitted by a particle system.
  19682. * This is mainly define by its coordinates, direction, velocity and age.
  19683. */
  19684. export class Particle {
  19685. /**
  19686. * The particle system the particle belongs to.
  19687. */
  19688. particleSystem: ParticleSystem;
  19689. private static _Count;
  19690. /**
  19691. * Unique ID of the particle
  19692. */
  19693. id: number;
  19694. /**
  19695. * The world position of the particle in the scene.
  19696. */
  19697. position: Vector3;
  19698. /**
  19699. * The world direction of the particle in the scene.
  19700. */
  19701. direction: Vector3;
  19702. /**
  19703. * The color of the particle.
  19704. */
  19705. color: Color4;
  19706. /**
  19707. * The color change of the particle per step.
  19708. */
  19709. colorStep: Color4;
  19710. /**
  19711. * Defines how long will the life of the particle be.
  19712. */
  19713. lifeTime: number;
  19714. /**
  19715. * The current age of the particle.
  19716. */
  19717. age: number;
  19718. /**
  19719. * The current size of the particle.
  19720. */
  19721. size: number;
  19722. /**
  19723. * The current scale of the particle.
  19724. */
  19725. scale: Vector2;
  19726. /**
  19727. * The current angle of the particle.
  19728. */
  19729. angle: number;
  19730. /**
  19731. * Defines how fast is the angle changing.
  19732. */
  19733. angularSpeed: number;
  19734. /**
  19735. * Defines the cell index used by the particle to be rendered from a sprite.
  19736. */
  19737. cellIndex: number;
  19738. /**
  19739. * The information required to support color remapping
  19740. */
  19741. remapData: Vector4;
  19742. /** @hidden */ private _randomCellOffset?: number;
  19743. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  19744. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  19745. /** @hidden */ private _initialStartSpriteCellID: number;
  19746. /** @hidden */ private _initialEndSpriteCellID: number;
  19747. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  19748. /** @hidden */ private _currentColor1: Color4;
  19749. /** @hidden */ private _currentColor2: Color4;
  19750. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  19751. /** @hidden */ private _currentSize1: number;
  19752. /** @hidden */ private _currentSize2: number;
  19753. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  19754. /** @hidden */ private _currentAngularSpeed1: number;
  19755. /** @hidden */ private _currentAngularSpeed2: number;
  19756. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  19757. /** @hidden */ private _currentVelocity1: number;
  19758. /** @hidden */ private _currentVelocity2: number;
  19759. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  19760. /** @hidden */ private _currentLimitVelocity1: number;
  19761. /** @hidden */ private _currentLimitVelocity2: number;
  19762. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  19763. /** @hidden */ private _currentDrag1: number;
  19764. /** @hidden */ private _currentDrag2: number;
  19765. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  19766. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  19767. /**
  19768. * Creates a new instance Particle
  19769. * @param particleSystem the particle system the particle belongs to
  19770. */
  19771. constructor(
  19772. /**
  19773. * The particle system the particle belongs to.
  19774. */
  19775. particleSystem: ParticleSystem);
  19776. private updateCellInfoFromSystem;
  19777. /**
  19778. * Defines how the sprite cell index is updated for the particle
  19779. */
  19780. updateCellIndex(): void;
  19781. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  19782. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  19783. /** @hidden */ private _reset(): void;
  19784. /**
  19785. * Copy the properties of particle to another one.
  19786. * @param other the particle to copy the information to.
  19787. */
  19788. copyTo(other: Particle): void;
  19789. }
  19790. }
  19791. declare module BABYLON {
  19792. /**
  19793. * Particle emitter represents a volume emitting particles.
  19794. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  19795. */
  19796. export interface IParticleEmitterType {
  19797. /**
  19798. * Called by the particle System when the direction is computed for the created particle.
  19799. * @param worldMatrix is the world matrix of the particle system
  19800. * @param directionToUpdate is the direction vector to update with the result
  19801. * @param particle is the particle we are computed the direction for
  19802. */
  19803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19804. /**
  19805. * Called by the particle System when the position is computed for the created particle.
  19806. * @param worldMatrix is the world matrix of the particle system
  19807. * @param positionToUpdate is the position vector to update with the result
  19808. * @param particle is the particle we are computed the position for
  19809. */
  19810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19811. /**
  19812. * Clones the current emitter and returns a copy of it
  19813. * @returns the new emitter
  19814. */
  19815. clone(): IParticleEmitterType;
  19816. /**
  19817. * Called by the GPUParticleSystem to setup the update shader
  19818. * @param effect defines the update shader
  19819. */
  19820. applyToShader(effect: Effect): void;
  19821. /**
  19822. * Returns a string to use to update the GPU particles update shader
  19823. * @returns the effect defines string
  19824. */
  19825. getEffectDefines(): string;
  19826. /**
  19827. * Returns a string representing the class name
  19828. * @returns a string containing the class name
  19829. */
  19830. getClassName(): string;
  19831. /**
  19832. * Serializes the particle system to a JSON object.
  19833. * @returns the JSON object
  19834. */
  19835. serialize(): any;
  19836. /**
  19837. * Parse properties from a JSON object
  19838. * @param serializationObject defines the JSON object
  19839. */
  19840. parse(serializationObject: any): void;
  19841. }
  19842. }
  19843. declare module BABYLON {
  19844. /**
  19845. * Particle emitter emitting particles from the inside of a box.
  19846. * It emits the particles randomly between 2 given directions.
  19847. */
  19848. export class BoxParticleEmitter implements IParticleEmitterType {
  19849. /**
  19850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19851. */
  19852. direction1: Vector3;
  19853. /**
  19854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19855. */
  19856. direction2: Vector3;
  19857. /**
  19858. * 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.
  19859. */
  19860. minEmitBox: Vector3;
  19861. /**
  19862. * 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.
  19863. */
  19864. maxEmitBox: Vector3;
  19865. /**
  19866. * Creates a new instance BoxParticleEmitter
  19867. */
  19868. constructor();
  19869. /**
  19870. * Called by the particle System when the direction is computed for the created particle.
  19871. * @param worldMatrix is the world matrix of the particle system
  19872. * @param directionToUpdate is the direction vector to update with the result
  19873. * @param particle is the particle we are computed the direction for
  19874. */
  19875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19876. /**
  19877. * Called by the particle System when the position is computed for the created particle.
  19878. * @param worldMatrix is the world matrix of the particle system
  19879. * @param positionToUpdate is the position vector to update with the result
  19880. * @param particle is the particle we are computed the position for
  19881. */
  19882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19883. /**
  19884. * Clones the current emitter and returns a copy of it
  19885. * @returns the new emitter
  19886. */
  19887. clone(): BoxParticleEmitter;
  19888. /**
  19889. * Called by the GPUParticleSystem to setup the update shader
  19890. * @param effect defines the update shader
  19891. */
  19892. applyToShader(effect: Effect): void;
  19893. /**
  19894. * Returns a string to use to update the GPU particles update shader
  19895. * @returns a string containng the defines string
  19896. */
  19897. getEffectDefines(): string;
  19898. /**
  19899. * Returns the string "BoxParticleEmitter"
  19900. * @returns a string containing the class name
  19901. */
  19902. getClassName(): string;
  19903. /**
  19904. * Serializes the particle system to a JSON object.
  19905. * @returns the JSON object
  19906. */
  19907. serialize(): any;
  19908. /**
  19909. * Parse properties from a JSON object
  19910. * @param serializationObject defines the JSON object
  19911. */
  19912. parse(serializationObject: any): void;
  19913. }
  19914. }
  19915. declare module BABYLON {
  19916. /**
  19917. * Particle emitter emitting particles from the inside of a cone.
  19918. * It emits the particles alongside the cone volume from the base to the particle.
  19919. * The emission direction might be randomized.
  19920. */
  19921. export class ConeParticleEmitter implements IParticleEmitterType {
  19922. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  19923. directionRandomizer: number;
  19924. private _radius;
  19925. private _angle;
  19926. private _height;
  19927. /**
  19928. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  19929. */
  19930. radiusRange: number;
  19931. /**
  19932. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  19933. */
  19934. heightRange: number;
  19935. /**
  19936. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  19937. */
  19938. emitFromSpawnPointOnly: boolean;
  19939. /**
  19940. * Gets or sets the radius of the emission cone
  19941. */
  19942. radius: number;
  19943. /**
  19944. * Gets or sets the angle of the emission cone
  19945. */
  19946. angle: number;
  19947. private _buildHeight;
  19948. /**
  19949. * Creates a new instance ConeParticleEmitter
  19950. * @param radius the radius of the emission cone (1 by default)
  19951. * @param angle the cone base angle (PI by default)
  19952. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  19953. */
  19954. constructor(radius?: number, angle?: number,
  19955. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  19956. directionRandomizer?: number);
  19957. /**
  19958. * Called by the particle System when the direction is computed for the created particle.
  19959. * @param worldMatrix is the world matrix of the particle system
  19960. * @param directionToUpdate is the direction vector to update with the result
  19961. * @param particle is the particle we are computed the direction for
  19962. */
  19963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19964. /**
  19965. * Called by the particle System when the position is computed for the created particle.
  19966. * @param worldMatrix is the world matrix of the particle system
  19967. * @param positionToUpdate is the position vector to update with the result
  19968. * @param particle is the particle we are computed the position for
  19969. */
  19970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19971. /**
  19972. * Clones the current emitter and returns a copy of it
  19973. * @returns the new emitter
  19974. */
  19975. clone(): ConeParticleEmitter;
  19976. /**
  19977. * Called by the GPUParticleSystem to setup the update shader
  19978. * @param effect defines the update shader
  19979. */
  19980. applyToShader(effect: Effect): void;
  19981. /**
  19982. * Returns a string to use to update the GPU particles update shader
  19983. * @returns a string containng the defines string
  19984. */
  19985. getEffectDefines(): string;
  19986. /**
  19987. * Returns the string "ConeParticleEmitter"
  19988. * @returns a string containing the class name
  19989. */
  19990. getClassName(): string;
  19991. /**
  19992. * Serializes the particle system to a JSON object.
  19993. * @returns the JSON object
  19994. */
  19995. serialize(): any;
  19996. /**
  19997. * Parse properties from a JSON object
  19998. * @param serializationObject defines the JSON object
  19999. */
  20000. parse(serializationObject: any): void;
  20001. }
  20002. }
  20003. declare module BABYLON {
  20004. /**
  20005. * Particle emitter emitting particles from the inside of a cylinder.
  20006. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20007. */
  20008. export class CylinderParticleEmitter implements IParticleEmitterType {
  20009. /**
  20010. * The radius of the emission cylinder.
  20011. */
  20012. radius: number;
  20013. /**
  20014. * The height of the emission cylinder.
  20015. */
  20016. height: number;
  20017. /**
  20018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20019. */
  20020. radiusRange: number;
  20021. /**
  20022. * How much to randomize the particle direction [0-1].
  20023. */
  20024. directionRandomizer: number;
  20025. /**
  20026. * Creates a new instance CylinderParticleEmitter
  20027. * @param radius the radius of the emission cylinder (1 by default)
  20028. * @param height the height of the emission cylinder (1 by default)
  20029. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20030. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20031. */
  20032. constructor(
  20033. /**
  20034. * The radius of the emission cylinder.
  20035. */
  20036. radius?: number,
  20037. /**
  20038. * The height of the emission cylinder.
  20039. */
  20040. height?: number,
  20041. /**
  20042. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20043. */
  20044. radiusRange?: number,
  20045. /**
  20046. * How much to randomize the particle direction [0-1].
  20047. */
  20048. directionRandomizer?: number);
  20049. /**
  20050. * Called by the particle System when the direction is computed for the created particle.
  20051. * @param worldMatrix is the world matrix of the particle system
  20052. * @param directionToUpdate is the direction vector to update with the result
  20053. * @param particle is the particle we are computed the direction for
  20054. */
  20055. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20056. /**
  20057. * Called by the particle System when the position is computed for the created particle.
  20058. * @param worldMatrix is the world matrix of the particle system
  20059. * @param positionToUpdate is the position vector to update with the result
  20060. * @param particle is the particle we are computed the position for
  20061. */
  20062. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20063. /**
  20064. * Clones the current emitter and returns a copy of it
  20065. * @returns the new emitter
  20066. */
  20067. clone(): CylinderParticleEmitter;
  20068. /**
  20069. * Called by the GPUParticleSystem to setup the update shader
  20070. * @param effect defines the update shader
  20071. */
  20072. applyToShader(effect: Effect): void;
  20073. /**
  20074. * Returns a string to use to update the GPU particles update shader
  20075. * @returns a string containng the defines string
  20076. */
  20077. getEffectDefines(): string;
  20078. /**
  20079. * Returns the string "CylinderParticleEmitter"
  20080. * @returns a string containing the class name
  20081. */
  20082. getClassName(): string;
  20083. /**
  20084. * Serializes the particle system to a JSON object.
  20085. * @returns the JSON object
  20086. */
  20087. serialize(): any;
  20088. /**
  20089. * Parse properties from a JSON object
  20090. * @param serializationObject defines the JSON object
  20091. */
  20092. parse(serializationObject: any): void;
  20093. }
  20094. /**
  20095. * Particle emitter emitting particles from the inside of a cylinder.
  20096. * It emits the particles randomly between two vectors.
  20097. */
  20098. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20099. /**
  20100. * The min limit of the emission direction.
  20101. */
  20102. direction1: Vector3;
  20103. /**
  20104. * The max limit of the emission direction.
  20105. */
  20106. direction2: Vector3;
  20107. /**
  20108. * Creates a new instance CylinderDirectedParticleEmitter
  20109. * @param radius the radius of the emission cylinder (1 by default)
  20110. * @param height the height of the emission cylinder (1 by default)
  20111. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20112. * @param direction1 the min limit of the emission direction (up vector by default)
  20113. * @param direction2 the max limit of the emission direction (up vector by default)
  20114. */
  20115. constructor(radius?: number, height?: number, radiusRange?: number,
  20116. /**
  20117. * The min limit of the emission direction.
  20118. */
  20119. direction1?: Vector3,
  20120. /**
  20121. * The max limit of the emission direction.
  20122. */
  20123. direction2?: Vector3);
  20124. /**
  20125. * Called by the particle System when the direction is computed for the created particle.
  20126. * @param worldMatrix is the world matrix of the particle system
  20127. * @param directionToUpdate is the direction vector to update with the result
  20128. * @param particle is the particle we are computed the direction for
  20129. */
  20130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20131. /**
  20132. * Clones the current emitter and returns a copy of it
  20133. * @returns the new emitter
  20134. */
  20135. clone(): CylinderDirectedParticleEmitter;
  20136. /**
  20137. * Called by the GPUParticleSystem to setup the update shader
  20138. * @param effect defines the update shader
  20139. */
  20140. applyToShader(effect: Effect): void;
  20141. /**
  20142. * Returns a string to use to update the GPU particles update shader
  20143. * @returns a string containng the defines string
  20144. */
  20145. getEffectDefines(): string;
  20146. /**
  20147. * Returns the string "CylinderDirectedParticleEmitter"
  20148. * @returns a string containing the class name
  20149. */
  20150. getClassName(): string;
  20151. /**
  20152. * Serializes the particle system to a JSON object.
  20153. * @returns the JSON object
  20154. */
  20155. serialize(): any;
  20156. /**
  20157. * Parse properties from a JSON object
  20158. * @param serializationObject defines the JSON object
  20159. */
  20160. parse(serializationObject: any): void;
  20161. }
  20162. }
  20163. declare module BABYLON {
  20164. /**
  20165. * Particle emitter emitting particles from the inside of a hemisphere.
  20166. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20167. */
  20168. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20169. /**
  20170. * The radius of the emission hemisphere.
  20171. */
  20172. radius: number;
  20173. /**
  20174. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20175. */
  20176. radiusRange: number;
  20177. /**
  20178. * How much to randomize the particle direction [0-1].
  20179. */
  20180. directionRandomizer: number;
  20181. /**
  20182. * Creates a new instance HemisphericParticleEmitter
  20183. * @param radius the radius of the emission hemisphere (1 by default)
  20184. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20185. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20186. */
  20187. constructor(
  20188. /**
  20189. * The radius of the emission hemisphere.
  20190. */
  20191. radius?: number,
  20192. /**
  20193. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20194. */
  20195. radiusRange?: number,
  20196. /**
  20197. * How much to randomize the particle direction [0-1].
  20198. */
  20199. directionRandomizer?: number);
  20200. /**
  20201. * Called by the particle System when the direction is computed for the created particle.
  20202. * @param worldMatrix is the world matrix of the particle system
  20203. * @param directionToUpdate is the direction vector to update with the result
  20204. * @param particle is the particle we are computed the direction for
  20205. */
  20206. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20207. /**
  20208. * Called by the particle System when the position is computed for the created particle.
  20209. * @param worldMatrix is the world matrix of the particle system
  20210. * @param positionToUpdate is the position vector to update with the result
  20211. * @param particle is the particle we are computed the position for
  20212. */
  20213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20214. /**
  20215. * Clones the current emitter and returns a copy of it
  20216. * @returns the new emitter
  20217. */
  20218. clone(): HemisphericParticleEmitter;
  20219. /**
  20220. * Called by the GPUParticleSystem to setup the update shader
  20221. * @param effect defines the update shader
  20222. */
  20223. applyToShader(effect: Effect): void;
  20224. /**
  20225. * Returns a string to use to update the GPU particles update shader
  20226. * @returns a string containng the defines string
  20227. */
  20228. getEffectDefines(): string;
  20229. /**
  20230. * Returns the string "HemisphericParticleEmitter"
  20231. * @returns a string containing the class name
  20232. */
  20233. getClassName(): string;
  20234. /**
  20235. * Serializes the particle system to a JSON object.
  20236. * @returns the JSON object
  20237. */
  20238. serialize(): any;
  20239. /**
  20240. * Parse properties from a JSON object
  20241. * @param serializationObject defines the JSON object
  20242. */
  20243. parse(serializationObject: any): void;
  20244. }
  20245. }
  20246. declare module BABYLON {
  20247. /**
  20248. * Particle emitter emitting particles from a point.
  20249. * It emits the particles randomly between 2 given directions.
  20250. */
  20251. export class PointParticleEmitter implements IParticleEmitterType {
  20252. /**
  20253. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20254. */
  20255. direction1: Vector3;
  20256. /**
  20257. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20258. */
  20259. direction2: Vector3;
  20260. /**
  20261. * Creates a new instance PointParticleEmitter
  20262. */
  20263. constructor();
  20264. /**
  20265. * Called by the particle System when the direction is computed for the created particle.
  20266. * @param worldMatrix is the world matrix of the particle system
  20267. * @param directionToUpdate is the direction vector to update with the result
  20268. * @param particle is the particle we are computed the direction for
  20269. */
  20270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20271. /**
  20272. * Called by the particle System when the position is computed for the created particle.
  20273. * @param worldMatrix is the world matrix of the particle system
  20274. * @param positionToUpdate is the position vector to update with the result
  20275. * @param particle is the particle we are computed the position for
  20276. */
  20277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20278. /**
  20279. * Clones the current emitter and returns a copy of it
  20280. * @returns the new emitter
  20281. */
  20282. clone(): PointParticleEmitter;
  20283. /**
  20284. * Called by the GPUParticleSystem to setup the update shader
  20285. * @param effect defines the update shader
  20286. */
  20287. applyToShader(effect: Effect): void;
  20288. /**
  20289. * Returns a string to use to update the GPU particles update shader
  20290. * @returns a string containng the defines string
  20291. */
  20292. getEffectDefines(): string;
  20293. /**
  20294. * Returns the string "PointParticleEmitter"
  20295. * @returns a string containing the class name
  20296. */
  20297. getClassName(): string;
  20298. /**
  20299. * Serializes the particle system to a JSON object.
  20300. * @returns the JSON object
  20301. */
  20302. serialize(): any;
  20303. /**
  20304. * Parse properties from a JSON object
  20305. * @param serializationObject defines the JSON object
  20306. */
  20307. parse(serializationObject: any): void;
  20308. }
  20309. }
  20310. declare module BABYLON {
  20311. /**
  20312. * Particle emitter emitting particles from the inside of a sphere.
  20313. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20314. */
  20315. export class SphereParticleEmitter implements IParticleEmitterType {
  20316. /**
  20317. * The radius of the emission sphere.
  20318. */
  20319. radius: number;
  20320. /**
  20321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20322. */
  20323. radiusRange: number;
  20324. /**
  20325. * How much to randomize the particle direction [0-1].
  20326. */
  20327. directionRandomizer: number;
  20328. /**
  20329. * Creates a new instance SphereParticleEmitter
  20330. * @param radius the radius of the emission sphere (1 by default)
  20331. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20332. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20333. */
  20334. constructor(
  20335. /**
  20336. * The radius of the emission sphere.
  20337. */
  20338. radius?: number,
  20339. /**
  20340. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20341. */
  20342. radiusRange?: number,
  20343. /**
  20344. * How much to randomize the particle direction [0-1].
  20345. */
  20346. directionRandomizer?: number);
  20347. /**
  20348. * Called by the particle System when the direction is computed for the created particle.
  20349. * @param worldMatrix is the world matrix of the particle system
  20350. * @param directionToUpdate is the direction vector to update with the result
  20351. * @param particle is the particle we are computed the direction for
  20352. */
  20353. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20354. /**
  20355. * Called by the particle System when the position is computed for the created particle.
  20356. * @param worldMatrix is the world matrix of the particle system
  20357. * @param positionToUpdate is the position vector to update with the result
  20358. * @param particle is the particle we are computed the position for
  20359. */
  20360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20361. /**
  20362. * Clones the current emitter and returns a copy of it
  20363. * @returns the new emitter
  20364. */
  20365. clone(): SphereParticleEmitter;
  20366. /**
  20367. * Called by the GPUParticleSystem to setup the update shader
  20368. * @param effect defines the update shader
  20369. */
  20370. applyToShader(effect: Effect): void;
  20371. /**
  20372. * Returns a string to use to update the GPU particles update shader
  20373. * @returns a string containng the defines string
  20374. */
  20375. getEffectDefines(): string;
  20376. /**
  20377. * Returns the string "SphereParticleEmitter"
  20378. * @returns a string containing the class name
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Serializes the particle system to a JSON object.
  20383. * @returns the JSON object
  20384. */
  20385. serialize(): any;
  20386. /**
  20387. * Parse properties from a JSON object
  20388. * @param serializationObject defines the JSON object
  20389. */
  20390. parse(serializationObject: any): void;
  20391. }
  20392. /**
  20393. * Particle emitter emitting particles from the inside of a sphere.
  20394. * It emits the particles randomly between two vectors.
  20395. */
  20396. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20397. /**
  20398. * The min limit of the emission direction.
  20399. */
  20400. direction1: Vector3;
  20401. /**
  20402. * The max limit of the emission direction.
  20403. */
  20404. direction2: Vector3;
  20405. /**
  20406. * Creates a new instance SphereDirectedParticleEmitter
  20407. * @param radius the radius of the emission sphere (1 by default)
  20408. * @param direction1 the min limit of the emission direction (up vector by default)
  20409. * @param direction2 the max limit of the emission direction (up vector by default)
  20410. */
  20411. constructor(radius?: number,
  20412. /**
  20413. * The min limit of the emission direction.
  20414. */
  20415. direction1?: Vector3,
  20416. /**
  20417. * The max limit of the emission direction.
  20418. */
  20419. direction2?: Vector3);
  20420. /**
  20421. * Called by the particle System when the direction is computed for the created particle.
  20422. * @param worldMatrix is the world matrix of the particle system
  20423. * @param directionToUpdate is the direction vector to update with the result
  20424. * @param particle is the particle we are computed the direction for
  20425. */
  20426. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20427. /**
  20428. * Clones the current emitter and returns a copy of it
  20429. * @returns the new emitter
  20430. */
  20431. clone(): SphereDirectedParticleEmitter;
  20432. /**
  20433. * Called by the GPUParticleSystem to setup the update shader
  20434. * @param effect defines the update shader
  20435. */
  20436. applyToShader(effect: Effect): void;
  20437. /**
  20438. * Returns a string to use to update the GPU particles update shader
  20439. * @returns a string containng the defines string
  20440. */
  20441. getEffectDefines(): string;
  20442. /**
  20443. * Returns the string "SphereDirectedParticleEmitter"
  20444. * @returns a string containing the class name
  20445. */
  20446. getClassName(): string;
  20447. /**
  20448. * Serializes the particle system to a JSON object.
  20449. * @returns the JSON object
  20450. */
  20451. serialize(): any;
  20452. /**
  20453. * Parse properties from a JSON object
  20454. * @param serializationObject defines the JSON object
  20455. */
  20456. parse(serializationObject: any): void;
  20457. }
  20458. }
  20459. declare module BABYLON {
  20460. /**
  20461. * Interface representing a particle system in Babylon.js.
  20462. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20463. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20464. */
  20465. export interface IParticleSystem {
  20466. /**
  20467. * List of animations used by the particle system.
  20468. */
  20469. animations: Animation[];
  20470. /**
  20471. * The id of the Particle system.
  20472. */
  20473. id: string;
  20474. /**
  20475. * The name of the Particle system.
  20476. */
  20477. name: string;
  20478. /**
  20479. * The emitter represents the Mesh or position we are attaching the particle system to.
  20480. */
  20481. emitter: Nullable<AbstractMesh | Vector3>;
  20482. /**
  20483. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20484. */
  20485. isBillboardBased: boolean;
  20486. /**
  20487. * The rendering group used by the Particle system to chose when to render.
  20488. */
  20489. renderingGroupId: number;
  20490. /**
  20491. * The layer mask we are rendering the particles through.
  20492. */
  20493. layerMask: number;
  20494. /**
  20495. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20496. */
  20497. updateSpeed: number;
  20498. /**
  20499. * The amount of time the particle system is running (depends of the overall update speed).
  20500. */
  20501. targetStopDuration: number;
  20502. /**
  20503. * The texture used to render each particle. (this can be a spritesheet)
  20504. */
  20505. particleTexture: Nullable<Texture>;
  20506. /**
  20507. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20508. */
  20509. blendMode: number;
  20510. /**
  20511. * Minimum life time of emitting particles.
  20512. */
  20513. minLifeTime: number;
  20514. /**
  20515. * Maximum life time of emitting particles.
  20516. */
  20517. maxLifeTime: number;
  20518. /**
  20519. * Minimum Size of emitting particles.
  20520. */
  20521. minSize: number;
  20522. /**
  20523. * Maximum Size of emitting particles.
  20524. */
  20525. maxSize: number;
  20526. /**
  20527. * Minimum scale of emitting particles on X axis.
  20528. */
  20529. minScaleX: number;
  20530. /**
  20531. * Maximum scale of emitting particles on X axis.
  20532. */
  20533. maxScaleX: number;
  20534. /**
  20535. * Minimum scale of emitting particles on Y axis.
  20536. */
  20537. minScaleY: number;
  20538. /**
  20539. * Maximum scale of emitting particles on Y axis.
  20540. */
  20541. maxScaleY: number;
  20542. /**
  20543. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20544. */
  20545. color1: Color4;
  20546. /**
  20547. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20548. */
  20549. color2: Color4;
  20550. /**
  20551. * Color the particle will have at the end of its lifetime.
  20552. */
  20553. colorDead: Color4;
  20554. /**
  20555. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20556. */
  20557. emitRate: number;
  20558. /**
  20559. * You can use gravity if you want to give an orientation to your particles.
  20560. */
  20561. gravity: Vector3;
  20562. /**
  20563. * Minimum power of emitting particles.
  20564. */
  20565. minEmitPower: number;
  20566. /**
  20567. * Maximum power of emitting particles.
  20568. */
  20569. maxEmitPower: number;
  20570. /**
  20571. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20572. */
  20573. minAngularSpeed: number;
  20574. /**
  20575. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20576. */
  20577. maxAngularSpeed: number;
  20578. /**
  20579. * Gets or sets the minimal initial rotation in radians.
  20580. */
  20581. minInitialRotation: number;
  20582. /**
  20583. * Gets or sets the maximal initial rotation in radians.
  20584. */
  20585. maxInitialRotation: number;
  20586. /**
  20587. * The particle emitter type defines the emitter used by the particle system.
  20588. * It can be for example box, sphere, or cone...
  20589. */
  20590. particleEmitterType: Nullable<IParticleEmitterType>;
  20591. /**
  20592. * Defines the delay in milliseconds before starting the system (0 by default)
  20593. */
  20594. startDelay: number;
  20595. /**
  20596. * 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
  20597. */
  20598. preWarmCycles: number;
  20599. /**
  20600. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20601. */
  20602. preWarmStepOffset: number;
  20603. /**
  20604. * 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)
  20605. */
  20606. spriteCellChangeSpeed: number;
  20607. /**
  20608. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20609. */
  20610. startSpriteCellID: number;
  20611. /**
  20612. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20613. */
  20614. endSpriteCellID: number;
  20615. /**
  20616. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20617. */
  20618. spriteCellWidth: number;
  20619. /**
  20620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20621. */
  20622. spriteCellHeight: number;
  20623. /**
  20624. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20625. */
  20626. spriteRandomStartCell: boolean;
  20627. /**
  20628. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20629. */
  20630. isAnimationSheetEnabled: boolean;
  20631. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20632. translationPivot: Vector2;
  20633. /**
  20634. * Gets or sets a texture used to add random noise to particle positions
  20635. */
  20636. noiseTexture: Nullable<BaseTexture>;
  20637. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20638. noiseStrength: Vector3;
  20639. /**
  20640. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20641. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20642. */
  20643. billboardMode: number;
  20644. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20645. limitVelocityDamping: number;
  20646. /**
  20647. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20648. */
  20649. beginAnimationOnStart: boolean;
  20650. /**
  20651. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20652. */
  20653. beginAnimationFrom: number;
  20654. /**
  20655. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20656. */
  20657. beginAnimationTo: number;
  20658. /**
  20659. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20660. */
  20661. beginAnimationLoop: boolean;
  20662. /**
  20663. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20664. */
  20665. disposeOnStop: boolean;
  20666. /**
  20667. * Gets the maximum number of particles active at the same time.
  20668. * @returns The max number of active particles.
  20669. */
  20670. getCapacity(): number;
  20671. /**
  20672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20673. * @returns True if it has been started, otherwise false.
  20674. */
  20675. isStarted(): boolean;
  20676. /**
  20677. * Animates the particle system for this frame.
  20678. */
  20679. animate(): void;
  20680. /**
  20681. * Renders the particle system in its current state.
  20682. * @returns the current number of particles
  20683. */
  20684. render(): number;
  20685. /**
  20686. * Dispose the particle system and frees its associated resources.
  20687. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20688. */
  20689. dispose(disposeTexture?: boolean): void;
  20690. /**
  20691. * Clones the particle system.
  20692. * @param name The name of the cloned object
  20693. * @param newEmitter The new emitter to use
  20694. * @returns the cloned particle system
  20695. */
  20696. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  20697. /**
  20698. * Serializes the particle system to a JSON object.
  20699. * @returns the JSON object
  20700. */
  20701. serialize(): any;
  20702. /**
  20703. * Rebuild the particle system
  20704. */
  20705. rebuild(): void;
  20706. /**
  20707. * Starts the particle system and begins to emit
  20708. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  20709. */
  20710. start(delay?: number): void;
  20711. /**
  20712. * Stops the particle system.
  20713. */
  20714. stop(): void;
  20715. /**
  20716. * Remove all active particles
  20717. */
  20718. reset(): void;
  20719. /**
  20720. * Is this system ready to be used/rendered
  20721. * @return true if the system is ready
  20722. */
  20723. isReady(): boolean;
  20724. /**
  20725. * Adds a new color gradient
  20726. * @param gradient defines the gradient to use (between 0 and 1)
  20727. * @param color1 defines the color to affect to the specified gradient
  20728. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20729. * @returns the current particle system
  20730. */
  20731. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20732. /**
  20733. * Remove a specific color gradient
  20734. * @param gradient defines the gradient to remove
  20735. * @returns the current particle system
  20736. */
  20737. removeColorGradient(gradient: number): IParticleSystem;
  20738. /**
  20739. * Adds a new size gradient
  20740. * @param gradient defines the gradient to use (between 0 and 1)
  20741. * @param factor defines the size factor to affect to the specified gradient
  20742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20743. * @returns the current particle system
  20744. */
  20745. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20746. /**
  20747. * Remove a specific size gradient
  20748. * @param gradient defines the gradient to remove
  20749. * @returns the current particle system
  20750. */
  20751. removeSizeGradient(gradient: number): IParticleSystem;
  20752. /**
  20753. * Gets the current list of color gradients.
  20754. * You must use addColorGradient and removeColorGradient to udpate this list
  20755. * @returns the list of color gradients
  20756. */
  20757. getColorGradients(): Nullable<Array<ColorGradient>>;
  20758. /**
  20759. * Gets the current list of size gradients.
  20760. * You must use addSizeGradient and removeSizeGradient to udpate this list
  20761. * @returns the list of size gradients
  20762. */
  20763. getSizeGradients(): Nullable<Array<FactorGradient>>;
  20764. /**
  20765. * Gets the current list of angular speed gradients.
  20766. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  20767. * @returns the list of angular speed gradients
  20768. */
  20769. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  20770. /**
  20771. * Adds a new angular speed gradient
  20772. * @param gradient defines the gradient to use (between 0 and 1)
  20773. * @param factor defines the angular speed to affect to the specified gradient
  20774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20775. * @returns the current particle system
  20776. */
  20777. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20778. /**
  20779. * Remove a specific angular speed gradient
  20780. * @param gradient defines the gradient to remove
  20781. * @returns the current particle system
  20782. */
  20783. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20784. /**
  20785. * Gets the current list of velocity gradients.
  20786. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  20787. * @returns the list of velocity gradients
  20788. */
  20789. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  20790. /**
  20791. * Adds a new velocity gradient
  20792. * @param gradient defines the gradient to use (between 0 and 1)
  20793. * @param factor defines the velocity to affect to the specified gradient
  20794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20795. * @returns the current particle system
  20796. */
  20797. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20798. /**
  20799. * Remove a specific velocity gradient
  20800. * @param gradient defines the gradient to remove
  20801. * @returns the current particle system
  20802. */
  20803. removeVelocityGradient(gradient: number): IParticleSystem;
  20804. /**
  20805. * Gets the current list of limit velocity gradients.
  20806. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  20807. * @returns the list of limit velocity gradients
  20808. */
  20809. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  20810. /**
  20811. * Adds a new limit velocity gradient
  20812. * @param gradient defines the gradient to use (between 0 and 1)
  20813. * @param factor defines the limit velocity to affect to the specified gradient
  20814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20815. * @returns the current particle system
  20816. */
  20817. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20818. /**
  20819. * Remove a specific limit velocity gradient
  20820. * @param gradient defines the gradient to remove
  20821. * @returns the current particle system
  20822. */
  20823. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20824. /**
  20825. * Adds a new drag gradient
  20826. * @param gradient defines the gradient to use (between 0 and 1)
  20827. * @param factor defines the drag to affect to the specified gradient
  20828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20829. * @returns the current particle system
  20830. */
  20831. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20832. /**
  20833. * Remove a specific drag gradient
  20834. * @param gradient defines the gradient to remove
  20835. * @returns the current particle system
  20836. */
  20837. removeDragGradient(gradient: number): IParticleSystem;
  20838. /**
  20839. * Gets the current list of drag gradients.
  20840. * You must use addDragGradient and removeDragGradient to udpate this list
  20841. * @returns the list of drag gradients
  20842. */
  20843. getDragGradients(): Nullable<Array<FactorGradient>>;
  20844. /**
  20845. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20846. * @param gradient defines the gradient to use (between 0 and 1)
  20847. * @param factor defines the emit rate to affect to the specified gradient
  20848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20849. * @returns the current particle system
  20850. */
  20851. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20852. /**
  20853. * Remove a specific emit rate gradient
  20854. * @param gradient defines the gradient to remove
  20855. * @returns the current particle system
  20856. */
  20857. removeEmitRateGradient(gradient: number): IParticleSystem;
  20858. /**
  20859. * Gets the current list of emit rate gradients.
  20860. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  20861. * @returns the list of emit rate gradients
  20862. */
  20863. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  20864. /**
  20865. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20866. * @param gradient defines the gradient to use (between 0 and 1)
  20867. * @param factor defines the start size to affect to the specified gradient
  20868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20869. * @returns the current particle system
  20870. */
  20871. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20872. /**
  20873. * Remove a specific start size gradient
  20874. * @param gradient defines the gradient to remove
  20875. * @returns the current particle system
  20876. */
  20877. removeStartSizeGradient(gradient: number): IParticleSystem;
  20878. /**
  20879. * Gets the current list of start size gradients.
  20880. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  20881. * @returns the list of start size gradients
  20882. */
  20883. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  20884. /**
  20885. * Adds a new life time gradient
  20886. * @param gradient defines the gradient to use (between 0 and 1)
  20887. * @param factor defines the life time factor to affect to the specified gradient
  20888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20889. * @returns the current particle system
  20890. */
  20891. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20892. /**
  20893. * Remove a specific life time gradient
  20894. * @param gradient defines the gradient to remove
  20895. * @returns the current particle system
  20896. */
  20897. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20898. /**
  20899. * Gets the current list of life time gradients.
  20900. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  20901. * @returns the list of life time gradients
  20902. */
  20903. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  20904. /**
  20905. * Gets the current list of color gradients.
  20906. * You must use addColorGradient and removeColorGradient to udpate this list
  20907. * @returns the list of color gradients
  20908. */
  20909. getColorGradients(): Nullable<Array<ColorGradient>>;
  20910. /**
  20911. * Adds a new ramp gradient used to remap particle colors
  20912. * @param gradient defines the gradient to use (between 0 and 1)
  20913. * @param color defines the color to affect to the specified gradient
  20914. * @returns the current particle system
  20915. */
  20916. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  20917. /**
  20918. * Gets the current list of ramp gradients.
  20919. * You must use addRampGradient and removeRampGradient to udpate this list
  20920. * @returns the list of ramp gradients
  20921. */
  20922. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20923. /** Gets or sets a boolean indicating that ramp gradients must be used
  20924. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20925. */
  20926. useRampGradients: boolean;
  20927. /**
  20928. * Adds a new color remap gradient
  20929. * @param gradient defines the gradient to use (between 0 and 1)
  20930. * @param min defines the color remap minimal range
  20931. * @param max defines the color remap maximal range
  20932. * @returns the current particle system
  20933. */
  20934. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20935. /**
  20936. * Gets the current list of color remap gradients.
  20937. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  20938. * @returns the list of color remap gradients
  20939. */
  20940. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  20941. /**
  20942. * Adds a new alpha remap gradient
  20943. * @param gradient defines the gradient to use (between 0 and 1)
  20944. * @param min defines the alpha remap minimal range
  20945. * @param max defines the alpha remap maximal range
  20946. * @returns the current particle system
  20947. */
  20948. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20949. /**
  20950. * Gets the current list of alpha remap gradients.
  20951. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  20952. * @returns the list of alpha remap gradients
  20953. */
  20954. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  20955. /**
  20956. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  20957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  20958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  20959. * @returns the emitter
  20960. */
  20961. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  20962. /**
  20963. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  20964. * @param radius The radius of the hemisphere to emit from
  20965. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  20966. * @returns the emitter
  20967. */
  20968. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  20969. /**
  20970. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  20971. * @param radius The radius of the sphere to emit from
  20972. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  20973. * @returns the emitter
  20974. */
  20975. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  20976. /**
  20977. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  20978. * @param radius The radius of the sphere to emit from
  20979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  20980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  20981. * @returns the emitter
  20982. */
  20983. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  20984. /**
  20985. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  20986. * @param radius The radius of the emission cylinder
  20987. * @param height The height of the emission cylinder
  20988. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  20989. * @param directionRandomizer How much to randomize the particle direction [0-1]
  20990. * @returns the emitter
  20991. */
  20992. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  20993. /**
  20994. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  20995. * @param radius The radius of the cylinder to emit from
  20996. * @param height The height of the emission cylinder
  20997. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20998. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  20999. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21000. * @returns the emitter
  21001. */
  21002. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21003. /**
  21004. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21005. * @param radius The radius of the cone to emit from
  21006. * @param angle The base angle of the cone
  21007. * @returns the emitter
  21008. */
  21009. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21010. /**
  21011. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21014. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21015. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21016. * @returns the emitter
  21017. */
  21018. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21019. /**
  21020. * Get hosting scene
  21021. * @returns the scene
  21022. */
  21023. getScene(): Scene;
  21024. }
  21025. }
  21026. declare module BABYLON {
  21027. /** @hidden */
  21028. export var linePixelShader: {
  21029. name: string;
  21030. shader: string;
  21031. };
  21032. }
  21033. declare module BABYLON {
  21034. /** @hidden */
  21035. export var lineVertexShader: {
  21036. name: string;
  21037. shader: string;
  21038. };
  21039. }
  21040. declare module BABYLON {
  21041. interface AbstractMesh {
  21042. /**
  21043. * Gets the edgesRenderer associated with the mesh
  21044. */
  21045. edgesRenderer: Nullable<EdgesRenderer>;
  21046. }
  21047. interface LinesMesh {
  21048. /**
  21049. * Enables the edge rendering mode on the mesh.
  21050. * This mode makes the mesh edges visible
  21051. * @param epsilon defines the maximal distance between two angles to detect a face
  21052. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21053. * @returns the currentAbstractMesh
  21054. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21055. */
  21056. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21057. }
  21058. interface InstancedLinesMesh {
  21059. /**
  21060. * Enables the edge rendering mode on the mesh.
  21061. * This mode makes the mesh edges visible
  21062. * @param epsilon defines the maximal distance between two angles to detect a face
  21063. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21064. * @returns the current InstancedLinesMesh
  21065. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21066. */
  21067. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21068. }
  21069. /**
  21070. * Defines the minimum contract an Edges renderer should follow.
  21071. */
  21072. export interface IEdgesRenderer extends IDisposable {
  21073. /**
  21074. * Gets or sets a boolean indicating if the edgesRenderer is active
  21075. */
  21076. isEnabled: boolean;
  21077. /**
  21078. * Renders the edges of the attached mesh,
  21079. */
  21080. render(): void;
  21081. /**
  21082. * Checks wether or not the edges renderer is ready to render.
  21083. * @return true if ready, otherwise false.
  21084. */
  21085. isReady(): boolean;
  21086. }
  21087. /**
  21088. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21089. */
  21090. export class EdgesRenderer implements IEdgesRenderer {
  21091. /**
  21092. * Define the size of the edges with an orthographic camera
  21093. */
  21094. edgesWidthScalerForOrthographic: number;
  21095. /**
  21096. * Define the size of the edges with a perspective camera
  21097. */
  21098. edgesWidthScalerForPerspective: number;
  21099. protected _source: AbstractMesh;
  21100. protected _linesPositions: number[];
  21101. protected _linesNormals: number[];
  21102. protected _linesIndices: number[];
  21103. protected _epsilon: number;
  21104. protected _indicesCount: number;
  21105. protected _lineShader: ShaderMaterial;
  21106. protected _ib: DataBuffer;
  21107. protected _buffers: {
  21108. [key: string]: Nullable<VertexBuffer>;
  21109. };
  21110. protected _checkVerticesInsteadOfIndices: boolean;
  21111. private _meshRebuildObserver;
  21112. private _meshDisposeObserver;
  21113. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21114. isEnabled: boolean;
  21115. /**
  21116. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21117. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21118. * @param source Mesh used to create edges
  21119. * @param epsilon sum of angles in adjacency to check for edge
  21120. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21121. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21122. */
  21123. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21124. protected _prepareRessources(): void;
  21125. /** @hidden */ private _rebuild(): void;
  21126. /**
  21127. * Releases the required resources for the edges renderer
  21128. */
  21129. dispose(): void;
  21130. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21131. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21132. /**
  21133. * Checks if the pair of p0 and p1 is en edge
  21134. * @param faceIndex
  21135. * @param edge
  21136. * @param faceNormals
  21137. * @param p0
  21138. * @param p1
  21139. * @private
  21140. */
  21141. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21142. /**
  21143. * push line into the position, normal and index buffer
  21144. * @protected
  21145. */
  21146. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21147. /**
  21148. * Generates lines edges from adjacencjes
  21149. * @private
  21150. */ private _generateEdgesLines(): void;
  21151. /**
  21152. * Checks wether or not the edges renderer is ready to render.
  21153. * @return true if ready, otherwise false.
  21154. */
  21155. isReady(): boolean;
  21156. /**
  21157. * Renders the edges of the attached mesh,
  21158. */
  21159. render(): void;
  21160. }
  21161. /**
  21162. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21163. */
  21164. export class LineEdgesRenderer extends EdgesRenderer {
  21165. /**
  21166. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21167. * @param source LineMesh used to generate edges
  21168. * @param epsilon not important (specified angle for edge detection)
  21169. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21170. */
  21171. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21172. /**
  21173. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21174. */ private _generateEdgesLines(): void;
  21175. }
  21176. }
  21177. declare module BABYLON {
  21178. /**
  21179. * This represents the object necessary to create a rendering group.
  21180. * This is exclusively used and created by the rendering manager.
  21181. * To modify the behavior, you use the available helpers in your scene or meshes.
  21182. * @hidden
  21183. */
  21184. export class RenderingGroup {
  21185. index: number;
  21186. private static _zeroVector;
  21187. private _scene;
  21188. private _opaqueSubMeshes;
  21189. private _transparentSubMeshes;
  21190. private _alphaTestSubMeshes;
  21191. private _depthOnlySubMeshes;
  21192. private _particleSystems;
  21193. private _spriteManagers;
  21194. private _opaqueSortCompareFn;
  21195. private _alphaTestSortCompareFn;
  21196. private _transparentSortCompareFn;
  21197. private _renderOpaque;
  21198. private _renderAlphaTest;
  21199. private _renderTransparent;
  21200. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  21201. onBeforeTransparentRendering: () => void;
  21202. /**
  21203. * Set the opaque sort comparison function.
  21204. * If null the sub meshes will be render in the order they were created
  21205. */
  21206. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21207. /**
  21208. * Set the alpha test sort comparison function.
  21209. * If null the sub meshes will be render in the order they were created
  21210. */
  21211. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21212. /**
  21213. * Set the transparent sort comparison function.
  21214. * If null the sub meshes will be render in the order they were created
  21215. */
  21216. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21217. /**
  21218. * Creates a new rendering group.
  21219. * @param index The rendering group index
  21220. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21221. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21222. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21223. */
  21224. 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>);
  21225. /**
  21226. * Render all the sub meshes contained in the group.
  21227. * @param customRenderFunction Used to override the default render behaviour of the group.
  21228. * @returns true if rendered some submeshes.
  21229. */
  21230. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21231. /**
  21232. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21233. * @param subMeshes The submeshes to render
  21234. */
  21235. private renderOpaqueSorted;
  21236. /**
  21237. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21238. * @param subMeshes The submeshes to render
  21239. */
  21240. private renderAlphaTestSorted;
  21241. /**
  21242. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21243. * @param subMeshes The submeshes to render
  21244. */
  21245. private renderTransparentSorted;
  21246. /**
  21247. * Renders the submeshes in a specified order.
  21248. * @param subMeshes The submeshes to sort before render
  21249. * @param sortCompareFn The comparison function use to sort
  21250. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21251. * @param transparent Specifies to activate blending if true
  21252. */
  21253. private static renderSorted;
  21254. /**
  21255. * Renders the submeshes in the order they were dispatched (no sort applied).
  21256. * @param subMeshes The submeshes to render
  21257. */
  21258. private static renderUnsorted;
  21259. /**
  21260. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21261. * are rendered back to front if in the same alpha index.
  21262. *
  21263. * @param a The first submesh
  21264. * @param b The second submesh
  21265. * @returns The result of the comparison
  21266. */
  21267. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21268. /**
  21269. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21270. * are rendered back to front.
  21271. *
  21272. * @param a The first submesh
  21273. * @param b The second submesh
  21274. * @returns The result of the comparison
  21275. */
  21276. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21277. /**
  21278. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21279. * are rendered front to back (prevent overdraw).
  21280. *
  21281. * @param a The first submesh
  21282. * @param b The second submesh
  21283. * @returns The result of the comparison
  21284. */
  21285. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21286. /**
  21287. * Resets the different lists of submeshes to prepare a new frame.
  21288. */
  21289. prepare(): void;
  21290. dispose(): void;
  21291. /**
  21292. * Inserts the submesh in its correct queue depending on its material.
  21293. * @param subMesh The submesh to dispatch
  21294. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21295. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21296. */
  21297. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21298. dispatchSprites(spriteManager: ISpriteManager): void;
  21299. dispatchParticles(particleSystem: IParticleSystem): void;
  21300. private _renderParticles;
  21301. private _renderSprites;
  21302. }
  21303. }
  21304. declare module BABYLON {
  21305. /**
  21306. * Interface describing the different options available in the rendering manager
  21307. * regarding Auto Clear between groups.
  21308. */
  21309. export interface IRenderingManagerAutoClearSetup {
  21310. /**
  21311. * Defines whether or not autoclear is enable.
  21312. */
  21313. autoClear: boolean;
  21314. /**
  21315. * Defines whether or not to autoclear the depth buffer.
  21316. */
  21317. depth: boolean;
  21318. /**
  21319. * Defines whether or not to autoclear the stencil buffer.
  21320. */
  21321. stencil: boolean;
  21322. }
  21323. /**
  21324. * This class is used by the onRenderingGroupObservable
  21325. */
  21326. export class RenderingGroupInfo {
  21327. /**
  21328. * The Scene that being rendered
  21329. */
  21330. scene: Scene;
  21331. /**
  21332. * The camera currently used for the rendering pass
  21333. */
  21334. camera: Nullable<Camera>;
  21335. /**
  21336. * The ID of the renderingGroup being processed
  21337. */
  21338. renderingGroupId: number;
  21339. }
  21340. /**
  21341. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21342. * It is enable to manage the different groups as well as the different necessary sort functions.
  21343. * This should not be used directly aside of the few static configurations
  21344. */
  21345. export class RenderingManager {
  21346. /**
  21347. * The max id used for rendering groups (not included)
  21348. */
  21349. static MAX_RENDERINGGROUPS: number;
  21350. /**
  21351. * The min id used for rendering groups (included)
  21352. */
  21353. static MIN_RENDERINGGROUPS: number;
  21354. /**
  21355. * Used to globally prevent autoclearing scenes.
  21356. */
  21357. static AUTOCLEAR: boolean;
  21358. /**
  21359. * @hidden
  21360. */ private _useSceneAutoClearSetup: boolean;
  21361. private _scene;
  21362. private _renderingGroups;
  21363. private _depthStencilBufferAlreadyCleaned;
  21364. private _autoClearDepthStencil;
  21365. private _customOpaqueSortCompareFn;
  21366. private _customAlphaTestSortCompareFn;
  21367. private _customTransparentSortCompareFn;
  21368. private _renderingGroupInfo;
  21369. /**
  21370. * Instantiates a new rendering group for a particular scene
  21371. * @param scene Defines the scene the groups belongs to
  21372. */
  21373. constructor(scene: Scene);
  21374. private _clearDepthStencilBuffer;
  21375. /**
  21376. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21377. * @hidden
  21378. */
  21379. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21380. /**
  21381. * Resets the different information of the group to prepare a new frame
  21382. * @hidden
  21383. */
  21384. reset(): void;
  21385. /**
  21386. * Dispose and release the group and its associated resources.
  21387. * @hidden
  21388. */
  21389. dispose(): void;
  21390. /**
  21391. * Clear the info related to rendering groups preventing retention points during dispose.
  21392. */
  21393. freeRenderingGroups(): void;
  21394. private _prepareRenderingGroup;
  21395. /**
  21396. * Add a sprite manager to the rendering manager in order to render it this frame.
  21397. * @param spriteManager Define the sprite manager to render
  21398. */
  21399. dispatchSprites(spriteManager: ISpriteManager): void;
  21400. /**
  21401. * Add a particle system to the rendering manager in order to render it this frame.
  21402. * @param particleSystem Define the particle system to render
  21403. */
  21404. dispatchParticles(particleSystem: IParticleSystem): void;
  21405. /**
  21406. * Add a submesh to the manager in order to render it this frame
  21407. * @param subMesh The submesh to dispatch
  21408. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21409. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21410. */
  21411. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21412. /**
  21413. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21414. * This allowed control for front to back rendering or reversly depending of the special needs.
  21415. *
  21416. * @param renderingGroupId The rendering group id corresponding to its index
  21417. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21418. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21419. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21420. */
  21421. 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;
  21422. /**
  21423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21424. *
  21425. * @param renderingGroupId The rendering group id corresponding to its index
  21426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21427. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21428. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21429. */
  21430. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21431. /**
  21432. * Gets the current auto clear configuration for one rendering group of the rendering
  21433. * manager.
  21434. * @param index the rendering group index to get the information for
  21435. * @returns The auto clear setup for the requested rendering group
  21436. */
  21437. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21438. }
  21439. }
  21440. declare module BABYLON {
  21441. /**
  21442. * This Helps creating a texture that will be created from a camera in your scene.
  21443. * It is basically a dynamic texture that could be used to create special effects for instance.
  21444. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21445. */
  21446. export class RenderTargetTexture extends Texture {
  21447. isCube: boolean;
  21448. /**
  21449. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21450. */
  21451. static readonly REFRESHRATE_RENDER_ONCE: number;
  21452. /**
  21453. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21454. */
  21455. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21456. /**
  21457. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21458. * the central point of your effect and can save a lot of performances.
  21459. */
  21460. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21461. /**
  21462. * Use this predicate to dynamically define the list of mesh you want to render.
  21463. * If set, the renderList property will be overwritten.
  21464. */
  21465. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21466. private _renderList;
  21467. /**
  21468. * Use this list to define the list of mesh you want to render.
  21469. */
  21470. renderList: Nullable<Array<AbstractMesh>>;
  21471. private _hookArray;
  21472. /**
  21473. * Define if particles should be rendered in your texture.
  21474. */
  21475. renderParticles: boolean;
  21476. /**
  21477. * Define if sprites should be rendered in your texture.
  21478. */
  21479. renderSprites: boolean;
  21480. /**
  21481. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21482. */
  21483. coordinatesMode: number;
  21484. /**
  21485. * Define the camera used to render the texture.
  21486. */
  21487. activeCamera: Nullable<Camera>;
  21488. /**
  21489. * Override the render function of the texture with your own one.
  21490. */
  21491. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21492. /**
  21493. * Define if camera post processes should be use while rendering the texture.
  21494. */
  21495. useCameraPostProcesses: boolean;
  21496. /**
  21497. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21498. */
  21499. ignoreCameraViewport: boolean;
  21500. private _postProcessManager;
  21501. private _postProcesses;
  21502. private _resizeObserver;
  21503. /**
  21504. * An event triggered when the texture is unbind.
  21505. */
  21506. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21507. /**
  21508. * An event triggered when the texture is unbind.
  21509. */
  21510. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21511. private _onAfterUnbindObserver;
  21512. /**
  21513. * Set a after unbind callback in the texture.
  21514. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21515. */
  21516. onAfterUnbind: () => void;
  21517. /**
  21518. * An event triggered before rendering the texture
  21519. */
  21520. onBeforeRenderObservable: Observable<number>;
  21521. private _onBeforeRenderObserver;
  21522. /**
  21523. * Set a before render callback in the texture.
  21524. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21525. */
  21526. onBeforeRender: (faceIndex: number) => void;
  21527. /**
  21528. * An event triggered after rendering the texture
  21529. */
  21530. onAfterRenderObservable: Observable<number>;
  21531. private _onAfterRenderObserver;
  21532. /**
  21533. * Set a after render callback in the texture.
  21534. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21535. */
  21536. onAfterRender: (faceIndex: number) => void;
  21537. /**
  21538. * An event triggered after the texture clear
  21539. */
  21540. onClearObservable: Observable<Engine>;
  21541. private _onClearObserver;
  21542. /**
  21543. * Set a clear callback in the texture.
  21544. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21545. */
  21546. onClear: (Engine: Engine) => void;
  21547. /**
  21548. * Define the clear color of the Render Target if it should be different from the scene.
  21549. */
  21550. clearColor: Color4;
  21551. protected _size: number | {
  21552. width: number;
  21553. height: number;
  21554. };
  21555. protected _initialSizeParameter: number | {
  21556. width: number;
  21557. height: number;
  21558. } | {
  21559. ratio: number;
  21560. };
  21561. protected _sizeRatio: Nullable<number>;
  21562. /** @hidden */ private _generateMipMaps: boolean;
  21563. protected _renderingManager: RenderingManager;
  21564. /** @hidden */ private _waitingRenderList: string[];
  21565. protected _doNotChangeAspectRatio: boolean;
  21566. protected _currentRefreshId: number;
  21567. protected _refreshRate: number;
  21568. protected _textureMatrix: Matrix;
  21569. protected _samples: number;
  21570. protected _renderTargetOptions: RenderTargetCreationOptions;
  21571. /**
  21572. * Gets render target creation options that were used.
  21573. */
  21574. readonly renderTargetOptions: RenderTargetCreationOptions;
  21575. protected _engine: Engine;
  21576. protected _onRatioRescale(): void;
  21577. /**
  21578. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21579. * It must define where the camera used to render the texture is set
  21580. */
  21581. boundingBoxPosition: Vector3;
  21582. private _boundingBoxSize;
  21583. /**
  21584. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21585. * When defined, the cubemap will switch to local mode
  21586. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21587. * @example https://www.babylonjs-playground.com/#RNASML
  21588. */
  21589. boundingBoxSize: Vector3;
  21590. /**
  21591. * In case the RTT has been created with a depth texture, get the associated
  21592. * depth texture.
  21593. * Otherwise, return null.
  21594. */
  21595. depthStencilTexture: Nullable<InternalTexture>;
  21596. /**
  21597. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21598. * or used a shadow, depth texture...
  21599. * @param name The friendly name of the texture
  21600. * @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)
  21601. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21602. * @param generateMipMaps True if mip maps need to be generated after render.
  21603. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21604. * @param type The type of the buffer in the RTT (int, half float, float...)
  21605. * @param isCube True if a cube texture needs to be created
  21606. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21607. * @param generateDepthBuffer True to generate a depth buffer
  21608. * @param generateStencilBuffer True to generate a stencil buffer
  21609. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21610. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21611. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21612. */
  21613. constructor(name: string, size: number | {
  21614. width: number;
  21615. height: number;
  21616. } | {
  21617. ratio: number;
  21618. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21619. /**
  21620. * Creates a depth stencil texture.
  21621. * This is only available in WebGL 2 or with the depth texture extension available.
  21622. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21623. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21624. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21625. */
  21626. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21627. private _processSizeParameter;
  21628. /**
  21629. * Define the number of samples to use in case of MSAA.
  21630. * It defaults to one meaning no MSAA has been enabled.
  21631. */
  21632. samples: number;
  21633. /**
  21634. * Resets the refresh counter of the texture and start bak from scratch.
  21635. * Could be useful to regenerate the texture if it is setup to render only once.
  21636. */
  21637. resetRefreshCounter(): void;
  21638. /**
  21639. * Define the refresh rate of the texture or the rendering frequency.
  21640. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21641. */
  21642. refreshRate: number;
  21643. /**
  21644. * Adds a post process to the render target rendering passes.
  21645. * @param postProcess define the post process to add
  21646. */
  21647. addPostProcess(postProcess: PostProcess): void;
  21648. /**
  21649. * Clear all the post processes attached to the render target
  21650. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21651. */
  21652. clearPostProcesses(dispose?: boolean): void;
  21653. /**
  21654. * Remove one of the post process from the list of attached post processes to the texture
  21655. * @param postProcess define the post process to remove from the list
  21656. */
  21657. removePostProcess(postProcess: PostProcess): void;
  21658. /** @hidden */ private _shouldRender(): boolean;
  21659. /**
  21660. * Gets the actual render size of the texture.
  21661. * @returns the width of the render size
  21662. */
  21663. getRenderSize(): number;
  21664. /**
  21665. * Gets the actual render width of the texture.
  21666. * @returns the width of the render size
  21667. */
  21668. getRenderWidth(): number;
  21669. /**
  21670. * Gets the actual render height of the texture.
  21671. * @returns the height of the render size
  21672. */
  21673. getRenderHeight(): number;
  21674. /**
  21675. * Get if the texture can be rescaled or not.
  21676. */
  21677. readonly canRescale: boolean;
  21678. /**
  21679. * Resize the texture using a ratio.
  21680. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21681. */
  21682. scale(ratio: number): void;
  21683. /**
  21684. * Get the texture reflection matrix used to rotate/transform the reflection.
  21685. * @returns the reflection matrix
  21686. */
  21687. getReflectionTextureMatrix(): Matrix;
  21688. /**
  21689. * Resize the texture to a new desired size.
  21690. * Be carrefull as it will recreate all the data in the new texture.
  21691. * @param size Define the new size. It can be:
  21692. * - a number for squared texture,
  21693. * - an object containing { width: number, height: number }
  21694. * - or an object containing a ratio { ratio: number }
  21695. */
  21696. resize(size: number | {
  21697. width: number;
  21698. height: number;
  21699. } | {
  21700. ratio: number;
  21701. }): void;
  21702. /**
  21703. * Renders all the objects from the render list into the texture.
  21704. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21705. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21706. */
  21707. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21708. private _bestReflectionRenderTargetDimension;
  21709. /**
  21710. * @hidden
  21711. * @param faceIndex face index to bind to if this is a cubetexture
  21712. */ private _bindFrameBuffer(faceIndex?: number): void;
  21713. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21714. private renderToTarget;
  21715. /**
  21716. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21717. * This allowed control for front to back rendering or reversly depending of the special needs.
  21718. *
  21719. * @param renderingGroupId The rendering group id corresponding to its index
  21720. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21721. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21722. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21723. */
  21724. 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;
  21725. /**
  21726. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21727. *
  21728. * @param renderingGroupId The rendering group id corresponding to its index
  21729. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21730. */
  21731. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21732. /**
  21733. * Clones the texture.
  21734. * @returns the cloned texture
  21735. */
  21736. clone(): RenderTargetTexture;
  21737. /**
  21738. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21739. * @returns The JSON representation of the texture
  21740. */
  21741. serialize(): any;
  21742. /**
  21743. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21744. */
  21745. disposeFramebufferObjects(): void;
  21746. /**
  21747. * Dispose the texture and release its associated resources.
  21748. */
  21749. dispose(): void;
  21750. /** @hidden */ private _rebuild(): void;
  21751. /**
  21752. * Clear the info related to rendering groups preventing retention point in material dispose.
  21753. */
  21754. freeRenderingGroups(): void;
  21755. /**
  21756. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21757. * @returns the view count
  21758. */
  21759. getViewCount(): number;
  21760. }
  21761. }
  21762. declare module BABYLON {
  21763. /**
  21764. * Base class for the main features of a material in Babylon.js
  21765. */
  21766. export class Material implements IAnimatable {
  21767. /**
  21768. * Returns the triangle fill mode
  21769. */
  21770. static readonly TriangleFillMode: number;
  21771. /**
  21772. * Returns the wireframe mode
  21773. */
  21774. static readonly WireFrameFillMode: number;
  21775. /**
  21776. * Returns the point fill mode
  21777. */
  21778. static readonly PointFillMode: number;
  21779. /**
  21780. * Returns the point list draw mode
  21781. */
  21782. static readonly PointListDrawMode: number;
  21783. /**
  21784. * Returns the line list draw mode
  21785. */
  21786. static readonly LineListDrawMode: number;
  21787. /**
  21788. * Returns the line loop draw mode
  21789. */
  21790. static readonly LineLoopDrawMode: number;
  21791. /**
  21792. * Returns the line strip draw mode
  21793. */
  21794. static readonly LineStripDrawMode: number;
  21795. /**
  21796. * Returns the triangle strip draw mode
  21797. */
  21798. static readonly TriangleStripDrawMode: number;
  21799. /**
  21800. * Returns the triangle fan draw mode
  21801. */
  21802. static readonly TriangleFanDrawMode: number;
  21803. /**
  21804. * Stores the clock-wise side orientation
  21805. */
  21806. static readonly ClockWiseSideOrientation: number;
  21807. /**
  21808. * Stores the counter clock-wise side orientation
  21809. */
  21810. static readonly CounterClockWiseSideOrientation: number;
  21811. /**
  21812. * The dirty texture flag value
  21813. */
  21814. static readonly TextureDirtyFlag: number;
  21815. /**
  21816. * The dirty light flag value
  21817. */
  21818. static readonly LightDirtyFlag: number;
  21819. /**
  21820. * The dirty fresnel flag value
  21821. */
  21822. static readonly FresnelDirtyFlag: number;
  21823. /**
  21824. * The dirty attribute flag value
  21825. */
  21826. static readonly AttributesDirtyFlag: number;
  21827. /**
  21828. * The dirty misc flag value
  21829. */
  21830. static readonly MiscDirtyFlag: number;
  21831. /**
  21832. * The all dirty flag value
  21833. */
  21834. static readonly AllDirtyFlag: number;
  21835. /**
  21836. * The ID of the material
  21837. */
  21838. id: string;
  21839. /**
  21840. * Gets or sets the unique id of the material
  21841. */
  21842. uniqueId: number;
  21843. /**
  21844. * The name of the material
  21845. */
  21846. name: string;
  21847. /**
  21848. * Gets or sets user defined metadata
  21849. */
  21850. metadata: any;
  21851. /**
  21852. * For internal use only. Please do not use.
  21853. */
  21854. reservedDataStore: any;
  21855. /**
  21856. * Specifies if the ready state should be checked on each call
  21857. */
  21858. checkReadyOnEveryCall: boolean;
  21859. /**
  21860. * Specifies if the ready state should be checked once
  21861. */
  21862. checkReadyOnlyOnce: boolean;
  21863. /**
  21864. * The state of the material
  21865. */
  21866. state: string;
  21867. /**
  21868. * The alpha value of the material
  21869. */
  21870. protected _alpha: number;
  21871. /**
  21872. * List of inspectable custom properties (used by the Inspector)
  21873. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21874. */
  21875. inspectableCustomProperties: IInspectable[];
  21876. /**
  21877. * Sets the alpha value of the material
  21878. */
  21879. /**
  21880. * Gets the alpha value of the material
  21881. */
  21882. alpha: number;
  21883. /**
  21884. * Specifies if back face culling is enabled
  21885. */
  21886. protected _backFaceCulling: boolean;
  21887. /**
  21888. * Sets the back-face culling state
  21889. */
  21890. /**
  21891. * Gets the back-face culling state
  21892. */
  21893. backFaceCulling: boolean;
  21894. /**
  21895. * Stores the value for side orientation
  21896. */
  21897. sideOrientation: number;
  21898. /**
  21899. * Callback triggered when the material is compiled
  21900. */
  21901. onCompiled: Nullable<(effect: Effect) => void>;
  21902. /**
  21903. * Callback triggered when an error occurs
  21904. */
  21905. onError: Nullable<(effect: Effect, errors: string) => void>;
  21906. /**
  21907. * Callback triggered to get the render target textures
  21908. */
  21909. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21910. /**
  21911. * Gets a boolean indicating that current material needs to register RTT
  21912. */
  21913. readonly hasRenderTargetTextures: boolean;
  21914. /**
  21915. * Specifies if the material should be serialized
  21916. */
  21917. doNotSerialize: boolean;
  21918. /**
  21919. * @hidden
  21920. */ private _storeEffectOnSubMeshes: boolean;
  21921. /**
  21922. * Stores the animations for the material
  21923. */
  21924. animations: Nullable<Array<Animation>>;
  21925. /**
  21926. * An event triggered when the material is disposed
  21927. */
  21928. onDisposeObservable: Observable<Material>;
  21929. /**
  21930. * An observer which watches for dispose events
  21931. */
  21932. private _onDisposeObserver;
  21933. private _onUnBindObservable;
  21934. /**
  21935. * Called during a dispose event
  21936. */
  21937. onDispose: () => void;
  21938. private _onBindObservable;
  21939. /**
  21940. * An event triggered when the material is bound
  21941. */
  21942. readonly onBindObservable: Observable<AbstractMesh>;
  21943. /**
  21944. * An observer which watches for bind events
  21945. */
  21946. private _onBindObserver;
  21947. /**
  21948. * Called during a bind event
  21949. */
  21950. onBind: (Mesh: AbstractMesh) => void;
  21951. /**
  21952. * An event triggered when the material is unbound
  21953. */
  21954. readonly onUnBindObservable: Observable<Material>;
  21955. /**
  21956. * Stores the value of the alpha mode
  21957. */
  21958. private _alphaMode;
  21959. /**
  21960. * Sets the value of the alpha mode.
  21961. *
  21962. * | Value | Type | Description |
  21963. * | --- | --- | --- |
  21964. * | 0 | ALPHA_DISABLE | |
  21965. * | 1 | ALPHA_ADD | |
  21966. * | 2 | ALPHA_COMBINE | |
  21967. * | 3 | ALPHA_SUBTRACT | |
  21968. * | 4 | ALPHA_MULTIPLY | |
  21969. * | 5 | ALPHA_MAXIMIZED | |
  21970. * | 6 | ALPHA_ONEONE | |
  21971. * | 7 | ALPHA_PREMULTIPLIED | |
  21972. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21973. * | 9 | ALPHA_INTERPOLATE | |
  21974. * | 10 | ALPHA_SCREENMODE | |
  21975. *
  21976. */
  21977. /**
  21978. * Gets the value of the alpha mode
  21979. */
  21980. alphaMode: number;
  21981. /**
  21982. * Stores the state of the need depth pre-pass value
  21983. */
  21984. private _needDepthPrePass;
  21985. /**
  21986. * Sets the need depth pre-pass value
  21987. */
  21988. /**
  21989. * Gets the depth pre-pass value
  21990. */
  21991. needDepthPrePass: boolean;
  21992. /**
  21993. * Specifies if depth writing should be disabled
  21994. */
  21995. disableDepthWrite: boolean;
  21996. /**
  21997. * Specifies if depth writing should be forced
  21998. */
  21999. forceDepthWrite: boolean;
  22000. /**
  22001. * Specifies if there should be a separate pass for culling
  22002. */
  22003. separateCullingPass: boolean;
  22004. /**
  22005. * Stores the state specifing if fog should be enabled
  22006. */
  22007. private _fogEnabled;
  22008. /**
  22009. * Sets the state for enabling fog
  22010. */
  22011. /**
  22012. * Gets the value of the fog enabled state
  22013. */
  22014. fogEnabled: boolean;
  22015. /**
  22016. * Stores the size of points
  22017. */
  22018. pointSize: number;
  22019. /**
  22020. * Stores the z offset value
  22021. */
  22022. zOffset: number;
  22023. /**
  22024. * Gets a value specifying if wireframe mode is enabled
  22025. */
  22026. /**
  22027. * Sets the state of wireframe mode
  22028. */
  22029. wireframe: boolean;
  22030. /**
  22031. * Gets the value specifying if point clouds are enabled
  22032. */
  22033. /**
  22034. * Sets the state of point cloud mode
  22035. */
  22036. pointsCloud: boolean;
  22037. /**
  22038. * Gets the material fill mode
  22039. */
  22040. /**
  22041. * Sets the material fill mode
  22042. */
  22043. fillMode: number;
  22044. /**
  22045. * @hidden
  22046. * Stores the effects for the material
  22047. */ private _effect: Nullable<Effect>;
  22048. /**
  22049. * @hidden
  22050. * Specifies if the material was previously ready
  22051. */ private _wasPreviouslyReady: boolean;
  22052. /**
  22053. * Specifies if uniform buffers should be used
  22054. */
  22055. private _useUBO;
  22056. /**
  22057. * Stores a reference to the scene
  22058. */
  22059. private _scene;
  22060. /**
  22061. * Stores the fill mode state
  22062. */
  22063. private _fillMode;
  22064. /**
  22065. * Specifies if the depth write state should be cached
  22066. */
  22067. private _cachedDepthWriteState;
  22068. /**
  22069. * Stores the uniform buffer
  22070. */
  22071. protected _uniformBuffer: UniformBuffer;
  22072. /** @hidden */ private _indexInSceneMaterialArray: number;
  22073. /** @hidden */
  22074. meshMap: Nullable<{
  22075. [id: string]: AbstractMesh | undefined;
  22076. }>;
  22077. /**
  22078. * Creates a material instance
  22079. * @param name defines the name of the material
  22080. * @param scene defines the scene to reference
  22081. * @param doNotAdd specifies if the material should be added to the scene
  22082. */
  22083. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22084. /**
  22085. * Returns a string representation of the current material
  22086. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22087. * @returns a string with material information
  22088. */
  22089. toString(fullDetails?: boolean): string;
  22090. /**
  22091. * Gets the class name of the material
  22092. * @returns a string with the class name of the material
  22093. */
  22094. getClassName(): string;
  22095. /**
  22096. * Specifies if updates for the material been locked
  22097. */
  22098. readonly isFrozen: boolean;
  22099. /**
  22100. * Locks updates for the material
  22101. */
  22102. freeze(): void;
  22103. /**
  22104. * Unlocks updates for the material
  22105. */
  22106. unfreeze(): void;
  22107. /**
  22108. * Specifies if the material is ready to be used
  22109. * @param mesh defines the mesh to check
  22110. * @param useInstances specifies if instances should be used
  22111. * @returns a boolean indicating if the material is ready to be used
  22112. */
  22113. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22114. /**
  22115. * Specifies that the submesh is ready to be used
  22116. * @param mesh defines the mesh to check
  22117. * @param subMesh defines which submesh to check
  22118. * @param useInstances specifies that instances should be used
  22119. * @returns a boolean indicating that the submesh is ready or not
  22120. */
  22121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22122. /**
  22123. * Returns the material effect
  22124. * @returns the effect associated with the material
  22125. */
  22126. getEffect(): Nullable<Effect>;
  22127. /**
  22128. * Returns the current scene
  22129. * @returns a Scene
  22130. */
  22131. getScene(): Scene;
  22132. /**
  22133. * Specifies if the material will require alpha blending
  22134. * @returns a boolean specifying if alpha blending is needed
  22135. */
  22136. needAlphaBlending(): boolean;
  22137. /**
  22138. * Specifies if the mesh will require alpha blending
  22139. * @param mesh defines the mesh to check
  22140. * @returns a boolean specifying if alpha blending is needed for the mesh
  22141. */
  22142. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22143. /**
  22144. * Specifies if this material should be rendered in alpha test mode
  22145. * @returns a boolean specifying if an alpha test is needed.
  22146. */
  22147. needAlphaTesting(): boolean;
  22148. /**
  22149. * Gets the texture used for the alpha test
  22150. * @returns the texture to use for alpha testing
  22151. */
  22152. getAlphaTestTexture(): Nullable<BaseTexture>;
  22153. /**
  22154. * Marks the material to indicate that it needs to be re-calculated
  22155. */
  22156. markDirty(): void;
  22157. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22158. /**
  22159. * Binds the material to the mesh
  22160. * @param world defines the world transformation matrix
  22161. * @param mesh defines the mesh to bind the material to
  22162. */
  22163. bind(world: Matrix, mesh?: Mesh): void;
  22164. /**
  22165. * Binds the submesh to the material
  22166. * @param world defines the world transformation matrix
  22167. * @param mesh defines the mesh containing the submesh
  22168. * @param subMesh defines the submesh to bind the material to
  22169. */
  22170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22171. /**
  22172. * Binds the world matrix to the material
  22173. * @param world defines the world transformation matrix
  22174. */
  22175. bindOnlyWorldMatrix(world: Matrix): void;
  22176. /**
  22177. * Binds the scene's uniform buffer to the effect.
  22178. * @param effect defines the effect to bind to the scene uniform buffer
  22179. * @param sceneUbo defines the uniform buffer storing scene data
  22180. */
  22181. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22182. /**
  22183. * Binds the view matrix to the effect
  22184. * @param effect defines the effect to bind the view matrix to
  22185. */
  22186. bindView(effect: Effect): void;
  22187. /**
  22188. * Binds the view projection matrix to the effect
  22189. * @param effect defines the effect to bind the view projection matrix to
  22190. */
  22191. bindViewProjection(effect: Effect): void;
  22192. /**
  22193. * Specifies if material alpha testing should be turned on for the mesh
  22194. * @param mesh defines the mesh to check
  22195. */
  22196. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22197. /**
  22198. * Processes to execute after binding the material to a mesh
  22199. * @param mesh defines the rendered mesh
  22200. */
  22201. protected _afterBind(mesh?: Mesh): void;
  22202. /**
  22203. * Unbinds the material from the mesh
  22204. */
  22205. unbind(): void;
  22206. /**
  22207. * Gets the active textures from the material
  22208. * @returns an array of textures
  22209. */
  22210. getActiveTextures(): BaseTexture[];
  22211. /**
  22212. * Specifies if the material uses a texture
  22213. * @param texture defines the texture to check against the material
  22214. * @returns a boolean specifying if the material uses the texture
  22215. */
  22216. hasTexture(texture: BaseTexture): boolean;
  22217. /**
  22218. * Makes a duplicate of the material, and gives it a new name
  22219. * @param name defines the new name for the duplicated material
  22220. * @returns the cloned material
  22221. */
  22222. clone(name: string): Nullable<Material>;
  22223. /**
  22224. * Gets the meshes bound to the material
  22225. * @returns an array of meshes bound to the material
  22226. */
  22227. getBindedMeshes(): AbstractMesh[];
  22228. /**
  22229. * Force shader compilation
  22230. * @param mesh defines the mesh associated with this material
  22231. * @param onCompiled defines a function to execute once the material is compiled
  22232. * @param options defines the options to configure the compilation
  22233. */
  22234. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22235. clipPlane: boolean;
  22236. }>): void;
  22237. /**
  22238. * Force shader compilation
  22239. * @param mesh defines the mesh that will use this material
  22240. * @param options defines additional options for compiling the shaders
  22241. * @returns a promise that resolves when the compilation completes
  22242. */
  22243. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22244. clipPlane: boolean;
  22245. }>): Promise<void>;
  22246. private static readonly _AllDirtyCallBack;
  22247. private static readonly _ImageProcessingDirtyCallBack;
  22248. private static readonly _TextureDirtyCallBack;
  22249. private static readonly _FresnelDirtyCallBack;
  22250. private static readonly _MiscDirtyCallBack;
  22251. private static readonly _LightsDirtyCallBack;
  22252. private static readonly _AttributeDirtyCallBack;
  22253. private static _FresnelAndMiscDirtyCallBack;
  22254. private static _TextureAndMiscDirtyCallBack;
  22255. private static readonly _DirtyCallbackArray;
  22256. private static readonly _RunDirtyCallBacks;
  22257. /**
  22258. * Marks a define in the material to indicate that it needs to be re-computed
  22259. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22260. */
  22261. markAsDirty(flag: number): void;
  22262. /**
  22263. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22264. * @param func defines a function which checks material defines against the submeshes
  22265. */
  22266. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22267. /**
  22268. * Indicates that we need to re-calculated for all submeshes
  22269. */
  22270. protected _markAllSubMeshesAsAllDirty(): void;
  22271. /**
  22272. * Indicates that image processing needs to be re-calculated for all submeshes
  22273. */
  22274. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22275. /**
  22276. * Indicates that textures need to be re-calculated for all submeshes
  22277. */
  22278. protected _markAllSubMeshesAsTexturesDirty(): void;
  22279. /**
  22280. * Indicates that fresnel needs to be re-calculated for all submeshes
  22281. */
  22282. protected _markAllSubMeshesAsFresnelDirty(): void;
  22283. /**
  22284. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22285. */
  22286. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22287. /**
  22288. * Indicates that lights need to be re-calculated for all submeshes
  22289. */
  22290. protected _markAllSubMeshesAsLightsDirty(): void;
  22291. /**
  22292. * Indicates that attributes need to be re-calculated for all submeshes
  22293. */
  22294. protected _markAllSubMeshesAsAttributesDirty(): void;
  22295. /**
  22296. * Indicates that misc needs to be re-calculated for all submeshes
  22297. */
  22298. protected _markAllSubMeshesAsMiscDirty(): void;
  22299. /**
  22300. * Indicates that textures and misc need to be re-calculated for all submeshes
  22301. */
  22302. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22303. /**
  22304. * Disposes the material
  22305. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22306. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22307. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22308. */
  22309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22310. /** @hidden */
  22311. private releaseVertexArrayObject;
  22312. /**
  22313. * Serializes this material
  22314. * @returns the serialized material object
  22315. */
  22316. serialize(): any;
  22317. /**
  22318. * Creates a material from parsed material data
  22319. * @param parsedMaterial defines parsed material data
  22320. * @param scene defines the hosting scene
  22321. * @param rootUrl defines the root URL to use to load textures
  22322. * @returns a new material
  22323. */
  22324. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22325. }
  22326. }
  22327. declare module BABYLON {
  22328. /**
  22329. * Base class for submeshes
  22330. */
  22331. export class BaseSubMesh {
  22332. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  22333. /** @hidden */ private _materialEffect: Nullable<Effect>;
  22334. /**
  22335. * Gets associated effect
  22336. */
  22337. readonly effect: Nullable<Effect>;
  22338. /**
  22339. * Sets associated effect (effect used to render this submesh)
  22340. * @param effect defines the effect to associate with
  22341. * @param defines defines the set of defines used to compile this effect
  22342. */
  22343. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22344. }
  22345. /**
  22346. * Defines a subdivision inside a mesh
  22347. */
  22348. export class SubMesh extends BaseSubMesh implements ICullable {
  22349. /** the material index to use */
  22350. materialIndex: number;
  22351. /** vertex index start */
  22352. verticesStart: number;
  22353. /** vertices count */
  22354. verticesCount: number;
  22355. /** index start */
  22356. indexStart: number;
  22357. /** indices count */
  22358. indexCount: number;
  22359. /** @hidden */ private _linesIndexCount: number;
  22360. private _mesh;
  22361. private _renderingMesh;
  22362. private _boundingInfo;
  22363. private _linesIndexBuffer;
  22364. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  22365. /** @hidden */ private _trianglePlanes: Plane[];
  22366. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  22367. /** @hidden */ private _renderId: number;
  22368. /** @hidden */ private _alphaIndex: number;
  22369. /** @hidden */ private _distanceToCamera: number;
  22370. /** @hidden */ private _id: number;
  22371. private _currentMaterial;
  22372. /**
  22373. * Add a new submesh to a mesh
  22374. * @param materialIndex defines the material index to use
  22375. * @param verticesStart defines vertex index start
  22376. * @param verticesCount defines vertices count
  22377. * @param indexStart defines index start
  22378. * @param indexCount defines indices count
  22379. * @param mesh defines the parent mesh
  22380. * @param renderingMesh defines an optional rendering mesh
  22381. * @param createBoundingBox defines if bounding box should be created for this submesh
  22382. * @returns the new submesh
  22383. */
  22384. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22385. /**
  22386. * Creates a new submesh
  22387. * @param materialIndex defines the material index to use
  22388. * @param verticesStart defines vertex index start
  22389. * @param verticesCount defines vertices count
  22390. * @param indexStart defines index start
  22391. * @param indexCount defines indices count
  22392. * @param mesh defines the parent mesh
  22393. * @param renderingMesh defines an optional rendering mesh
  22394. * @param createBoundingBox defines if bounding box should be created for this submesh
  22395. */
  22396. constructor(
  22397. /** the material index to use */
  22398. materialIndex: number,
  22399. /** vertex index start */
  22400. verticesStart: number,
  22401. /** vertices count */
  22402. verticesCount: number,
  22403. /** index start */
  22404. indexStart: number,
  22405. /** indices count */
  22406. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22407. /**
  22408. * Returns true if this submesh covers the entire parent mesh
  22409. * @ignorenaming
  22410. */
  22411. readonly IsGlobal: boolean;
  22412. /**
  22413. * Returns the submesh BoudingInfo object
  22414. * @returns current bounding info (or mesh's one if the submesh is global)
  22415. */
  22416. getBoundingInfo(): BoundingInfo;
  22417. /**
  22418. * Sets the submesh BoundingInfo
  22419. * @param boundingInfo defines the new bounding info to use
  22420. * @returns the SubMesh
  22421. */
  22422. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22423. /**
  22424. * Returns the mesh of the current submesh
  22425. * @return the parent mesh
  22426. */
  22427. getMesh(): AbstractMesh;
  22428. /**
  22429. * Returns the rendering mesh of the submesh
  22430. * @returns the rendering mesh (could be different from parent mesh)
  22431. */
  22432. getRenderingMesh(): Mesh;
  22433. /**
  22434. * Returns the submesh material
  22435. * @returns null or the current material
  22436. */
  22437. getMaterial(): Nullable<Material>;
  22438. /**
  22439. * Sets a new updated BoundingInfo object to the submesh
  22440. * @param data defines an optional position array to use to determine the bounding info
  22441. * @returns the SubMesh
  22442. */
  22443. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22444. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  22445. /**
  22446. * Updates the submesh BoundingInfo
  22447. * @param world defines the world matrix to use to update the bounding info
  22448. * @returns the submesh
  22449. */
  22450. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22451. /**
  22452. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22453. * @param frustumPlanes defines the frustum planes
  22454. * @returns true if the submesh is intersecting with the frustum
  22455. */
  22456. isInFrustum(frustumPlanes: Plane[]): boolean;
  22457. /**
  22458. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22459. * @param frustumPlanes defines the frustum planes
  22460. * @returns true if the submesh is inside the frustum
  22461. */
  22462. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22463. /**
  22464. * Renders the submesh
  22465. * @param enableAlphaMode defines if alpha needs to be used
  22466. * @returns the submesh
  22467. */
  22468. render(enableAlphaMode: boolean): SubMesh;
  22469. /**
  22470. * @hidden
  22471. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22472. /**
  22473. * Checks if the submesh intersects with a ray
  22474. * @param ray defines the ray to test
  22475. * @returns true is the passed ray intersects the submesh bounding box
  22476. */
  22477. canIntersects(ray: Ray): boolean;
  22478. /**
  22479. * Intersects current submesh with a ray
  22480. * @param ray defines the ray to test
  22481. * @param positions defines mesh's positions array
  22482. * @param indices defines mesh's indices array
  22483. * @param fastCheck defines if only bounding info should be used
  22484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22485. * @returns intersection info or null if no intersection
  22486. */
  22487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22488. /** @hidden */
  22489. private _intersectLines;
  22490. /** @hidden */
  22491. private _intersectUnIndexedLines;
  22492. /** @hidden */
  22493. private _intersectTriangles;
  22494. /** @hidden */
  22495. private _intersectUnIndexedTriangles;
  22496. /** @hidden */ private _rebuild(): void;
  22497. /**
  22498. * Creates a new submesh from the passed mesh
  22499. * @param newMesh defines the new hosting mesh
  22500. * @param newRenderingMesh defines an optional rendering mesh
  22501. * @returns the new submesh
  22502. */
  22503. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22504. /**
  22505. * Release associated resources
  22506. */
  22507. dispose(): void;
  22508. /**
  22509. * Gets the class name
  22510. * @returns the string "SubMesh".
  22511. */
  22512. getClassName(): string;
  22513. /**
  22514. * Creates a new submesh from indices data
  22515. * @param materialIndex the index of the main mesh material
  22516. * @param startIndex the index where to start the copy in the mesh indices array
  22517. * @param indexCount the number of indices to copy then from the startIndex
  22518. * @param mesh the main mesh to create the submesh from
  22519. * @param renderingMesh the optional rendering mesh
  22520. * @returns a new submesh
  22521. */
  22522. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22523. }
  22524. }
  22525. declare module BABYLON {
  22526. /**
  22527. * Class used to store geometry data (vertex buffers + index buffer)
  22528. */
  22529. export class Geometry implements IGetSetVerticesData {
  22530. /**
  22531. * Gets or sets the ID of the geometry
  22532. */
  22533. id: string;
  22534. /**
  22535. * Gets or sets the unique ID of the geometry
  22536. */
  22537. uniqueId: number;
  22538. /**
  22539. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22540. */
  22541. delayLoadState: number;
  22542. /**
  22543. * Gets the file containing the data to load when running in delay load state
  22544. */
  22545. delayLoadingFile: Nullable<string>;
  22546. /**
  22547. * Callback called when the geometry is updated
  22548. */
  22549. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22550. private _scene;
  22551. private _engine;
  22552. private _meshes;
  22553. private _totalVertices;
  22554. /** @hidden */ private _indices: IndicesArray;
  22555. /** @hidden */ private _vertexBuffers: {
  22556. [key: string]: VertexBuffer;
  22557. };
  22558. private _isDisposed;
  22559. private _extend;
  22560. private _boundingBias;
  22561. /** @hidden */ private _delayInfo: Array<string>;
  22562. private _indexBuffer;
  22563. private _indexBufferIsUpdatable;
  22564. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  22565. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22566. /** @hidden */ private _softwareSkinningFrameId: number;
  22567. private _vertexArrayObjects;
  22568. private _updatable;
  22569. /** @hidden */ private _positions: Nullable<Vector3[]>;
  22570. /**
  22571. * 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
  22572. */
  22573. /**
  22574. * 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
  22575. */
  22576. boundingBias: Vector2;
  22577. /**
  22578. * Static function used to attach a new empty geometry to a mesh
  22579. * @param mesh defines the mesh to attach the geometry to
  22580. * @returns the new Geometry
  22581. */
  22582. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22583. /**
  22584. * Creates a new geometry
  22585. * @param id defines the unique ID
  22586. * @param scene defines the hosting scene
  22587. * @param vertexData defines the VertexData used to get geometry data
  22588. * @param updatable defines if geometry must be updatable (false by default)
  22589. * @param mesh defines the mesh that will be associated with the geometry
  22590. */
  22591. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22592. /**
  22593. * Gets the current extend of the geometry
  22594. */
  22595. readonly extend: {
  22596. minimum: Vector3;
  22597. maximum: Vector3;
  22598. };
  22599. /**
  22600. * Gets the hosting scene
  22601. * @returns the hosting Scene
  22602. */
  22603. getScene(): Scene;
  22604. /**
  22605. * Gets the hosting engine
  22606. * @returns the hosting Engine
  22607. */
  22608. getEngine(): Engine;
  22609. /**
  22610. * Defines if the geometry is ready to use
  22611. * @returns true if the geometry is ready to be used
  22612. */
  22613. isReady(): boolean;
  22614. /**
  22615. * Gets a value indicating that the geometry should not be serialized
  22616. */
  22617. readonly doNotSerialize: boolean;
  22618. /** @hidden */ private _rebuild(): void;
  22619. /**
  22620. * Affects all geometry data in one call
  22621. * @param vertexData defines the geometry data
  22622. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22623. */
  22624. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22625. /**
  22626. * Set specific vertex data
  22627. * @param kind defines the data kind (Position, normal, etc...)
  22628. * @param data defines the vertex data to use
  22629. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22630. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22631. */
  22632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22633. /**
  22634. * Removes a specific vertex data
  22635. * @param kind defines the data kind (Position, normal, etc...)
  22636. */
  22637. removeVerticesData(kind: string): void;
  22638. /**
  22639. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22640. * @param buffer defines the vertex buffer to use
  22641. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22642. */
  22643. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22644. /**
  22645. * Update a specific vertex buffer
  22646. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22647. * It will do nothing if the buffer is not updatable
  22648. * @param kind defines the data kind (Position, normal, etc...)
  22649. * @param data defines the data to use
  22650. * @param offset defines the offset in the target buffer where to store the data
  22651. * @param useBytes set to true if the offset is in bytes
  22652. */
  22653. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22654. /**
  22655. * Update a specific vertex buffer
  22656. * This function will create a new buffer if the current one is not updatable
  22657. * @param kind defines the data kind (Position, normal, etc...)
  22658. * @param data defines the data to use
  22659. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22660. */
  22661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22662. private _updateBoundingInfo;
  22663. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22664. /**
  22665. * Gets total number of vertices
  22666. * @returns the total number of vertices
  22667. */
  22668. getTotalVertices(): number;
  22669. /**
  22670. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22671. * @param kind defines the data kind (Position, normal, etc...)
  22672. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22674. * @returns a float array containing vertex data
  22675. */
  22676. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22677. /**
  22678. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22679. * @param kind defines the data kind (Position, normal, etc...)
  22680. * @returns true if the vertex buffer with the specified kind is updatable
  22681. */
  22682. isVertexBufferUpdatable(kind: string): boolean;
  22683. /**
  22684. * Gets a specific vertex buffer
  22685. * @param kind defines the data kind (Position, normal, etc...)
  22686. * @returns a VertexBuffer
  22687. */
  22688. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22689. /**
  22690. * Returns all vertex buffers
  22691. * @return an object holding all vertex buffers indexed by kind
  22692. */
  22693. getVertexBuffers(): Nullable<{
  22694. [key: string]: VertexBuffer;
  22695. }>;
  22696. /**
  22697. * Gets a boolean indicating if specific vertex buffer is present
  22698. * @param kind defines the data kind (Position, normal, etc...)
  22699. * @returns true if data is present
  22700. */
  22701. isVerticesDataPresent(kind: string): boolean;
  22702. /**
  22703. * Gets a list of all attached data kinds (Position, normal, etc...)
  22704. * @returns a list of string containing all kinds
  22705. */
  22706. getVerticesDataKinds(): string[];
  22707. /**
  22708. * Update index buffer
  22709. * @param indices defines the indices to store in the index buffer
  22710. * @param offset defines the offset in the target buffer where to store the data
  22711. * @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)
  22712. */
  22713. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22714. /**
  22715. * Creates a new index buffer
  22716. * @param indices defines the indices to store in the index buffer
  22717. * @param totalVertices defines the total number of vertices (could be null)
  22718. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22719. */
  22720. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22721. /**
  22722. * Return the total number of indices
  22723. * @returns the total number of indices
  22724. */
  22725. getTotalIndices(): number;
  22726. /**
  22727. * Gets the index buffer array
  22728. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22729. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22730. * @returns the index buffer array
  22731. */
  22732. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22733. /**
  22734. * Gets the index buffer
  22735. * @return the index buffer
  22736. */
  22737. getIndexBuffer(): Nullable<DataBuffer>;
  22738. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22739. /**
  22740. * Release the associated resources for a specific mesh
  22741. * @param mesh defines the source mesh
  22742. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22743. */
  22744. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22745. /**
  22746. * Apply current geometry to a given mesh
  22747. * @param mesh defines the mesh to apply geometry to
  22748. */
  22749. applyToMesh(mesh: Mesh): void;
  22750. private _updateExtend;
  22751. private _applyToMesh;
  22752. private notifyUpdate;
  22753. /**
  22754. * Load the geometry if it was flagged as delay loaded
  22755. * @param scene defines the hosting scene
  22756. * @param onLoaded defines a callback called when the geometry is loaded
  22757. */
  22758. load(scene: Scene, onLoaded?: () => void): void;
  22759. private _queueLoad;
  22760. /**
  22761. * Invert the geometry to move from a right handed system to a left handed one.
  22762. */
  22763. toLeftHanded(): void;
  22764. /** @hidden */ private _resetPointsArrayCache(): void;
  22765. /** @hidden */ private _generatePointsArray(): boolean;
  22766. /**
  22767. * Gets a value indicating if the geometry is disposed
  22768. * @returns true if the geometry was disposed
  22769. */
  22770. isDisposed(): boolean;
  22771. private _disposeVertexArrayObjects;
  22772. /**
  22773. * Free all associated resources
  22774. */
  22775. dispose(): void;
  22776. /**
  22777. * Clone the current geometry into a new geometry
  22778. * @param id defines the unique ID of the new geometry
  22779. * @returns a new geometry object
  22780. */
  22781. copy(id: string): Geometry;
  22782. /**
  22783. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22784. * @return a JSON representation of the current geometry data (without the vertices data)
  22785. */
  22786. serialize(): any;
  22787. private toNumberArray;
  22788. /**
  22789. * Serialize all vertices data into a JSON oject
  22790. * @returns a JSON representation of the current geometry data
  22791. */
  22792. serializeVerticeData(): any;
  22793. /**
  22794. * Extracts a clone of a mesh geometry
  22795. * @param mesh defines the source mesh
  22796. * @param id defines the unique ID of the new geometry object
  22797. * @returns the new geometry object
  22798. */
  22799. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22800. /**
  22801. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22802. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22803. * Be aware Math.random() could cause collisions, but:
  22804. * "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"
  22805. * @returns a string containing a new GUID
  22806. */
  22807. static RandomId(): string;
  22808. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22809. private static _CleanMatricesWeights;
  22810. /**
  22811. * Create a new geometry from persisted data (Using .babylon file format)
  22812. * @param parsedVertexData defines the persisted data
  22813. * @param scene defines the hosting scene
  22814. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22815. * @returns the new geometry object
  22816. */
  22817. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22818. }
  22819. }
  22820. declare module BABYLON {
  22821. /**
  22822. * Define an interface for all classes that will get and set the data on vertices
  22823. */
  22824. export interface IGetSetVerticesData {
  22825. /**
  22826. * Gets a boolean indicating if specific vertex data is present
  22827. * @param kind defines the vertex data kind to use
  22828. * @returns true is data kind is present
  22829. */
  22830. isVerticesDataPresent(kind: string): boolean;
  22831. /**
  22832. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22833. * @param kind defines the data kind (Position, normal, etc...)
  22834. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22836. * @returns a float array containing vertex data
  22837. */
  22838. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22839. /**
  22840. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22841. * @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.
  22842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22843. * @returns the indices array or an empty array if the mesh has no geometry
  22844. */
  22845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22846. /**
  22847. * Set specific vertex data
  22848. * @param kind defines the data kind (Position, normal, etc...)
  22849. * @param data defines the vertex data to use
  22850. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22851. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22852. */
  22853. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22854. /**
  22855. * Update a specific associated vertex buffer
  22856. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22857. * - VertexBuffer.PositionKind
  22858. * - VertexBuffer.UVKind
  22859. * - VertexBuffer.UV2Kind
  22860. * - VertexBuffer.UV3Kind
  22861. * - VertexBuffer.UV4Kind
  22862. * - VertexBuffer.UV5Kind
  22863. * - VertexBuffer.UV6Kind
  22864. * - VertexBuffer.ColorKind
  22865. * - VertexBuffer.MatricesIndicesKind
  22866. * - VertexBuffer.MatricesIndicesExtraKind
  22867. * - VertexBuffer.MatricesWeightsKind
  22868. * - VertexBuffer.MatricesWeightsExtraKind
  22869. * @param data defines the data source
  22870. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22871. * @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)
  22872. */
  22873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22874. /**
  22875. * Creates a new index buffer
  22876. * @param indices defines the indices to store in the index buffer
  22877. * @param totalVertices defines the total number of vertices (could be null)
  22878. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22879. */
  22880. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22881. }
  22882. /**
  22883. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22884. */
  22885. export class VertexData {
  22886. /**
  22887. * Mesh side orientation : usually the external or front surface
  22888. */
  22889. static readonly FRONTSIDE: number;
  22890. /**
  22891. * Mesh side orientation : usually the internal or back surface
  22892. */
  22893. static readonly BACKSIDE: number;
  22894. /**
  22895. * Mesh side orientation : both internal and external or front and back surfaces
  22896. */
  22897. static readonly DOUBLESIDE: number;
  22898. /**
  22899. * Mesh side orientation : by default, `FRONTSIDE`
  22900. */
  22901. static readonly DEFAULTSIDE: number;
  22902. /**
  22903. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22904. */
  22905. positions: Nullable<FloatArray>;
  22906. /**
  22907. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22908. */
  22909. normals: Nullable<FloatArray>;
  22910. /**
  22911. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22912. */
  22913. tangents: Nullable<FloatArray>;
  22914. /**
  22915. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22916. */
  22917. uvs: Nullable<FloatArray>;
  22918. /**
  22919. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22920. */
  22921. uvs2: Nullable<FloatArray>;
  22922. /**
  22923. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22924. */
  22925. uvs3: Nullable<FloatArray>;
  22926. /**
  22927. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22928. */
  22929. uvs4: Nullable<FloatArray>;
  22930. /**
  22931. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22932. */
  22933. uvs5: Nullable<FloatArray>;
  22934. /**
  22935. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22936. */
  22937. uvs6: Nullable<FloatArray>;
  22938. /**
  22939. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22940. */
  22941. colors: Nullable<FloatArray>;
  22942. /**
  22943. * 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).
  22944. */
  22945. matricesIndices: Nullable<FloatArray>;
  22946. /**
  22947. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22948. */
  22949. matricesWeights: Nullable<FloatArray>;
  22950. /**
  22951. * An array extending the number of possible indices
  22952. */
  22953. matricesIndicesExtra: Nullable<FloatArray>;
  22954. /**
  22955. * An array extending the number of possible weights when the number of indices is extended
  22956. */
  22957. matricesWeightsExtra: Nullable<FloatArray>;
  22958. /**
  22959. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22960. */
  22961. indices: Nullable<IndicesArray>;
  22962. /**
  22963. * Uses the passed data array to set the set the values for the specified kind of data
  22964. * @param data a linear array of floating numbers
  22965. * @param kind the type of data that is being set, eg positions, colors etc
  22966. */
  22967. set(data: FloatArray, kind: string): void;
  22968. /**
  22969. * Associates the vertexData to the passed Mesh.
  22970. * Sets it as updatable or not (default `false`)
  22971. * @param mesh the mesh the vertexData is applied to
  22972. * @param updatable when used and having the value true allows new data to update the vertexData
  22973. * @returns the VertexData
  22974. */
  22975. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22976. /**
  22977. * Associates the vertexData to the passed Geometry.
  22978. * Sets it as updatable or not (default `false`)
  22979. * @param geometry the geometry the vertexData is applied to
  22980. * @param updatable when used and having the value true allows new data to update the vertexData
  22981. * @returns VertexData
  22982. */
  22983. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22984. /**
  22985. * Updates the associated mesh
  22986. * @param mesh the mesh to be updated
  22987. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22988. * @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
  22989. * @returns VertexData
  22990. */
  22991. updateMesh(mesh: Mesh): VertexData;
  22992. /**
  22993. * Updates the associated geometry
  22994. * @param geometry the geometry to be updated
  22995. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22996. * @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
  22997. * @returns VertexData.
  22998. */
  22999. updateGeometry(geometry: Geometry): VertexData;
  23000. private _applyTo;
  23001. private _update;
  23002. /**
  23003. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23004. * @param matrix the transforming matrix
  23005. * @returns the VertexData
  23006. */
  23007. transform(matrix: Matrix): VertexData;
  23008. /**
  23009. * Merges the passed VertexData into the current one
  23010. * @param other the VertexData to be merged into the current one
  23011. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23012. * @returns the modified VertexData
  23013. */
  23014. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23015. private _mergeElement;
  23016. private _validate;
  23017. /**
  23018. * Serializes the VertexData
  23019. * @returns a serialized object
  23020. */
  23021. serialize(): any;
  23022. /**
  23023. * Extracts the vertexData from a mesh
  23024. * @param mesh the mesh from which to extract the VertexData
  23025. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23026. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23027. * @returns the object VertexData associated to the passed mesh
  23028. */
  23029. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23030. /**
  23031. * Extracts the vertexData from the geometry
  23032. * @param geometry the geometry from which to extract the VertexData
  23033. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23034. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23035. * @returns the object VertexData associated to the passed mesh
  23036. */
  23037. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23038. private static _ExtractFrom;
  23039. /**
  23040. * Creates the VertexData for a Ribbon
  23041. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23042. * * pathArray array of paths, each of which an array of successive Vector3
  23043. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23044. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23045. * * 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
  23046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23047. * * 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)
  23048. * * 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)
  23049. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23050. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23051. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23052. * @returns the VertexData of the ribbon
  23053. */
  23054. static CreateRibbon(options: {
  23055. pathArray: Vector3[][];
  23056. closeArray?: boolean;
  23057. closePath?: boolean;
  23058. offset?: number;
  23059. sideOrientation?: number;
  23060. frontUVs?: Vector4;
  23061. backUVs?: Vector4;
  23062. invertUV?: boolean;
  23063. uvs?: Vector2[];
  23064. colors?: Color4[];
  23065. }): VertexData;
  23066. /**
  23067. * Creates the VertexData for a box
  23068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23069. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23070. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23071. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23072. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23073. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23074. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23076. * * 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)
  23077. * * 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)
  23078. * @returns the VertexData of the box
  23079. */
  23080. static CreateBox(options: {
  23081. size?: number;
  23082. width?: number;
  23083. height?: number;
  23084. depth?: number;
  23085. faceUV?: Vector4[];
  23086. faceColors?: Color4[];
  23087. sideOrientation?: number;
  23088. frontUVs?: Vector4;
  23089. backUVs?: Vector4;
  23090. }): VertexData;
  23091. /**
  23092. * Creates the VertexData for a tiled box
  23093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23094. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23095. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23096. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23098. * @returns the VertexData of the box
  23099. */
  23100. static CreateTiledBox(options: {
  23101. pattern?: number;
  23102. width?: number;
  23103. height?: number;
  23104. depth?: number;
  23105. tileSize?: number;
  23106. tileWidth?: number;
  23107. tileHeight?: number;
  23108. alignHorizontal?: number;
  23109. alignVertical?: number;
  23110. faceUV?: Vector4[];
  23111. faceColors?: Color4[];
  23112. sideOrientation?: number;
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData for a tiled plane
  23116. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23117. * * pattern a limited pattern arrangement depending on the number
  23118. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23119. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23120. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23122. * * 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)
  23123. * * 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)
  23124. * @returns the VertexData of the tiled plane
  23125. */
  23126. static CreateTiledPlane(options: {
  23127. pattern?: number;
  23128. tileSize?: number;
  23129. tileWidth?: number;
  23130. tileHeight?: number;
  23131. size?: number;
  23132. width?: number;
  23133. height?: number;
  23134. alignHorizontal?: number;
  23135. alignVertical?: number;
  23136. sideOrientation?: number;
  23137. frontUVs?: Vector4;
  23138. backUVs?: Vector4;
  23139. }): VertexData;
  23140. /**
  23141. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23142. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23143. * * segments sets the number of horizontal strips optional, default 32
  23144. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23145. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23146. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23147. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23148. * * 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
  23149. * * 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
  23150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23151. * * 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)
  23152. * * 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)
  23153. * @returns the VertexData of the ellipsoid
  23154. */
  23155. static CreateSphere(options: {
  23156. segments?: number;
  23157. diameter?: number;
  23158. diameterX?: number;
  23159. diameterY?: number;
  23160. diameterZ?: number;
  23161. arc?: number;
  23162. slice?: number;
  23163. sideOrientation?: number;
  23164. frontUVs?: Vector4;
  23165. backUVs?: Vector4;
  23166. }): VertexData;
  23167. /**
  23168. * Creates the VertexData for a cylinder, cone or prism
  23169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23170. * * height sets the height (y direction) of the cylinder, optional, default 2
  23171. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23172. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23173. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23174. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23175. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23176. * * 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
  23177. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23178. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23179. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23180. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23182. * * 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)
  23183. * * 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)
  23184. * @returns the VertexData of the cylinder, cone or prism
  23185. */
  23186. static CreateCylinder(options: {
  23187. height?: number;
  23188. diameterTop?: number;
  23189. diameterBottom?: number;
  23190. diameter?: number;
  23191. tessellation?: number;
  23192. subdivisions?: number;
  23193. arc?: number;
  23194. faceColors?: Color4[];
  23195. faceUV?: Vector4[];
  23196. hasRings?: boolean;
  23197. enclose?: boolean;
  23198. sideOrientation?: number;
  23199. frontUVs?: Vector4;
  23200. backUVs?: Vector4;
  23201. }): VertexData;
  23202. /**
  23203. * Creates the VertexData for a torus
  23204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23205. * * diameter the diameter of the torus, optional default 1
  23206. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23207. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23208. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23209. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23210. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23211. * @returns the VertexData of the torus
  23212. */
  23213. static CreateTorus(options: {
  23214. diameter?: number;
  23215. thickness?: number;
  23216. tessellation?: number;
  23217. sideOrientation?: number;
  23218. frontUVs?: Vector4;
  23219. backUVs?: Vector4;
  23220. }): VertexData;
  23221. /**
  23222. * Creates the VertexData of the LineSystem
  23223. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23224. * - lines an array of lines, each line being an array of successive Vector3
  23225. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23226. * @returns the VertexData of the LineSystem
  23227. */
  23228. static CreateLineSystem(options: {
  23229. lines: Vector3[][];
  23230. colors?: Nullable<Color4[][]>;
  23231. }): VertexData;
  23232. /**
  23233. * Create the VertexData for a DashedLines
  23234. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23235. * - points an array successive Vector3
  23236. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23237. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23238. * - dashNb the intended total number of dashes, optional, default 200
  23239. * @returns the VertexData for the DashedLines
  23240. */
  23241. static CreateDashedLines(options: {
  23242. points: Vector3[];
  23243. dashSize?: number;
  23244. gapSize?: number;
  23245. dashNb?: number;
  23246. }): VertexData;
  23247. /**
  23248. * Creates the VertexData for a Ground
  23249. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23250. * - width the width (x direction) of the ground, optional, default 1
  23251. * - height the height (z direction) of the ground, optional, default 1
  23252. * - subdivisions the number of subdivisions per side, optional, default 1
  23253. * @returns the VertexData of the Ground
  23254. */
  23255. static CreateGround(options: {
  23256. width?: number;
  23257. height?: number;
  23258. subdivisions?: number;
  23259. subdivisionsX?: number;
  23260. subdivisionsY?: number;
  23261. }): VertexData;
  23262. /**
  23263. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23264. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23265. * * xmin the ground minimum X coordinate, optional, default -1
  23266. * * zmin the ground minimum Z coordinate, optional, default -1
  23267. * * xmax the ground maximum X coordinate, optional, default 1
  23268. * * zmax the ground maximum Z coordinate, optional, default 1
  23269. * * 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}
  23270. * * 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}
  23271. * @returns the VertexData of the TiledGround
  23272. */
  23273. static CreateTiledGround(options: {
  23274. xmin: number;
  23275. zmin: number;
  23276. xmax: number;
  23277. zmax: number;
  23278. subdivisions?: {
  23279. w: number;
  23280. h: number;
  23281. };
  23282. precision?: {
  23283. w: number;
  23284. h: number;
  23285. };
  23286. }): VertexData;
  23287. /**
  23288. * Creates the VertexData of the Ground designed from a heightmap
  23289. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23290. * * width the width (x direction) of the ground
  23291. * * height the height (z direction) of the ground
  23292. * * subdivisions the number of subdivisions per side
  23293. * * minHeight the minimum altitude on the ground, optional, default 0
  23294. * * maxHeight the maximum altitude on the ground, optional default 1
  23295. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23296. * * buffer the array holding the image color data
  23297. * * bufferWidth the width of image
  23298. * * bufferHeight the height of image
  23299. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23300. * @returns the VertexData of the Ground designed from a heightmap
  23301. */
  23302. static CreateGroundFromHeightMap(options: {
  23303. width: number;
  23304. height: number;
  23305. subdivisions: number;
  23306. minHeight: number;
  23307. maxHeight: number;
  23308. colorFilter: Color3;
  23309. buffer: Uint8Array;
  23310. bufferWidth: number;
  23311. bufferHeight: number;
  23312. alphaFilter: number;
  23313. }): VertexData;
  23314. /**
  23315. * Creates the VertexData for a Plane
  23316. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23317. * * size sets the width and height of the plane to the value of size, optional default 1
  23318. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23319. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23321. * * 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)
  23322. * * 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)
  23323. * @returns the VertexData of the box
  23324. */
  23325. static CreatePlane(options: {
  23326. size?: number;
  23327. width?: number;
  23328. height?: number;
  23329. sideOrientation?: number;
  23330. frontUVs?: Vector4;
  23331. backUVs?: Vector4;
  23332. }): VertexData;
  23333. /**
  23334. * Creates the VertexData of the Disc or regular Polygon
  23335. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23336. * * radius the radius of the disc, optional default 0.5
  23337. * * tessellation the number of polygon sides, optional, default 64
  23338. * * 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
  23339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23340. * * 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)
  23341. * * 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)
  23342. * @returns the VertexData of the box
  23343. */
  23344. static CreateDisc(options: {
  23345. radius?: number;
  23346. tessellation?: number;
  23347. arc?: number;
  23348. sideOrientation?: number;
  23349. frontUVs?: Vector4;
  23350. backUVs?: Vector4;
  23351. }): VertexData;
  23352. /**
  23353. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23354. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23355. * @param polygon a mesh built from polygonTriangulation.build()
  23356. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23357. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23358. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23359. * @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)
  23360. * @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)
  23361. * @returns the VertexData of the Polygon
  23362. */
  23363. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23364. /**
  23365. * Creates the VertexData of the IcoSphere
  23366. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23367. * * radius the radius of the IcoSphere, optional default 1
  23368. * * radiusX allows stretching in the x direction, optional, default radius
  23369. * * radiusY allows stretching in the y direction, optional, default radius
  23370. * * radiusZ allows stretching in the z direction, optional, default radius
  23371. * * flat when true creates a flat shaded mesh, optional, default true
  23372. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23374. * * 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)
  23375. * * 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)
  23376. * @returns the VertexData of the IcoSphere
  23377. */
  23378. static CreateIcoSphere(options: {
  23379. radius?: number;
  23380. radiusX?: number;
  23381. radiusY?: number;
  23382. radiusZ?: number;
  23383. flat?: boolean;
  23384. subdivisions?: number;
  23385. sideOrientation?: number;
  23386. frontUVs?: Vector4;
  23387. backUVs?: Vector4;
  23388. }): VertexData;
  23389. /**
  23390. * Creates the VertexData for a Polyhedron
  23391. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23392. * * type provided types are:
  23393. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23394. * * 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)
  23395. * * size the size of the IcoSphere, optional default 1
  23396. * * sizeX allows stretching in the x direction, optional, default size
  23397. * * sizeY allows stretching in the y direction, optional, default size
  23398. * * sizeZ allows stretching in the z direction, optional, default size
  23399. * * 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
  23400. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23401. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23402. * * flat when true creates a flat shaded mesh, optional, default true
  23403. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23405. * * 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)
  23406. * * 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)
  23407. * @returns the VertexData of the Polyhedron
  23408. */
  23409. static CreatePolyhedron(options: {
  23410. type?: number;
  23411. size?: number;
  23412. sizeX?: number;
  23413. sizeY?: number;
  23414. sizeZ?: number;
  23415. custom?: any;
  23416. faceUV?: Vector4[];
  23417. faceColors?: Color4[];
  23418. flat?: boolean;
  23419. sideOrientation?: number;
  23420. frontUVs?: Vector4;
  23421. backUVs?: Vector4;
  23422. }): VertexData;
  23423. /**
  23424. * Creates the VertexData for a TorusKnot
  23425. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23426. * * radius the radius of the torus knot, optional, default 2
  23427. * * tube the thickness of the tube, optional, default 0.5
  23428. * * radialSegments the number of sides on each tube segments, optional, default 32
  23429. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23430. * * p the number of windings around the z axis, optional, default 2
  23431. * * q the number of windings around the x axis, optional, default 3
  23432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23433. * * 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)
  23434. * * 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)
  23435. * @returns the VertexData of the Torus Knot
  23436. */
  23437. static CreateTorusKnot(options: {
  23438. radius?: number;
  23439. tube?: number;
  23440. radialSegments?: number;
  23441. tubularSegments?: number;
  23442. p?: number;
  23443. q?: number;
  23444. sideOrientation?: number;
  23445. frontUVs?: Vector4;
  23446. backUVs?: Vector4;
  23447. }): VertexData;
  23448. /**
  23449. * Compute normals for given positions and indices
  23450. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23451. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23452. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23453. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23454. * * facetNormals : optional array of facet normals (vector3)
  23455. * * facetPositions : optional array of facet positions (vector3)
  23456. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23457. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23458. * * bInfo : optional bounding info, required for facetPartitioning computation
  23459. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23460. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23461. * * useRightHandedSystem: optional boolean to for right handed system computation
  23462. * * depthSort : optional boolean to enable the facet depth sort computation
  23463. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23464. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23465. */
  23466. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23467. facetNormals?: any;
  23468. facetPositions?: any;
  23469. facetPartitioning?: any;
  23470. ratio?: number;
  23471. bInfo?: any;
  23472. bbSize?: Vector3;
  23473. subDiv?: any;
  23474. useRightHandedSystem?: boolean;
  23475. depthSort?: boolean;
  23476. distanceTo?: Vector3;
  23477. depthSortedFacets?: any;
  23478. }): void;
  23479. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23480. /**
  23481. * Applies VertexData created from the imported parameters to the geometry
  23482. * @param parsedVertexData the parsed data from an imported file
  23483. * @param geometry the geometry to apply the VertexData to
  23484. */
  23485. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /**
  23490. * Class containing static functions to help procedurally build meshes
  23491. */
  23492. export class DiscBuilder {
  23493. /**
  23494. * Creates a plane polygonal mesh. By default, this is a disc
  23495. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23496. * * 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
  23497. * * 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
  23498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23499. * * 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
  23500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23501. * @param name defines the name of the mesh
  23502. * @param options defines the options used to create the mesh
  23503. * @param scene defines the hosting scene
  23504. * @returns the plane polygonal mesh
  23505. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23506. */
  23507. static CreateDisc(name: string, options: {
  23508. radius?: number;
  23509. tessellation?: number;
  23510. arc?: number;
  23511. updatable?: boolean;
  23512. sideOrientation?: number;
  23513. frontUVs?: Vector4;
  23514. backUVs?: Vector4;
  23515. }, scene?: Nullable<Scene>): Mesh;
  23516. }
  23517. }
  23518. declare module BABYLON {
  23519. /**
  23520. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23521. *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.
  23522. * The SPS is also a particle system. It provides some methods to manage the particles.
  23523. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23524. *
  23525. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23526. */
  23527. export class SolidParticleSystem implements IDisposable {
  23528. /**
  23529. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23530. * Example : var p = SPS.particles[i];
  23531. */
  23532. particles: SolidParticle[];
  23533. /**
  23534. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23535. */
  23536. nbParticles: number;
  23537. /**
  23538. * If the particles must ever face the camera (default false). Useful for planar particles.
  23539. */
  23540. billboard: boolean;
  23541. /**
  23542. * Recompute normals when adding a shape
  23543. */
  23544. recomputeNormals: boolean;
  23545. /**
  23546. * This a counter ofr your own usage. It's not set by any SPS functions.
  23547. */
  23548. counter: number;
  23549. /**
  23550. * The SPS name. This name is also given to the underlying mesh.
  23551. */
  23552. name: string;
  23553. /**
  23554. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23555. */
  23556. mesh: Mesh;
  23557. /**
  23558. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23559. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23560. */
  23561. vars: any;
  23562. /**
  23563. * This array is populated when the SPS is set as 'pickable'.
  23564. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23565. * Each element of this array is an object `{idx: int, faceId: int}`.
  23566. * `idx` is the picked particle index in the `SPS.particles` array
  23567. * `faceId` is the picked face index counted within this particle.
  23568. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23569. */
  23570. pickedParticles: {
  23571. idx: number;
  23572. faceId: number;
  23573. }[];
  23574. /**
  23575. * This array is populated when `enableDepthSort` is set to true.
  23576. * Each element of this array is an instance of the class DepthSortedParticle.
  23577. */
  23578. depthSortedParticles: DepthSortedParticle[];
  23579. /**
  23580. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23581. * @hidden
  23582. */ private _bSphereOnly: boolean;
  23583. /**
  23584. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23585. * @hidden
  23586. */ private _bSphereRadiusFactor: number;
  23587. private _scene;
  23588. private _positions;
  23589. private _indices;
  23590. private _normals;
  23591. private _colors;
  23592. private _uvs;
  23593. private _indices32;
  23594. private _positions32;
  23595. private _normals32;
  23596. private _fixedNormal32;
  23597. private _colors32;
  23598. private _uvs32;
  23599. private _index;
  23600. private _updatable;
  23601. private _pickable;
  23602. private _isVisibilityBoxLocked;
  23603. private _alwaysVisible;
  23604. private _depthSort;
  23605. private _shapeCounter;
  23606. private _copy;
  23607. private _color;
  23608. private _computeParticleColor;
  23609. private _computeParticleTexture;
  23610. private _computeParticleRotation;
  23611. private _computeParticleVertex;
  23612. private _computeBoundingBox;
  23613. private _depthSortParticles;
  23614. private _camera;
  23615. private _mustUnrotateFixedNormals;
  23616. private _particlesIntersect;
  23617. private _needs32Bits;
  23618. /**
  23619. * Creates a SPS (Solid Particle System) object.
  23620. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23621. * @param scene (Scene) is the scene in which the SPS is added.
  23622. * @param options defines the options of the sps e.g.
  23623. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23624. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23625. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23626. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23627. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23628. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23629. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23630. */
  23631. constructor(name: string, scene: Scene, options?: {
  23632. updatable?: boolean;
  23633. isPickable?: boolean;
  23634. enableDepthSort?: boolean;
  23635. particleIntersection?: boolean;
  23636. boundingSphereOnly?: boolean;
  23637. bSphereRadiusFactor?: number;
  23638. });
  23639. /**
  23640. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23641. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23642. * @returns the created mesh
  23643. */
  23644. buildMesh(): Mesh;
  23645. /**
  23646. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23647. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23648. * Thus the particles generated from `digest()` have their property `position` set yet.
  23649. * @param mesh ( Mesh ) is the mesh to be digested
  23650. * @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
  23651. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23652. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23653. * @returns the current SPS
  23654. */
  23655. digest(mesh: Mesh, options?: {
  23656. facetNb?: number;
  23657. number?: number;
  23658. delta?: number;
  23659. }): SolidParticleSystem;
  23660. private _unrotateFixedNormals;
  23661. private _resetCopy;
  23662. private _meshBuilder;
  23663. private _posToShape;
  23664. private _uvsToShapeUV;
  23665. private _addParticle;
  23666. /**
  23667. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23668. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23669. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23670. * @param nb (positive integer) the number of particles to be created from this model
  23671. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23672. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23673. * @returns the number of shapes in the system
  23674. */
  23675. addShape(mesh: Mesh, nb: number, options?: {
  23676. positionFunction?: any;
  23677. vertexFunction?: any;
  23678. }): number;
  23679. private _rebuildParticle;
  23680. /**
  23681. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23682. * @returns the SPS.
  23683. */
  23684. rebuildMesh(): SolidParticleSystem;
  23685. /**
  23686. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23687. * This method calls `updateParticle()` for each particle of the SPS.
  23688. * For an animated SPS, it is usually called within the render loop.
  23689. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23690. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23691. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23692. * @returns the SPS.
  23693. */
  23694. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23695. /**
  23696. * Disposes the SPS.
  23697. */
  23698. dispose(): void;
  23699. /**
  23700. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23701. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23702. * @returns the SPS.
  23703. */
  23704. refreshVisibleSize(): SolidParticleSystem;
  23705. /**
  23706. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23707. * @param size the size (float) of the visibility box
  23708. * note : this doesn't lock the SPS mesh bounding box.
  23709. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23710. */
  23711. setVisibilityBox(size: number): void;
  23712. /**
  23713. * Gets whether the SPS as always visible or not
  23714. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23715. */
  23716. /**
  23717. * Sets the SPS as always visible or not
  23718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23719. */
  23720. isAlwaysVisible: boolean;
  23721. /**
  23722. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23723. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23724. */
  23725. /**
  23726. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23728. */
  23729. isVisibilityBoxLocked: boolean;
  23730. /**
  23731. * Tells to `setParticles()` to compute the particle rotations or not.
  23732. * Default value : true. The SPS is faster when it's set to false.
  23733. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23734. */
  23735. /**
  23736. * Gets if `setParticles()` computes the particle rotations or not.
  23737. * Default value : true. The SPS is faster when it's set to false.
  23738. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23739. */
  23740. computeParticleRotation: boolean;
  23741. /**
  23742. * Tells to `setParticles()` to compute the particle colors or not.
  23743. * Default value : true. The SPS is faster when it's set to false.
  23744. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23745. */
  23746. /**
  23747. * Gets if `setParticles()` computes the particle colors or not.
  23748. * Default value : true. The SPS is faster when it's set to false.
  23749. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23750. */
  23751. computeParticleColor: boolean;
  23752. /**
  23753. * Gets if `setParticles()` computes the particle textures or not.
  23754. * Default value : true. The SPS is faster when it's set to false.
  23755. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23756. */
  23757. computeParticleTexture: boolean;
  23758. /**
  23759. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23760. * Default value : false. The SPS is faster when it's set to false.
  23761. * Note : the particle custom vertex positions aren't stored values.
  23762. */
  23763. /**
  23764. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23765. * Default value : false. The SPS is faster when it's set to false.
  23766. * Note : the particle custom vertex positions aren't stored values.
  23767. */
  23768. computeParticleVertex: boolean;
  23769. /**
  23770. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23771. */
  23772. /**
  23773. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23774. */
  23775. computeBoundingBox: boolean;
  23776. /**
  23777. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23778. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23779. * Default : `true`
  23780. */
  23781. /**
  23782. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23783. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23784. * Default : `true`
  23785. */
  23786. depthSortParticles: boolean;
  23787. /**
  23788. * This function does nothing. It may be overwritten to set all the particle first values.
  23789. * The SPS doesn't call this function, you may have to call it by your own.
  23790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23791. */
  23792. initParticles(): void;
  23793. /**
  23794. * This function does nothing. It may be overwritten to recycle a particle.
  23795. * The SPS doesn't call this function, you may have to call it by your own.
  23796. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23797. * @param particle The particle to recycle
  23798. * @returns the recycled particle
  23799. */
  23800. recycleParticle(particle: SolidParticle): SolidParticle;
  23801. /**
  23802. * Updates a particle : this function should be overwritten by the user.
  23803. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23805. * @example : just set a particle position or velocity and recycle conditions
  23806. * @param particle The particle to update
  23807. * @returns the updated particle
  23808. */
  23809. updateParticle(particle: SolidParticle): SolidParticle;
  23810. /**
  23811. * Updates a vertex of a particle : it can be overwritten by the user.
  23812. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23813. * @param particle the current particle
  23814. * @param vertex the current index of the current particle
  23815. * @param pt the index of the current vertex in the particle shape
  23816. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23817. * @example : just set a vertex particle position
  23818. * @returns the updated vertex
  23819. */
  23820. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23821. /**
  23822. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23823. * This does nothing and may be overwritten by the user.
  23824. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23825. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23826. * @param update the boolean update value actually passed to setParticles()
  23827. */
  23828. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23829. /**
  23830. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23831. * This will be passed three parameters.
  23832. * This does nothing and may be overwritten by the user.
  23833. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23834. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23835. * @param update the boolean update value actually passed to setParticles()
  23836. */
  23837. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23838. }
  23839. }
  23840. declare module BABYLON {
  23841. /**
  23842. * Represents one particle of a solid particle system.
  23843. */
  23844. export class SolidParticle {
  23845. /**
  23846. * particle global index
  23847. */
  23848. idx: number;
  23849. /**
  23850. * The color of the particle
  23851. */
  23852. color: Nullable<Color4>;
  23853. /**
  23854. * The world space position of the particle.
  23855. */
  23856. position: Vector3;
  23857. /**
  23858. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23859. */
  23860. rotation: Vector3;
  23861. /**
  23862. * The world space rotation quaternion of the particle.
  23863. */
  23864. rotationQuaternion: Nullable<Quaternion>;
  23865. /**
  23866. * The scaling of the particle.
  23867. */
  23868. scaling: Vector3;
  23869. /**
  23870. * The uvs of the particle.
  23871. */
  23872. uvs: Vector4;
  23873. /**
  23874. * The current speed of the particle.
  23875. */
  23876. velocity: Vector3;
  23877. /**
  23878. * The pivot point in the particle local space.
  23879. */
  23880. pivot: Vector3;
  23881. /**
  23882. * Must the particle be translated from its pivot point in its local space ?
  23883. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23884. * Default : false
  23885. */
  23886. translateFromPivot: boolean;
  23887. /**
  23888. * Is the particle active or not ?
  23889. */
  23890. alive: boolean;
  23891. /**
  23892. * Is the particle visible or not ?
  23893. */
  23894. isVisible: boolean;
  23895. /**
  23896. * Index of this particle in the global "positions" array (Internal use)
  23897. * @hidden
  23898. */ private _pos: number;
  23899. /**
  23900. * @hidden Index of this particle in the global "indices" array (Internal use)
  23901. */ private _ind: number;
  23902. /**
  23903. * @hidden ModelShape of this particle (Internal use)
  23904. */ private _model: ModelShape;
  23905. /**
  23906. * ModelShape id of this particle
  23907. */
  23908. shapeId: number;
  23909. /**
  23910. * Index of the particle in its shape id (Internal use)
  23911. */
  23912. idxInShape: number;
  23913. /**
  23914. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23915. */ private _modelBoundingInfo: BoundingInfo;
  23916. /**
  23917. * @hidden Particle BoundingInfo object (Internal use)
  23918. */ private _boundingInfo: BoundingInfo;
  23919. /**
  23920. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23921. */ private _sps: SolidParticleSystem;
  23922. /**
  23923. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23924. */ private _stillInvisible: boolean;
  23925. /**
  23926. * @hidden Last computed particle rotation matrix
  23927. */ private _rotationMatrix: number[];
  23928. /**
  23929. * Parent particle Id, if any.
  23930. * Default null.
  23931. */
  23932. parentId: Nullable<number>;
  23933. /**
  23934. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23935. * The possible values are :
  23936. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23937. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23938. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23939. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23940. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23941. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23942. * */
  23943. cullingStrategy: number;
  23944. /**
  23945. * @hidden Internal global position in the SPS.
  23946. */ private _globalPosition: Vector3;
  23947. /**
  23948. * Creates a Solid Particle object.
  23949. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23950. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23951. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23952. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23953. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23954. * @param shapeId (integer) is the model shape identifier in the SPS.
  23955. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23956. * @param sps defines the sps it is associated to
  23957. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23958. */
  23959. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23960. /**
  23961. * Legacy support, changed scale to scaling
  23962. */
  23963. /**
  23964. * Legacy support, changed scale to scaling
  23965. */
  23966. scale: Vector3;
  23967. /**
  23968. * Legacy support, changed quaternion to rotationQuaternion
  23969. */
  23970. /**
  23971. * Legacy support, changed quaternion to rotationQuaternion
  23972. */
  23973. quaternion: Nullable<Quaternion>;
  23974. /**
  23975. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23976. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23977. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23978. * @returns true if it intersects
  23979. */
  23980. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23981. /**
  23982. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23983. * A particle is in the frustum if its bounding box intersects the frustum
  23984. * @param frustumPlanes defines the frustum to test
  23985. * @returns true if the particle is in the frustum planes
  23986. */
  23987. isInFrustum(frustumPlanes: Plane[]): boolean;
  23988. /**
  23989. * get the rotation matrix of the particle
  23990. * @hidden
  23991. */
  23992. getRotationMatrix(m: Matrix): void;
  23993. }
  23994. /**
  23995. * Represents the shape of the model used by one particle of a solid particle system.
  23996. * SPS internal tool, don't use it manually.
  23997. */
  23998. export class ModelShape {
  23999. /**
  24000. * The shape id
  24001. * @hidden
  24002. */
  24003. shapeID: number;
  24004. /**
  24005. * flat array of model positions (internal use)
  24006. * @hidden
  24007. */ private _shape: Vector3[];
  24008. /**
  24009. * flat array of model UVs (internal use)
  24010. * @hidden
  24011. */ private _shapeUV: number[];
  24012. /**
  24013. * length of the shape in the model indices array (internal use)
  24014. * @hidden
  24015. */ private _indicesLength: number;
  24016. /**
  24017. * Custom position function (internal use)
  24018. * @hidden
  24019. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24020. /**
  24021. * Custom vertex function (internal use)
  24022. * @hidden
  24023. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24024. /**
  24025. * 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.
  24026. * SPS internal tool, don't use it manually.
  24027. * @hidden
  24028. */
  24029. 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>);
  24030. }
  24031. /**
  24032. * Represents a Depth Sorted Particle in the solid particle system.
  24033. */
  24034. export class DepthSortedParticle {
  24035. /**
  24036. * Index of the particle in the "indices" array
  24037. */
  24038. ind: number;
  24039. /**
  24040. * Length of the particle shape in the "indices" array
  24041. */
  24042. indicesLength: number;
  24043. /**
  24044. * Squared distance from the particle to the camera
  24045. */
  24046. sqDistance: number;
  24047. }
  24048. }
  24049. declare module BABYLON {
  24050. /**
  24051. * @hidden
  24052. */
  24053. 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>>;
  24054. }
  24055. }
  24056. declare module BABYLON {
  24057. /** @hidden */ private class _FacetDataStorage {
  24058. facetPositions: Vector3[];
  24059. facetNormals: Vector3[];
  24060. facetPartitioning: number[][];
  24061. facetNb: number;
  24062. partitioningSubdivisions: number;
  24063. partitioningBBoxRatio: number;
  24064. facetDataEnabled: boolean;
  24065. facetParameters: any;
  24066. bbSize: Vector3;
  24067. subDiv: {
  24068. max: number;
  24069. X: number;
  24070. Y: number;
  24071. Z: number;
  24072. };
  24073. facetDepthSort: boolean;
  24074. facetDepthSortEnabled: boolean;
  24075. depthSortedIndices: IndicesArray;
  24076. depthSortedFacets: {
  24077. ind: number;
  24078. sqDistance: number;
  24079. }[];
  24080. facetDepthSortFunction: (f1: {
  24081. ind: number;
  24082. sqDistance: number;
  24083. }, f2: {
  24084. ind: number;
  24085. sqDistance: number;
  24086. }) => number;
  24087. facetDepthSortFrom: Vector3;
  24088. facetDepthSortOrigin: Vector3;
  24089. invertedMatrix: Matrix;
  24090. }
  24091. /**
  24092. * @hidden
  24093. **/ 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;
  24094. }
  24095. /**
  24096. * Class used to store all common mesh properties
  24097. */
  24098. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24099. /** No occlusion */
  24100. static OCCLUSION_TYPE_NONE: number;
  24101. /** Occlusion set to optimisitic */
  24102. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24103. /** Occlusion set to strict */
  24104. static OCCLUSION_TYPE_STRICT: number;
  24105. /** Use an accurante occlusion algorithm */
  24106. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24107. /** Use a conservative occlusion algorithm */
  24108. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24109. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24110. * Test order :
  24111. * Is the bounding sphere outside the frustum ?
  24112. * If not, are the bounding box vertices outside the frustum ?
  24113. * It not, then the cullable object is in the frustum.
  24114. */
  24115. static readonly CULLINGSTRATEGY_STANDARD: number;
  24116. /** Culling strategy : Bounding Sphere Only.
  24117. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24118. * It's also less accurate than the standard because some not visible objects can still be selected.
  24119. * Test : is the bounding sphere outside the frustum ?
  24120. * If not, then the cullable object is in the frustum.
  24121. */
  24122. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24123. /** Culling strategy : Optimistic Inclusion.
  24124. * This in an inclusion test first, then the standard exclusion test.
  24125. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24126. * 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.
  24127. * Anyway, it's as accurate as the standard strategy.
  24128. * Test :
  24129. * Is the cullable object bounding sphere center in the frustum ?
  24130. * If not, apply the default culling strategy.
  24131. */
  24132. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24133. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24134. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24135. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24136. * 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.
  24137. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24138. * Test :
  24139. * Is the cullable object bounding sphere center in the frustum ?
  24140. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24141. */
  24142. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24143. /**
  24144. * No billboard
  24145. */
  24146. static readonly BILLBOARDMODE_NONE: number;
  24147. /** Billboard on X axis */
  24148. static readonly BILLBOARDMODE_X: number;
  24149. /** Billboard on Y axis */
  24150. static readonly BILLBOARDMODE_Y: number;
  24151. /** Billboard on Z axis */
  24152. static readonly BILLBOARDMODE_Z: number;
  24153. /** Billboard on all axes */
  24154. static readonly BILLBOARDMODE_ALL: number;
  24155. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24156. /**
  24157. * The culling strategy to use to check whether the mesh must be rendered or not.
  24158. * This value can be changed at any time and will be used on the next render mesh selection.
  24159. * The possible values are :
  24160. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24161. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24162. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24163. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24164. * Please read each static variable documentation to get details about the culling process.
  24165. * */
  24166. cullingStrategy: number;
  24167. /**
  24168. * Gets the number of facets in the mesh
  24169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24170. */
  24171. readonly facetNb: number;
  24172. /**
  24173. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24175. */
  24176. partitioningSubdivisions: number;
  24177. /**
  24178. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24179. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24181. */
  24182. partitioningBBoxRatio: number;
  24183. /**
  24184. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24185. * Works only for updatable meshes.
  24186. * Doesn't work with multi-materials
  24187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24188. */
  24189. mustDepthSortFacets: boolean;
  24190. /**
  24191. * The location (Vector3) where the facet depth sort must be computed from.
  24192. * By default, the active camera position.
  24193. * Used only when facet depth sort is enabled
  24194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24195. */
  24196. facetDepthSortFrom: Vector3;
  24197. /**
  24198. * gets a boolean indicating if facetData is enabled
  24199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24200. */
  24201. readonly isFacetDataEnabled: boolean;
  24202. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  24203. /**
  24204. * An event triggered when this mesh collides with another one
  24205. */
  24206. onCollideObservable: Observable<AbstractMesh>;
  24207. /** Set a function to call when this mesh collides with another one */
  24208. onCollide: () => void;
  24209. /**
  24210. * An event triggered when the collision's position changes
  24211. */
  24212. onCollisionPositionChangeObservable: Observable<Vector3>;
  24213. /** Set a function to call when the collision's position changes */
  24214. onCollisionPositionChange: () => void;
  24215. /**
  24216. * An event triggered when material is changed
  24217. */
  24218. onMaterialChangedObservable: Observable<AbstractMesh>;
  24219. /**
  24220. * Gets or sets the orientation for POV movement & rotation
  24221. */
  24222. definedFacingForward: boolean;
  24223. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  24224. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  24225. /**
  24226. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24227. */
  24228. /**
  24229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24230. */
  24231. visibility: number;
  24232. /** Gets or sets the alpha index used to sort transparent meshes
  24233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24234. */
  24235. alphaIndex: number;
  24236. /**
  24237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24238. */
  24239. isVisible: boolean;
  24240. /**
  24241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24242. */
  24243. isPickable: boolean;
  24244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24245. showSubMeshesBoundingBox: boolean;
  24246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24247. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24248. */
  24249. isBlocker: boolean;
  24250. /**
  24251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24252. */
  24253. enablePointerMoveEvents: boolean;
  24254. /**
  24255. * Specifies the rendering group id for this mesh (0 by default)
  24256. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24257. */
  24258. renderingGroupId: number;
  24259. private _material;
  24260. /** Gets or sets current material */
  24261. material: Nullable<Material>;
  24262. /**
  24263. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24264. * @see http://doc.babylonjs.com/babylon101/shadows
  24265. */
  24266. receiveShadows: boolean;
  24267. /** Defines color to use when rendering outline */
  24268. outlineColor: Color3;
  24269. /** Define width to use when rendering outline */
  24270. outlineWidth: number;
  24271. /** Defines color to use when rendering overlay */
  24272. overlayColor: Color3;
  24273. /** Defines alpha to use when rendering overlay */
  24274. overlayAlpha: number;
  24275. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24276. hasVertexAlpha: boolean;
  24277. /** 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) */
  24278. useVertexColors: boolean;
  24279. /**
  24280. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24281. */
  24282. computeBonesUsingShaders: boolean;
  24283. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24284. numBoneInfluencers: number;
  24285. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24286. applyFog: boolean;
  24287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24288. useOctreeForRenderingSelection: boolean;
  24289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24290. useOctreeForPicking: boolean;
  24291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24292. useOctreeForCollisions: boolean;
  24293. /**
  24294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24296. */
  24297. layerMask: number;
  24298. /**
  24299. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24300. */
  24301. alwaysSelectAsActiveMesh: boolean;
  24302. /**
  24303. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24304. */
  24305. doNotSyncBoundingInfo: boolean;
  24306. /**
  24307. * Gets or sets the current action manager
  24308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24309. */
  24310. actionManager: Nullable<AbstractActionManager>;
  24311. private _meshCollisionData;
  24312. /**
  24313. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24315. */
  24316. ellipsoid: Vector3;
  24317. /**
  24318. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24320. */
  24321. ellipsoidOffset: Vector3;
  24322. /**
  24323. * Gets or sets a collision mask used to mask collisions (default is -1).
  24324. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24325. */
  24326. collisionMask: number;
  24327. /**
  24328. * Gets or sets the current collision group mask (-1 by default).
  24329. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24330. */
  24331. collisionGroup: number;
  24332. /**
  24333. * Defines edge width used when edgesRenderer is enabled
  24334. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24335. */
  24336. edgesWidth: number;
  24337. /**
  24338. * Defines edge color used when edgesRenderer is enabled
  24339. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24340. */
  24341. edgesColor: Color4;
  24342. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  24343. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  24344. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  24345. /** @hidden */ private _renderId: number;
  24346. /**
  24347. * Gets or sets the list of subMeshes
  24348. * @see http://doc.babylonjs.com/how_to/multi_materials
  24349. */
  24350. subMeshes: SubMesh[];
  24351. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  24352. /** @hidden */ private _unIndexed: boolean;
  24353. /** @hidden */ private _lightSources: Light[];
  24354. /** Gets the list of lights affecting that mesh */
  24355. readonly lightSources: Light[];
  24356. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24357. /** @hidden */ private _waitingData: {
  24358. lods: Nullable<any>;
  24359. actions: Nullable<any>;
  24360. freezeWorldMatrix: Nullable<boolean>;
  24361. };
  24362. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  24363. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  24364. /**
  24365. * Gets or sets a skeleton to apply skining transformations
  24366. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24367. */
  24368. skeleton: Nullable<Skeleton>;
  24369. /**
  24370. * An event triggered when the mesh is rebuilt.
  24371. */
  24372. onRebuildObservable: Observable<AbstractMesh>;
  24373. /**
  24374. * Creates a new AbstractMesh
  24375. * @param name defines the name of the mesh
  24376. * @param scene defines the hosting scene
  24377. */
  24378. constructor(name: string, scene?: Nullable<Scene>);
  24379. /**
  24380. * Returns the string "AbstractMesh"
  24381. * @returns "AbstractMesh"
  24382. */
  24383. getClassName(): string;
  24384. /**
  24385. * Gets a string representation of the current mesh
  24386. * @param fullDetails defines a boolean indicating if full details must be included
  24387. * @returns a string representation of the current mesh
  24388. */
  24389. toString(fullDetails?: boolean): string;
  24390. /**
  24391. * @hidden
  24392. */
  24393. protected _getEffectiveParent(): Nullable<Node>;
  24394. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24395. /** @hidden */ private _rebuild(): void;
  24396. /** @hidden */ private _resyncLightSources(): void;
  24397. /** @hidden */ private _resyncLighSource(light: Light): void;
  24398. /** @hidden */ private _unBindEffect(): void;
  24399. /** @hidden */ private _removeLightSource(light: Light): void;
  24400. private _markSubMeshesAsDirty;
  24401. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  24402. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  24403. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  24404. /**
  24405. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24406. */
  24407. scaling: Vector3;
  24408. /**
  24409. * Returns true if the mesh is blocked. Implemented by child classes
  24410. */
  24411. readonly isBlocked: boolean;
  24412. /**
  24413. * Returns the mesh itself by default. Implemented by child classes
  24414. * @param camera defines the camera to use to pick the right LOD level
  24415. * @returns the currentAbstractMesh
  24416. */
  24417. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24418. /**
  24419. * Returns 0 by default. Implemented by child classes
  24420. * @returns an integer
  24421. */
  24422. getTotalVertices(): number;
  24423. /**
  24424. * Returns a positive integer : the total number of indices in this mesh geometry.
  24425. * @returns the numner of indices or zero if the mesh has no geometry.
  24426. */
  24427. getTotalIndices(): number;
  24428. /**
  24429. * Returns null by default. Implemented by child classes
  24430. * @returns null
  24431. */
  24432. getIndices(): Nullable<IndicesArray>;
  24433. /**
  24434. * Returns the array of the requested vertex data kind. Implemented by child classes
  24435. * @param kind defines the vertex data kind to use
  24436. * @returns null
  24437. */
  24438. getVerticesData(kind: string): Nullable<FloatArray>;
  24439. /**
  24440. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24441. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24442. * Note that a new underlying VertexBuffer object is created each call.
  24443. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24444. * @param kind defines vertex data kind:
  24445. * * VertexBuffer.PositionKind
  24446. * * VertexBuffer.UVKind
  24447. * * VertexBuffer.UV2Kind
  24448. * * VertexBuffer.UV3Kind
  24449. * * VertexBuffer.UV4Kind
  24450. * * VertexBuffer.UV5Kind
  24451. * * VertexBuffer.UV6Kind
  24452. * * VertexBuffer.ColorKind
  24453. * * VertexBuffer.MatricesIndicesKind
  24454. * * VertexBuffer.MatricesIndicesExtraKind
  24455. * * VertexBuffer.MatricesWeightsKind
  24456. * * VertexBuffer.MatricesWeightsExtraKind
  24457. * @param data defines the data source
  24458. * @param updatable defines if the data must be flagged as updatable (or static)
  24459. * @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
  24460. * @returns the current mesh
  24461. */
  24462. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24463. /**
  24464. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24465. * If the mesh has no geometry, it is simply returned as it is.
  24466. * @param kind defines vertex data kind:
  24467. * * VertexBuffer.PositionKind
  24468. * * VertexBuffer.UVKind
  24469. * * VertexBuffer.UV2Kind
  24470. * * VertexBuffer.UV3Kind
  24471. * * VertexBuffer.UV4Kind
  24472. * * VertexBuffer.UV5Kind
  24473. * * VertexBuffer.UV6Kind
  24474. * * VertexBuffer.ColorKind
  24475. * * VertexBuffer.MatricesIndicesKind
  24476. * * VertexBuffer.MatricesIndicesExtraKind
  24477. * * VertexBuffer.MatricesWeightsKind
  24478. * * VertexBuffer.MatricesWeightsExtraKind
  24479. * @param data defines the data source
  24480. * @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
  24481. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24482. * @returns the current mesh
  24483. */
  24484. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24485. /**
  24486. * Sets the mesh indices,
  24487. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24488. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24489. * @param totalVertices Defines the total number of vertices
  24490. * @returns the current mesh
  24491. */
  24492. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24493. /**
  24494. * Gets a boolean indicating if specific vertex data is present
  24495. * @param kind defines the vertex data kind to use
  24496. * @returns true is data kind is present
  24497. */
  24498. isVerticesDataPresent(kind: string): boolean;
  24499. /**
  24500. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24501. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24502. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24503. * @returns a BoundingInfo
  24504. */
  24505. getBoundingInfo(): BoundingInfo;
  24506. /**
  24507. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24508. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24509. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24510. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24511. * @returns the current mesh
  24512. */
  24513. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24514. /**
  24515. * Overwrite the current bounding info
  24516. * @param boundingInfo defines the new bounding info
  24517. * @returns the current mesh
  24518. */
  24519. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24520. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24521. readonly useBones: boolean;
  24522. /** @hidden */ private _preActivate(): void;
  24523. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  24524. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  24525. /** @hidden */ private _postActivate(): void;
  24526. /** @hidden */ private _freeze(): void;
  24527. /** @hidden */ private _unFreeze(): void;
  24528. /**
  24529. * Gets the current world matrix
  24530. * @returns a Matrix
  24531. */
  24532. getWorldMatrix(): Matrix;
  24533. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24534. /**
  24535. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24536. */
  24537. readonly isAnInstance: boolean;
  24538. /**
  24539. * Perform relative position change from the point of view of behind the front of the mesh.
  24540. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24541. * Supports definition of mesh facing forward or backward
  24542. * @param amountRight defines the distance on the right axis
  24543. * @param amountUp defines the distance on the up axis
  24544. * @param amountForward defines the distance on the forward axis
  24545. * @returns the current mesh
  24546. */
  24547. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24548. /**
  24549. * Calculate relative position change from the point of view of behind the front of the mesh.
  24550. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24551. * Supports definition of mesh facing forward or backward
  24552. * @param amountRight defines the distance on the right axis
  24553. * @param amountUp defines the distance on the up axis
  24554. * @param amountForward defines the distance on the forward axis
  24555. * @returns the new displacement vector
  24556. */
  24557. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24558. /**
  24559. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24560. * Supports definition of mesh facing forward or backward
  24561. * @param flipBack defines the flip
  24562. * @param twirlClockwise defines the twirl
  24563. * @param tiltRight defines the tilt
  24564. * @returns the current mesh
  24565. */
  24566. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24567. /**
  24568. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24569. * Supports definition of mesh facing forward or backward.
  24570. * @param flipBack defines the flip
  24571. * @param twirlClockwise defines the twirl
  24572. * @param tiltRight defines the tilt
  24573. * @returns the new rotation vector
  24574. */
  24575. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24576. /**
  24577. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24578. * This means the mesh underlying bounding box and sphere are recomputed.
  24579. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24580. * @returns the current mesh
  24581. */
  24582. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24583. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24584. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24585. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  24586. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24587. /** @hidden */
  24588. protected _afterComputeWorldMatrix(): void;
  24589. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24590. /**
  24591. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24592. * A mesh is in the frustum if its bounding box intersects the frustum
  24593. * @param frustumPlanes defines the frustum to test
  24594. * @returns true if the mesh is in the frustum planes
  24595. */
  24596. isInFrustum(frustumPlanes: Plane[]): boolean;
  24597. /**
  24598. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24599. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24600. * @param frustumPlanes defines the frustum to test
  24601. * @returns true if the mesh is completely in the frustum planes
  24602. */
  24603. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24604. /**
  24605. * True if the mesh intersects another mesh or a SolidParticle object
  24606. * @param mesh defines a target mesh or SolidParticle to test
  24607. * @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)
  24608. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24609. * @returns true if there is an intersection
  24610. */
  24611. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24612. /**
  24613. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24614. * @param point defines the point to test
  24615. * @returns true if there is an intersection
  24616. */
  24617. intersectsPoint(point: Vector3): boolean;
  24618. /**
  24619. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24621. */
  24622. checkCollisions: boolean;
  24623. /**
  24624. * Gets Collider object used to compute collisions (not physics)
  24625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24626. */
  24627. readonly collider: Nullable<Collider>;
  24628. /**
  24629. * Move the mesh using collision engine
  24630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24631. * @param displacement defines the requested displacement vector
  24632. * @returns the current mesh
  24633. */
  24634. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24635. private _onCollisionPositionChange;
  24636. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24637. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24638. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  24639. /** @hidden */ private _generatePointsArray(): boolean;
  24640. /**
  24641. * Checks if the passed Ray intersects with the mesh
  24642. * @param ray defines the ray to use
  24643. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24644. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24645. * @returns the picking info
  24646. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24647. */
  24648. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24649. /**
  24650. * Clones the current mesh
  24651. * @param name defines the mesh name
  24652. * @param newParent defines the new mesh parent
  24653. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24654. * @returns the new mesh
  24655. */
  24656. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24657. /**
  24658. * Disposes all the submeshes of the current meshnp
  24659. * @returns the current mesh
  24660. */
  24661. releaseSubMeshes(): AbstractMesh;
  24662. /**
  24663. * Releases resources associated with this abstract mesh.
  24664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24666. */
  24667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24668. /**
  24669. * Adds the passed mesh as a child to the current mesh
  24670. * @param mesh defines the child mesh
  24671. * @returns the current mesh
  24672. */
  24673. addChild(mesh: AbstractMesh): AbstractMesh;
  24674. /**
  24675. * Removes the passed mesh from the current mesh children list
  24676. * @param mesh defines the child mesh
  24677. * @returns the current mesh
  24678. */
  24679. removeChild(mesh: AbstractMesh): AbstractMesh;
  24680. /** @hidden */
  24681. private _initFacetData;
  24682. /**
  24683. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24684. * This method can be called within the render loop.
  24685. * 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
  24686. * @returns the current mesh
  24687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24688. */
  24689. updateFacetData(): AbstractMesh;
  24690. /**
  24691. * Returns the facetLocalNormals array.
  24692. * The normals are expressed in the mesh local spac
  24693. * @returns an array of Vector3
  24694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24695. */
  24696. getFacetLocalNormals(): Vector3[];
  24697. /**
  24698. * Returns the facetLocalPositions array.
  24699. * The facet positions are expressed in the mesh local space
  24700. * @returns an array of Vector3
  24701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24702. */
  24703. getFacetLocalPositions(): Vector3[];
  24704. /**
  24705. * Returns the facetLocalPartioning array
  24706. * @returns an array of array of numbers
  24707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24708. */
  24709. getFacetLocalPartitioning(): number[][];
  24710. /**
  24711. * Returns the i-th facet position in the world system.
  24712. * This method allocates a new Vector3 per call
  24713. * @param i defines the facet index
  24714. * @returns a new Vector3
  24715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24716. */
  24717. getFacetPosition(i: number): Vector3;
  24718. /**
  24719. * Sets the reference Vector3 with the i-th facet position in the world system
  24720. * @param i defines the facet index
  24721. * @param ref defines the target vector
  24722. * @returns the current mesh
  24723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24724. */
  24725. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24726. /**
  24727. * Returns the i-th facet normal in the world system.
  24728. * This method allocates a new Vector3 per call
  24729. * @param i defines the facet index
  24730. * @returns a new Vector3
  24731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24732. */
  24733. getFacetNormal(i: number): Vector3;
  24734. /**
  24735. * Sets the reference Vector3 with the i-th facet normal in the world system
  24736. * @param i defines the facet index
  24737. * @param ref defines the target vector
  24738. * @returns the current mesh
  24739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24740. */
  24741. getFacetNormalToRef(i: number, ref: Vector3): this;
  24742. /**
  24743. * 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)
  24744. * @param x defines x coordinate
  24745. * @param y defines y coordinate
  24746. * @param z defines z coordinate
  24747. * @returns the array of facet indexes
  24748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24749. */
  24750. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24751. /**
  24752. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24753. * @param projected sets as the (x,y,z) world projection on the facet
  24754. * @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
  24755. * @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
  24756. * @param x defines x coordinate
  24757. * @param y defines y coordinate
  24758. * @param z defines z coordinate
  24759. * @returns the face index if found (or null instead)
  24760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24761. */
  24762. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24763. /**
  24764. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24765. * @param projected sets as the (x,y,z) local projection on the facet
  24766. * @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
  24767. * @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
  24768. * @param x defines x coordinate
  24769. * @param y defines y coordinate
  24770. * @param z defines z coordinate
  24771. * @returns the face index if found (or null instead)
  24772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24773. */
  24774. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24775. /**
  24776. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24777. * @returns the parameters
  24778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24779. */
  24780. getFacetDataParameters(): any;
  24781. /**
  24782. * Disables the feature FacetData and frees the related memory
  24783. * @returns the current mesh
  24784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24785. */
  24786. disableFacetData(): AbstractMesh;
  24787. /**
  24788. * Updates the AbstractMesh indices array
  24789. * @param indices defines the data source
  24790. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24791. * @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)
  24792. * @returns the current mesh
  24793. */
  24794. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24795. /**
  24796. * Creates new normals data for the mesh
  24797. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24798. * @returns the current mesh
  24799. */
  24800. createNormals(updatable: boolean): AbstractMesh;
  24801. /**
  24802. * Align the mesh with a normal
  24803. * @param normal defines the normal to use
  24804. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24805. * @returns the current mesh
  24806. */
  24807. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24808. /** @hidden */ private _checkOcclusionQuery(): boolean;
  24809. /**
  24810. * Disables the mesh edge rendering mode
  24811. * @returns the currentAbstractMesh
  24812. */
  24813. disableEdgesRendering(): AbstractMesh;
  24814. /**
  24815. * Enables the edge rendering mode on the mesh.
  24816. * This mode makes the mesh edges visible
  24817. * @param epsilon defines the maximal distance between two angles to detect a face
  24818. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24819. * @returns the currentAbstractMesh
  24820. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24821. */
  24822. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24823. }
  24824. }
  24825. declare module BABYLON {
  24826. /**
  24827. * Interface used to define ActionEvent
  24828. */
  24829. export interface IActionEvent {
  24830. /** The mesh or sprite that triggered the action */
  24831. source: any;
  24832. /** The X mouse cursor position at the time of the event */
  24833. pointerX: number;
  24834. /** The Y mouse cursor position at the time of the event */
  24835. pointerY: number;
  24836. /** The mesh that is currently pointed at (can be null) */
  24837. meshUnderPointer: Nullable<AbstractMesh>;
  24838. /** the original (browser) event that triggered the ActionEvent */
  24839. sourceEvent?: any;
  24840. /** additional data for the event */
  24841. additionalData?: any;
  24842. }
  24843. /**
  24844. * ActionEvent is the event being sent when an action is triggered.
  24845. */
  24846. export class ActionEvent implements IActionEvent {
  24847. /** The mesh or sprite that triggered the action */
  24848. source: any;
  24849. /** The X mouse cursor position at the time of the event */
  24850. pointerX: number;
  24851. /** The Y mouse cursor position at the time of the event */
  24852. pointerY: number;
  24853. /** The mesh that is currently pointed at (can be null) */
  24854. meshUnderPointer: Nullable<AbstractMesh>;
  24855. /** the original (browser) event that triggered the ActionEvent */
  24856. sourceEvent?: any;
  24857. /** additional data for the event */
  24858. additionalData?: any;
  24859. /**
  24860. * Creates a new ActionEvent
  24861. * @param source The mesh or sprite that triggered the action
  24862. * @param pointerX The X mouse cursor position at the time of the event
  24863. * @param pointerY The Y mouse cursor position at the time of the event
  24864. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24865. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24866. * @param additionalData additional data for the event
  24867. */
  24868. constructor(
  24869. /** The mesh or sprite that triggered the action */
  24870. source: any,
  24871. /** The X mouse cursor position at the time of the event */
  24872. pointerX: number,
  24873. /** The Y mouse cursor position at the time of the event */
  24874. pointerY: number,
  24875. /** The mesh that is currently pointed at (can be null) */
  24876. meshUnderPointer: Nullable<AbstractMesh>,
  24877. /** the original (browser) event that triggered the ActionEvent */
  24878. sourceEvent?: any,
  24879. /** additional data for the event */
  24880. additionalData?: any);
  24881. /**
  24882. * Helper function to auto-create an ActionEvent from a source mesh.
  24883. * @param source The source mesh that triggered the event
  24884. * @param evt The original (browser) event
  24885. * @param additionalData additional data for the event
  24886. * @returns the new ActionEvent
  24887. */
  24888. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24889. /**
  24890. * Helper function to auto-create an ActionEvent from a source sprite
  24891. * @param source The source sprite that triggered the event
  24892. * @param scene Scene associated with the sprite
  24893. * @param evt The original (browser) event
  24894. * @param additionalData additional data for the event
  24895. * @returns the new ActionEvent
  24896. */
  24897. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24898. /**
  24899. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24900. * @param scene the scene where the event occurred
  24901. * @param evt The original (browser) event
  24902. * @returns the new ActionEvent
  24903. */
  24904. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24905. /**
  24906. * Helper function to auto-create an ActionEvent from a primitive
  24907. * @param prim defines the target primitive
  24908. * @param pointerPos defines the pointer position
  24909. * @param evt The original (browser) event
  24910. * @param additionalData additional data for the event
  24911. * @returns the new ActionEvent
  24912. */
  24913. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24914. }
  24915. }
  24916. declare module BABYLON {
  24917. /**
  24918. * Abstract class used to decouple action Manager from scene and meshes.
  24919. * Do not instantiate.
  24920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24921. */
  24922. export abstract class AbstractActionManager implements IDisposable {
  24923. /** Gets the list of active triggers */
  24924. static Triggers: {
  24925. [key: string]: number;
  24926. };
  24927. /** Gets the cursor to use when hovering items */
  24928. hoverCursor: string;
  24929. /** Gets the list of actions */
  24930. actions: IAction[];
  24931. /**
  24932. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24933. */
  24934. isRecursive: boolean;
  24935. /**
  24936. * Releases all associated resources
  24937. */
  24938. abstract dispose(): void;
  24939. /**
  24940. * Does this action manager has pointer triggers
  24941. */
  24942. abstract readonly hasPointerTriggers: boolean;
  24943. /**
  24944. * Does this action manager has pick triggers
  24945. */
  24946. abstract readonly hasPickTriggers: boolean;
  24947. /**
  24948. * Process a specific trigger
  24949. * @param trigger defines the trigger to process
  24950. * @param evt defines the event details to be processed
  24951. */
  24952. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24953. /**
  24954. * Does this action manager handles actions of any of the given triggers
  24955. * @param triggers defines the triggers to be tested
  24956. * @return a boolean indicating whether one (or more) of the triggers is handled
  24957. */
  24958. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24959. /**
  24960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24961. * speed.
  24962. * @param triggerA defines the trigger to be tested
  24963. * @param triggerB defines the trigger to be tested
  24964. * @return a boolean indicating whether one (or more) of the triggers is handled
  24965. */
  24966. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24967. /**
  24968. * Does this action manager handles actions of a given trigger
  24969. * @param trigger defines the trigger to be tested
  24970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24971. * @return whether the trigger is handled
  24972. */
  24973. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24974. /**
  24975. * Serialize this manager to a JSON object
  24976. * @param name defines the property name to store this manager
  24977. * @returns a JSON representation of this manager
  24978. */
  24979. abstract serialize(name: string): any;
  24980. /**
  24981. * Registers an action to this action manager
  24982. * @param action defines the action to be registered
  24983. * @return the action amended (prepared) after registration
  24984. */
  24985. abstract registerAction(action: IAction): Nullable<IAction>;
  24986. /**
  24987. * Unregisters an action to this action manager
  24988. * @param action defines the action to be unregistered
  24989. * @return a boolean indicating whether the action has been unregistered
  24990. */
  24991. abstract unregisterAction(action: IAction): Boolean;
  24992. /**
  24993. * Does exist one action manager with at least one trigger
  24994. **/
  24995. static readonly HasTriggers: boolean;
  24996. /**
  24997. * Does exist one action manager with at least one pick trigger
  24998. **/
  24999. static readonly HasPickTriggers: boolean;
  25000. /**
  25001. * Does exist one action manager that handles actions of a given trigger
  25002. * @param trigger defines the trigger to be tested
  25003. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25004. **/
  25005. static HasSpecificTrigger(trigger: number): boolean;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * Defines how a node can be built from a string name.
  25011. */
  25012. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25013. /**
  25014. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25015. */
  25016. export class Node implements IBehaviorAware<Node> {
  25017. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25018. private static _NodeConstructors;
  25019. /**
  25020. * Add a new node constructor
  25021. * @param type defines the type name of the node to construct
  25022. * @param constructorFunc defines the constructor function
  25023. */
  25024. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25025. /**
  25026. * Returns a node constructor based on type name
  25027. * @param type defines the type name
  25028. * @param name defines the new node name
  25029. * @param scene defines the hosting scene
  25030. * @param options defines optional options to transmit to constructors
  25031. * @returns the new constructor or null
  25032. */
  25033. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25034. /**
  25035. * Gets or sets the name of the node
  25036. */
  25037. name: string;
  25038. /**
  25039. * Gets or sets the id of the node
  25040. */
  25041. id: string;
  25042. /**
  25043. * Gets or sets the unique id of the node
  25044. */
  25045. uniqueId: number;
  25046. /**
  25047. * Gets or sets a string used to store user defined state for the node
  25048. */
  25049. state: string;
  25050. /**
  25051. * Gets or sets an object used to store user defined information for the node
  25052. */
  25053. metadata: any;
  25054. /**
  25055. * For internal use only. Please do not use.
  25056. */
  25057. reservedDataStore: any;
  25058. /**
  25059. * List of inspectable custom properties (used by the Inspector)
  25060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25061. */
  25062. inspectableCustomProperties: IInspectable[];
  25063. /**
  25064. * Gets or sets a boolean used to define if the node must be serialized
  25065. */
  25066. doNotSerialize: boolean;
  25067. /** @hidden */ private _isDisposed: boolean;
  25068. /**
  25069. * Gets a list of Animations associated with the node
  25070. */
  25071. animations: Animation[];
  25072. protected _ranges: {
  25073. [name: string]: Nullable<AnimationRange>;
  25074. };
  25075. /**
  25076. * Callback raised when the node is ready to be used
  25077. */
  25078. onReady: Nullable<(node: Node) => void>;
  25079. private _isEnabled;
  25080. private _isParentEnabled;
  25081. private _isReady;
  25082. /** @hidden */ private _currentRenderId: number;
  25083. private _parentUpdateId;
  25084. /** @hidden */ private _childUpdateId: number;
  25085. /** @hidden */ private _waitingParentId: Nullable<string>;
  25086. /** @hidden */ private _scene: Scene;
  25087. /** @hidden */ private _cache: any;
  25088. private _parentNode;
  25089. private _children;
  25090. /** @hidden */ private _worldMatrix: Matrix;
  25091. /** @hidden */ private _worldMatrixDeterminant: number;
  25092. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  25093. /** @hidden */
  25094. private _sceneRootNodesIndex;
  25095. /**
  25096. * Gets a boolean indicating if the node has been disposed
  25097. * @returns true if the node was disposed
  25098. */
  25099. isDisposed(): boolean;
  25100. /**
  25101. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25102. * @see https://doc.babylonjs.com/how_to/parenting
  25103. */
  25104. parent: Nullable<Node>;
  25105. private addToSceneRootNodes;
  25106. private removeFromSceneRootNodes;
  25107. private _animationPropertiesOverride;
  25108. /**
  25109. * Gets or sets the animation properties override
  25110. */
  25111. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25112. /**
  25113. * Gets a string idenfifying the name of the class
  25114. * @returns "Node" string
  25115. */
  25116. getClassName(): string;
  25117. /** @hidden */ protected readonly _isNode: boolean;
  25118. /**
  25119. * An event triggered when the mesh is disposed
  25120. */
  25121. onDisposeObservable: Observable<Node>;
  25122. private _onDisposeObserver;
  25123. /**
  25124. * Sets a callback that will be raised when the node will be disposed
  25125. */
  25126. onDispose: () => void;
  25127. /**
  25128. * Creates a new Node
  25129. * @param name the name and id to be given to this node
  25130. * @param scene the scene this node will be added to
  25131. * @param addToRootNodes the node will be added to scene.rootNodes
  25132. */
  25133. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25134. /**
  25135. * Gets the scene of the node
  25136. * @returns a scene
  25137. */
  25138. getScene(): Scene;
  25139. /**
  25140. * Gets the engine of the node
  25141. * @returns a Engine
  25142. */
  25143. getEngine(): Engine;
  25144. private _behaviors;
  25145. /**
  25146. * Attach a behavior to the node
  25147. * @see http://doc.babylonjs.com/features/behaviour
  25148. * @param behavior defines the behavior to attach
  25149. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25150. * @returns the current Node
  25151. */
  25152. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25153. /**
  25154. * Remove an attached behavior
  25155. * @see http://doc.babylonjs.com/features/behaviour
  25156. * @param behavior defines the behavior to attach
  25157. * @returns the current Node
  25158. */
  25159. removeBehavior(behavior: Behavior<Node>): Node;
  25160. /**
  25161. * Gets the list of attached behaviors
  25162. * @see http://doc.babylonjs.com/features/behaviour
  25163. */
  25164. readonly behaviors: Behavior<Node>[];
  25165. /**
  25166. * Gets an attached behavior by name
  25167. * @param name defines the name of the behavior to look for
  25168. * @see http://doc.babylonjs.com/features/behaviour
  25169. * @returns null if behavior was not found else the requested behavior
  25170. */
  25171. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25172. /**
  25173. * Returns the latest update of the World matrix
  25174. * @returns a Matrix
  25175. */
  25176. getWorldMatrix(): Matrix;
  25177. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25178. /**
  25179. * Returns directly the latest state of the mesh World matrix.
  25180. * A Matrix is returned.
  25181. */
  25182. readonly worldMatrixFromCache: Matrix;
  25183. /** @hidden */ private _initCache(): void;
  25184. /** @hidden */
  25185. updateCache(force?: boolean): void;
  25186. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25187. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  25188. /** @hidden */ private _isSynchronized(): boolean;
  25189. /** @hidden */ private _markSyncedWithParent(): void;
  25190. /** @hidden */
  25191. isSynchronizedWithParent(): boolean;
  25192. /** @hidden */
  25193. isSynchronized(): boolean;
  25194. /**
  25195. * Is this node ready to be used/rendered
  25196. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25197. * @return true if the node is ready
  25198. */
  25199. isReady(completeCheck?: boolean): boolean;
  25200. /**
  25201. * Is this node enabled?
  25202. * 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
  25203. * @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
  25204. * @return whether this node (and its parent) is enabled
  25205. */
  25206. isEnabled(checkAncestors?: boolean): boolean;
  25207. /** @hidden */
  25208. protected _syncParentEnabledState(): void;
  25209. /**
  25210. * Set the enabled state of this node
  25211. * @param value defines the new enabled state
  25212. */
  25213. setEnabled(value: boolean): void;
  25214. /**
  25215. * Is this node a descendant of the given node?
  25216. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25217. * @param ancestor defines the parent node to inspect
  25218. * @returns a boolean indicating if this node is a descendant of the given node
  25219. */
  25220. isDescendantOf(ancestor: Node): boolean;
  25221. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25222. /**
  25223. * Will return all nodes that have this node as ascendant
  25224. * @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
  25225. * @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
  25226. * @return all children nodes of all types
  25227. */
  25228. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25229. /**
  25230. * Get all child-meshes of this node
  25231. * @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)
  25232. * @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
  25233. * @returns an array of AbstractMesh
  25234. */
  25235. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25236. /**
  25237. * Get all direct children of this node
  25238. * @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
  25239. * @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)
  25240. * @returns an array of Node
  25241. */
  25242. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25243. /** @hidden */ private _setReady(state: boolean): void;
  25244. /**
  25245. * Get an animation by name
  25246. * @param name defines the name of the animation to look for
  25247. * @returns null if not found else the requested animation
  25248. */
  25249. getAnimationByName(name: string): Nullable<Animation>;
  25250. /**
  25251. * Creates an animation range for this node
  25252. * @param name defines the name of the range
  25253. * @param from defines the starting key
  25254. * @param to defines the end key
  25255. */
  25256. createAnimationRange(name: string, from: number, to: number): void;
  25257. /**
  25258. * Delete a specific animation range
  25259. * @param name defines the name of the range to delete
  25260. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25261. */
  25262. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25263. /**
  25264. * Get an animation range by name
  25265. * @param name defines the name of the animation range to look for
  25266. * @returns null if not found else the requested animation range
  25267. */
  25268. getAnimationRange(name: string): Nullable<AnimationRange>;
  25269. /**
  25270. * Gets the list of all animation ranges defined on this node
  25271. * @returns an array
  25272. */
  25273. getAnimationRanges(): Nullable<AnimationRange>[];
  25274. /**
  25275. * Will start the animation sequence
  25276. * @param name defines the range frames for animation sequence
  25277. * @param loop defines if the animation should loop (false by default)
  25278. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25279. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25280. * @returns the object created for this animation. If range does not exist, it will return null
  25281. */
  25282. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25283. /**
  25284. * Serialize animation ranges into a JSON compatible object
  25285. * @returns serialization object
  25286. */
  25287. serializeAnimationRanges(): any;
  25288. /**
  25289. * Computes the world matrix of the node
  25290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25291. * @returns the world matrix
  25292. */
  25293. computeWorldMatrix(force?: boolean): Matrix;
  25294. /**
  25295. * Releases resources associated with this node.
  25296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25298. */
  25299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25300. /**
  25301. * Parse animation range data from a serialization object and store them into a given node
  25302. * @param node defines where to store the animation ranges
  25303. * @param parsedNode defines the serialization object to read data from
  25304. * @param scene defines the hosting scene
  25305. */
  25306. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25307. /**
  25308. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25309. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25310. * @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
  25311. * @returns the new bounding vectors
  25312. */
  25313. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25314. min: Vector3;
  25315. max: Vector3;
  25316. };
  25317. }
  25318. }
  25319. declare module BABYLON {
  25320. /**
  25321. * @hidden
  25322. */
  25323. export class _IAnimationState {
  25324. key: number;
  25325. repeatCount: number;
  25326. workValue?: any;
  25327. loopMode?: number;
  25328. offsetValue?: any;
  25329. highLimitValue?: any;
  25330. }
  25331. /**
  25332. * Class used to store any kind of animation
  25333. */
  25334. export class Animation {
  25335. /**Name of the animation */
  25336. name: string;
  25337. /**Property to animate */
  25338. targetProperty: string;
  25339. /**The frames per second of the animation */
  25340. framePerSecond: number;
  25341. /**The data type of the animation */
  25342. dataType: number;
  25343. /**The loop mode of the animation */
  25344. loopMode?: number | undefined;
  25345. /**Specifies if blending should be enabled */
  25346. enableBlending?: boolean | undefined;
  25347. /**
  25348. * Use matrix interpolation instead of using direct key value when animating matrices
  25349. */
  25350. static AllowMatricesInterpolation: boolean;
  25351. /**
  25352. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25353. */
  25354. static AllowMatrixDecomposeForInterpolation: boolean;
  25355. /**
  25356. * Stores the key frames of the animation
  25357. */
  25358. private _keys;
  25359. /**
  25360. * Stores the easing function of the animation
  25361. */
  25362. private _easingFunction;
  25363. /**
  25364. * @hidden Internal use only
  25365. */ private _runtimeAnimations: RuntimeAnimation[];
  25366. /**
  25367. * The set of event that will be linked to this animation
  25368. */
  25369. private _events;
  25370. /**
  25371. * Stores an array of target property paths
  25372. */
  25373. targetPropertyPath: string[];
  25374. /**
  25375. * Stores the blending speed of the animation
  25376. */
  25377. blendingSpeed: number;
  25378. /**
  25379. * Stores the animation ranges for the animation
  25380. */
  25381. private _ranges;
  25382. /**
  25383. * @hidden Internal use
  25384. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25385. /**
  25386. * Sets up an animation
  25387. * @param property The property to animate
  25388. * @param animationType The animation type to apply
  25389. * @param framePerSecond The frames per second of the animation
  25390. * @param easingFunction The easing function used in the animation
  25391. * @returns The created animation
  25392. */
  25393. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25394. /**
  25395. * Create and start an animation on a node
  25396. * @param name defines the name of the global animation that will be run on all nodes
  25397. * @param node defines the root node where the animation will take place
  25398. * @param targetProperty defines property to animate
  25399. * @param framePerSecond defines the number of frame per second yo use
  25400. * @param totalFrame defines the number of frames in total
  25401. * @param from defines the initial value
  25402. * @param to defines the final value
  25403. * @param loopMode defines which loop mode you want to use (off by default)
  25404. * @param easingFunction defines the easing function to use (linear by default)
  25405. * @param onAnimationEnd defines the callback to call when animation end
  25406. * @returns the animatable created for this animation
  25407. */
  25408. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25409. /**
  25410. * Create and start an animation on a node and its descendants
  25411. * @param name defines the name of the global animation that will be run on all nodes
  25412. * @param node defines the root node where the animation will take place
  25413. * @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
  25414. * @param targetProperty defines property to animate
  25415. * @param framePerSecond defines the number of frame per second to use
  25416. * @param totalFrame defines the number of frames in total
  25417. * @param from defines the initial value
  25418. * @param to defines the final value
  25419. * @param loopMode defines which loop mode you want to use (off by default)
  25420. * @param easingFunction defines the easing function to use (linear by default)
  25421. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25422. * @returns the list of animatables created for all nodes
  25423. * @example https://www.babylonjs-playground.com/#MH0VLI
  25424. */
  25425. 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[]>;
  25426. /**
  25427. * Creates a new animation, merges it with the existing animations and starts it
  25428. * @param name Name of the animation
  25429. * @param node Node which contains the scene that begins the animations
  25430. * @param targetProperty Specifies which property to animate
  25431. * @param framePerSecond The frames per second of the animation
  25432. * @param totalFrame The total number of frames
  25433. * @param from The frame at the beginning of the animation
  25434. * @param to The frame at the end of the animation
  25435. * @param loopMode Specifies the loop mode of the animation
  25436. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25437. * @param onAnimationEnd Callback to run once the animation is complete
  25438. * @returns Nullable animation
  25439. */
  25440. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25441. /**
  25442. * Transition property of an host to the target Value
  25443. * @param property The property to transition
  25444. * @param targetValue The target Value of the property
  25445. * @param host The object where the property to animate belongs
  25446. * @param scene Scene used to run the animation
  25447. * @param frameRate Framerate (in frame/s) to use
  25448. * @param transition The transition type we want to use
  25449. * @param duration The duration of the animation, in milliseconds
  25450. * @param onAnimationEnd Callback trigger at the end of the animation
  25451. * @returns Nullable animation
  25452. */
  25453. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25454. /**
  25455. * Return the array of runtime animations currently using this animation
  25456. */
  25457. readonly runtimeAnimations: RuntimeAnimation[];
  25458. /**
  25459. * Specifies if any of the runtime animations are currently running
  25460. */
  25461. readonly hasRunningRuntimeAnimations: boolean;
  25462. /**
  25463. * Initializes the animation
  25464. * @param name Name of the animation
  25465. * @param targetProperty Property to animate
  25466. * @param framePerSecond The frames per second of the animation
  25467. * @param dataType The data type of the animation
  25468. * @param loopMode The loop mode of the animation
  25469. * @param enableBlending Specifies if blending should be enabled
  25470. */
  25471. constructor(
  25472. /**Name of the animation */
  25473. name: string,
  25474. /**Property to animate */
  25475. targetProperty: string,
  25476. /**The frames per second of the animation */
  25477. framePerSecond: number,
  25478. /**The data type of the animation */
  25479. dataType: number,
  25480. /**The loop mode of the animation */
  25481. loopMode?: number | undefined,
  25482. /**Specifies if blending should be enabled */
  25483. enableBlending?: boolean | undefined);
  25484. /**
  25485. * Converts the animation to a string
  25486. * @param fullDetails support for multiple levels of logging within scene loading
  25487. * @returns String form of the animation
  25488. */
  25489. toString(fullDetails?: boolean): string;
  25490. /**
  25491. * Add an event to this animation
  25492. * @param event Event to add
  25493. */
  25494. addEvent(event: AnimationEvent): void;
  25495. /**
  25496. * Remove all events found at the given frame
  25497. * @param frame The frame to remove events from
  25498. */
  25499. removeEvents(frame: number): void;
  25500. /**
  25501. * Retrieves all the events from the animation
  25502. * @returns Events from the animation
  25503. */
  25504. getEvents(): AnimationEvent[];
  25505. /**
  25506. * Creates an animation range
  25507. * @param name Name of the animation range
  25508. * @param from Starting frame of the animation range
  25509. * @param to Ending frame of the animation
  25510. */
  25511. createRange(name: string, from: number, to: number): void;
  25512. /**
  25513. * Deletes an animation range by name
  25514. * @param name Name of the animation range to delete
  25515. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25516. */
  25517. deleteRange(name: string, deleteFrames?: boolean): void;
  25518. /**
  25519. * Gets the animation range by name, or null if not defined
  25520. * @param name Name of the animation range
  25521. * @returns Nullable animation range
  25522. */
  25523. getRange(name: string): Nullable<AnimationRange>;
  25524. /**
  25525. * Gets the key frames from the animation
  25526. * @returns The key frames of the animation
  25527. */
  25528. getKeys(): Array<IAnimationKey>;
  25529. /**
  25530. * Gets the highest frame rate of the animation
  25531. * @returns Highest frame rate of the animation
  25532. */
  25533. getHighestFrame(): number;
  25534. /**
  25535. * Gets the easing function of the animation
  25536. * @returns Easing function of the animation
  25537. */
  25538. getEasingFunction(): IEasingFunction;
  25539. /**
  25540. * Sets the easing function of the animation
  25541. * @param easingFunction A custom mathematical formula for animation
  25542. */
  25543. setEasingFunction(easingFunction: EasingFunction): void;
  25544. /**
  25545. * Interpolates a scalar linearly
  25546. * @param startValue Start value of the animation curve
  25547. * @param endValue End value of the animation curve
  25548. * @param gradient Scalar amount to interpolate
  25549. * @returns Interpolated scalar value
  25550. */
  25551. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25552. /**
  25553. * Interpolates a scalar cubically
  25554. * @param startValue Start value of the animation curve
  25555. * @param outTangent End tangent of the animation
  25556. * @param endValue End value of the animation curve
  25557. * @param inTangent Start tangent of the animation curve
  25558. * @param gradient Scalar amount to interpolate
  25559. * @returns Interpolated scalar value
  25560. */
  25561. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25562. /**
  25563. * Interpolates a quaternion using a spherical linear interpolation
  25564. * @param startValue Start value of the animation curve
  25565. * @param endValue End value of the animation curve
  25566. * @param gradient Scalar amount to interpolate
  25567. * @returns Interpolated quaternion value
  25568. */
  25569. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25570. /**
  25571. * Interpolates a quaternion cubically
  25572. * @param startValue Start value of the animation curve
  25573. * @param outTangent End tangent of the animation curve
  25574. * @param endValue End value of the animation curve
  25575. * @param inTangent Start tangent of the animation curve
  25576. * @param gradient Scalar amount to interpolate
  25577. * @returns Interpolated quaternion value
  25578. */
  25579. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25580. /**
  25581. * Interpolates a Vector3 linearl
  25582. * @param startValue Start value of the animation curve
  25583. * @param endValue End value of the animation curve
  25584. * @param gradient Scalar amount to interpolate
  25585. * @returns Interpolated scalar value
  25586. */
  25587. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25588. /**
  25589. * Interpolates a Vector3 cubically
  25590. * @param startValue Start value of the animation curve
  25591. * @param outTangent End tangent of the animation
  25592. * @param endValue End value of the animation curve
  25593. * @param inTangent Start tangent of the animation curve
  25594. * @param gradient Scalar amount to interpolate
  25595. * @returns InterpolatedVector3 value
  25596. */
  25597. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25598. /**
  25599. * Interpolates a Vector2 linearly
  25600. * @param startValue Start value of the animation curve
  25601. * @param endValue End value of the animation curve
  25602. * @param gradient Scalar amount to interpolate
  25603. * @returns Interpolated Vector2 value
  25604. */
  25605. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25606. /**
  25607. * Interpolates a Vector2 cubically
  25608. * @param startValue Start value of the animation curve
  25609. * @param outTangent End tangent of the animation
  25610. * @param endValue End value of the animation curve
  25611. * @param inTangent Start tangent of the animation curve
  25612. * @param gradient Scalar amount to interpolate
  25613. * @returns Interpolated Vector2 value
  25614. */
  25615. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25616. /**
  25617. * Interpolates a size linearly
  25618. * @param startValue Start value of the animation curve
  25619. * @param endValue End value of the animation curve
  25620. * @param gradient Scalar amount to interpolate
  25621. * @returns Interpolated Size value
  25622. */
  25623. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25624. /**
  25625. * Interpolates a Color3 linearly
  25626. * @param startValue Start value of the animation curve
  25627. * @param endValue End value of the animation curve
  25628. * @param gradient Scalar amount to interpolate
  25629. * @returns Interpolated Color3 value
  25630. */
  25631. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25632. /**
  25633. * @hidden Internal use only
  25634. */ private _getKeyValue(value: any): any;
  25635. /**
  25636. * @hidden Internal use only
  25637. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  25638. /**
  25639. * Defines the function to use to interpolate matrices
  25640. * @param startValue defines the start matrix
  25641. * @param endValue defines the end matrix
  25642. * @param gradient defines the gradient between both matrices
  25643. * @param result defines an optional target matrix where to store the interpolation
  25644. * @returns the interpolated matrix
  25645. */
  25646. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25647. /**
  25648. * Makes a copy of the animation
  25649. * @returns Cloned animation
  25650. */
  25651. clone(): Animation;
  25652. /**
  25653. * Sets the key frames of the animation
  25654. * @param values The animation key frames to set
  25655. */
  25656. setKeys(values: Array<IAnimationKey>): void;
  25657. /**
  25658. * Serializes the animation to an object
  25659. * @returns Serialized object
  25660. */
  25661. serialize(): any;
  25662. /**
  25663. * Float animation type
  25664. */
  25665. private static _ANIMATIONTYPE_FLOAT;
  25666. /**
  25667. * Vector3 animation type
  25668. */
  25669. private static _ANIMATIONTYPE_VECTOR3;
  25670. /**
  25671. * Quaternion animation type
  25672. */
  25673. private static _ANIMATIONTYPE_QUATERNION;
  25674. /**
  25675. * Matrix animation type
  25676. */
  25677. private static _ANIMATIONTYPE_MATRIX;
  25678. /**
  25679. * Color3 animation type
  25680. */
  25681. private static _ANIMATIONTYPE_COLOR3;
  25682. /**
  25683. * Vector2 animation type
  25684. */
  25685. private static _ANIMATIONTYPE_VECTOR2;
  25686. /**
  25687. * Size animation type
  25688. */
  25689. private static _ANIMATIONTYPE_SIZE;
  25690. /**
  25691. * Relative Loop Mode
  25692. */
  25693. private static _ANIMATIONLOOPMODE_RELATIVE;
  25694. /**
  25695. * Cycle Loop Mode
  25696. */
  25697. private static _ANIMATIONLOOPMODE_CYCLE;
  25698. /**
  25699. * Constant Loop Mode
  25700. */
  25701. private static _ANIMATIONLOOPMODE_CONSTANT;
  25702. /**
  25703. * Get the float animation type
  25704. */
  25705. static readonly ANIMATIONTYPE_FLOAT: number;
  25706. /**
  25707. * Get the Vector3 animation type
  25708. */
  25709. static readonly ANIMATIONTYPE_VECTOR3: number;
  25710. /**
  25711. * Get the Vector2 animation type
  25712. */
  25713. static readonly ANIMATIONTYPE_VECTOR2: number;
  25714. /**
  25715. * Get the Size animation type
  25716. */
  25717. static readonly ANIMATIONTYPE_SIZE: number;
  25718. /**
  25719. * Get the Quaternion animation type
  25720. */
  25721. static readonly ANIMATIONTYPE_QUATERNION: number;
  25722. /**
  25723. * Get the Matrix animation type
  25724. */
  25725. static readonly ANIMATIONTYPE_MATRIX: number;
  25726. /**
  25727. * Get the Color3 animation type
  25728. */
  25729. static readonly ANIMATIONTYPE_COLOR3: number;
  25730. /**
  25731. * Get the Relative Loop Mode
  25732. */
  25733. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25734. /**
  25735. * Get the Cycle Loop Mode
  25736. */
  25737. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25738. /**
  25739. * Get the Constant Loop Mode
  25740. */
  25741. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25742. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25743. /**
  25744. * Parses an animation object and creates an animation
  25745. * @param parsedAnimation Parsed animation object
  25746. * @returns Animation object
  25747. */
  25748. static Parse(parsedAnimation: any): Animation;
  25749. /**
  25750. * Appends the serialized animations from the source animations
  25751. * @param source Source containing the animations
  25752. * @param destination Target to store the animations
  25753. */
  25754. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25755. }
  25756. }
  25757. declare module BABYLON {
  25758. /**
  25759. * Base class of all the textures in babylon.
  25760. * It groups all the common properties the materials, post process, lights... might need
  25761. * in order to make a correct use of the texture.
  25762. */
  25763. export class BaseTexture implements IAnimatable {
  25764. /**
  25765. * Default anisotropic filtering level for the application.
  25766. * It is set to 4 as a good tradeoff between perf and quality.
  25767. */
  25768. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25769. /**
  25770. * Gets or sets the unique id of the texture
  25771. */
  25772. uniqueId: number;
  25773. /**
  25774. * Define the name of the texture.
  25775. */
  25776. name: string;
  25777. /**
  25778. * Gets or sets an object used to store user defined information.
  25779. */
  25780. metadata: any;
  25781. /**
  25782. * For internal use only. Please do not use.
  25783. */
  25784. reservedDataStore: any;
  25785. private _hasAlpha;
  25786. /**
  25787. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25788. */
  25789. hasAlpha: boolean;
  25790. /**
  25791. * Defines if the alpha value should be determined via the rgb values.
  25792. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25793. */
  25794. getAlphaFromRGB: boolean;
  25795. /**
  25796. * Intensity or strength of the texture.
  25797. * It is commonly used by materials to fine tune the intensity of the texture
  25798. */
  25799. level: number;
  25800. /**
  25801. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25802. * This is part of the texture as textures usually maps to one uv set.
  25803. */
  25804. coordinatesIndex: number;
  25805. private _coordinatesMode;
  25806. /**
  25807. * How a texture is mapped.
  25808. *
  25809. * | Value | Type | Description |
  25810. * | ----- | ----------------------------------- | ----------- |
  25811. * | 0 | EXPLICIT_MODE | |
  25812. * | 1 | SPHERICAL_MODE | |
  25813. * | 2 | PLANAR_MODE | |
  25814. * | 3 | CUBIC_MODE | |
  25815. * | 4 | PROJECTION_MODE | |
  25816. * | 5 | SKYBOX_MODE | |
  25817. * | 6 | INVCUBIC_MODE | |
  25818. * | 7 | EQUIRECTANGULAR_MODE | |
  25819. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25820. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25821. */
  25822. coordinatesMode: number;
  25823. /**
  25824. * | Value | Type | Description |
  25825. * | ----- | ------------------ | ----------- |
  25826. * | 0 | CLAMP_ADDRESSMODE | |
  25827. * | 1 | WRAP_ADDRESSMODE | |
  25828. * | 2 | MIRROR_ADDRESSMODE | |
  25829. */
  25830. wrapU: number;
  25831. /**
  25832. * | Value | Type | Description |
  25833. * | ----- | ------------------ | ----------- |
  25834. * | 0 | CLAMP_ADDRESSMODE | |
  25835. * | 1 | WRAP_ADDRESSMODE | |
  25836. * | 2 | MIRROR_ADDRESSMODE | |
  25837. */
  25838. wrapV: number;
  25839. /**
  25840. * | Value | Type | Description |
  25841. * | ----- | ------------------ | ----------- |
  25842. * | 0 | CLAMP_ADDRESSMODE | |
  25843. * | 1 | WRAP_ADDRESSMODE | |
  25844. * | 2 | MIRROR_ADDRESSMODE | |
  25845. */
  25846. wrapR: number;
  25847. /**
  25848. * With compliant hardware and browser (supporting anisotropic filtering)
  25849. * this defines the level of anisotropic filtering in the texture.
  25850. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25851. */
  25852. anisotropicFilteringLevel: number;
  25853. /**
  25854. * Define if the texture is a cube texture or if false a 2d texture.
  25855. */
  25856. isCube: boolean;
  25857. /**
  25858. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25859. */
  25860. is3D: boolean;
  25861. /**
  25862. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25863. * HDR texture are usually stored in linear space.
  25864. * This only impacts the PBR and Background materials
  25865. */
  25866. gammaSpace: boolean;
  25867. /**
  25868. * Gets whether or not the texture contains RGBD data.
  25869. */
  25870. readonly isRGBD: boolean;
  25871. /**
  25872. * Is Z inverted in the texture (useful in a cube texture).
  25873. */
  25874. invertZ: boolean;
  25875. /**
  25876. * Are mip maps generated for this texture or not.
  25877. */
  25878. readonly noMipmap: boolean;
  25879. /**
  25880. * @hidden
  25881. */
  25882. lodLevelInAlpha: boolean;
  25883. /**
  25884. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25885. */
  25886. lodGenerationOffset: number;
  25887. /**
  25888. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25889. */
  25890. lodGenerationScale: number;
  25891. /**
  25892. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  25893. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  25894. * average roughness values.
  25895. */
  25896. linearSpecularLOD: boolean;
  25897. /**
  25898. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  25899. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  25900. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  25901. */
  25902. irradianceTexture: Nullable<BaseTexture>;
  25903. /**
  25904. * Define if the texture is a render target.
  25905. */
  25906. isRenderTarget: boolean;
  25907. /**
  25908. * Define the unique id of the texture in the scene.
  25909. */
  25910. readonly uid: string;
  25911. /**
  25912. * Return a string representation of the texture.
  25913. * @returns the texture as a string
  25914. */
  25915. toString(): string;
  25916. /**
  25917. * Get the class name of the texture.
  25918. * @returns "BaseTexture"
  25919. */
  25920. getClassName(): string;
  25921. /**
  25922. * Define the list of animation attached to the texture.
  25923. */
  25924. animations: Animation[];
  25925. /**
  25926. * An event triggered when the texture is disposed.
  25927. */
  25928. onDisposeObservable: Observable<BaseTexture>;
  25929. private _onDisposeObserver;
  25930. /**
  25931. * Callback triggered when the texture has been disposed.
  25932. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25933. */
  25934. onDispose: () => void;
  25935. /**
  25936. * Define the current state of the loading sequence when in delayed load mode.
  25937. */
  25938. delayLoadState: number;
  25939. private _scene;
  25940. /** @hidden */ private _texture: Nullable<InternalTexture>;
  25941. private _uid;
  25942. /**
  25943. * Define if the texture is preventinga material to render or not.
  25944. * If not and the texture is not ready, the engine will use a default black texture instead.
  25945. */
  25946. readonly isBlocking: boolean;
  25947. /**
  25948. * Instantiates a new BaseTexture.
  25949. * Base class of all the textures in babylon.
  25950. * It groups all the common properties the materials, post process, lights... might need
  25951. * in order to make a correct use of the texture.
  25952. * @param scene Define the scene the texture blongs to
  25953. */
  25954. constructor(scene: Nullable<Scene>);
  25955. /**
  25956. * Get the scene the texture belongs to.
  25957. * @returns the scene or null if undefined
  25958. */
  25959. getScene(): Nullable<Scene>;
  25960. /**
  25961. * Get the texture transform matrix used to offset tile the texture for istance.
  25962. * @returns the transformation matrix
  25963. */
  25964. getTextureMatrix(): Matrix;
  25965. /**
  25966. * Get the texture reflection matrix used to rotate/transform the reflection.
  25967. * @returns the reflection matrix
  25968. */
  25969. getReflectionTextureMatrix(): Matrix;
  25970. /**
  25971. * Get the underlying lower level texture from Babylon.
  25972. * @returns the insternal texture
  25973. */
  25974. getInternalTexture(): Nullable<InternalTexture>;
  25975. /**
  25976. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25977. * @returns true if ready or not blocking
  25978. */
  25979. isReadyOrNotBlocking(): boolean;
  25980. /**
  25981. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25982. * @returns true if fully ready
  25983. */
  25984. isReady(): boolean;
  25985. private _cachedSize;
  25986. /**
  25987. * Get the size of the texture.
  25988. * @returns the texture size.
  25989. */
  25990. getSize(): ISize;
  25991. /**
  25992. * Get the base size of the texture.
  25993. * It can be different from the size if the texture has been resized for POT for instance
  25994. * @returns the base size
  25995. */
  25996. getBaseSize(): ISize;
  25997. /**
  25998. * Update the sampling mode of the texture.
  25999. * Default is Trilinear mode.
  26000. *
  26001. * | Value | Type | Description |
  26002. * | ----- | ------------------ | ----------- |
  26003. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26004. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26005. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26006. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26007. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26008. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26009. * | 7 | NEAREST_LINEAR | |
  26010. * | 8 | NEAREST_NEAREST | |
  26011. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26012. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26013. * | 11 | LINEAR_LINEAR | |
  26014. * | 12 | LINEAR_NEAREST | |
  26015. *
  26016. * > _mag_: magnification filter (close to the viewer)
  26017. * > _min_: minification filter (far from the viewer)
  26018. * > _mip_: filter used between mip map levels
  26019. *@param samplingMode Define the new sampling mode of the texture
  26020. */
  26021. updateSamplingMode(samplingMode: number): void;
  26022. /**
  26023. * Scales the texture if is `canRescale()`
  26024. * @param ratio the resize factor we want to use to rescale
  26025. */
  26026. scale(ratio: number): void;
  26027. /**
  26028. * Get if the texture can rescale.
  26029. */
  26030. readonly canRescale: boolean;
  26031. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26032. /** @hidden */ private _rebuild(): void;
  26033. /**
  26034. * Triggers the load sequence in delayed load mode.
  26035. */
  26036. delayLoad(): void;
  26037. /**
  26038. * Clones the texture.
  26039. * @returns the cloned texture
  26040. */
  26041. clone(): Nullable<BaseTexture>;
  26042. /**
  26043. * Get the texture underlying type (INT, FLOAT...)
  26044. */
  26045. readonly textureType: number;
  26046. /**
  26047. * Get the texture underlying format (RGB, RGBA...)
  26048. */
  26049. readonly textureFormat: number;
  26050. /**
  26051. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26052. * This will returns an RGBA array buffer containing either in values (0-255) or
  26053. * float values (0-1) depending of the underlying buffer type.
  26054. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26055. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26056. * @param buffer defines a user defined buffer to fill with data (can be null)
  26057. * @returns The Array buffer containing the pixels data.
  26058. */
  26059. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26060. /**
  26061. * Release and destroy the underlying lower level texture aka internalTexture.
  26062. */
  26063. releaseInternalTexture(): void;
  26064. /**
  26065. * Get the polynomial representation of the texture data.
  26066. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26067. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26068. */
  26069. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26070. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  26071. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  26072. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  26073. /**
  26074. * Dispose the texture and release its associated resources.
  26075. */
  26076. dispose(): void;
  26077. /**
  26078. * Serialize the texture into a JSON representation that can be parsed later on.
  26079. * @returns the JSON representation of the texture
  26080. */
  26081. serialize(): any;
  26082. /**
  26083. * Helper function to be called back once a list of texture contains only ready textures.
  26084. * @param textures Define the list of textures to wait for
  26085. * @param callback Define the callback triggered once the entire list will be ready
  26086. */
  26087. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26088. }
  26089. }
  26090. declare module BABYLON {
  26091. /**
  26092. * Uniform buffer objects.
  26093. *
  26094. * Handles blocks of uniform on the GPU.
  26095. *
  26096. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26097. *
  26098. * For more information, please refer to :
  26099. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26100. */
  26101. export class UniformBuffer {
  26102. private _engine;
  26103. private _buffer;
  26104. private _data;
  26105. private _bufferData;
  26106. private _dynamic?;
  26107. private _uniformLocations;
  26108. private _uniformSizes;
  26109. private _uniformLocationPointer;
  26110. private _needSync;
  26111. private _noUBO;
  26112. private _currentEffect;
  26113. private static _MAX_UNIFORM_SIZE;
  26114. private static _tempBuffer;
  26115. /**
  26116. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26117. * This is dynamic to allow compat with webgl 1 and 2.
  26118. * You will need to pass the name of the uniform as well as the value.
  26119. */
  26120. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26121. /**
  26122. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26123. * This is dynamic to allow compat with webgl 1 and 2.
  26124. * You will need to pass the name of the uniform as well as the value.
  26125. */
  26126. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26127. /**
  26128. * Lambda to Update a single float in a uniform buffer.
  26129. * This is dynamic to allow compat with webgl 1 and 2.
  26130. * You will need to pass the name of the uniform as well as the value.
  26131. */
  26132. updateFloat: (name: string, x: number) => void;
  26133. /**
  26134. * Lambda to Update a vec2 of float in a uniform buffer.
  26135. * This is dynamic to allow compat with webgl 1 and 2.
  26136. * You will need to pass the name of the uniform as well as the value.
  26137. */
  26138. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26139. /**
  26140. * Lambda to Update a vec3 of float in a uniform buffer.
  26141. * This is dynamic to allow compat with webgl 1 and 2.
  26142. * You will need to pass the name of the uniform as well as the value.
  26143. */
  26144. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26145. /**
  26146. * Lambda to Update a vec4 of float in a uniform buffer.
  26147. * This is dynamic to allow compat with webgl 1 and 2.
  26148. * You will need to pass the name of the uniform as well as the value.
  26149. */
  26150. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26151. /**
  26152. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26153. * This is dynamic to allow compat with webgl 1 and 2.
  26154. * You will need to pass the name of the uniform as well as the value.
  26155. */
  26156. updateMatrix: (name: string, mat: Matrix) => void;
  26157. /**
  26158. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26159. * This is dynamic to allow compat with webgl 1 and 2.
  26160. * You will need to pass the name of the uniform as well as the value.
  26161. */
  26162. updateVector3: (name: string, vector: Vector3) => void;
  26163. /**
  26164. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26165. * This is dynamic to allow compat with webgl 1 and 2.
  26166. * You will need to pass the name of the uniform as well as the value.
  26167. */
  26168. updateVector4: (name: string, vector: Vector4) => void;
  26169. /**
  26170. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26171. * This is dynamic to allow compat with webgl 1 and 2.
  26172. * You will need to pass the name of the uniform as well as the value.
  26173. */
  26174. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26175. /**
  26176. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26177. * This is dynamic to allow compat with webgl 1 and 2.
  26178. * You will need to pass the name of the uniform as well as the value.
  26179. */
  26180. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26181. /**
  26182. * Instantiates a new Uniform buffer objects.
  26183. *
  26184. * Handles blocks of uniform on the GPU.
  26185. *
  26186. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26187. *
  26188. * For more information, please refer to :
  26189. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26190. * @param engine Define the engine the buffer is associated with
  26191. * @param data Define the data contained in the buffer
  26192. * @param dynamic Define if the buffer is updatable
  26193. */
  26194. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26195. /**
  26196. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26197. * or just falling back on setUniformXXX calls.
  26198. */
  26199. readonly useUbo: boolean;
  26200. /**
  26201. * Indicates if the WebGL underlying uniform buffer is in sync
  26202. * with the javascript cache data.
  26203. */
  26204. readonly isSync: boolean;
  26205. /**
  26206. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26207. * Also, a dynamic UniformBuffer will disable cache verification and always
  26208. * update the underlying WebGL uniform buffer to the GPU.
  26209. * @returns if Dynamic, otherwise false
  26210. */
  26211. isDynamic(): boolean;
  26212. /**
  26213. * The data cache on JS side.
  26214. * @returns the underlying data as a float array
  26215. */
  26216. getData(): Float32Array;
  26217. /**
  26218. * The underlying WebGL Uniform buffer.
  26219. * @returns the webgl buffer
  26220. */
  26221. getBuffer(): Nullable<DataBuffer>;
  26222. /**
  26223. * std140 layout specifies how to align data within an UBO structure.
  26224. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26225. * for specs.
  26226. */
  26227. private _fillAlignment;
  26228. /**
  26229. * Adds an uniform in the buffer.
  26230. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26231. * for the layout to be correct !
  26232. * @param name Name of the uniform, as used in the uniform block in the shader.
  26233. * @param size Data size, or data directly.
  26234. */
  26235. addUniform(name: string, size: number | number[]): void;
  26236. /**
  26237. * Adds a Matrix 4x4 to the uniform buffer.
  26238. * @param name Name of the uniform, as used in the uniform block in the shader.
  26239. * @param mat A 4x4 matrix.
  26240. */
  26241. addMatrix(name: string, mat: Matrix): void;
  26242. /**
  26243. * Adds a vec2 to the uniform buffer.
  26244. * @param name Name of the uniform, as used in the uniform block in the shader.
  26245. * @param x Define the x component value of the vec2
  26246. * @param y Define the y component value of the vec2
  26247. */
  26248. addFloat2(name: string, x: number, y: number): void;
  26249. /**
  26250. * Adds a vec3 to the uniform buffer.
  26251. * @param name Name of the uniform, as used in the uniform block in the shader.
  26252. * @param x Define the x component value of the vec3
  26253. * @param y Define the y component value of the vec3
  26254. * @param z Define the z component value of the vec3
  26255. */
  26256. addFloat3(name: string, x: number, y: number, z: number): void;
  26257. /**
  26258. * Adds a vec3 to the uniform buffer.
  26259. * @param name Name of the uniform, as used in the uniform block in the shader.
  26260. * @param color Define the vec3 from a Color
  26261. */
  26262. addColor3(name: string, color: Color3): void;
  26263. /**
  26264. * Adds a vec4 to the uniform buffer.
  26265. * @param name Name of the uniform, as used in the uniform block in the shader.
  26266. * @param color Define the rgb components from a Color
  26267. * @param alpha Define the a component of the vec4
  26268. */
  26269. addColor4(name: string, color: Color3, alpha: number): void;
  26270. /**
  26271. * Adds a vec3 to the uniform buffer.
  26272. * @param name Name of the uniform, as used in the uniform block in the shader.
  26273. * @param vector Define the vec3 components from a Vector
  26274. */
  26275. addVector3(name: string, vector: Vector3): void;
  26276. /**
  26277. * Adds a Matrix 3x3 to the uniform buffer.
  26278. * @param name Name of the uniform, as used in the uniform block in the shader.
  26279. */
  26280. addMatrix3x3(name: string): void;
  26281. /**
  26282. * Adds a Matrix 2x2 to the uniform buffer.
  26283. * @param name Name of the uniform, as used in the uniform block in the shader.
  26284. */
  26285. addMatrix2x2(name: string): void;
  26286. /**
  26287. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26288. */
  26289. create(): void;
  26290. /** @hidden */ private _rebuild(): void;
  26291. /**
  26292. * Updates the WebGL Uniform Buffer on the GPU.
  26293. * If the `dynamic` flag is set to true, no cache comparison is done.
  26294. * Otherwise, the buffer will be updated only if the cache differs.
  26295. */
  26296. update(): void;
  26297. /**
  26298. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26299. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26300. * @param data Define the flattened data
  26301. * @param size Define the size of the data.
  26302. */
  26303. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26304. private _updateMatrix3x3ForUniform;
  26305. private _updateMatrix3x3ForEffect;
  26306. private _updateMatrix2x2ForEffect;
  26307. private _updateMatrix2x2ForUniform;
  26308. private _updateFloatForEffect;
  26309. private _updateFloatForUniform;
  26310. private _updateFloat2ForEffect;
  26311. private _updateFloat2ForUniform;
  26312. private _updateFloat3ForEffect;
  26313. private _updateFloat3ForUniform;
  26314. private _updateFloat4ForEffect;
  26315. private _updateFloat4ForUniform;
  26316. private _updateMatrixForEffect;
  26317. private _updateMatrixForUniform;
  26318. private _updateVector3ForEffect;
  26319. private _updateVector3ForUniform;
  26320. private _updateVector4ForEffect;
  26321. private _updateVector4ForUniform;
  26322. private _updateColor3ForEffect;
  26323. private _updateColor3ForUniform;
  26324. private _updateColor4ForEffect;
  26325. private _updateColor4ForUniform;
  26326. /**
  26327. * Sets a sampler uniform on the effect.
  26328. * @param name Define the name of the sampler.
  26329. * @param texture Define the texture to set in the sampler
  26330. */
  26331. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26332. /**
  26333. * Directly updates the value of the uniform in the cache AND on the GPU.
  26334. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26335. * @param data Define the flattened data
  26336. */
  26337. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26338. /**
  26339. * Binds this uniform buffer to an effect.
  26340. * @param effect Define the effect to bind the buffer to
  26341. * @param name Name of the uniform block in the shader.
  26342. */
  26343. bindToEffect(effect: Effect, name: string): void;
  26344. /**
  26345. * Disposes the uniform buffer.
  26346. */
  26347. dispose(): void;
  26348. }
  26349. }
  26350. declare module BABYLON {
  26351. /**
  26352. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26354. */
  26355. export class Analyser {
  26356. /**
  26357. * Gets or sets the smoothing
  26358. * @ignorenaming
  26359. */
  26360. SMOOTHING: number;
  26361. /**
  26362. * Gets or sets the FFT table size
  26363. * @ignorenaming
  26364. */
  26365. FFT_SIZE: number;
  26366. /**
  26367. * Gets or sets the bar graph amplitude
  26368. * @ignorenaming
  26369. */
  26370. BARGRAPHAMPLITUDE: number;
  26371. /**
  26372. * Gets or sets the position of the debug canvas
  26373. * @ignorenaming
  26374. */
  26375. DEBUGCANVASPOS: {
  26376. x: number;
  26377. y: number;
  26378. };
  26379. /**
  26380. * Gets or sets the debug canvas size
  26381. * @ignorenaming
  26382. */
  26383. DEBUGCANVASSIZE: {
  26384. width: number;
  26385. height: number;
  26386. };
  26387. private _byteFreqs;
  26388. private _byteTime;
  26389. private _floatFreqs;
  26390. private _webAudioAnalyser;
  26391. private _debugCanvas;
  26392. private _debugCanvasContext;
  26393. private _scene;
  26394. private _registerFunc;
  26395. private _audioEngine;
  26396. /**
  26397. * Creates a new analyser
  26398. * @param scene defines hosting scene
  26399. */
  26400. constructor(scene: Scene);
  26401. /**
  26402. * Get the number of data values you will have to play with for the visualization
  26403. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26404. * @returns a number
  26405. */
  26406. getFrequencyBinCount(): number;
  26407. /**
  26408. * Gets the current frequency data as a byte array
  26409. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26410. * @returns a Uint8Array
  26411. */
  26412. getByteFrequencyData(): Uint8Array;
  26413. /**
  26414. * Gets the current waveform as a byte array
  26415. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26416. * @returns a Uint8Array
  26417. */
  26418. getByteTimeDomainData(): Uint8Array;
  26419. /**
  26420. * Gets the current frequency data as a float array
  26421. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26422. * @returns a Float32Array
  26423. */
  26424. getFloatFrequencyData(): Float32Array;
  26425. /**
  26426. * Renders the debug canvas
  26427. */
  26428. drawDebugCanvas(): void;
  26429. /**
  26430. * Stops rendering the debug canvas and removes it
  26431. */
  26432. stopDebugCanvas(): void;
  26433. /**
  26434. * Connects two audio nodes
  26435. * @param inputAudioNode defines first node to connect
  26436. * @param outputAudioNode defines second node to connect
  26437. */
  26438. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26439. /**
  26440. * Releases all associated resources
  26441. */
  26442. dispose(): void;
  26443. }
  26444. }
  26445. declare module BABYLON {
  26446. /**
  26447. * This represents an audio engine and it is responsible
  26448. * to play, synchronize and analyse sounds throughout the application.
  26449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26450. */
  26451. export interface IAudioEngine extends IDisposable {
  26452. /**
  26453. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26454. */
  26455. readonly canUseWebAudio: boolean;
  26456. /**
  26457. * Gets the current AudioContext if available.
  26458. */
  26459. readonly audioContext: Nullable<AudioContext>;
  26460. /**
  26461. * The master gain node defines the global audio volume of your audio engine.
  26462. */
  26463. readonly masterGain: GainNode;
  26464. /**
  26465. * Gets whether or not mp3 are supported by your browser.
  26466. */
  26467. readonly isMP3supported: boolean;
  26468. /**
  26469. * Gets whether or not ogg are supported by your browser.
  26470. */
  26471. readonly isOGGsupported: boolean;
  26472. /**
  26473. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26474. * @ignoreNaming
  26475. */
  26476. WarnedWebAudioUnsupported: boolean;
  26477. /**
  26478. * Defines if the audio engine relies on a custom unlocked button.
  26479. * In this case, the embedded button will not be displayed.
  26480. */
  26481. useCustomUnlockedButton: boolean;
  26482. /**
  26483. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26484. */
  26485. readonly unlocked: boolean;
  26486. /**
  26487. * Event raised when audio has been unlocked on the browser.
  26488. */
  26489. onAudioUnlockedObservable: Observable<AudioEngine>;
  26490. /**
  26491. * Event raised when audio has been locked on the browser.
  26492. */
  26493. onAudioLockedObservable: Observable<AudioEngine>;
  26494. /**
  26495. * Flags the audio engine in Locked state.
  26496. * This happens due to new browser policies preventing audio to autoplay.
  26497. */
  26498. lock(): void;
  26499. /**
  26500. * Unlocks the audio engine once a user action has been done on the dom.
  26501. * This is helpful to resume play once browser policies have been satisfied.
  26502. */
  26503. unlock(): void;
  26504. }
  26505. /**
  26506. * This represents the default audio engine used in babylon.
  26507. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26509. */
  26510. export class AudioEngine implements IAudioEngine {
  26511. private _audioContext;
  26512. private _audioContextInitialized;
  26513. private _muteButton;
  26514. private _hostElement;
  26515. /**
  26516. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26517. */
  26518. canUseWebAudio: boolean;
  26519. /**
  26520. * The master gain node defines the global audio volume of your audio engine.
  26521. */
  26522. masterGain: GainNode;
  26523. /**
  26524. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26525. * @ignoreNaming
  26526. */
  26527. WarnedWebAudioUnsupported: boolean;
  26528. /**
  26529. * Gets whether or not mp3 are supported by your browser.
  26530. */
  26531. isMP3supported: boolean;
  26532. /**
  26533. * Gets whether or not ogg are supported by your browser.
  26534. */
  26535. isOGGsupported: boolean;
  26536. /**
  26537. * Gets whether audio has been unlocked on the device.
  26538. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26539. * a user interaction has happened.
  26540. */
  26541. unlocked: boolean;
  26542. /**
  26543. * Defines if the audio engine relies on a custom unlocked button.
  26544. * In this case, the embedded button will not be displayed.
  26545. */
  26546. useCustomUnlockedButton: boolean;
  26547. /**
  26548. * Event raised when audio has been unlocked on the browser.
  26549. */
  26550. onAudioUnlockedObservable: Observable<AudioEngine>;
  26551. /**
  26552. * Event raised when audio has been locked on the browser.
  26553. */
  26554. onAudioLockedObservable: Observable<AudioEngine>;
  26555. /**
  26556. * Gets the current AudioContext if available.
  26557. */
  26558. readonly audioContext: Nullable<AudioContext>;
  26559. private _connectedAnalyser;
  26560. /**
  26561. * Instantiates a new audio engine.
  26562. *
  26563. * There should be only one per page as some browsers restrict the number
  26564. * of audio contexts you can create.
  26565. * @param hostElement defines the host element where to display the mute icon if necessary
  26566. */
  26567. constructor(hostElement?: Nullable<HTMLElement>);
  26568. /**
  26569. * Flags the audio engine in Locked state.
  26570. * This happens due to new browser policies preventing audio to autoplay.
  26571. */
  26572. lock(): void;
  26573. /**
  26574. * Unlocks the audio engine once a user action has been done on the dom.
  26575. * This is helpful to resume play once browser policies have been satisfied.
  26576. */
  26577. unlock(): void;
  26578. private _resumeAudioContext;
  26579. private _initializeAudioContext;
  26580. private _tryToRun;
  26581. private _triggerRunningState;
  26582. private _triggerSuspendedState;
  26583. private _displayMuteButton;
  26584. private _moveButtonToTopLeft;
  26585. private _onResize;
  26586. private _hideMuteButton;
  26587. /**
  26588. * Destroy and release the resources associated with the audio ccontext.
  26589. */
  26590. dispose(): void;
  26591. /**
  26592. * Gets the global volume sets on the master gain.
  26593. * @returns the global volume if set or -1 otherwise
  26594. */
  26595. getGlobalVolume(): number;
  26596. /**
  26597. * Sets the global volume of your experience (sets on the master gain).
  26598. * @param newVolume Defines the new global volume of the application
  26599. */
  26600. setGlobalVolume(newVolume: number): void;
  26601. /**
  26602. * Connect the audio engine to an audio analyser allowing some amazing
  26603. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26605. * @param analyser The analyser to connect to the engine
  26606. */
  26607. connectToAnalyser(analyser: Analyser): void;
  26608. }
  26609. }
  26610. declare module BABYLON {
  26611. /**
  26612. * Interface used to present a loading screen while loading a scene
  26613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26614. */
  26615. export interface ILoadingScreen {
  26616. /**
  26617. * Function called to display the loading screen
  26618. */
  26619. displayLoadingUI: () => void;
  26620. /**
  26621. * Function called to hide the loading screen
  26622. */
  26623. hideLoadingUI: () => void;
  26624. /**
  26625. * Gets or sets the color to use for the background
  26626. */
  26627. loadingUIBackgroundColor: string;
  26628. /**
  26629. * Gets or sets the text to display while loading
  26630. */
  26631. loadingUIText: string;
  26632. }
  26633. /**
  26634. * Class used for the default loading screen
  26635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26636. */
  26637. export class DefaultLoadingScreen implements ILoadingScreen {
  26638. private _renderingCanvas;
  26639. private _loadingText;
  26640. private _loadingDivBackgroundColor;
  26641. private _loadingDiv;
  26642. private _loadingTextDiv;
  26643. /** Gets or sets the logo url to use for the default loading screen */
  26644. static DefaultLogoUrl: string;
  26645. /** Gets or sets the spinner url to use for the default loading screen */
  26646. static DefaultSpinnerUrl: string;
  26647. /**
  26648. * Creates a new default loading screen
  26649. * @param _renderingCanvas defines the canvas used to render the scene
  26650. * @param _loadingText defines the default text to display
  26651. * @param _loadingDivBackgroundColor defines the default background color
  26652. */
  26653. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26654. /**
  26655. * Function called to display the loading screen
  26656. */
  26657. displayLoadingUI(): void;
  26658. /**
  26659. * Function called to hide the loading screen
  26660. */
  26661. hideLoadingUI(): void;
  26662. /**
  26663. * Gets or sets the text to display while loading
  26664. */
  26665. loadingUIText: string;
  26666. /**
  26667. * Gets or sets the color to use for the background
  26668. */
  26669. loadingUIBackgroundColor: string;
  26670. private _resizeLoadingUI;
  26671. }
  26672. }
  26673. declare module BABYLON {
  26674. /** @hidden */
  26675. export class WebGLPipelineContext implements IPipelineContext {
  26676. engine: Engine;
  26677. program: Nullable<WebGLProgram>;
  26678. context?: WebGLRenderingContext;
  26679. vertexShader?: WebGLShader;
  26680. fragmentShader?: WebGLShader;
  26681. isParallelCompiled: boolean;
  26682. onCompiled?: () => void;
  26683. transformFeedback?: WebGLTransformFeedback | null;
  26684. readonly isAsync: boolean;
  26685. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26686. }
  26687. }
  26688. declare module BABYLON {
  26689. /** @hidden */
  26690. export class WebGLDataBuffer extends DataBuffer {
  26691. private _buffer;
  26692. constructor(resource: WebGLBuffer);
  26693. readonly underlyingResource: any;
  26694. }
  26695. }
  26696. declare module BABYLON {
  26697. /** @hidden */
  26698. export class WebGL2ShaderProcessor implements IShaderProcessor {
  26699. attributeProcessor(attribute: string): string;
  26700. varyingProcessor(varying: string, isFragment: boolean): string;
  26701. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  26702. }
  26703. }
  26704. declare module BABYLON {
  26705. /**
  26706. * Settings for finer control over video usage
  26707. */
  26708. export interface VideoTextureSettings {
  26709. /**
  26710. * Applies `autoplay` to video, if specified
  26711. */
  26712. autoPlay?: boolean;
  26713. /**
  26714. * Applies `loop` to video, if specified
  26715. */
  26716. loop?: boolean;
  26717. /**
  26718. * Automatically updates internal texture from video at every frame in the render loop
  26719. */
  26720. autoUpdateTexture: boolean;
  26721. /**
  26722. * Image src displayed during the video loading or until the user interacts with the video.
  26723. */
  26724. poster?: string;
  26725. }
  26726. /**
  26727. * If you want to display a video in your scene, this is the special texture for that.
  26728. * This special texture works similar to other textures, with the exception of a few parameters.
  26729. * @see https://doc.babylonjs.com/how_to/video_texture
  26730. */
  26731. export class VideoTexture extends Texture {
  26732. /**
  26733. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26734. */
  26735. readonly autoUpdateTexture: boolean;
  26736. /**
  26737. * The video instance used by the texture internally
  26738. */
  26739. readonly video: HTMLVideoElement;
  26740. private _onUserActionRequestedObservable;
  26741. /**
  26742. * Event triggerd when a dom action is required by the user to play the video.
  26743. * This happens due to recent changes in browser policies preventing video to auto start.
  26744. */
  26745. readonly onUserActionRequestedObservable: Observable<Texture>;
  26746. private _generateMipMaps;
  26747. private _engine;
  26748. private _stillImageCaptured;
  26749. private _displayingPosterTexture;
  26750. private _settings;
  26751. private _createInternalTextureOnEvent;
  26752. /**
  26753. * Creates a video texture.
  26754. * If you want to display a video in your scene, this is the special texture for that.
  26755. * This special texture works similar to other textures, with the exception of a few parameters.
  26756. * @see https://doc.babylonjs.com/how_to/video_texture
  26757. * @param name optional name, will detect from video source, if not defined
  26758. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26759. * @param scene is obviously the current scene.
  26760. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26761. * @param invertY is false by default but can be used to invert video on Y axis
  26762. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26763. * @param settings allows finer control over video usage
  26764. */
  26765. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26766. private _getName;
  26767. private _getVideo;
  26768. private _createInternalTexture;
  26769. private reset;
  26770. /**
  26771. * @hidden Internal method to initiate `update`.
  26772. */ private _rebuild(): void;
  26773. /**
  26774. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26775. */
  26776. update(): void;
  26777. /**
  26778. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26779. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26780. */
  26781. updateTexture(isVisible: boolean): void;
  26782. protected _updateInternalTexture: () => void;
  26783. /**
  26784. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26785. * @param url New url.
  26786. */
  26787. updateURL(url: string): void;
  26788. /**
  26789. * Dispose the texture and release its associated resources.
  26790. */
  26791. dispose(): void;
  26792. /**
  26793. * Creates a video texture straight from a stream.
  26794. * @param scene Define the scene the texture should be created in
  26795. * @param stream Define the stream the texture should be created from
  26796. * @returns The created video texture as a promise
  26797. */
  26798. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26799. /**
  26800. * Creates a video texture straight from your WebCam video feed.
  26801. * @param scene Define the scene the texture should be created in
  26802. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26803. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26804. * @returns The created video texture as a promise
  26805. */
  26806. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26807. minWidth: number;
  26808. maxWidth: number;
  26809. minHeight: number;
  26810. maxHeight: number;
  26811. deviceId: string;
  26812. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26813. /**
  26814. * Creates a video texture straight from your WebCam video feed.
  26815. * @param scene Define the scene the texture should be created in
  26816. * @param onReady Define a callback to triggered once the texture will be ready
  26817. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26818. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26819. */
  26820. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26821. minWidth: number;
  26822. maxWidth: number;
  26823. minHeight: number;
  26824. maxHeight: number;
  26825. deviceId: string;
  26826. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26827. }
  26828. }
  26829. declare module BABYLON {
  26830. /**
  26831. * Interface for attribute information associated with buffer instanciation
  26832. */
  26833. export class InstancingAttributeInfo {
  26834. /**
  26835. * Index/offset of the attribute in the vertex shader
  26836. */
  26837. index: number;
  26838. /**
  26839. * size of the attribute, 1, 2, 3 or 4
  26840. */
  26841. attributeSize: number;
  26842. /**
  26843. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26844. * default is FLOAT
  26845. */
  26846. attribyteType: number;
  26847. /**
  26848. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26849. */
  26850. normalized: boolean;
  26851. /**
  26852. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26853. */
  26854. offset: number;
  26855. /**
  26856. * Name of the GLSL attribute, for debugging purpose only
  26857. */
  26858. attributeName: string;
  26859. }
  26860. /**
  26861. * Define options used to create a depth texture
  26862. */
  26863. export class DepthTextureCreationOptions {
  26864. /** Specifies whether or not a stencil should be allocated in the texture */
  26865. generateStencil?: boolean;
  26866. /** Specifies whether or not bilinear filtering is enable on the texture */
  26867. bilinearFiltering?: boolean;
  26868. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26869. comparisonFunction?: number;
  26870. /** Specifies if the created texture is a cube texture */
  26871. isCube?: boolean;
  26872. }
  26873. /**
  26874. * Class used to describe the capabilities of the engine relatively to the current browser
  26875. */
  26876. export class EngineCapabilities {
  26877. /** Maximum textures units per fragment shader */
  26878. maxTexturesImageUnits: number;
  26879. /** Maximum texture units per vertex shader */
  26880. maxVertexTextureImageUnits: number;
  26881. /** Maximum textures units in the entire pipeline */
  26882. maxCombinedTexturesImageUnits: number;
  26883. /** Maximum texture size */
  26884. maxTextureSize: number;
  26885. /** Maximum cube texture size */
  26886. maxCubemapTextureSize: number;
  26887. /** Maximum render texture size */
  26888. maxRenderTextureSize: number;
  26889. /** Maximum number of vertex attributes */
  26890. maxVertexAttribs: number;
  26891. /** Maximum number of varyings */
  26892. maxVaryingVectors: number;
  26893. /** Maximum number of uniforms per vertex shader */
  26894. maxVertexUniformVectors: number;
  26895. /** Maximum number of uniforms per fragment shader */
  26896. maxFragmentUniformVectors: number;
  26897. /** Defines if standard derivates (dx/dy) are supported */
  26898. standardDerivatives: boolean;
  26899. /** Defines if s3tc texture compression is supported */
  26900. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26901. /** Defines if pvrtc texture compression is supported */
  26902. pvrtc: any;
  26903. /** Defines if etc1 texture compression is supported */
  26904. etc1: any;
  26905. /** Defines if etc2 texture compression is supported */
  26906. etc2: any;
  26907. /** Defines if astc texture compression is supported */
  26908. astc: any;
  26909. /** Defines if float textures are supported */
  26910. textureFloat: boolean;
  26911. /** Defines if vertex array objects are supported */
  26912. vertexArrayObject: boolean;
  26913. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26914. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26915. /** Gets the maximum level of anisotropy supported */
  26916. maxAnisotropy: number;
  26917. /** Defines if instancing is supported */
  26918. instancedArrays: boolean;
  26919. /** Defines if 32 bits indices are supported */
  26920. uintIndices: boolean;
  26921. /** Defines if high precision shaders are supported */
  26922. highPrecisionShaderSupported: boolean;
  26923. /** Defines if depth reading in the fragment shader is supported */
  26924. fragmentDepthSupported: boolean;
  26925. /** Defines if float texture linear filtering is supported*/
  26926. textureFloatLinearFiltering: boolean;
  26927. /** Defines if rendering to float textures is supported */
  26928. textureFloatRender: boolean;
  26929. /** Defines if half float textures are supported*/
  26930. textureHalfFloat: boolean;
  26931. /** Defines if half float texture linear filtering is supported*/
  26932. textureHalfFloatLinearFiltering: boolean;
  26933. /** Defines if rendering to half float textures is supported */
  26934. textureHalfFloatRender: boolean;
  26935. /** Defines if textureLOD shader command is supported */
  26936. textureLOD: boolean;
  26937. /** Defines if draw buffers extension is supported */
  26938. drawBuffersExtension: boolean;
  26939. /** Defines if depth textures are supported */
  26940. depthTextureExtension: boolean;
  26941. /** Defines if float color buffer are supported */
  26942. colorBufferFloat: boolean;
  26943. /** Gets disjoint timer query extension (null if not supported) */
  26944. timerQuery: EXT_disjoint_timer_query;
  26945. /** Defines if timestamp can be used with timer query */
  26946. canUseTimestampForTimerQuery: boolean;
  26947. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26948. multiview: any;
  26949. /** Function used to let the system compiles shaders in background */
  26950. parallelShaderCompile: {
  26951. COMPLETION_STATUS_KHR: number;
  26952. };
  26953. }
  26954. /** Interface defining initialization parameters for Engine class */
  26955. export interface EngineOptions extends WebGLContextAttributes {
  26956. /**
  26957. * Defines if the engine should no exceed a specified device ratio
  26958. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26959. */
  26960. limitDeviceRatio?: number;
  26961. /**
  26962. * Defines if webvr should be enabled automatically
  26963. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26964. */
  26965. autoEnableWebVR?: boolean;
  26966. /**
  26967. * Defines if webgl2 should be turned off even if supported
  26968. * @see http://doc.babylonjs.com/features/webgl2
  26969. */
  26970. disableWebGL2Support?: boolean;
  26971. /**
  26972. * Defines if webaudio should be initialized as well
  26973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26974. */
  26975. audioEngine?: boolean;
  26976. /**
  26977. * Defines if animations should run using a deterministic lock step
  26978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26979. */
  26980. deterministicLockstep?: boolean;
  26981. /** Defines the maximum steps to use with deterministic lock step mode */
  26982. lockstepMaxSteps?: number;
  26983. /**
  26984. * Defines that engine should ignore context lost events
  26985. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26986. */
  26987. doNotHandleContextLost?: boolean;
  26988. /**
  26989. * Defines that engine should ignore modifying touch action attribute and style
  26990. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26991. */
  26992. doNotHandleTouchAction?: boolean;
  26993. /**
  26994. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26995. */
  26996. useHighPrecisionFloats?: boolean;
  26997. }
  26998. /**
  26999. * Defines the interface used by display changed events
  27000. */
  27001. export interface IDisplayChangedEventArgs {
  27002. /** Gets the vrDisplay object (if any) */
  27003. vrDisplay: Nullable<any>;
  27004. /** Gets a boolean indicating if webVR is supported */
  27005. vrSupported: boolean;
  27006. }
  27007. /**
  27008. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27009. */
  27010. export class Engine {
  27011. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27012. static ExceptionList: ({
  27013. key: string;
  27014. capture: string;
  27015. captureConstraint: number;
  27016. targets: string[];
  27017. } | {
  27018. key: string;
  27019. capture: null;
  27020. captureConstraint: null;
  27021. targets: string[];
  27022. })[];
  27023. /** Gets the list of created engines */
  27024. static readonly Instances: Engine[];
  27025. /**
  27026. * Gets the latest created engine
  27027. */
  27028. static readonly LastCreatedEngine: Nullable<Engine>;
  27029. /**
  27030. * Gets the latest created scene
  27031. */
  27032. static readonly LastCreatedScene: Nullable<Scene>;
  27033. /**
  27034. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27035. * @param flag defines which part of the materials must be marked as dirty
  27036. * @param predicate defines a predicate used to filter which materials should be affected
  27037. */
  27038. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27039. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  27040. /** Defines that alpha blending is disabled */
  27041. static readonly ALPHA_DISABLE: number;
  27042. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27043. static readonly ALPHA_ADD: number;
  27044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27045. static readonly ALPHA_COMBINE: number;
  27046. /** Defines that alpha blending to DEST - SRC * DEST */
  27047. static readonly ALPHA_SUBTRACT: number;
  27048. /** Defines that alpha blending to SRC * DEST */
  27049. static readonly ALPHA_MULTIPLY: number;
  27050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27051. static readonly ALPHA_MAXIMIZED: number;
  27052. /** Defines that alpha blending to SRC + DEST */
  27053. static readonly ALPHA_ONEONE: number;
  27054. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27055. static readonly ALPHA_PREMULTIPLIED: number;
  27056. /**
  27057. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27058. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27059. */
  27060. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27061. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27062. static readonly ALPHA_INTERPOLATE: number;
  27063. /**
  27064. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27065. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27066. */
  27067. static readonly ALPHA_SCREENMODE: number;
  27068. /** Defines that the ressource is not delayed*/
  27069. static readonly DELAYLOADSTATE_NONE: number;
  27070. /** Defines that the ressource was successfully delay loaded */
  27071. static readonly DELAYLOADSTATE_LOADED: number;
  27072. /** Defines that the ressource is currently delay loading */
  27073. static readonly DELAYLOADSTATE_LOADING: number;
  27074. /** Defines that the ressource is delayed and has not started loading */
  27075. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27077. static readonly NEVER: number;
  27078. /** 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 */
  27079. static readonly ALWAYS: number;
  27080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27081. static readonly LESS: number;
  27082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27083. static readonly EQUAL: number;
  27084. /** 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 */
  27085. static readonly LEQUAL: number;
  27086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27087. static readonly GREATER: number;
  27088. /** 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 */
  27089. static readonly GEQUAL: number;
  27090. /** 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 */
  27091. static readonly NOTEQUAL: number;
  27092. /** Passed to stencilOperation to specify that stencil value must be kept */
  27093. static readonly KEEP: number;
  27094. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27095. static readonly REPLACE: number;
  27096. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27097. static readonly INCR: number;
  27098. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27099. static readonly DECR: number;
  27100. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27101. static readonly INVERT: number;
  27102. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27103. static readonly INCR_WRAP: number;
  27104. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27105. static readonly DECR_WRAP: number;
  27106. /** Texture is not repeating outside of 0..1 UVs */
  27107. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27108. /** Texture is repeating outside of 0..1 UVs */
  27109. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27110. /** Texture is repeating and mirrored */
  27111. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27112. /** ALPHA */
  27113. static readonly TEXTUREFORMAT_ALPHA: number;
  27114. /** LUMINANCE */
  27115. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27116. /** LUMINANCE_ALPHA */
  27117. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27118. /** RGB */
  27119. static readonly TEXTUREFORMAT_RGB: number;
  27120. /** RGBA */
  27121. static readonly TEXTUREFORMAT_RGBA: number;
  27122. /** RED */
  27123. static readonly TEXTUREFORMAT_RED: number;
  27124. /** RED (2nd reference) */
  27125. static readonly TEXTUREFORMAT_R: number;
  27126. /** RG */
  27127. static readonly TEXTUREFORMAT_RG: number;
  27128. /** RED_INTEGER */
  27129. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27130. /** RED_INTEGER (2nd reference) */
  27131. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27132. /** RG_INTEGER */
  27133. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27134. /** RGB_INTEGER */
  27135. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27136. /** RGBA_INTEGER */
  27137. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27138. /** UNSIGNED_BYTE */
  27139. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27140. /** UNSIGNED_BYTE (2nd reference) */
  27141. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27142. /** FLOAT */
  27143. static readonly TEXTURETYPE_FLOAT: number;
  27144. /** HALF_FLOAT */
  27145. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27146. /** BYTE */
  27147. static readonly TEXTURETYPE_BYTE: number;
  27148. /** SHORT */
  27149. static readonly TEXTURETYPE_SHORT: number;
  27150. /** UNSIGNED_SHORT */
  27151. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27152. /** INT */
  27153. static readonly TEXTURETYPE_INT: number;
  27154. /** UNSIGNED_INT */
  27155. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27156. /** UNSIGNED_SHORT_4_4_4_4 */
  27157. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27158. /** UNSIGNED_SHORT_5_5_5_1 */
  27159. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27160. /** UNSIGNED_SHORT_5_6_5 */
  27161. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27162. /** UNSIGNED_INT_2_10_10_10_REV */
  27163. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27164. /** UNSIGNED_INT_24_8 */
  27165. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27166. /** UNSIGNED_INT_10F_11F_11F_REV */
  27167. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27168. /** UNSIGNED_INT_5_9_9_9_REV */
  27169. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27170. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27171. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27172. /** nearest is mag = nearest and min = nearest and mip = linear */
  27173. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27175. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27176. /** Trilinear is mag = linear and min = linear and mip = linear */
  27177. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27178. /** nearest is mag = nearest and min = nearest and mip = linear */
  27179. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27181. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27182. /** Trilinear is mag = linear and min = linear and mip = linear */
  27183. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27184. /** mag = nearest and min = nearest and mip = nearest */
  27185. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27186. /** mag = nearest and min = linear and mip = nearest */
  27187. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27188. /** mag = nearest and min = linear and mip = linear */
  27189. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27190. /** mag = nearest and min = linear and mip = none */
  27191. static readonly TEXTURE_NEAREST_LINEAR: number;
  27192. /** mag = nearest and min = nearest and mip = none */
  27193. static readonly TEXTURE_NEAREST_NEAREST: number;
  27194. /** mag = linear and min = nearest and mip = nearest */
  27195. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27196. /** mag = linear and min = nearest and mip = linear */
  27197. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27198. /** mag = linear and min = linear and mip = none */
  27199. static readonly TEXTURE_LINEAR_LINEAR: number;
  27200. /** mag = linear and min = nearest and mip = none */
  27201. static readonly TEXTURE_LINEAR_NEAREST: number;
  27202. /** Explicit coordinates mode */
  27203. static readonly TEXTURE_EXPLICIT_MODE: number;
  27204. /** Spherical coordinates mode */
  27205. static readonly TEXTURE_SPHERICAL_MODE: number;
  27206. /** Planar coordinates mode */
  27207. static readonly TEXTURE_PLANAR_MODE: number;
  27208. /** Cubic coordinates mode */
  27209. static readonly TEXTURE_CUBIC_MODE: number;
  27210. /** Projection coordinates mode */
  27211. static readonly TEXTURE_PROJECTION_MODE: number;
  27212. /** Skybox coordinates mode */
  27213. static readonly TEXTURE_SKYBOX_MODE: number;
  27214. /** Inverse Cubic coordinates mode */
  27215. static readonly TEXTURE_INVCUBIC_MODE: number;
  27216. /** Equirectangular coordinates mode */
  27217. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27218. /** Equirectangular Fixed coordinates mode */
  27219. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27220. /** Equirectangular Fixed Mirrored coordinates mode */
  27221. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27222. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27223. static readonly SCALEMODE_FLOOR: number;
  27224. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27225. static readonly SCALEMODE_NEAREST: number;
  27226. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27227. static readonly SCALEMODE_CEILING: number;
  27228. /**
  27229. * Returns the current npm package of the sdk
  27230. */
  27231. static readonly NpmPackage: string;
  27232. /**
  27233. * Returns the current version of the framework
  27234. */
  27235. static readonly Version: string;
  27236. /**
  27237. * Returns a string describing the current engine
  27238. */
  27239. readonly description: string;
  27240. /**
  27241. * Gets or sets the epsilon value used by collision engine
  27242. */
  27243. static CollisionsEpsilon: number;
  27244. /**
  27245. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27246. */
  27247. static ShadersRepository: string;
  27248. /**
  27249. * Method called to create the default loading screen.
  27250. * This can be overriden in your own app.
  27251. * @param canvas The rendering canvas element
  27252. * @returns The loading screen
  27253. */
  27254. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27255. /**
  27256. * Method called to create the default rescale post process on each engine.
  27257. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27258. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  27259. /**
  27260. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27261. */
  27262. forcePOTTextures: boolean;
  27263. /**
  27264. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27265. */
  27266. isFullscreen: boolean;
  27267. /**
  27268. * Gets a boolean indicating if the pointer is currently locked
  27269. */
  27270. isPointerLock: boolean;
  27271. /**
  27272. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27273. */
  27274. cullBackFaces: boolean;
  27275. /**
  27276. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27277. */
  27278. renderEvenInBackground: boolean;
  27279. /**
  27280. * Gets or sets a boolean indicating that cache can be kept between frames
  27281. */
  27282. preventCacheWipeBetweenFrames: boolean;
  27283. /**
  27284. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27285. **/
  27286. enableOfflineSupport: boolean;
  27287. /**
  27288. * 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)
  27289. **/
  27290. disableManifestCheck: boolean;
  27291. /**
  27292. * Gets the list of created scenes
  27293. */
  27294. scenes: Scene[];
  27295. /**
  27296. * Event raised when a new scene is created
  27297. */
  27298. onNewSceneAddedObservable: Observable<Scene>;
  27299. /**
  27300. * Gets the list of created postprocesses
  27301. */
  27302. postProcesses: PostProcess[];
  27303. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27304. validateShaderPrograms: boolean;
  27305. /**
  27306. * Observable event triggered each time the rendering canvas is resized
  27307. */
  27308. onResizeObservable: Observable<Engine>;
  27309. /**
  27310. * Observable event triggered each time the canvas loses focus
  27311. */
  27312. onCanvasBlurObservable: Observable<Engine>;
  27313. /**
  27314. * Observable event triggered each time the canvas gains focus
  27315. */
  27316. onCanvasFocusObservable: Observable<Engine>;
  27317. /**
  27318. * Observable event triggered each time the canvas receives pointerout event
  27319. */
  27320. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27321. /**
  27322. * Observable event triggered before each texture is initialized
  27323. */
  27324. onBeforeTextureInitObservable: Observable<Texture>;
  27325. /**
  27326. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27327. */
  27328. disableUniformBuffers: boolean;
  27329. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  27330. /**
  27331. * Gets a boolean indicating that the engine supports uniform buffers
  27332. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27333. */
  27334. readonly supportsUniformBuffers: boolean;
  27335. /**
  27336. * Observable raised when the engine begins a new frame
  27337. */
  27338. onBeginFrameObservable: Observable<Engine>;
  27339. /**
  27340. * If set, will be used to request the next animation frame for the render loop
  27341. */
  27342. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27343. /**
  27344. * Observable raised when the engine ends the current frame
  27345. */
  27346. onEndFrameObservable: Observable<Engine>;
  27347. /**
  27348. * Observable raised when the engine is about to compile a shader
  27349. */
  27350. onBeforeShaderCompilationObservable: Observable<Engine>;
  27351. /**
  27352. * Observable raised when the engine has jsut compiled a shader
  27353. */
  27354. onAfterShaderCompilationObservable: Observable<Engine>;
  27355. /** @hidden */ private _gl: WebGLRenderingContext;
  27356. private _renderingCanvas;
  27357. private _windowIsBackground;
  27358. private _webGLVersion;
  27359. protected _highPrecisionShadersAllowed: boolean;
  27360. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27361. /**
  27362. * Gets a boolean indicating that only power of 2 textures are supported
  27363. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27364. */
  27365. readonly needPOTTextures: boolean;
  27366. /** @hidden */ private _badOS: boolean;
  27367. /** @hidden */ private _badDesktopOS: boolean;
  27368. /**
  27369. * Gets the audio engine
  27370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27371. * @ignorenaming
  27372. */
  27373. static audioEngine: IAudioEngine;
  27374. /**
  27375. * Default AudioEngine factory responsible of creating the Audio Engine.
  27376. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27377. */
  27378. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27379. /**
  27380. * Default offline support factory responsible of creating a tool used to store data locally.
  27381. * By default, this will create a Database object if the workload has been embedded.
  27382. */
  27383. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27384. private _onFocus;
  27385. private _onBlur;
  27386. private _onCanvasPointerOut;
  27387. private _onCanvasBlur;
  27388. private _onCanvasFocus;
  27389. private _onFullscreenChange;
  27390. private _onPointerLockChange;
  27391. private _hardwareScalingLevel;
  27392. /** @hidden */ private _caps: EngineCapabilities;
  27393. private _pointerLockRequested;
  27394. private _isStencilEnable;
  27395. private _colorWrite;
  27396. private _loadingScreen;
  27397. /** @hidden */ private _drawCalls: PerfCounter;
  27398. private _glVersion;
  27399. private _glRenderer;
  27400. private _glVendor;
  27401. private _videoTextureSupported;
  27402. private _renderingQueueLaunched;
  27403. private _activeRenderLoops;
  27404. private _deterministicLockstep;
  27405. private _lockstepMaxSteps;
  27406. /**
  27407. * Observable signaled when a context lost event is raised
  27408. */
  27409. onContextLostObservable: Observable<Engine>;
  27410. /**
  27411. * Observable signaled when a context restored event is raised
  27412. */
  27413. onContextRestoredObservable: Observable<Engine>;
  27414. private _onContextLost;
  27415. private _onContextRestored;
  27416. private _contextWasLost;
  27417. /** @hidden */ private _doNotHandleContextLost: boolean;
  27418. /**
  27419. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27421. */
  27422. doNotHandleContextLost: boolean;
  27423. private _performanceMonitor;
  27424. private _fps;
  27425. private _deltaTime;
  27426. /**
  27427. * Turn this value on if you want to pause FPS computation when in background
  27428. */
  27429. disablePerformanceMonitorInBackground: boolean;
  27430. /**
  27431. * Gets the performance monitor attached to this engine
  27432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27433. */
  27434. readonly performanceMonitor: PerformanceMonitor;
  27435. /**
  27436. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27437. */
  27438. disableVertexArrayObjects: boolean;
  27439. /** @hidden */
  27440. protected _depthCullingState: _DepthCullingState;
  27441. /** @hidden */
  27442. protected _stencilState: _StencilState;
  27443. /** @hidden */
  27444. protected _alphaState: _AlphaState;
  27445. /** @hidden */
  27446. protected _alphaMode: number;
  27447. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  27448. /** @hidden */
  27449. protected _activeChannel: number;
  27450. private _currentTextureChannel;
  27451. /** @hidden */
  27452. protected _boundTexturesCache: {
  27453. [key: string]: Nullable<InternalTexture>;
  27454. };
  27455. /** @hidden */
  27456. protected _currentEffect: Nullable<Effect>;
  27457. /** @hidden */
  27458. protected _currentProgram: Nullable<WebGLProgram>;
  27459. private _compiledEffects;
  27460. private _vertexAttribArraysEnabled;
  27461. /** @hidden */
  27462. protected _cachedViewport: Nullable<Viewport>;
  27463. private _cachedVertexArrayObject;
  27464. /** @hidden */
  27465. protected _cachedVertexBuffers: any;
  27466. /** @hidden */
  27467. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27468. /** @hidden */
  27469. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27470. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  27471. private _uintIndicesCurrentlySet;
  27472. private _currentBoundBuffer;
  27473. /** @hidden */
  27474. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27475. private _currentBufferPointers;
  27476. private _currentInstanceLocations;
  27477. private _currentInstanceBuffers;
  27478. private _textureUnits;
  27479. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27480. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27481. private _rescalePostProcess;
  27482. private _dummyFramebuffer;
  27483. private _externalData;
  27484. /** @hidden */ private _bindedRenderFunction: any;
  27485. private _vaoRecordInProgress;
  27486. private _mustWipeVertexAttributes;
  27487. private _emptyTexture;
  27488. private _emptyCubeTexture;
  27489. private _emptyTexture3D;
  27490. /** @hidden */ private _frameHandler: number;
  27491. private _nextFreeTextureSlots;
  27492. private _maxSimultaneousTextures;
  27493. private _activeRequests;
  27494. private _texturesSupported;
  27495. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  27496. /**
  27497. * Gets the list of texture formats supported
  27498. */
  27499. readonly texturesSupported: Array<string>;
  27500. /**
  27501. * Gets the list of texture formats in use
  27502. */
  27503. readonly textureFormatInUse: Nullable<string>;
  27504. /**
  27505. * Gets the current viewport
  27506. */
  27507. readonly currentViewport: Nullable<Viewport>;
  27508. /**
  27509. * Gets the default empty texture
  27510. */
  27511. readonly emptyTexture: InternalTexture;
  27512. /**
  27513. * Gets the default empty 3D texture
  27514. */
  27515. readonly emptyTexture3D: InternalTexture;
  27516. /**
  27517. * Gets the default empty cube texture
  27518. */
  27519. readonly emptyCubeTexture: InternalTexture;
  27520. /**
  27521. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27522. */
  27523. readonly premultipliedAlpha: boolean;
  27524. /**
  27525. * Creates a new engine
  27526. * @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
  27527. * @param antialias defines enable antialiasing (default: false)
  27528. * @param options defines further options to be sent to the getContext() function
  27529. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27530. */
  27531. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27532. /**
  27533. * Initializes a webVR display and starts listening to display change events
  27534. * The onVRDisplayChangedObservable will be notified upon these changes
  27535. * @returns The onVRDisplayChangedObservable
  27536. */
  27537. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27538. /** @hidden */ private _prepareVRComponent(): void;
  27539. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27540. /** @hidden */ private _submitVRFrame(): void;
  27541. /**
  27542. * Call this function to leave webVR mode
  27543. * Will do nothing if webVR is not supported or if there is no webVR device
  27544. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27545. */
  27546. disableVR(): void;
  27547. /**
  27548. * Gets a boolean indicating that the system is in VR mode and is presenting
  27549. * @returns true if VR mode is engaged
  27550. */
  27551. isVRPresenting(): boolean;
  27552. /** @hidden */ private _requestVRFrame(): void;
  27553. private _disableTouchAction;
  27554. private _rebuildInternalTextures;
  27555. private _rebuildEffects;
  27556. /**
  27557. * Gets a boolean indicating if all created effects are ready
  27558. * @returns true if all effects are ready
  27559. */
  27560. areAllEffectsReady(): boolean;
  27561. private _rebuildBuffers;
  27562. private _initGLContext;
  27563. /**
  27564. * Gets version of the current webGL context
  27565. */
  27566. readonly webGLVersion: number;
  27567. /**
  27568. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27569. */
  27570. readonly isStencilEnable: boolean;
  27571. /** @hidden */ private _prepareWorkingCanvas(): void;
  27572. /**
  27573. * Reset the texture cache to empty state
  27574. */
  27575. resetTextureCache(): void;
  27576. /**
  27577. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27578. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27579. * @returns true if engine is in deterministic lock step mode
  27580. */
  27581. isDeterministicLockStep(): boolean;
  27582. /**
  27583. * Gets the max steps when engine is running in deterministic lock step
  27584. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27585. * @returns the max steps
  27586. */
  27587. getLockstepMaxSteps(): number;
  27588. /**
  27589. * Gets an object containing information about the current webGL context
  27590. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27591. */
  27592. getGlInfo(): {
  27593. vendor: string;
  27594. renderer: string;
  27595. version: string;
  27596. };
  27597. /**
  27598. * Gets current aspect ratio
  27599. * @param camera defines the camera to use to get the aspect ratio
  27600. * @param useScreen defines if screen size must be used (or the current render target if any)
  27601. * @returns a number defining the aspect ratio
  27602. */
  27603. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27604. /**
  27605. * Gets current screen aspect ratio
  27606. * @returns a number defining the aspect ratio
  27607. */
  27608. getScreenAspectRatio(): number;
  27609. /**
  27610. * Gets the current render width
  27611. * @param useScreen defines if screen size must be used (or the current render target if any)
  27612. * @returns a number defining the current render width
  27613. */
  27614. getRenderWidth(useScreen?: boolean): number;
  27615. /**
  27616. * Gets the current render height
  27617. * @param useScreen defines if screen size must be used (or the current render target if any)
  27618. * @returns a number defining the current render height
  27619. */
  27620. getRenderHeight(useScreen?: boolean): number;
  27621. /**
  27622. * Gets the HTML canvas attached with the current webGL context
  27623. * @returns a HTML canvas
  27624. */
  27625. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27626. /**
  27627. * Gets the client rect of the HTML canvas attached with the current webGL context
  27628. * @returns a client rectanglee
  27629. */
  27630. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27631. /**
  27632. * Defines the hardware scaling level.
  27633. * By default the hardware scaling level is computed from the window device ratio.
  27634. * 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.
  27635. * @param level defines the level to use
  27636. */
  27637. setHardwareScalingLevel(level: number): void;
  27638. /**
  27639. * Gets the current hardware scaling level.
  27640. * By default the hardware scaling level is computed from the window device ratio.
  27641. * 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.
  27642. * @returns a number indicating the current hardware scaling level
  27643. */
  27644. getHardwareScalingLevel(): number;
  27645. /**
  27646. * Gets the list of loaded textures
  27647. * @returns an array containing all loaded textures
  27648. */
  27649. getLoadedTexturesCache(): InternalTexture[];
  27650. /**
  27651. * Gets the object containing all engine capabilities
  27652. * @returns the EngineCapabilities object
  27653. */
  27654. getCaps(): EngineCapabilities;
  27655. /**
  27656. * Gets the current depth function
  27657. * @returns a number defining the depth function
  27658. */
  27659. getDepthFunction(): Nullable<number>;
  27660. /**
  27661. * Sets the current depth function
  27662. * @param depthFunc defines the function to use
  27663. */
  27664. setDepthFunction(depthFunc: number): void;
  27665. /**
  27666. * Sets the current depth function to GREATER
  27667. */
  27668. setDepthFunctionToGreater(): void;
  27669. /**
  27670. * Sets the current depth function to GEQUAL
  27671. */
  27672. setDepthFunctionToGreaterOrEqual(): void;
  27673. /**
  27674. * Sets the current depth function to LESS
  27675. */
  27676. setDepthFunctionToLess(): void;
  27677. private _cachedStencilBuffer;
  27678. private _cachedStencilFunction;
  27679. private _cachedStencilMask;
  27680. private _cachedStencilOperationPass;
  27681. private _cachedStencilOperationFail;
  27682. private _cachedStencilOperationDepthFail;
  27683. private _cachedStencilReference;
  27684. /**
  27685. * Caches the the state of the stencil buffer
  27686. */
  27687. cacheStencilState(): void;
  27688. /**
  27689. * Restores the state of the stencil buffer
  27690. */
  27691. restoreStencilState(): void;
  27692. /**
  27693. * Sets the current depth function to LEQUAL
  27694. */
  27695. setDepthFunctionToLessOrEqual(): void;
  27696. /**
  27697. * Gets a boolean indicating if stencil buffer is enabled
  27698. * @returns the current stencil buffer state
  27699. */
  27700. getStencilBuffer(): boolean;
  27701. /**
  27702. * Enable or disable the stencil buffer
  27703. * @param enable defines if the stencil buffer must be enabled or disabled
  27704. */
  27705. setStencilBuffer(enable: boolean): void;
  27706. /**
  27707. * Gets the current stencil mask
  27708. * @returns a number defining the new stencil mask to use
  27709. */
  27710. getStencilMask(): number;
  27711. /**
  27712. * Sets the current stencil mask
  27713. * @param mask defines the new stencil mask to use
  27714. */
  27715. setStencilMask(mask: number): void;
  27716. /**
  27717. * Gets the current stencil function
  27718. * @returns a number defining the stencil function to use
  27719. */
  27720. getStencilFunction(): number;
  27721. /**
  27722. * Gets the current stencil reference value
  27723. * @returns a number defining the stencil reference value to use
  27724. */
  27725. getStencilFunctionReference(): number;
  27726. /**
  27727. * Gets the current stencil mask
  27728. * @returns a number defining the stencil mask to use
  27729. */
  27730. getStencilFunctionMask(): number;
  27731. /**
  27732. * Sets the current stencil function
  27733. * @param stencilFunc defines the new stencil function to use
  27734. */
  27735. setStencilFunction(stencilFunc: number): void;
  27736. /**
  27737. * Sets the current stencil reference
  27738. * @param reference defines the new stencil reference to use
  27739. */
  27740. setStencilFunctionReference(reference: number): void;
  27741. /**
  27742. * Sets the current stencil mask
  27743. * @param mask defines the new stencil mask to use
  27744. */
  27745. setStencilFunctionMask(mask: number): void;
  27746. /**
  27747. * Gets the current stencil operation when stencil fails
  27748. * @returns a number defining stencil operation to use when stencil fails
  27749. */
  27750. getStencilOperationFail(): number;
  27751. /**
  27752. * Gets the current stencil operation when depth fails
  27753. * @returns a number defining stencil operation to use when depth fails
  27754. */
  27755. getStencilOperationDepthFail(): number;
  27756. /**
  27757. * Gets the current stencil operation when stencil passes
  27758. * @returns a number defining stencil operation to use when stencil passes
  27759. */
  27760. getStencilOperationPass(): number;
  27761. /**
  27762. * Sets the stencil operation to use when stencil fails
  27763. * @param operation defines the stencil operation to use when stencil fails
  27764. */
  27765. setStencilOperationFail(operation: number): void;
  27766. /**
  27767. * Sets the stencil operation to use when depth fails
  27768. * @param operation defines the stencil operation to use when depth fails
  27769. */
  27770. setStencilOperationDepthFail(operation: number): void;
  27771. /**
  27772. * Sets the stencil operation to use when stencil passes
  27773. * @param operation defines the stencil operation to use when stencil passes
  27774. */
  27775. setStencilOperationPass(operation: number): void;
  27776. /**
  27777. * Sets a boolean indicating if the dithering state is enabled or disabled
  27778. * @param value defines the dithering state
  27779. */
  27780. setDitheringState(value: boolean): void;
  27781. /**
  27782. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27783. * @param value defines the rasterizer state
  27784. */
  27785. setRasterizerState(value: boolean): void;
  27786. /**
  27787. * stop executing a render loop function and remove it from the execution array
  27788. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27789. */
  27790. stopRenderLoop(renderFunction?: () => void): void;
  27791. /** @hidden */ private _renderLoop(): void;
  27792. /**
  27793. * Register and execute a render loop. The engine can have more than one render function
  27794. * @param renderFunction defines the function to continuously execute
  27795. */
  27796. runRenderLoop(renderFunction: () => void): void;
  27797. /**
  27798. * Toggle full screen mode
  27799. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27800. */
  27801. switchFullscreen(requestPointerLock: boolean): void;
  27802. /**
  27803. * Enters full screen mode
  27804. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27805. */
  27806. enterFullscreen(requestPointerLock: boolean): void;
  27807. /**
  27808. * Exits full screen mode
  27809. */
  27810. exitFullscreen(): void;
  27811. /**
  27812. * Enters Pointerlock mode
  27813. */
  27814. enterPointerlock(): void;
  27815. /**
  27816. * Exits Pointerlock mode
  27817. */
  27818. exitPointerlock(): void;
  27819. /**
  27820. * Clear the current render buffer or the current render target (if any is set up)
  27821. * @param color defines the color to use
  27822. * @param backBuffer defines if the back buffer must be cleared
  27823. * @param depth defines if the depth buffer must be cleared
  27824. * @param stencil defines if the stencil buffer must be cleared
  27825. */
  27826. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27827. /**
  27828. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27829. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27830. * @param y defines the y-coordinate of the corner of the clear rectangle
  27831. * @param width defines the width of the clear rectangle
  27832. * @param height defines the height of the clear rectangle
  27833. * @param clearColor defines the clear color
  27834. */
  27835. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27836. /**
  27837. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27838. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27839. * @param y defines the y-coordinate of the corner of the clear rectangle
  27840. * @param width defines the width of the clear rectangle
  27841. * @param height defines the height of the clear rectangle
  27842. */
  27843. enableScissor(x: number, y: number, width: number, height: number): void;
  27844. /**
  27845. * Disable previously set scissor test rectangle
  27846. */
  27847. disableScissor(): void;
  27848. private _viewportCached;
  27849. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  27850. /**
  27851. * Set the WebGL's viewport
  27852. * @param viewport defines the viewport element to be used
  27853. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27854. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27855. */
  27856. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27857. /**
  27858. * Directly set the WebGL Viewport
  27859. * @param x defines the x coordinate of the viewport (in screen space)
  27860. * @param y defines the y coordinate of the viewport (in screen space)
  27861. * @param width defines the width of the viewport (in screen space)
  27862. * @param height defines the height of the viewport (in screen space)
  27863. * @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
  27864. */
  27865. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27866. /**
  27867. * Begin a new frame
  27868. */
  27869. beginFrame(): void;
  27870. /**
  27871. * Enf the current frame
  27872. */
  27873. endFrame(): void;
  27874. /**
  27875. * Resize the view according to the canvas' size
  27876. */
  27877. resize(): void;
  27878. /**
  27879. * Force a specific size of the canvas
  27880. * @param width defines the new canvas' width
  27881. * @param height defines the new canvas' height
  27882. */
  27883. setSize(width: number, height: number): void;
  27884. /**
  27885. * Binds the frame buffer to the specified texture.
  27886. * @param texture The texture to render to or null for the default canvas
  27887. * @param faceIndex The face of the texture to render to in case of cube texture
  27888. * @param requiredWidth The width of the target to render to
  27889. * @param requiredHeight The height of the target to render to
  27890. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27891. * @param depthStencilTexture The depth stencil texture to use to render
  27892. * @param lodLevel defines le lod level to bind to the frame buffer
  27893. */
  27894. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27895. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27896. /**
  27897. * Unbind the current render target texture from the webGL context
  27898. * @param texture defines the render target texture to unbind
  27899. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27900. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27901. */
  27902. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27903. /**
  27904. * Force the mipmap generation for the given render target texture
  27905. * @param texture defines the render target texture to use
  27906. */
  27907. generateMipMapsForCubemap(texture: InternalTexture): void;
  27908. /**
  27909. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27910. */
  27911. flushFramebuffer(): void;
  27912. /**
  27913. * Unbind the current render target and bind the default framebuffer
  27914. */
  27915. restoreDefaultFramebuffer(): void;
  27916. /**
  27917. * Create an uniform buffer
  27918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27919. * @param elements defines the content of the uniform buffer
  27920. * @returns the webGL uniform buffer
  27921. */
  27922. createUniformBuffer(elements: FloatArray): DataBuffer;
  27923. /**
  27924. * Create a dynamic uniform buffer
  27925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27926. * @param elements defines the content of the uniform buffer
  27927. * @returns the webGL uniform buffer
  27928. */
  27929. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27930. /**
  27931. * Update an existing uniform buffer
  27932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27933. * @param uniformBuffer defines the target uniform buffer
  27934. * @param elements defines the content to update
  27935. * @param offset defines the offset in the uniform buffer where update should start
  27936. * @param count defines the size of the data to update
  27937. */
  27938. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27939. private _resetVertexBufferBinding;
  27940. /**
  27941. * Creates a vertex buffer
  27942. * @param data the data for the vertex buffer
  27943. * @returns the new WebGL static buffer
  27944. */
  27945. createVertexBuffer(data: DataArray): DataBuffer;
  27946. /**
  27947. * Creates a dynamic vertex buffer
  27948. * @param data the data for the dynamic vertex buffer
  27949. * @returns the new WebGL dynamic buffer
  27950. */
  27951. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27952. /**
  27953. * Update a dynamic index buffer
  27954. * @param indexBuffer defines the target index buffer
  27955. * @param indices defines the data to update
  27956. * @param offset defines the offset in the target index buffer where update should start
  27957. */
  27958. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27959. /**
  27960. * Updates a dynamic vertex buffer.
  27961. * @param vertexBuffer the vertex buffer to update
  27962. * @param data the data used to update the vertex buffer
  27963. * @param byteOffset the byte offset of the data
  27964. * @param byteLength the byte length of the data
  27965. */
  27966. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27967. private _resetIndexBufferBinding;
  27968. /**
  27969. * Creates a new index buffer
  27970. * @param indices defines the content of the index buffer
  27971. * @param updatable defines if the index buffer must be updatable
  27972. * @returns a new webGL buffer
  27973. */
  27974. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27975. /**
  27976. * Bind a webGL buffer to the webGL context
  27977. * @param buffer defines the buffer to bind
  27978. */
  27979. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27980. /**
  27981. * Bind an uniform buffer to the current webGL context
  27982. * @param buffer defines the buffer to bind
  27983. */
  27984. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27985. /**
  27986. * Bind a buffer to the current webGL context at a given location
  27987. * @param buffer defines the buffer to bind
  27988. * @param location defines the index where to bind the buffer
  27989. */
  27990. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27991. /**
  27992. * Bind a specific block at a given index in a specific shader program
  27993. * @param pipelineContext defines the pipeline context to use
  27994. * @param blockName defines the block name
  27995. * @param index defines the index where to bind the block
  27996. */
  27997. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27998. private bindIndexBuffer;
  27999. private bindBuffer;
  28000. /**
  28001. * update the bound buffer with the given data
  28002. * @param data defines the data to update
  28003. */
  28004. updateArrayBuffer(data: Float32Array): void;
  28005. private _vertexAttribPointer;
  28006. private _bindIndexBufferWithCache;
  28007. private _bindVertexBuffersAttributes;
  28008. /**
  28009. * Records a vertex array object
  28010. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28011. * @param vertexBuffers defines the list of vertex buffers to store
  28012. * @param indexBuffer defines the index buffer to store
  28013. * @param effect defines the effect to store
  28014. * @returns the new vertex array object
  28015. */
  28016. recordVertexArrayObject(vertexBuffers: {
  28017. [key: string]: VertexBuffer;
  28018. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28019. /**
  28020. * Bind a specific vertex array object
  28021. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28022. * @param vertexArrayObject defines the vertex array object to bind
  28023. * @param indexBuffer defines the index buffer to bind
  28024. */
  28025. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28026. /**
  28027. * Bind webGl buffers directly to the webGL context
  28028. * @param vertexBuffer defines the vertex buffer to bind
  28029. * @param indexBuffer defines the index buffer to bind
  28030. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28031. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28032. * @param effect defines the effect associated with the vertex buffer
  28033. */
  28034. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28035. private _unbindVertexArrayObject;
  28036. /**
  28037. * Bind a list of vertex buffers to the webGL context
  28038. * @param vertexBuffers defines the list of vertex buffers to bind
  28039. * @param indexBuffer defines the index buffer to bind
  28040. * @param effect defines the effect associated with the vertex buffers
  28041. */
  28042. bindBuffers(vertexBuffers: {
  28043. [key: string]: Nullable<VertexBuffer>;
  28044. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28045. /**
  28046. * Unbind all instance attributes
  28047. */
  28048. unbindInstanceAttributes(): void;
  28049. /**
  28050. * Release and free the memory of a vertex array object
  28051. * @param vao defines the vertex array object to delete
  28052. */
  28053. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28054. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  28055. /**
  28056. * Creates a webGL buffer to use with instanciation
  28057. * @param capacity defines the size of the buffer
  28058. * @returns the webGL buffer
  28059. */
  28060. createInstancesBuffer(capacity: number): DataBuffer;
  28061. /**
  28062. * Delete a webGL buffer used with instanciation
  28063. * @param buffer defines the webGL buffer to delete
  28064. */
  28065. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28066. /**
  28067. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28068. * @param instancesBuffer defines the webGL buffer to update and bind
  28069. * @param data defines the data to store in the buffer
  28070. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28071. */
  28072. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28073. /**
  28074. * Apply all cached states (depth, culling, stencil and alpha)
  28075. */
  28076. applyStates(): void;
  28077. /**
  28078. * Send a draw order
  28079. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28080. * @param indexStart defines the starting index
  28081. * @param indexCount defines the number of index to draw
  28082. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28083. */
  28084. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28085. /**
  28086. * Draw a list of points
  28087. * @param verticesStart defines the index of first vertex to draw
  28088. * @param verticesCount defines the count of vertices to draw
  28089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28090. */
  28091. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28092. /**
  28093. * Draw a list of unindexed primitives
  28094. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28095. * @param verticesStart defines the index of first vertex to draw
  28096. * @param verticesCount defines the count of vertices to draw
  28097. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28098. */
  28099. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28100. /**
  28101. * Draw a list of indexed primitives
  28102. * @param fillMode defines the primitive to use
  28103. * @param indexStart defines the starting index
  28104. * @param indexCount defines the number of index to draw
  28105. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28106. */
  28107. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28108. /**
  28109. * Draw a list of unindexed primitives
  28110. * @param fillMode defines the primitive to use
  28111. * @param verticesStart defines the index of first vertex to draw
  28112. * @param verticesCount defines the count of vertices to draw
  28113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28114. */
  28115. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28116. private _drawMode;
  28117. /** @hidden */ private _releaseEffect(effect: Effect): void;
  28118. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28119. /**
  28120. * Create a new effect (used to store vertex/fragment shaders)
  28121. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28122. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28123. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28124. * @param samplers defines an array of string used to represent textures
  28125. * @param defines defines the string containing the defines to use to compile the shaders
  28126. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28127. * @param onCompiled defines a function to call when the effect creation is successful
  28128. * @param onError defines a function to call when the effect creation has failed
  28129. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28130. * @returns the new Effect
  28131. */
  28132. 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;
  28133. private _compileShader;
  28134. private _compileRawShader;
  28135. /**
  28136. * Directly creates a webGL program
  28137. * @param pipelineContext defines the pipeline context to attach to
  28138. * @param vertexCode defines the vertex shader code to use
  28139. * @param fragmentCode defines the fragment shader code to use
  28140. * @param context defines the webGL context to use (if not set, the current one will be used)
  28141. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28142. * @returns the new webGL program
  28143. */
  28144. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28145. /**
  28146. * Creates a webGL program
  28147. * @param pipelineContext defines the pipeline context to attach to
  28148. * @param vertexCode defines the vertex shader code to use
  28149. * @param fragmentCode defines the fragment shader code to use
  28150. * @param defines defines the string containing the defines to use to compile the shaders
  28151. * @param context defines the webGL context to use (if not set, the current one will be used)
  28152. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28153. * @returns the new webGL program
  28154. */
  28155. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28156. /**
  28157. * Creates a new pipeline context
  28158. * @returns the new pipeline
  28159. */
  28160. createPipelineContext(): WebGLPipelineContext;
  28161. private _createShaderProgram;
  28162. private _finalizePipelineContext;
  28163. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28164. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28165. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28166. /**
  28167. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28168. * @param pipelineContext defines the pipeline context to use
  28169. * @param uniformsNames defines the list of uniform names
  28170. * @returns an array of webGL uniform locations
  28171. */
  28172. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28173. /**
  28174. * Gets the lsit of active attributes for a given webGL program
  28175. * @param pipelineContext defines the pipeline context to use
  28176. * @param attributesNames defines the list of attribute names to get
  28177. * @returns an array of indices indicating the offset of each attribute
  28178. */
  28179. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28180. /**
  28181. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28182. * @param effect defines the effect to activate
  28183. */
  28184. enableEffect(effect: Nullable<Effect>): void;
  28185. /**
  28186. * Set the value of an uniform to an array of int32
  28187. * @param uniform defines the webGL uniform location where to store the value
  28188. * @param array defines the array of int32 to store
  28189. */
  28190. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28191. /**
  28192. * Set the value of an uniform to an array of int32 (stored as vec2)
  28193. * @param uniform defines the webGL uniform location where to store the value
  28194. * @param array defines the array of int32 to store
  28195. */
  28196. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28197. /**
  28198. * Set the value of an uniform to an array of int32 (stored as vec3)
  28199. * @param uniform defines the webGL uniform location where to store the value
  28200. * @param array defines the array of int32 to store
  28201. */
  28202. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28203. /**
  28204. * Set the value of an uniform to an array of int32 (stored as vec4)
  28205. * @param uniform defines the webGL uniform location where to store the value
  28206. * @param array defines the array of int32 to store
  28207. */
  28208. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28209. /**
  28210. * Set the value of an uniform to an array of float32
  28211. * @param uniform defines the webGL uniform location where to store the value
  28212. * @param array defines the array of float32 to store
  28213. */
  28214. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28215. /**
  28216. * Set the value of an uniform to an array of float32 (stored as vec2)
  28217. * @param uniform defines the webGL uniform location where to store the value
  28218. * @param array defines the array of float32 to store
  28219. */
  28220. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28221. /**
  28222. * Set the value of an uniform to an array of float32 (stored as vec3)
  28223. * @param uniform defines the webGL uniform location where to store the value
  28224. * @param array defines the array of float32 to store
  28225. */
  28226. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28227. /**
  28228. * Set the value of an uniform to an array of float32 (stored as vec4)
  28229. * @param uniform defines the webGL uniform location where to store the value
  28230. * @param array defines the array of float32 to store
  28231. */
  28232. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28233. /**
  28234. * Set the value of an uniform to an array of number
  28235. * @param uniform defines the webGL uniform location where to store the value
  28236. * @param array defines the array of number to store
  28237. */
  28238. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28239. /**
  28240. * Set the value of an uniform to an array of number (stored as vec2)
  28241. * @param uniform defines the webGL uniform location where to store the value
  28242. * @param array defines the array of number to store
  28243. */
  28244. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28245. /**
  28246. * Set the value of an uniform to an array of number (stored as vec3)
  28247. * @param uniform defines the webGL uniform location where to store the value
  28248. * @param array defines the array of number to store
  28249. */
  28250. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28251. /**
  28252. * Set the value of an uniform to an array of number (stored as vec4)
  28253. * @param uniform defines the webGL uniform location where to store the value
  28254. * @param array defines the array of number to store
  28255. */
  28256. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28257. /**
  28258. * Set the value of an uniform to an array of float32 (stored as matrices)
  28259. * @param uniform defines the webGL uniform location where to store the value
  28260. * @param matrices defines the array of float32 to store
  28261. */
  28262. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28263. /**
  28264. * Set the value of an uniform to a matrix
  28265. * @param uniform defines the webGL uniform location where to store the value
  28266. * @param matrix defines the matrix to store
  28267. */
  28268. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28269. /**
  28270. * Set the value of an uniform to a matrix (3x3)
  28271. * @param uniform defines the webGL uniform location where to store the value
  28272. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28273. */
  28274. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28275. /**
  28276. * Set the value of an uniform to a matrix (2x2)
  28277. * @param uniform defines the webGL uniform location where to store the value
  28278. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28279. */
  28280. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28281. /**
  28282. * Set the value of an uniform to a number (int)
  28283. * @param uniform defines the webGL uniform location where to store the value
  28284. * @param value defines the int number to store
  28285. */
  28286. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28287. /**
  28288. * Set the value of an uniform to a number (float)
  28289. * @param uniform defines the webGL uniform location where to store the value
  28290. * @param value defines the float number to store
  28291. */
  28292. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28293. /**
  28294. * Set the value of an uniform to a vec2
  28295. * @param uniform defines the webGL uniform location where to store the value
  28296. * @param x defines the 1st component of the value
  28297. * @param y defines the 2nd component of the value
  28298. */
  28299. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28300. /**
  28301. * Set the value of an uniform to a vec3
  28302. * @param uniform defines the webGL uniform location where to store the value
  28303. * @param x defines the 1st component of the value
  28304. * @param y defines the 2nd component of the value
  28305. * @param z defines the 3rd component of the value
  28306. */
  28307. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28308. /**
  28309. * Set the value of an uniform to a boolean
  28310. * @param uniform defines the webGL uniform location where to store the value
  28311. * @param bool defines the boolean to store
  28312. */
  28313. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28314. /**
  28315. * Set the value of an uniform to a vec4
  28316. * @param uniform defines the webGL uniform location where to store the value
  28317. * @param x defines the 1st component of the value
  28318. * @param y defines the 2nd component of the value
  28319. * @param z defines the 3rd component of the value
  28320. * @param w defines the 4th component of the value
  28321. */
  28322. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28323. /**
  28324. * Set the value of an uniform to a Color3
  28325. * @param uniform defines the webGL uniform location where to store the value
  28326. * @param color3 defines the color to store
  28327. */
  28328. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28329. /**
  28330. * Set the value of an uniform to a Color3 and an alpha value
  28331. * @param uniform defines the webGL uniform location where to store the value
  28332. * @param color3 defines the color to store
  28333. * @param alpha defines the alpha component to store
  28334. */
  28335. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28336. /**
  28337. * Sets a Color4 on a uniform variable
  28338. * @param uniform defines the uniform location
  28339. * @param color4 defines the value to be set
  28340. */
  28341. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28342. /**
  28343. * Set various states to the webGL context
  28344. * @param culling defines backface culling state
  28345. * @param zOffset defines the value to apply to zOffset (0 by default)
  28346. * @param force defines if states must be applied even if cache is up to date
  28347. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28348. */
  28349. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28350. /**
  28351. * Set the z offset to apply to current rendering
  28352. * @param value defines the offset to apply
  28353. */
  28354. setZOffset(value: number): void;
  28355. /**
  28356. * Gets the current value of the zOffset
  28357. * @returns the current zOffset state
  28358. */
  28359. getZOffset(): number;
  28360. /**
  28361. * Enable or disable depth buffering
  28362. * @param enable defines the state to set
  28363. */
  28364. setDepthBuffer(enable: boolean): void;
  28365. /**
  28366. * Gets a boolean indicating if depth writing is enabled
  28367. * @returns the current depth writing state
  28368. */
  28369. getDepthWrite(): boolean;
  28370. /**
  28371. * Enable or disable depth writing
  28372. * @param enable defines the state to set
  28373. */
  28374. setDepthWrite(enable: boolean): void;
  28375. /**
  28376. * Enable or disable color writing
  28377. * @param enable defines the state to set
  28378. */
  28379. setColorWrite(enable: boolean): void;
  28380. /**
  28381. * Gets a boolean indicating if color writing is enabled
  28382. * @returns the current color writing state
  28383. */
  28384. getColorWrite(): boolean;
  28385. /**
  28386. * Sets alpha constants used by some alpha blending modes
  28387. * @param r defines the red component
  28388. * @param g defines the green component
  28389. * @param b defines the blue component
  28390. * @param a defines the alpha component
  28391. */
  28392. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28393. /**
  28394. * Sets the current alpha mode
  28395. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28396. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28397. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28398. */
  28399. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28400. /**
  28401. * Gets the current alpha mode
  28402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28403. * @returns the current alpha mode
  28404. */
  28405. getAlphaMode(): number;
  28406. /**
  28407. * Clears the list of texture accessible through engine.
  28408. * This can help preventing texture load conflict due to name collision.
  28409. */
  28410. clearInternalTexturesCache(): void;
  28411. /**
  28412. * Force the entire cache to be cleared
  28413. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28414. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28415. */
  28416. wipeCaches(bruteForce?: boolean): void;
  28417. /**
  28418. * Set the compressed texture format to use, based on the formats you have, and the formats
  28419. * supported by the hardware / browser.
  28420. *
  28421. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28422. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28423. * to API arguments needed to compressed textures. This puts the burden on the container
  28424. * generator to house the arcane code for determining these for current & future formats.
  28425. *
  28426. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28427. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28428. *
  28429. * Note: The result of this call is not taken into account when a texture is base64.
  28430. *
  28431. * @param formatsAvailable defines the list of those format families you have created
  28432. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28433. *
  28434. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28435. * @returns The extension selected.
  28436. */
  28437. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28438. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28439. min: number;
  28440. mag: number;
  28441. };
  28442. /** @hidden */ private _createTexture(): WebGLTexture;
  28443. /**
  28444. * Usually called from Texture.ts.
  28445. * Passed information to create a WebGLTexture
  28446. * @param urlArg defines a value which contains one of the following:
  28447. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28448. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28449. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28450. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28451. * @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)
  28452. * @param scene needed for loading to the correct scene
  28453. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28454. * @param onLoad optional callback to be called upon successful completion
  28455. * @param onError optional callback to be called upon failure
  28456. * @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
  28457. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28458. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28459. * @param forcedExtension defines the extension to use to pick the right loader
  28460. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28461. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28462. */
  28463. 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;
  28464. /**
  28465. * @hidden
  28466. * Rescales a texture
  28467. * @param source input texutre
  28468. * @param destination destination texture
  28469. * @param scene scene to use to render the resize
  28470. * @param internalFormat format to use when resizing
  28471. * @param onComplete callback to be called when resize has completed
  28472. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28473. private _unpackFlipYCached;
  28474. /**
  28475. * In case you are sharing the context with other applications, it might
  28476. * be interested to not cache the unpack flip y state to ensure a consistent
  28477. * value would be set.
  28478. */
  28479. enableUnpackFlipYCached: boolean;
  28480. /** @hidden */ private _unpackFlipY(value: boolean): void;
  28481. /** @hidden */ private _getUnpackAlignement(): number;
  28482. /**
  28483. * Creates a dynamic texture
  28484. * @param width defines the width of the texture
  28485. * @param height defines the height of the texture
  28486. * @param generateMipMaps defines if the engine should generate the mip levels
  28487. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28488. * @returns the dynamic texture inside an InternalTexture
  28489. */
  28490. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28491. /**
  28492. * Update the sampling mode of a given texture
  28493. * @param samplingMode defines the required sampling mode
  28494. * @param texture defines the texture to update
  28495. */
  28496. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28497. /**
  28498. * Update the content of a dynamic texture
  28499. * @param texture defines the texture to update
  28500. * @param canvas defines the canvas containing the source
  28501. * @param invertY defines if data must be stored with Y axis inverted
  28502. * @param premulAlpha defines if alpha is stored as premultiplied
  28503. * @param format defines the format of the data
  28504. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28505. */
  28506. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28507. /**
  28508. * Update a video texture
  28509. * @param texture defines the texture to update
  28510. * @param video defines the video element to use
  28511. * @param invertY defines if data must be stored with Y axis inverted
  28512. */
  28513. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28514. /**
  28515. * Updates a depth texture Comparison Mode and Function.
  28516. * If the comparison Function is equal to 0, the mode will be set to none.
  28517. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28518. * @param texture The texture to set the comparison function for
  28519. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28520. */
  28521. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28522. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28523. width: number;
  28524. height: number;
  28525. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28526. /**
  28527. * Creates a depth stencil texture.
  28528. * This is only available in WebGL 2 or with the depth texture extension available.
  28529. * @param size The size of face edge in the texture.
  28530. * @param options The options defining the texture.
  28531. * @returns The texture
  28532. */
  28533. createDepthStencilTexture(size: number | {
  28534. width: number;
  28535. height: number;
  28536. }, options: DepthTextureCreationOptions): InternalTexture;
  28537. /**
  28538. * Creates a depth stencil texture.
  28539. * This is only available in WebGL 2 or with the depth texture extension available.
  28540. * @param size The size of face edge in the texture.
  28541. * @param options The options defining the texture.
  28542. * @returns The texture
  28543. */
  28544. private _createDepthStencilTexture;
  28545. /**
  28546. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28547. * @param renderTarget The render target to set the frame buffer for
  28548. */
  28549. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28550. /**
  28551. * Creates a new render target texture
  28552. * @param size defines the size of the texture
  28553. * @param options defines the options used to create the texture
  28554. * @returns a new render target texture stored in an InternalTexture
  28555. */
  28556. createRenderTargetTexture(size: number | {
  28557. width: number;
  28558. height: number;
  28559. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28560. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28561. /**
  28562. * Updates the sample count of a render target texture
  28563. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28564. * @param texture defines the texture to update
  28565. * @param samples defines the sample count to set
  28566. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28567. */
  28568. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28569. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28570. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  28571. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28572. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28573. /**
  28574. * @hidden
  28575. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  28576. private _prepareWebGLTextureContinuation;
  28577. private _prepareWebGLTexture;
  28578. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28579. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  28580. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  28581. private setProgram;
  28582. private _boundUniforms;
  28583. /**
  28584. * Binds an effect to the webGL context
  28585. * @param effect defines the effect to bind
  28586. */
  28587. bindSamplers(effect: Effect): void;
  28588. private _activateCurrentTexture;
  28589. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28590. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28591. /**
  28592. * Sets a texture to the webGL context from a postprocess
  28593. * @param channel defines the channel to use
  28594. * @param postProcess defines the source postprocess
  28595. */
  28596. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28597. /**
  28598. * Binds the output of the passed in post process to the texture channel specified
  28599. * @param channel The channel the texture should be bound to
  28600. * @param postProcess The post process which's output should be bound
  28601. */
  28602. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28603. /**
  28604. * Unbind all textures from the webGL context
  28605. */
  28606. unbindAllTextures(): void;
  28607. /**
  28608. * Sets a texture to the according uniform.
  28609. * @param channel The texture channel
  28610. * @param uniform The uniform to set
  28611. * @param texture The texture to apply
  28612. */
  28613. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28614. /**
  28615. * Sets a depth stencil texture from a render target to the according uniform.
  28616. * @param channel The texture channel
  28617. * @param uniform The uniform to set
  28618. * @param texture The render target texture containing the depth stencil texture to apply
  28619. */
  28620. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28621. private _bindSamplerUniformToChannel;
  28622. private _getTextureWrapMode;
  28623. private _setTexture;
  28624. /**
  28625. * Sets an array of texture to the webGL context
  28626. * @param channel defines the channel where the texture array must be set
  28627. * @param uniform defines the associated uniform location
  28628. * @param textures defines the array of textures to bind
  28629. */
  28630. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28631. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28632. private _setTextureParameterFloat;
  28633. private _setTextureParameterInteger;
  28634. /**
  28635. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28636. * @param x defines the x coordinate of the rectangle where pixels must be read
  28637. * @param y defines the y coordinate of the rectangle where pixels must be read
  28638. * @param width defines the width of the rectangle where pixels must be read
  28639. * @param height defines the height of the rectangle where pixels must be read
  28640. * @returns a Uint8Array containing RGBA colors
  28641. */
  28642. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28643. /**
  28644. * Add an externaly attached data from its key.
  28645. * This method call will fail and return false, if such key already exists.
  28646. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28647. * @param key the unique key that identifies the data
  28648. * @param data the data object to associate to the key for this Engine instance
  28649. * @return true if no such key were already present and the data was added successfully, false otherwise
  28650. */
  28651. addExternalData<T>(key: string, data: T): boolean;
  28652. /**
  28653. * Get an externaly attached data from its key
  28654. * @param key the unique key that identifies the data
  28655. * @return the associated data, if present (can be null), or undefined if not present
  28656. */
  28657. getExternalData<T>(key: string): T;
  28658. /**
  28659. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28660. * @param key the unique key that identifies the data
  28661. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28662. * @return the associated data, can be null if the factory returned null.
  28663. */
  28664. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28665. /**
  28666. * Remove an externaly attached data from the Engine instance
  28667. * @param key the unique key that identifies the data
  28668. * @return true if the data was successfully removed, false if it doesn't exist
  28669. */
  28670. removeExternalData(key: string): boolean;
  28671. /**
  28672. * Unbind all vertex attributes from the webGL context
  28673. */
  28674. unbindAllAttributes(): void;
  28675. /**
  28676. * 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
  28677. */
  28678. releaseEffects(): void;
  28679. /**
  28680. * Dispose and release all associated resources
  28681. */
  28682. dispose(): void;
  28683. /**
  28684. * Display the loading screen
  28685. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28686. */
  28687. displayLoadingUI(): void;
  28688. /**
  28689. * Hide the loading screen
  28690. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28691. */
  28692. hideLoadingUI(): void;
  28693. /**
  28694. * Gets the current loading screen object
  28695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28696. */
  28697. /**
  28698. * Sets the current loading screen object
  28699. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28700. */
  28701. loadingScreen: ILoadingScreen;
  28702. /**
  28703. * Sets the current loading screen text
  28704. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28705. */
  28706. loadingUIText: string;
  28707. /**
  28708. * Sets the current loading screen background color
  28709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28710. */
  28711. loadingUIBackgroundColor: string;
  28712. /**
  28713. * Attach a new callback raised when context lost event is fired
  28714. * @param callback defines the callback to call
  28715. */
  28716. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28717. /**
  28718. * Attach a new callback raised when context restored event is fired
  28719. * @param callback defines the callback to call
  28720. */
  28721. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28722. /**
  28723. * Gets the source code of the vertex shader associated with a specific webGL program
  28724. * @param program defines the program to use
  28725. * @returns a string containing the source code of the vertex shader associated with the program
  28726. */
  28727. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28728. /**
  28729. * Gets the source code of the fragment shader associated with a specific webGL program
  28730. * @param program defines the program to use
  28731. * @returns a string containing the source code of the fragment shader associated with the program
  28732. */
  28733. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28734. /**
  28735. * Get the current error code of the webGL context
  28736. * @returns the error code
  28737. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28738. */
  28739. getError(): number;
  28740. /**
  28741. * Gets the current framerate
  28742. * @returns a number representing the framerate
  28743. */
  28744. getFps(): number;
  28745. /**
  28746. * Gets the time spent between current and previous frame
  28747. * @returns a number representing the delta time in ms
  28748. */
  28749. getDeltaTime(): number;
  28750. private _measureFps;
  28751. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28752. private _canRenderToFloatFramebuffer;
  28753. private _canRenderToHalfFloatFramebuffer;
  28754. private _canRenderToFramebuffer;
  28755. /** @hidden */ private _getWebGLTextureType(type: number): number;
  28756. /** @hidden */ private _getInternalFormat(format: number): number;
  28757. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28758. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  28759. /** @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;
  28760. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28761. /**
  28762. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28763. * @returns true if the engine can be created
  28764. * @ignorenaming
  28765. */
  28766. static isSupported(): boolean;
  28767. }
  28768. }
  28769. declare module BABYLON {
  28770. /**
  28771. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28772. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28773. */
  28774. export class EffectFallbacks {
  28775. private _defines;
  28776. private _currentRank;
  28777. private _maxRank;
  28778. private _mesh;
  28779. /**
  28780. * Removes the fallback from the bound mesh.
  28781. */
  28782. unBindMesh(): void;
  28783. /**
  28784. * Adds a fallback on the specified property.
  28785. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28786. * @param define The name of the define in the shader
  28787. */
  28788. addFallback(rank: number, define: string): void;
  28789. /**
  28790. * Sets the mesh to use CPU skinning when needing to fallback.
  28791. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28792. * @param mesh The mesh to use the fallbacks.
  28793. */
  28794. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28795. /**
  28796. * Checks to see if more fallbacks are still availible.
  28797. */
  28798. readonly isMoreFallbacks: boolean;
  28799. /**
  28800. * Removes the defines that should be removed when falling back.
  28801. * @param currentDefines defines the current define statements for the shader.
  28802. * @param effect defines the current effect we try to compile
  28803. * @returns The resulting defines with defines of the current rank removed.
  28804. */
  28805. reduce(currentDefines: string, effect: Effect): string;
  28806. }
  28807. /**
  28808. * Options to be used when creating an effect.
  28809. */
  28810. export class EffectCreationOptions {
  28811. /**
  28812. * Atrributes that will be used in the shader.
  28813. */
  28814. attributes: string[];
  28815. /**
  28816. * Uniform varible names that will be set in the shader.
  28817. */
  28818. uniformsNames: string[];
  28819. /**
  28820. * Uniform buffer varible names that will be set in the shader.
  28821. */
  28822. uniformBuffersNames: string[];
  28823. /**
  28824. * Sampler texture variable names that will be set in the shader.
  28825. */
  28826. samplers: string[];
  28827. /**
  28828. * Define statements that will be set in the shader.
  28829. */
  28830. defines: any;
  28831. /**
  28832. * Possible fallbacks for this effect to improve performance when needed.
  28833. */
  28834. fallbacks: Nullable<EffectFallbacks>;
  28835. /**
  28836. * Callback that will be called when the shader is compiled.
  28837. */
  28838. onCompiled: Nullable<(effect: Effect) => void>;
  28839. /**
  28840. * Callback that will be called if an error occurs during shader compilation.
  28841. */
  28842. onError: Nullable<(effect: Effect, errors: string) => void>;
  28843. /**
  28844. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28845. */
  28846. indexParameters: any;
  28847. /**
  28848. * Max number of lights that can be used in the shader.
  28849. */
  28850. maxSimultaneousLights: number;
  28851. /**
  28852. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28853. */
  28854. transformFeedbackVaryings: Nullable<string[]>;
  28855. }
  28856. /**
  28857. * Effect containing vertex and fragment shader that can be executed on an object.
  28858. */
  28859. export class Effect implements IDisposable {
  28860. /**
  28861. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28862. */
  28863. static ShadersRepository: string;
  28864. /**
  28865. * Name of the effect.
  28866. */
  28867. name: any;
  28868. /**
  28869. * String container all the define statements that should be set on the shader.
  28870. */
  28871. defines: string;
  28872. /**
  28873. * Callback that will be called when the shader is compiled.
  28874. */
  28875. onCompiled: Nullable<(effect: Effect) => void>;
  28876. /**
  28877. * Callback that will be called if an error occurs during shader compilation.
  28878. */
  28879. onError: Nullable<(effect: Effect, errors: string) => void>;
  28880. /**
  28881. * Callback that will be called when effect is bound.
  28882. */
  28883. onBind: Nullable<(effect: Effect) => void>;
  28884. /**
  28885. * Unique ID of the effect.
  28886. */
  28887. uniqueId: number;
  28888. /**
  28889. * Observable that will be called when the shader is compiled.
  28890. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28891. */
  28892. onCompileObservable: Observable<Effect>;
  28893. /**
  28894. * Observable that will be called if an error occurs during shader compilation.
  28895. */
  28896. onErrorObservable: Observable<Effect>;
  28897. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  28898. /**
  28899. * Observable that will be called when effect is bound.
  28900. */
  28901. readonly onBindObservable: Observable<Effect>;
  28902. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  28903. private static _uniqueIdSeed;
  28904. private _engine;
  28905. private _uniformBuffersNames;
  28906. private _uniformsNames;
  28907. private _samplerList;
  28908. private _samplers;
  28909. private _isReady;
  28910. private _compilationError;
  28911. private _attributesNames;
  28912. private _attributes;
  28913. private _uniforms;
  28914. /**
  28915. * Key for the effect.
  28916. * @hidden
  28917. */ private _key: string;
  28918. private _indexParameters;
  28919. private _fallbacks;
  28920. private _vertexSourceCode;
  28921. private _fragmentSourceCode;
  28922. private _vertexSourceCodeOverride;
  28923. private _fragmentSourceCodeOverride;
  28924. private _transformFeedbackVaryings;
  28925. /**
  28926. * Compiled shader to webGL program.
  28927. * @hidden
  28928. */ private _pipelineContext: Nullable<IPipelineContext>;
  28929. private _valueCache;
  28930. private static _baseCache;
  28931. /**
  28932. * Instantiates an effect.
  28933. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28934. * @param baseName Name of the effect.
  28935. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28936. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28937. * @param samplers List of sampler variables that will be passed to the shader.
  28938. * @param engine Engine to be used to render the effect
  28939. * @param defines Define statements to be added to the shader.
  28940. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28941. * @param onCompiled Callback that will be called when the shader is compiled.
  28942. * @param onError Callback that will be called if an error occurs during shader compilation.
  28943. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28944. */
  28945. 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);
  28946. private _useFinalCode;
  28947. /**
  28948. * Unique key for this effect
  28949. */
  28950. readonly key: string;
  28951. /**
  28952. * If the effect has been compiled and prepared.
  28953. * @returns if the effect is compiled and prepared.
  28954. */
  28955. isReady(): boolean;
  28956. /**
  28957. * The engine the effect was initialized with.
  28958. * @returns the engine.
  28959. */
  28960. getEngine(): Engine;
  28961. /**
  28962. * The pipeline context for this effect
  28963. * @returns the associated pipeline context
  28964. */
  28965. getPipelineContext(): Nullable<IPipelineContext>;
  28966. /**
  28967. * The set of names of attribute variables for the shader.
  28968. * @returns An array of attribute names.
  28969. */
  28970. getAttributesNames(): string[];
  28971. /**
  28972. * Returns the attribute at the given index.
  28973. * @param index The index of the attribute.
  28974. * @returns The location of the attribute.
  28975. */
  28976. getAttributeLocation(index: number): number;
  28977. /**
  28978. * Returns the attribute based on the name of the variable.
  28979. * @param name of the attribute to look up.
  28980. * @returns the attribute location.
  28981. */
  28982. getAttributeLocationByName(name: string): number;
  28983. /**
  28984. * The number of attributes.
  28985. * @returns the numnber of attributes.
  28986. */
  28987. getAttributesCount(): number;
  28988. /**
  28989. * Gets the index of a uniform variable.
  28990. * @param uniformName of the uniform to look up.
  28991. * @returns the index.
  28992. */
  28993. getUniformIndex(uniformName: string): number;
  28994. /**
  28995. * Returns the attribute based on the name of the variable.
  28996. * @param uniformName of the uniform to look up.
  28997. * @returns the location of the uniform.
  28998. */
  28999. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29000. /**
  29001. * Returns an array of sampler variable names
  29002. * @returns The array of sampler variable neames.
  29003. */
  29004. getSamplers(): string[];
  29005. /**
  29006. * The error from the last compilation.
  29007. * @returns the error string.
  29008. */
  29009. getCompilationError(): string;
  29010. /**
  29011. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29012. * @param func The callback to be used.
  29013. */
  29014. executeWhenCompiled(func: (effect: Effect) => void): void;
  29015. private _checkIsReady;
  29016. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29017. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29018. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29019. /**
  29020. * Recompiles the webGL program
  29021. * @param vertexSourceCode The source code for the vertex shader.
  29022. * @param fragmentSourceCode The source code for the fragment shader.
  29023. * @param onCompiled Callback called when completed.
  29024. * @param onError Callback called on error.
  29025. * @hidden
  29026. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29027. /**
  29028. * Prepares the effect
  29029. * @hidden
  29030. */ private _prepareEffect(): void;
  29031. /**
  29032. * Checks if the effect is supported. (Must be called after compilation)
  29033. */
  29034. readonly isSupported: boolean;
  29035. /**
  29036. * Binds a texture to the engine to be used as output of the shader.
  29037. * @param channel Name of the output variable.
  29038. * @param texture Texture to bind.
  29039. * @hidden
  29040. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  29041. /**
  29042. * Sets a texture on the engine to be used in the shader.
  29043. * @param channel Name of the sampler variable.
  29044. * @param texture Texture to set.
  29045. */
  29046. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29047. /**
  29048. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29049. * @param channel Name of the sampler variable.
  29050. * @param texture Texture to set.
  29051. */
  29052. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29053. /**
  29054. * Sets an array of textures on the engine to be used in the shader.
  29055. * @param channel Name of the variable.
  29056. * @param textures Textures to set.
  29057. */
  29058. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29059. /**
  29060. * 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)
  29061. * @param channel Name of the sampler variable.
  29062. * @param postProcess Post process to get the input texture from.
  29063. */
  29064. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29065. /**
  29066. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29067. * 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)
  29068. * @param channel Name of the sampler variable.
  29069. * @param postProcess Post process to get the output texture from.
  29070. */
  29071. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29072. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29073. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29074. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29075. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29076. /**
  29077. * Binds a buffer to a uniform.
  29078. * @param buffer Buffer to bind.
  29079. * @param name Name of the uniform variable to bind to.
  29080. */
  29081. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29082. /**
  29083. * Binds block to a uniform.
  29084. * @param blockName Name of the block to bind.
  29085. * @param index Index to bind.
  29086. */
  29087. bindUniformBlock(blockName: string, index: number): void;
  29088. /**
  29089. * Sets an interger value on a uniform variable.
  29090. * @param uniformName Name of the variable.
  29091. * @param value Value to be set.
  29092. * @returns this effect.
  29093. */
  29094. setInt(uniformName: string, value: number): Effect;
  29095. /**
  29096. * Sets an int array on a uniform variable.
  29097. * @param uniformName Name of the variable.
  29098. * @param array array to be set.
  29099. * @returns this effect.
  29100. */
  29101. setIntArray(uniformName: string, array: Int32Array): Effect;
  29102. /**
  29103. * 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)
  29104. * @param uniformName Name of the variable.
  29105. * @param array array to be set.
  29106. * @returns this effect.
  29107. */
  29108. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29109. /**
  29110. * 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)
  29111. * @param uniformName Name of the variable.
  29112. * @param array array to be set.
  29113. * @returns this effect.
  29114. */
  29115. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29116. /**
  29117. * 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)
  29118. * @param uniformName Name of the variable.
  29119. * @param array array to be set.
  29120. * @returns this effect.
  29121. */
  29122. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29123. /**
  29124. * Sets an float array on a uniform variable.
  29125. * @param uniformName Name of the variable.
  29126. * @param array array to be set.
  29127. * @returns this effect.
  29128. */
  29129. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29130. /**
  29131. * 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)
  29132. * @param uniformName Name of the variable.
  29133. * @param array array to be set.
  29134. * @returns this effect.
  29135. */
  29136. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29137. /**
  29138. * 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)
  29139. * @param uniformName Name of the variable.
  29140. * @param array array to be set.
  29141. * @returns this effect.
  29142. */
  29143. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29144. /**
  29145. * 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)
  29146. * @param uniformName Name of the variable.
  29147. * @param array array to be set.
  29148. * @returns this effect.
  29149. */
  29150. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29151. /**
  29152. * Sets an array on a uniform variable.
  29153. * @param uniformName Name of the variable.
  29154. * @param array array to be set.
  29155. * @returns this effect.
  29156. */
  29157. setArray(uniformName: string, array: number[]): Effect;
  29158. /**
  29159. * 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)
  29160. * @param uniformName Name of the variable.
  29161. * @param array array to be set.
  29162. * @returns this effect.
  29163. */
  29164. setArray2(uniformName: string, array: number[]): Effect;
  29165. /**
  29166. * 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)
  29167. * @param uniformName Name of the variable.
  29168. * @param array array to be set.
  29169. * @returns this effect.
  29170. */
  29171. setArray3(uniformName: string, array: number[]): Effect;
  29172. /**
  29173. * 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)
  29174. * @param uniformName Name of the variable.
  29175. * @param array array to be set.
  29176. * @returns this effect.
  29177. */
  29178. setArray4(uniformName: string, array: number[]): Effect;
  29179. /**
  29180. * Sets matrices on a uniform variable.
  29181. * @param uniformName Name of the variable.
  29182. * @param matrices matrices to be set.
  29183. * @returns this effect.
  29184. */
  29185. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29186. /**
  29187. * Sets matrix on a uniform variable.
  29188. * @param uniformName Name of the variable.
  29189. * @param matrix matrix to be set.
  29190. * @returns this effect.
  29191. */
  29192. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29193. /**
  29194. * 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)
  29195. * @param uniformName Name of the variable.
  29196. * @param matrix matrix to be set.
  29197. * @returns this effect.
  29198. */
  29199. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29200. /**
  29201. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29202. * @param uniformName Name of the variable.
  29203. * @param matrix matrix to be set.
  29204. * @returns this effect.
  29205. */
  29206. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29207. /**
  29208. * Sets a float on a uniform variable.
  29209. * @param uniformName Name of the variable.
  29210. * @param value value to be set.
  29211. * @returns this effect.
  29212. */
  29213. setFloat(uniformName: string, value: number): Effect;
  29214. /**
  29215. * Sets a boolean on a uniform variable.
  29216. * @param uniformName Name of the variable.
  29217. * @param bool value to be set.
  29218. * @returns this effect.
  29219. */
  29220. setBool(uniformName: string, bool: boolean): Effect;
  29221. /**
  29222. * Sets a Vector2 on a uniform variable.
  29223. * @param uniformName Name of the variable.
  29224. * @param vector2 vector2 to be set.
  29225. * @returns this effect.
  29226. */
  29227. setVector2(uniformName: string, vector2: Vector2): Effect;
  29228. /**
  29229. * Sets a float2 on a uniform variable.
  29230. * @param uniformName Name of the variable.
  29231. * @param x First float in float2.
  29232. * @param y Second float in float2.
  29233. * @returns this effect.
  29234. */
  29235. setFloat2(uniformName: string, x: number, y: number): Effect;
  29236. /**
  29237. * Sets a Vector3 on a uniform variable.
  29238. * @param uniformName Name of the variable.
  29239. * @param vector3 Value to be set.
  29240. * @returns this effect.
  29241. */
  29242. setVector3(uniformName: string, vector3: Vector3): Effect;
  29243. /**
  29244. * Sets a float3 on a uniform variable.
  29245. * @param uniformName Name of the variable.
  29246. * @param x First float in float3.
  29247. * @param y Second float in float3.
  29248. * @param z Third float in float3.
  29249. * @returns this effect.
  29250. */
  29251. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29252. /**
  29253. * Sets a Vector4 on a uniform variable.
  29254. * @param uniformName Name of the variable.
  29255. * @param vector4 Value to be set.
  29256. * @returns this effect.
  29257. */
  29258. setVector4(uniformName: string, vector4: Vector4): Effect;
  29259. /**
  29260. * Sets a float4 on a uniform variable.
  29261. * @param uniformName Name of the variable.
  29262. * @param x First float in float4.
  29263. * @param y Second float in float4.
  29264. * @param z Third float in float4.
  29265. * @param w Fourth float in float4.
  29266. * @returns this effect.
  29267. */
  29268. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29269. /**
  29270. * Sets a Color3 on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param color3 Value to be set.
  29273. * @returns this effect.
  29274. */
  29275. setColor3(uniformName: string, color3: Color3): Effect;
  29276. /**
  29277. * Sets a Color4 on a uniform variable.
  29278. * @param uniformName Name of the variable.
  29279. * @param color3 Value to be set.
  29280. * @param alpha Alpha value to be set.
  29281. * @returns this effect.
  29282. */
  29283. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29284. /**
  29285. * Sets a Color4 on a uniform variable
  29286. * @param uniformName defines the name of the variable
  29287. * @param color4 defines the value to be set
  29288. * @returns this effect.
  29289. */
  29290. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29291. /** Release all associated resources */
  29292. dispose(): void;
  29293. /**
  29294. * This function will add a new shader to the shader store
  29295. * @param name the name of the shader
  29296. * @param pixelShader optional pixel shader content
  29297. * @param vertexShader optional vertex shader content
  29298. */
  29299. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29300. /**
  29301. * Store of each shader (The can be looked up using effect.key)
  29302. */
  29303. static ShadersStore: {
  29304. [key: string]: string;
  29305. };
  29306. /**
  29307. * Store of each included file for a shader (The can be looked up using effect.key)
  29308. */
  29309. static IncludesShadersStore: {
  29310. [key: string]: string;
  29311. };
  29312. /**
  29313. * Resets the cache of effects.
  29314. */
  29315. static ResetCache(): void;
  29316. }
  29317. }
  29318. declare module BABYLON {
  29319. /**
  29320. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29321. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29322. * 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;
  29323. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29324. */
  29325. export class ColorCurves {
  29326. private _dirty;
  29327. private _tempColor;
  29328. private _globalCurve;
  29329. private _highlightsCurve;
  29330. private _midtonesCurve;
  29331. private _shadowsCurve;
  29332. private _positiveCurve;
  29333. private _negativeCurve;
  29334. private _globalHue;
  29335. private _globalDensity;
  29336. private _globalSaturation;
  29337. private _globalExposure;
  29338. /**
  29339. * Gets the global Hue value.
  29340. * 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).
  29341. */
  29342. /**
  29343. * Sets the global Hue value.
  29344. * 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).
  29345. */
  29346. globalHue: number;
  29347. /**
  29348. * Gets the global Density value.
  29349. * 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.
  29350. * Values less than zero provide a filter of opposite hue.
  29351. */
  29352. /**
  29353. * Sets the global Density value.
  29354. * 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.
  29355. * Values less than zero provide a filter of opposite hue.
  29356. */
  29357. globalDensity: number;
  29358. /**
  29359. * Gets the global Saturation value.
  29360. * 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.
  29361. */
  29362. /**
  29363. * Sets the global Saturation value.
  29364. * 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.
  29365. */
  29366. globalSaturation: number;
  29367. /**
  29368. * Gets the global Exposure value.
  29369. * 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.
  29370. */
  29371. /**
  29372. * Sets the global Exposure value.
  29373. * 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.
  29374. */
  29375. globalExposure: number;
  29376. private _highlightsHue;
  29377. private _highlightsDensity;
  29378. private _highlightsSaturation;
  29379. private _highlightsExposure;
  29380. /**
  29381. * Gets the highlights Hue value.
  29382. * 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).
  29383. */
  29384. /**
  29385. * Sets the highlights Hue value.
  29386. * 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).
  29387. */
  29388. highlightsHue: number;
  29389. /**
  29390. * Gets the highlights Density value.
  29391. * 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.
  29392. * Values less than zero provide a filter of opposite hue.
  29393. */
  29394. /**
  29395. * Sets the highlights Density value.
  29396. * 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.
  29397. * Values less than zero provide a filter of opposite hue.
  29398. */
  29399. highlightsDensity: number;
  29400. /**
  29401. * Gets the highlights Saturation value.
  29402. * 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.
  29403. */
  29404. /**
  29405. * Sets the highlights Saturation value.
  29406. * 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.
  29407. */
  29408. highlightsSaturation: number;
  29409. /**
  29410. * Gets the highlights Exposure value.
  29411. * 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.
  29412. */
  29413. /**
  29414. * Sets the highlights Exposure value.
  29415. * 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.
  29416. */
  29417. highlightsExposure: number;
  29418. private _midtonesHue;
  29419. private _midtonesDensity;
  29420. private _midtonesSaturation;
  29421. private _midtonesExposure;
  29422. /**
  29423. * Gets the midtones Hue value.
  29424. * 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).
  29425. */
  29426. /**
  29427. * Sets the midtones Hue value.
  29428. * 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).
  29429. */
  29430. midtonesHue: number;
  29431. /**
  29432. * Gets the midtones Density value.
  29433. * 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.
  29434. * Values less than zero provide a filter of opposite hue.
  29435. */
  29436. /**
  29437. * Sets the midtones Density value.
  29438. * 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.
  29439. * Values less than zero provide a filter of opposite hue.
  29440. */
  29441. midtonesDensity: number;
  29442. /**
  29443. * Gets the midtones Saturation value.
  29444. * 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.
  29445. */
  29446. /**
  29447. * Sets the midtones Saturation value.
  29448. * 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.
  29449. */
  29450. midtonesSaturation: number;
  29451. /**
  29452. * Gets the midtones Exposure value.
  29453. * 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.
  29454. */
  29455. /**
  29456. * Sets the midtones Exposure value.
  29457. * 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.
  29458. */
  29459. midtonesExposure: number;
  29460. private _shadowsHue;
  29461. private _shadowsDensity;
  29462. private _shadowsSaturation;
  29463. private _shadowsExposure;
  29464. /**
  29465. * Gets the shadows Hue value.
  29466. * 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).
  29467. */
  29468. /**
  29469. * Sets the shadows Hue value.
  29470. * 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).
  29471. */
  29472. shadowsHue: number;
  29473. /**
  29474. * Gets the shadows Density value.
  29475. * 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.
  29476. * Values less than zero provide a filter of opposite hue.
  29477. */
  29478. /**
  29479. * Sets the shadows Density value.
  29480. * 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.
  29481. * Values less than zero provide a filter of opposite hue.
  29482. */
  29483. shadowsDensity: number;
  29484. /**
  29485. * Gets the shadows Saturation value.
  29486. * 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.
  29487. */
  29488. /**
  29489. * Sets the shadows Saturation value.
  29490. * 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.
  29491. */
  29492. shadowsSaturation: number;
  29493. /**
  29494. * Gets the shadows Exposure value.
  29495. * 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.
  29496. */
  29497. /**
  29498. * Sets the shadows Exposure value.
  29499. * 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.
  29500. */
  29501. shadowsExposure: number;
  29502. /**
  29503. * Returns the class name
  29504. * @returns The class name
  29505. */
  29506. getClassName(): string;
  29507. /**
  29508. * Binds the color curves to the shader.
  29509. * @param colorCurves The color curve to bind
  29510. * @param effect The effect to bind to
  29511. * @param positiveUniform The positive uniform shader parameter
  29512. * @param neutralUniform The neutral uniform shader parameter
  29513. * @param negativeUniform The negative uniform shader parameter
  29514. */
  29515. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29516. /**
  29517. * Prepare the list of uniforms associated with the ColorCurves effects.
  29518. * @param uniformsList The list of uniforms used in the effect
  29519. */
  29520. static PrepareUniforms(uniformsList: string[]): void;
  29521. /**
  29522. * Returns color grading data based on a hue, density, saturation and exposure value.
  29523. * @param filterHue The hue of the color filter.
  29524. * @param filterDensity The density of the color filter.
  29525. * @param saturation The saturation.
  29526. * @param exposure The exposure.
  29527. * @param result The result data container.
  29528. */
  29529. private getColorGradingDataToRef;
  29530. /**
  29531. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29532. * @param value The input slider value in range [-100,100].
  29533. * @returns Adjusted value.
  29534. */
  29535. private static applyColorGradingSliderNonlinear;
  29536. /**
  29537. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29538. * @param hue The hue (H) input.
  29539. * @param saturation The saturation (S) input.
  29540. * @param brightness The brightness (B) input.
  29541. * @result An RGBA color represented as Vector4.
  29542. */
  29543. private static fromHSBToRef;
  29544. /**
  29545. * Returns a value clamped between min and max
  29546. * @param value The value to clamp
  29547. * @param min The minimum of value
  29548. * @param max The maximum of value
  29549. * @returns The clamped value.
  29550. */
  29551. private static clamp;
  29552. /**
  29553. * Clones the current color curve instance.
  29554. * @return The cloned curves
  29555. */
  29556. clone(): ColorCurves;
  29557. /**
  29558. * Serializes the current color curve instance to a json representation.
  29559. * @return a JSON representation
  29560. */
  29561. serialize(): any;
  29562. /**
  29563. * Parses the color curve from a json representation.
  29564. * @param source the JSON source to parse
  29565. * @return The parsed curves
  29566. */
  29567. static Parse(source: any): ColorCurves;
  29568. }
  29569. }
  29570. declare module BABYLON {
  29571. /**
  29572. * Interface to follow in your material defines to integrate easily the
  29573. * Image proccessing functions.
  29574. * @hidden
  29575. */
  29576. export interface IImageProcessingConfigurationDefines {
  29577. IMAGEPROCESSING: boolean;
  29578. VIGNETTE: boolean;
  29579. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29580. VIGNETTEBLENDMODEOPAQUE: boolean;
  29581. TONEMAPPING: boolean;
  29582. TONEMAPPING_ACES: boolean;
  29583. CONTRAST: boolean;
  29584. EXPOSURE: boolean;
  29585. COLORCURVES: boolean;
  29586. COLORGRADING: boolean;
  29587. COLORGRADING3D: boolean;
  29588. SAMPLER3DGREENDEPTH: boolean;
  29589. SAMPLER3DBGRMAP: boolean;
  29590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29591. }
  29592. /**
  29593. * @hidden
  29594. */
  29595. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29596. IMAGEPROCESSING: boolean;
  29597. VIGNETTE: boolean;
  29598. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29599. VIGNETTEBLENDMODEOPAQUE: boolean;
  29600. TONEMAPPING: boolean;
  29601. TONEMAPPING_ACES: boolean;
  29602. CONTRAST: boolean;
  29603. COLORCURVES: boolean;
  29604. COLORGRADING: boolean;
  29605. COLORGRADING3D: boolean;
  29606. SAMPLER3DGREENDEPTH: boolean;
  29607. SAMPLER3DBGRMAP: boolean;
  29608. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29609. EXPOSURE: boolean;
  29610. constructor();
  29611. }
  29612. /**
  29613. * This groups together the common properties used for image processing either in direct forward pass
  29614. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29615. * or not.
  29616. */
  29617. export class ImageProcessingConfiguration {
  29618. /**
  29619. * Default tone mapping applied in BabylonJS.
  29620. */
  29621. static readonly TONEMAPPING_STANDARD: number;
  29622. /**
  29623. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29624. * to other engines rendering to increase portability.
  29625. */
  29626. static readonly TONEMAPPING_ACES: number;
  29627. /**
  29628. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29629. */
  29630. colorCurves: Nullable<ColorCurves>;
  29631. private _colorCurvesEnabled;
  29632. /**
  29633. * Gets wether the color curves effect is enabled.
  29634. */
  29635. /**
  29636. * Sets wether the color curves effect is enabled.
  29637. */
  29638. colorCurvesEnabled: boolean;
  29639. private _colorGradingTexture;
  29640. /**
  29641. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29642. */
  29643. /**
  29644. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29645. */
  29646. colorGradingTexture: Nullable<BaseTexture>;
  29647. private _colorGradingEnabled;
  29648. /**
  29649. * Gets wether the color grading effect is enabled.
  29650. */
  29651. /**
  29652. * Sets wether the color grading effect is enabled.
  29653. */
  29654. colorGradingEnabled: boolean;
  29655. private _colorGradingWithGreenDepth;
  29656. /**
  29657. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29658. */
  29659. /**
  29660. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29661. */
  29662. colorGradingWithGreenDepth: boolean;
  29663. private _colorGradingBGR;
  29664. /**
  29665. * Gets wether the color grading texture contains BGR values.
  29666. */
  29667. /**
  29668. * Sets wether the color grading texture contains BGR values.
  29669. */
  29670. colorGradingBGR: boolean;
  29671. /** @hidden */ private _exposure: number;
  29672. /**
  29673. * Gets the Exposure used in the effect.
  29674. */
  29675. /**
  29676. * Sets the Exposure used in the effect.
  29677. */
  29678. exposure: number;
  29679. private _toneMappingEnabled;
  29680. /**
  29681. * Gets wether the tone mapping effect is enabled.
  29682. */
  29683. /**
  29684. * Sets wether the tone mapping effect is enabled.
  29685. */
  29686. toneMappingEnabled: boolean;
  29687. private _toneMappingType;
  29688. /**
  29689. * Gets the type of tone mapping effect.
  29690. */
  29691. /**
  29692. * Sets the type of tone mapping effect used in BabylonJS.
  29693. */
  29694. toneMappingType: number;
  29695. protected _contrast: number;
  29696. /**
  29697. * Gets the contrast used in the effect.
  29698. */
  29699. /**
  29700. * Sets the contrast used in the effect.
  29701. */
  29702. contrast: number;
  29703. /**
  29704. * Vignette stretch size.
  29705. */
  29706. vignetteStretch: number;
  29707. /**
  29708. * Vignette centre X Offset.
  29709. */
  29710. vignetteCentreX: number;
  29711. /**
  29712. * Vignette centre Y Offset.
  29713. */
  29714. vignetteCentreY: number;
  29715. /**
  29716. * Vignette weight or intensity of the vignette effect.
  29717. */
  29718. vignetteWeight: number;
  29719. /**
  29720. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29721. * if vignetteEnabled is set to true.
  29722. */
  29723. vignetteColor: Color4;
  29724. /**
  29725. * Camera field of view used by the Vignette effect.
  29726. */
  29727. vignetteCameraFov: number;
  29728. private _vignetteBlendMode;
  29729. /**
  29730. * Gets the vignette blend mode allowing different kind of effect.
  29731. */
  29732. /**
  29733. * Sets the vignette blend mode allowing different kind of effect.
  29734. */
  29735. vignetteBlendMode: number;
  29736. private _vignetteEnabled;
  29737. /**
  29738. * Gets wether the vignette effect is enabled.
  29739. */
  29740. /**
  29741. * Sets wether the vignette effect is enabled.
  29742. */
  29743. vignetteEnabled: boolean;
  29744. private _applyByPostProcess;
  29745. /**
  29746. * Gets wether the image processing is applied through a post process or not.
  29747. */
  29748. /**
  29749. * Sets wether the image processing is applied through a post process or not.
  29750. */
  29751. applyByPostProcess: boolean;
  29752. private _isEnabled;
  29753. /**
  29754. * Gets wether the image processing is enabled or not.
  29755. */
  29756. /**
  29757. * Sets wether the image processing is enabled or not.
  29758. */
  29759. isEnabled: boolean;
  29760. /**
  29761. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29762. */
  29763. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29764. /**
  29765. * Method called each time the image processing information changes requires to recompile the effect.
  29766. */
  29767. protected _updateParameters(): void;
  29768. /**
  29769. * Gets the current class name.
  29770. * @return "ImageProcessingConfiguration"
  29771. */
  29772. getClassName(): string;
  29773. /**
  29774. * Prepare the list of uniforms associated with the Image Processing effects.
  29775. * @param uniforms The list of uniforms used in the effect
  29776. * @param defines the list of defines currently in use
  29777. */
  29778. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29779. /**
  29780. * Prepare the list of samplers associated with the Image Processing effects.
  29781. * @param samplersList The list of uniforms used in the effect
  29782. * @param defines the list of defines currently in use
  29783. */
  29784. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29785. /**
  29786. * Prepare the list of defines associated to the shader.
  29787. * @param defines the list of defines to complete
  29788. * @param forPostProcess Define if we are currently in post process mode or not
  29789. */
  29790. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29791. /**
  29792. * Returns true if all the image processing information are ready.
  29793. * @returns True if ready, otherwise, false
  29794. */
  29795. isReady(): boolean;
  29796. /**
  29797. * Binds the image processing to the shader.
  29798. * @param effect The effect to bind to
  29799. * @param aspectRatio Define the current aspect ratio of the effect
  29800. */
  29801. bind(effect: Effect, aspectRatio?: number): void;
  29802. /**
  29803. * Clones the current image processing instance.
  29804. * @return The cloned image processing
  29805. */
  29806. clone(): ImageProcessingConfiguration;
  29807. /**
  29808. * Serializes the current image processing instance to a json representation.
  29809. * @return a JSON representation
  29810. */
  29811. serialize(): any;
  29812. /**
  29813. * Parses the image processing from a json representation.
  29814. * @param source the JSON source to parse
  29815. * @return The parsed image processing
  29816. */
  29817. static Parse(source: any): ImageProcessingConfiguration;
  29818. private static _VIGNETTEMODE_MULTIPLY;
  29819. private static _VIGNETTEMODE_OPAQUE;
  29820. /**
  29821. * Used to apply the vignette as a mix with the pixel color.
  29822. */
  29823. static readonly VIGNETTEMODE_MULTIPLY: number;
  29824. /**
  29825. * Used to apply the vignette as a replacement of the pixel color.
  29826. */
  29827. static readonly VIGNETTEMODE_OPAQUE: number;
  29828. }
  29829. }
  29830. declare module BABYLON {
  29831. /**
  29832. * This represents all the required information to add a fresnel effect on a material:
  29833. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29834. */
  29835. export class FresnelParameters {
  29836. private _isEnabled;
  29837. /**
  29838. * Define if the fresnel effect is enable or not.
  29839. */
  29840. isEnabled: boolean;
  29841. /**
  29842. * Define the color used on edges (grazing angle)
  29843. */
  29844. leftColor: Color3;
  29845. /**
  29846. * Define the color used on center
  29847. */
  29848. rightColor: Color3;
  29849. /**
  29850. * Define bias applied to computed fresnel term
  29851. */
  29852. bias: number;
  29853. /**
  29854. * Defined the power exponent applied to fresnel term
  29855. */
  29856. power: number;
  29857. /**
  29858. * Clones the current fresnel and its valuues
  29859. * @returns a clone fresnel configuration
  29860. */
  29861. clone(): FresnelParameters;
  29862. /**
  29863. * Serializes the current fresnel parameters to a JSON representation.
  29864. * @return the JSON serialization
  29865. */
  29866. serialize(): any;
  29867. /**
  29868. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29869. * @param parsedFresnelParameters Define the JSON representation
  29870. * @returns the parsed parameters
  29871. */
  29872. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29873. }
  29874. }
  29875. declare module BABYLON {
  29876. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29877. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29878. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29879. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29880. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29881. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29882. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29883. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29884. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29885. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29886. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29887. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29888. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29889. /**
  29890. * Decorator used to define property that can be serialized as reference to a camera
  29891. * @param sourceName defines the name of the property to decorate
  29892. */
  29893. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29894. /**
  29895. * Class used to help serialization objects
  29896. */
  29897. export class SerializationHelper {
  29898. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29899. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29900. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29901. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29902. /**
  29903. * Appends the serialized animations from the source animations
  29904. * @param source Source containing the animations
  29905. * @param destination Target to store the animations
  29906. */
  29907. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29908. /**
  29909. * Static function used to serialized a specific entity
  29910. * @param entity defines the entity to serialize
  29911. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29912. * @returns a JSON compatible object representing the serialization of the entity
  29913. */
  29914. static Serialize<T>(entity: T, serializationObject?: any): any;
  29915. /**
  29916. * Creates a new entity from a serialization data object
  29917. * @param creationFunction defines a function used to instanciated the new entity
  29918. * @param source defines the source serialization data
  29919. * @param scene defines the hosting scene
  29920. * @param rootUrl defines the root url for resources
  29921. * @returns a new entity
  29922. */
  29923. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29924. /**
  29925. * Clones an object
  29926. * @param creationFunction defines the function used to instanciate the new object
  29927. * @param source defines the source object
  29928. * @returns the cloned object
  29929. */
  29930. static Clone<T>(creationFunction: () => T, source: T): T;
  29931. /**
  29932. * Instanciates a new object based on a source one (some data will be shared between both object)
  29933. * @param creationFunction defines the function used to instanciate the new object
  29934. * @param source defines the source object
  29935. * @returns the new object
  29936. */
  29937. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29938. }
  29939. }
  29940. declare module BABYLON {
  29941. /**
  29942. * This is the base class of all the camera used in the application.
  29943. * @see http://doc.babylonjs.com/features/cameras
  29944. */
  29945. export class Camera extends Node {
  29946. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29947. /**
  29948. * This is the default projection mode used by the cameras.
  29949. * It helps recreating a feeling of perspective and better appreciate depth.
  29950. * This is the best way to simulate real life cameras.
  29951. */
  29952. static readonly PERSPECTIVE_CAMERA: number;
  29953. /**
  29954. * This helps creating camera with an orthographic mode.
  29955. * 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.
  29956. */
  29957. static readonly ORTHOGRAPHIC_CAMERA: number;
  29958. /**
  29959. * This is the default FOV mode for perspective cameras.
  29960. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29961. */
  29962. static readonly FOVMODE_VERTICAL_FIXED: number;
  29963. /**
  29964. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29965. */
  29966. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29967. /**
  29968. * This specifies ther is no need for a camera rig.
  29969. * Basically only one eye is rendered corresponding to the camera.
  29970. */
  29971. static readonly RIG_MODE_NONE: number;
  29972. /**
  29973. * Simulates a camera Rig with one blue eye and one red eye.
  29974. * This can be use with 3d blue and red glasses.
  29975. */
  29976. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29977. /**
  29978. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29979. */
  29980. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29981. /**
  29982. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29983. */
  29984. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29985. /**
  29986. * Defines that both eyes of the camera will be rendered over under each other.
  29987. */
  29988. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29989. /**
  29990. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29991. */
  29992. static readonly RIG_MODE_VR: number;
  29993. /**
  29994. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29995. */
  29996. static readonly RIG_MODE_WEBVR: number;
  29997. /**
  29998. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29999. */
  30000. static readonly RIG_MODE_CUSTOM: number;
  30001. /**
  30002. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30003. */
  30004. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30005. /**
  30006. * Define the input manager associated with the camera.
  30007. */
  30008. inputs: CameraInputsManager<Camera>;
  30009. /** @hidden */ private _position: Vector3;
  30010. /**
  30011. * Define the current local position of the camera in the scene
  30012. */
  30013. position: Vector3;
  30014. /**
  30015. * The vector the camera should consider as up.
  30016. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30017. */
  30018. upVector: Vector3;
  30019. /**
  30020. * Define the current limit on the left side for an orthographic camera
  30021. * In scene unit
  30022. */
  30023. orthoLeft: Nullable<number>;
  30024. /**
  30025. * Define the current limit on the right side for an orthographic camera
  30026. * In scene unit
  30027. */
  30028. orthoRight: Nullable<number>;
  30029. /**
  30030. * Define the current limit on the bottom side for an orthographic camera
  30031. * In scene unit
  30032. */
  30033. orthoBottom: Nullable<number>;
  30034. /**
  30035. * Define the current limit on the top side for an orthographic camera
  30036. * In scene unit
  30037. */
  30038. orthoTop: Nullable<number>;
  30039. /**
  30040. * Field Of View is set in Radians. (default is 0.8)
  30041. */
  30042. fov: number;
  30043. /**
  30044. * Define the minimum distance the camera can see from.
  30045. * This is important to note that the depth buffer are not infinite and the closer it starts
  30046. * the more your scene might encounter depth fighting issue.
  30047. */
  30048. minZ: number;
  30049. /**
  30050. * Define the maximum distance the camera can see to.
  30051. * This is important to note that the depth buffer are not infinite and the further it end
  30052. * the more your scene might encounter depth fighting issue.
  30053. */
  30054. maxZ: number;
  30055. /**
  30056. * Define the default inertia of the camera.
  30057. * This helps giving a smooth feeling to the camera movement.
  30058. */
  30059. inertia: number;
  30060. /**
  30061. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30062. */
  30063. mode: number;
  30064. /**
  30065. * Define wether the camera is intermediate.
  30066. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30067. */
  30068. isIntermediate: boolean;
  30069. /**
  30070. * Define the viewport of the camera.
  30071. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30072. */
  30073. viewport: Viewport;
  30074. /**
  30075. * Restricts the camera to viewing objects with the same layerMask.
  30076. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30077. */
  30078. layerMask: number;
  30079. /**
  30080. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30081. */
  30082. fovMode: number;
  30083. /**
  30084. * Rig mode of the camera.
  30085. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30086. * This is normally controlled byt the camera themselves as internal use.
  30087. */
  30088. cameraRigMode: number;
  30089. /**
  30090. * Defines the distance between both "eyes" in case of a RIG
  30091. */
  30092. interaxialDistance: number;
  30093. /**
  30094. * Defines if stereoscopic rendering is done side by side or over under.
  30095. */
  30096. isStereoscopicSideBySide: boolean;
  30097. /**
  30098. * 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
  30099. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30100. * else in the scene.
  30101. */
  30102. customRenderTargets: RenderTargetTexture[];
  30103. /**
  30104. * When set, the camera will render to this render target instead of the default canvas
  30105. */
  30106. outputRenderTarget: Nullable<RenderTargetTexture>;
  30107. /**
  30108. * Observable triggered when the camera view matrix has changed.
  30109. */
  30110. onViewMatrixChangedObservable: Observable<Camera>;
  30111. /**
  30112. * Observable triggered when the camera Projection matrix has changed.
  30113. */
  30114. onProjectionMatrixChangedObservable: Observable<Camera>;
  30115. /**
  30116. * Observable triggered when the inputs have been processed.
  30117. */
  30118. onAfterCheckInputsObservable: Observable<Camera>;
  30119. /**
  30120. * Observable triggered when reset has been called and applied to the camera.
  30121. */
  30122. onRestoreStateObservable: Observable<Camera>;
  30123. /** @hidden */ private _cameraRigParams: any;
  30124. /** @hidden */ private _rigCameras: Camera[];
  30125. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  30126. protected _webvrViewMatrix: Matrix;
  30127. /** @hidden */ private _skipRendering: boolean;
  30128. /** @hidden */ private _projectionMatrix: Matrix;
  30129. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  30130. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  30131. protected _globalPosition: Vector3;
  30132. /** @hidden */ private _computedViewMatrix: Matrix;
  30133. private _doNotComputeProjectionMatrix;
  30134. private _transformMatrix;
  30135. private _frustumPlanes;
  30136. private _refreshFrustumPlanes;
  30137. private _storedFov;
  30138. private _stateStored;
  30139. /**
  30140. * Instantiates a new camera object.
  30141. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30142. * @see http://doc.babylonjs.com/features/cameras
  30143. * @param name Defines the name of the camera in the scene
  30144. * @param position Defines the position of the camera
  30145. * @param scene Defines the scene the camera belongs too
  30146. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30147. */
  30148. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30149. /**
  30150. * Store current camera state (fov, position, etc..)
  30151. * @returns the camera
  30152. */
  30153. storeState(): Camera;
  30154. /**
  30155. * Restores the camera state values if it has been stored. You must call storeState() first
  30156. */
  30157. protected _restoreStateValues(): boolean;
  30158. /**
  30159. * Restored camera state. You must call storeState() first.
  30160. * @returns true if restored and false otherwise
  30161. */
  30162. restoreState(): boolean;
  30163. /**
  30164. * Gets the class name of the camera.
  30165. * @returns the class name
  30166. */
  30167. getClassName(): string;
  30168. /** @hidden */ protected readonly _isCamera: boolean;
  30169. /**
  30170. * Gets a string representation of the camera useful for debug purpose.
  30171. * @param fullDetails Defines that a more verboe level of logging is required
  30172. * @returns the string representation
  30173. */
  30174. toString(fullDetails?: boolean): string;
  30175. /**
  30176. * Gets the current world space position of the camera.
  30177. */
  30178. readonly globalPosition: Vector3;
  30179. /**
  30180. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30181. * @returns the active meshe list
  30182. */
  30183. getActiveMeshes(): SmartArray<AbstractMesh>;
  30184. /**
  30185. * Check wether a mesh is part of the current active mesh list of the camera
  30186. * @param mesh Defines the mesh to check
  30187. * @returns true if active, false otherwise
  30188. */
  30189. isActiveMesh(mesh: Mesh): boolean;
  30190. /**
  30191. * Is this camera ready to be used/rendered
  30192. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30193. * @return true if the camera is ready
  30194. */
  30195. isReady(completeCheck?: boolean): boolean;
  30196. /** @hidden */ private _initCache(): void;
  30197. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  30198. /** @hidden */ private _isSynchronized(): boolean;
  30199. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  30200. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  30201. /**
  30202. * Attach the input controls to a specific dom element to get the input from.
  30203. * @param element Defines the element the controls should be listened from
  30204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30205. */
  30206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30207. /**
  30208. * Detach the current controls from the specified dom element.
  30209. * @param element Defines the element to stop listening the inputs from
  30210. */
  30211. detachControl(element: HTMLElement): void;
  30212. /**
  30213. * Update the camera state according to the different inputs gathered during the frame.
  30214. */
  30215. update(): void;
  30216. /** @hidden */ private _checkInputs(): void;
  30217. /** @hidden */
  30218. readonly rigCameras: Camera[];
  30219. /**
  30220. * Gets the post process used by the rig cameras
  30221. */
  30222. readonly rigPostProcess: Nullable<PostProcess>;
  30223. /**
  30224. * Internal, gets the first post proces.
  30225. * @returns the first post process to be run on this camera.
  30226. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  30227. private _cascadePostProcessesToRigCams;
  30228. /**
  30229. * Attach a post process to the camera.
  30230. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30231. * @param postProcess The post process to attach to the camera
  30232. * @param insertAt The position of the post process in case several of them are in use in the scene
  30233. * @returns the position the post process has been inserted at
  30234. */
  30235. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30236. /**
  30237. * Detach a post process to the camera.
  30238. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30239. * @param postProcess The post process to detach from the camera
  30240. */
  30241. detachPostProcess(postProcess: PostProcess): void;
  30242. /**
  30243. * Gets the current world matrix of the camera
  30244. */
  30245. getWorldMatrix(): Matrix;
  30246. /** @hidden */ private _getViewMatrix(): Matrix;
  30247. /**
  30248. * Gets the current view matrix of the camera.
  30249. * @param force forces the camera to recompute the matrix without looking at the cached state
  30250. * @returns the view matrix
  30251. */
  30252. getViewMatrix(force?: boolean): Matrix;
  30253. /**
  30254. * Freeze the projection matrix.
  30255. * It will prevent the cache check of the camera projection compute and can speed up perf
  30256. * if no parameter of the camera are meant to change
  30257. * @param projection Defines manually a projection if necessary
  30258. */
  30259. freezeProjectionMatrix(projection?: Matrix): void;
  30260. /**
  30261. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30262. */
  30263. unfreezeProjectionMatrix(): void;
  30264. /**
  30265. * Gets the current projection matrix of the camera.
  30266. * @param force forces the camera to recompute the matrix without looking at the cached state
  30267. * @returns the projection matrix
  30268. */
  30269. getProjectionMatrix(force?: boolean): Matrix;
  30270. /**
  30271. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30272. * @returns a Matrix
  30273. */
  30274. getTransformationMatrix(): Matrix;
  30275. private _updateFrustumPlanes;
  30276. /**
  30277. * Checks if a cullable object (mesh...) is in the camera frustum
  30278. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30279. * @param target The object to check
  30280. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30281. * @returns true if the object is in frustum otherwise false
  30282. */
  30283. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30284. /**
  30285. * Checks if a cullable object (mesh...) is in the camera frustum
  30286. * Unlike isInFrustum this cheks the full bounding box
  30287. * @param target The object to check
  30288. * @returns true if the object is in frustum otherwise false
  30289. */
  30290. isCompletelyInFrustum(target: ICullable): boolean;
  30291. /**
  30292. * Gets a ray in the forward direction from the camera.
  30293. * @param length Defines the length of the ray to create
  30294. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30295. * @param origin Defines the start point of the ray which defaults to the camera position
  30296. * @returns the forward ray
  30297. */
  30298. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30299. /**
  30300. * Releases resources associated with this node.
  30301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30303. */
  30304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30305. /** @hidden */ private _isLeftCamera: boolean;
  30306. /**
  30307. * Gets the left camera of a rig setup in case of Rigged Camera
  30308. */
  30309. readonly isLeftCamera: boolean;
  30310. /** @hidden */ private _isRightCamera: boolean;
  30311. /**
  30312. * Gets the right camera of a rig setup in case of Rigged Camera
  30313. */
  30314. readonly isRightCamera: boolean;
  30315. /**
  30316. * Gets the left camera of a rig setup in case of Rigged Camera
  30317. */
  30318. readonly leftCamera: Nullable<FreeCamera>;
  30319. /**
  30320. * Gets the right camera of a rig setup in case of Rigged Camera
  30321. */
  30322. readonly rightCamera: Nullable<FreeCamera>;
  30323. /**
  30324. * Gets the left camera target of a rig setup in case of Rigged Camera
  30325. * @returns the target position
  30326. */
  30327. getLeftTarget(): Nullable<Vector3>;
  30328. /**
  30329. * Gets the right camera target of a rig setup in case of Rigged Camera
  30330. * @returns the target position
  30331. */
  30332. getRightTarget(): Nullable<Vector3>;
  30333. /**
  30334. * @hidden
  30335. */
  30336. setCameraRigMode(mode: number, rigParams: any): void;
  30337. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30338. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30339. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30340. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30341. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  30342. protected _updateCameraRotationMatrix(): void;
  30343. protected _updateWebVRCameraRotationMatrix(): void;
  30344. /**
  30345. * This function MUST be overwritten by the different WebVR cameras available.
  30346. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30347. * @hidden
  30348. */ private _getWebVRProjectionMatrix(): Matrix;
  30349. /**
  30350. * This function MUST be overwritten by the different WebVR cameras available.
  30351. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30352. * @hidden
  30353. */ private _getWebVRViewMatrix(): Matrix;
  30354. /** @hidden */
  30355. setCameraRigParameter(name: string, value: any): void;
  30356. /**
  30357. * needs to be overridden by children so sub has required properties to be copied
  30358. * @hidden
  30359. */
  30360. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30361. /**
  30362. * May need to be overridden by children
  30363. * @hidden
  30364. */ private _updateRigCameras(): void;
  30365. /** @hidden */ private _setupInputs(): void;
  30366. /**
  30367. * Serialiaze the camera setup to a json represention
  30368. * @returns the JSON representation
  30369. */
  30370. serialize(): any;
  30371. /**
  30372. * Clones the current camera.
  30373. * @param name The cloned camera name
  30374. * @returns the cloned camera
  30375. */
  30376. clone(name: string): Camera;
  30377. /**
  30378. * Gets the direction of the camera relative to a given local axis.
  30379. * @param localAxis Defines the reference axis to provide a relative direction.
  30380. * @return the direction
  30381. */
  30382. getDirection(localAxis: Vector3): Vector3;
  30383. /**
  30384. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30385. * @param localAxis Defines the reference axis to provide a relative direction.
  30386. * @param result Defines the vector to store the result in
  30387. */
  30388. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30389. /**
  30390. * Gets a camera constructor for a given camera type
  30391. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30392. * @param name The name of the camera the result will be able to instantiate
  30393. * @param scene The scene the result will construct the camera in
  30394. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30395. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30396. * @returns a factory method to construc the camera
  30397. */
  30398. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30399. /**
  30400. * Compute the world matrix of the camera.
  30401. * @returns the camera workd matrix
  30402. */
  30403. computeWorldMatrix(): Matrix;
  30404. /**
  30405. * Parse a JSON and creates the camera from the parsed information
  30406. * @param parsedCamera The JSON to parse
  30407. * @param scene The scene to instantiate the camera in
  30408. * @returns the newly constructed camera
  30409. */
  30410. static Parse(parsedCamera: any, scene: Scene): Camera;
  30411. }
  30412. }
  30413. declare module BABYLON {
  30414. /**
  30415. * Interface for any object that can request an animation frame
  30416. */
  30417. export interface ICustomAnimationFrameRequester {
  30418. /**
  30419. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30420. */
  30421. renderFunction?: Function;
  30422. /**
  30423. * Called to request the next frame to render to
  30424. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30425. */
  30426. requestAnimationFrame: Function;
  30427. /**
  30428. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30429. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30430. */
  30431. requestID?: number;
  30432. }
  30433. /**
  30434. * Interface containing an array of animations
  30435. */
  30436. export interface IAnimatable {
  30437. /**
  30438. * Array of animations
  30439. */
  30440. animations: Nullable<Array<Animation>>;
  30441. }
  30442. /** Interface used by value gradients (color, factor, ...) */
  30443. export interface IValueGradient {
  30444. /**
  30445. * Gets or sets the gradient value (between 0 and 1)
  30446. */
  30447. gradient: number;
  30448. }
  30449. /** Class used to store color4 gradient */
  30450. export class ColorGradient implements IValueGradient {
  30451. /**
  30452. * Gets or sets the gradient value (between 0 and 1)
  30453. */
  30454. gradient: number;
  30455. /**
  30456. * Gets or sets first associated color
  30457. */
  30458. color1: Color4;
  30459. /**
  30460. * Gets or sets second associated color
  30461. */
  30462. color2?: Color4;
  30463. /**
  30464. * Will get a color picked randomly between color1 and color2.
  30465. * If color2 is undefined then color1 will be used
  30466. * @param result defines the target Color4 to store the result in
  30467. */
  30468. getColorToRef(result: Color4): void;
  30469. }
  30470. /** Class used to store color 3 gradient */
  30471. export class Color3Gradient implements IValueGradient {
  30472. /**
  30473. * Gets or sets the gradient value (between 0 and 1)
  30474. */
  30475. gradient: number;
  30476. /**
  30477. * Gets or sets the associated color
  30478. */
  30479. color: Color3;
  30480. }
  30481. /** Class used to store factor gradient */
  30482. export class FactorGradient implements IValueGradient {
  30483. /**
  30484. * Gets or sets the gradient value (between 0 and 1)
  30485. */
  30486. gradient: number;
  30487. /**
  30488. * Gets or sets first associated factor
  30489. */
  30490. factor1: number;
  30491. /**
  30492. * Gets or sets second associated factor
  30493. */
  30494. factor2?: number;
  30495. /**
  30496. * Will get a number picked randomly between factor1 and factor2.
  30497. * If factor2 is undefined then factor1 will be used
  30498. * @returns the picked number
  30499. */
  30500. getFactor(): number;
  30501. }
  30502. /**
  30503. * @ignore
  30504. * Application error to support additional information when loading a file
  30505. */
  30506. export class LoadFileError extends Error {
  30507. /** defines the optional web request */
  30508. request?: WebRequest | undefined;
  30509. private static _setPrototypeOf;
  30510. /**
  30511. * Creates a new LoadFileError
  30512. * @param message defines the message of the error
  30513. * @param request defines the optional web request
  30514. */
  30515. constructor(message: string,
  30516. /** defines the optional web request */
  30517. request?: WebRequest | undefined);
  30518. }
  30519. /**
  30520. * Class used to define a retry strategy when error happens while loading assets
  30521. */
  30522. export class RetryStrategy {
  30523. /**
  30524. * Function used to defines an exponential back off strategy
  30525. * @param maxRetries defines the maximum number of retries (3 by default)
  30526. * @param baseInterval defines the interval between retries
  30527. * @returns the strategy function to use
  30528. */
  30529. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30530. }
  30531. /**
  30532. * File request interface
  30533. */
  30534. export interface IFileRequest {
  30535. /**
  30536. * Raised when the request is complete (success or error).
  30537. */
  30538. onCompleteObservable: Observable<IFileRequest>;
  30539. /**
  30540. * Aborts the request for a file.
  30541. */
  30542. abort: () => void;
  30543. }
  30544. /**
  30545. * Class containing a set of static utilities functions
  30546. */
  30547. export class Tools {
  30548. /**
  30549. * Gets or sets the base URL to use to load assets
  30550. */
  30551. static BaseUrl: string;
  30552. /**
  30553. * Enable/Disable Custom HTTP Request Headers globally.
  30554. * default = false
  30555. * @see CustomRequestHeaders
  30556. */
  30557. static UseCustomRequestHeaders: boolean;
  30558. /**
  30559. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30560. * i.e. when loading files, where the server/service expects an Authorization header
  30561. */
  30562. static CustomRequestHeaders: {
  30563. [key: string]: string;
  30564. };
  30565. /**
  30566. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30567. */
  30568. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30569. /**
  30570. * Default behaviour for cors in the application.
  30571. * It can be a string if the expected behavior is identical in the entire app.
  30572. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30573. */
  30574. static CorsBehavior: string | ((url: string | string[]) => string);
  30575. /**
  30576. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30577. * @ignorenaming
  30578. */
  30579. static UseFallbackTexture: boolean;
  30580. /**
  30581. * Use this object to register external classes like custom textures or material
  30582. * to allow the laoders to instantiate them
  30583. */
  30584. static RegisteredExternalClasses: {
  30585. [key: string]: Object;
  30586. };
  30587. /**
  30588. * Texture content used if a texture cannot loaded
  30589. * @ignorenaming
  30590. */
  30591. static fallbackTexture: string;
  30592. /**
  30593. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30594. * @param u defines the coordinate on X axis
  30595. * @param v defines the coordinate on Y axis
  30596. * @param width defines the width of the source data
  30597. * @param height defines the height of the source data
  30598. * @param pixels defines the source byte array
  30599. * @param color defines the output color
  30600. */
  30601. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30602. /**
  30603. * Interpolates between a and b via alpha
  30604. * @param a The lower value (returned when alpha = 0)
  30605. * @param b The upper value (returned when alpha = 1)
  30606. * @param alpha The interpolation-factor
  30607. * @return The mixed value
  30608. */
  30609. static Mix(a: number, b: number, alpha: number): number;
  30610. /**
  30611. * Tries to instantiate a new object from a given class name
  30612. * @param className defines the class name to instantiate
  30613. * @returns the new object or null if the system was not able to do the instantiation
  30614. */
  30615. static Instantiate(className: string): any;
  30616. /**
  30617. * Provides a slice function that will work even on IE
  30618. * @param data defines the array to slice
  30619. * @param start defines the start of the data (optional)
  30620. * @param end defines the end of the data (optional)
  30621. * @returns the new sliced array
  30622. */
  30623. static Slice<T>(data: T, start?: number, end?: number): T;
  30624. /**
  30625. * Polyfill for setImmediate
  30626. * @param action defines the action to execute after the current execution block
  30627. */
  30628. static SetImmediate(action: () => void): void;
  30629. /**
  30630. * Function indicating if a number is an exponent of 2
  30631. * @param value defines the value to test
  30632. * @returns true if the value is an exponent of 2
  30633. */
  30634. static IsExponentOfTwo(value: number): boolean;
  30635. private static _tmpFloatArray;
  30636. /**
  30637. * Returns the nearest 32-bit single precision float representation of a Number
  30638. * @param value A Number. If the parameter is of a different type, it will get converted
  30639. * to a number or to NaN if it cannot be converted
  30640. * @returns number
  30641. */
  30642. static FloatRound(value: number): number;
  30643. /**
  30644. * Find the next highest power of two.
  30645. * @param x Number to start search from.
  30646. * @return Next highest power of two.
  30647. */
  30648. static CeilingPOT(x: number): number;
  30649. /**
  30650. * Find the next lowest power of two.
  30651. * @param x Number to start search from.
  30652. * @return Next lowest power of two.
  30653. */
  30654. static FloorPOT(x: number): number;
  30655. /**
  30656. * Find the nearest power of two.
  30657. * @param x Number to start search from.
  30658. * @return Next nearest power of two.
  30659. */
  30660. static NearestPOT(x: number): number;
  30661. /**
  30662. * Get the closest exponent of two
  30663. * @param value defines the value to approximate
  30664. * @param max defines the maximum value to return
  30665. * @param mode defines how to define the closest value
  30666. * @returns closest exponent of two of the given value
  30667. */
  30668. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30669. /**
  30670. * Extracts the filename from a path
  30671. * @param path defines the path to use
  30672. * @returns the filename
  30673. */
  30674. static GetFilename(path: string): string;
  30675. /**
  30676. * Extracts the "folder" part of a path (everything before the filename).
  30677. * @param uri The URI to extract the info from
  30678. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30679. * @returns The "folder" part of the path
  30680. */
  30681. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30682. /**
  30683. * Extracts text content from a DOM element hierarchy
  30684. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30685. */
  30686. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30687. /**
  30688. * Convert an angle in radians to degrees
  30689. * @param angle defines the angle to convert
  30690. * @returns the angle in degrees
  30691. */
  30692. static ToDegrees(angle: number): number;
  30693. /**
  30694. * Convert an angle in degrees to radians
  30695. * @param angle defines the angle to convert
  30696. * @returns the angle in radians
  30697. */
  30698. static ToRadians(angle: number): number;
  30699. /**
  30700. * Encode a buffer to a base64 string
  30701. * @param buffer defines the buffer to encode
  30702. * @returns the encoded string
  30703. */
  30704. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30705. /**
  30706. * Extracts minimum and maximum values from a list of indexed positions
  30707. * @param positions defines the positions to use
  30708. * @param indices defines the indices to the positions
  30709. * @param indexStart defines the start index
  30710. * @param indexCount defines the end index
  30711. * @param bias defines bias value to add to the result
  30712. * @return minimum and maximum values
  30713. */
  30714. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30715. minimum: Vector3;
  30716. maximum: Vector3;
  30717. };
  30718. /**
  30719. * Extracts minimum and maximum values from a list of positions
  30720. * @param positions defines the positions to use
  30721. * @param start defines the start index in the positions array
  30722. * @param count defines the number of positions to handle
  30723. * @param bias defines bias value to add to the result
  30724. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30725. * @return minimum and maximum values
  30726. */
  30727. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30728. minimum: Vector3;
  30729. maximum: Vector3;
  30730. };
  30731. /**
  30732. * Returns an array if obj is not an array
  30733. * @param obj defines the object to evaluate as an array
  30734. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30735. * @returns either obj directly if obj is an array or a new array containing obj
  30736. */
  30737. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30738. /**
  30739. * Gets the pointer prefix to use
  30740. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30741. */
  30742. static GetPointerPrefix(): string;
  30743. /**
  30744. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30745. * @param func - the function to be called
  30746. * @param requester - the object that will request the next frame. Falls back to window.
  30747. * @returns frame number
  30748. */
  30749. static QueueNewFrame(func: () => void, requester?: any): number;
  30750. /**
  30751. * Ask the browser to promote the current element to fullscreen rendering mode
  30752. * @param element defines the DOM element to promote
  30753. */
  30754. static RequestFullscreen(element: HTMLElement): void;
  30755. /**
  30756. * Asks the browser to exit fullscreen mode
  30757. */
  30758. static ExitFullscreen(): void;
  30759. /**
  30760. * Ask the browser to promote the current element to pointerlock mode
  30761. * @param element defines the DOM element to promote
  30762. */
  30763. static RequestPointerlock(element: HTMLElement): void;
  30764. /**
  30765. * Asks the browser to exit pointerlock mode
  30766. */
  30767. static ExitPointerlock(): void;
  30768. /**
  30769. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30770. * @param url define the url we are trying
  30771. * @param element define the dom element where to configure the cors policy
  30772. */
  30773. static SetCorsBehavior(url: string | string[], element: {
  30774. crossOrigin: string | null;
  30775. }): void;
  30776. /**
  30777. * Removes unwanted characters from an url
  30778. * @param url defines the url to clean
  30779. * @returns the cleaned url
  30780. */
  30781. static CleanUrl(url: string): string;
  30782. /**
  30783. * Gets or sets a function used to pre-process url before using them to load assets
  30784. */
  30785. static PreprocessUrl: (url: string) => string;
  30786. /**
  30787. * Loads an image as an HTMLImageElement.
  30788. * @param input url string, ArrayBuffer, or Blob to load
  30789. * @param onLoad callback called when the image successfully loads
  30790. * @param onError callback called when the image fails to load
  30791. * @param offlineProvider offline provider for caching
  30792. * @returns the HTMLImageElement of the loaded image
  30793. */
  30794. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30795. /**
  30796. * Loads a file
  30797. * @param url url string, ArrayBuffer, or Blob to load
  30798. * @param onSuccess callback called when the file successfully loads
  30799. * @param onProgress callback called while file is loading (if the server supports this mode)
  30800. * @param offlineProvider defines the offline provider for caching
  30801. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30802. * @param onError callback called when the file fails to load
  30803. * @returns a file request object
  30804. */
  30805. 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;
  30806. /**
  30807. * Loads a file from a url
  30808. * @param url the file url to load
  30809. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  30810. */
  30811. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  30812. /**
  30813. * Load a script (identified by an url). When the url returns, the
  30814. * content of this file is added into a new script element, attached to the DOM (body element)
  30815. * @param scriptUrl defines the url of the script to laod
  30816. * @param onSuccess defines the callback called when the script is loaded
  30817. * @param onError defines the callback to call if an error occurs
  30818. * @param scriptId defines the id of the script element
  30819. */
  30820. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30821. /**
  30822. * Load an asynchronous script (identified by an url). When the url returns, the
  30823. * content of this file is added into a new script element, attached to the DOM (body element)
  30824. * @param scriptUrl defines the url of the script to laod
  30825. * @param scriptId defines the id of the script element
  30826. * @returns a promise request object
  30827. */
  30828. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  30829. /**
  30830. * Loads a file from a blob
  30831. * @param fileToLoad defines the blob to use
  30832. * @param callback defines the callback to call when data is loaded
  30833. * @param progressCallback defines the callback to call during loading process
  30834. * @returns a file request object
  30835. */
  30836. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30837. /**
  30838. * Loads a file
  30839. * @param fileToLoad defines the file to load
  30840. * @param callback defines the callback to call when data is loaded
  30841. * @param progressCallBack defines the callback to call during loading process
  30842. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30843. * @returns a file request object
  30844. */
  30845. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30846. /**
  30847. * Creates a data url from a given string content
  30848. * @param content defines the content to convert
  30849. * @returns the new data url link
  30850. */
  30851. static FileAsURL(content: string): string;
  30852. /**
  30853. * Format the given number to a specific decimal format
  30854. * @param value defines the number to format
  30855. * @param decimals defines the number of decimals to use
  30856. * @returns the formatted string
  30857. */
  30858. static Format(value: number, decimals?: number): string;
  30859. /**
  30860. * Checks if a given vector is inside a specific range
  30861. * @param v defines the vector to test
  30862. * @param min defines the minimum range
  30863. * @param max defines the maximum range
  30864. */
  30865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30866. /**
  30867. * Tries to copy an object by duplicating every property
  30868. * @param source defines the source object
  30869. * @param destination defines the target object
  30870. * @param doNotCopyList defines a list of properties to avoid
  30871. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30872. */
  30873. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30874. /**
  30875. * Gets a boolean indicating if the given object has no own property
  30876. * @param obj defines the object to test
  30877. * @returns true if object has no own property
  30878. */
  30879. static IsEmpty(obj: any): boolean;
  30880. /**
  30881. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30882. * @param str Source string
  30883. * @param suffix Suffix to search for in the source string
  30884. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30885. */
  30886. static EndsWith(str: string, suffix: string): boolean;
  30887. /**
  30888. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  30889. * @param str Source string
  30890. * @param suffix Suffix to search for in the source string
  30891. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30892. */
  30893. static StartsWith(str: string, suffix: string): boolean;
  30894. /**
  30895. * Function used to register events at window level
  30896. * @param events defines the events to register
  30897. */
  30898. static RegisterTopRootEvents(events: {
  30899. name: string;
  30900. handler: Nullable<(e: FocusEvent) => any>;
  30901. }[]): void;
  30902. /**
  30903. * Function used to unregister events from window level
  30904. * @param events defines the events to unregister
  30905. */
  30906. static UnregisterTopRootEvents(events: {
  30907. name: string;
  30908. handler: Nullable<(e: FocusEvent) => any>;
  30909. }[]): void;
  30910. /**
  30911. * @ignore
  30912. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30913. /**
  30914. * Dumps the current bound framebuffer
  30915. * @param width defines the rendering width
  30916. * @param height defines the rendering height
  30917. * @param engine defines the hosting engine
  30918. * @param successCallback defines the callback triggered once the data are available
  30919. * @param mimeType defines the mime type of the result
  30920. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30921. */
  30922. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30923. /**
  30924. * Converts the canvas data to blob.
  30925. * This acts as a polyfill for browsers not supporting the to blob function.
  30926. * @param canvas Defines the canvas to extract the data from
  30927. * @param successCallback Defines the callback triggered once the data are available
  30928. * @param mimeType Defines the mime type of the result
  30929. */
  30930. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30931. /**
  30932. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30933. * @param successCallback defines the callback triggered once the data are available
  30934. * @param mimeType defines the mime type of the result
  30935. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30936. */
  30937. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30938. /**
  30939. * Downloads a blob in the browser
  30940. * @param blob defines the blob to download
  30941. * @param fileName defines the name of the downloaded file
  30942. */
  30943. static Download(blob: Blob, fileName: string): void;
  30944. /**
  30945. * Captures a screenshot of the current rendering
  30946. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30947. * @param engine defines the rendering engine
  30948. * @param camera defines the source camera
  30949. * @param size This parameter can be set to a single number or to an object with the
  30950. * following (optional) properties: precision, width, height. If a single number is passed,
  30951. * it will be used for both width and height. If an object is passed, the screenshot size
  30952. * will be derived from the parameters. The precision property is a multiplier allowing
  30953. * rendering at a higher or lower resolution
  30954. * @param successCallback defines the callback receives a single parameter which contains the
  30955. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30956. * src parameter of an <img> to display it
  30957. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30958. * Check your browser for supported MIME types
  30959. */
  30960. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30961. /**
  30962. * Generates an image screenshot from the specified camera.
  30963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30964. * @param engine The engine to use for rendering
  30965. * @param camera The camera to use for rendering
  30966. * @param size This parameter can be set to a single number or to an object with the
  30967. * following (optional) properties: precision, width, height. If a single number is passed,
  30968. * it will be used for both width and height. If an object is passed, the screenshot size
  30969. * will be derived from the parameters. The precision property is a multiplier allowing
  30970. * rendering at a higher or lower resolution
  30971. * @param successCallback The callback receives a single parameter which contains the
  30972. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30973. * src parameter of an <img> to display it
  30974. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30975. * Check your browser for supported MIME types
  30976. * @param samples Texture samples (default: 1)
  30977. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30978. * @param fileName A name for for the downloaded file.
  30979. */
  30980. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30981. /**
  30982. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30983. * Be aware Math.random() could cause collisions, but:
  30984. * "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"
  30985. * @returns a pseudo random id
  30986. */
  30987. static RandomId(): string;
  30988. /**
  30989. * Test if the given uri is a base64 string
  30990. * @param uri The uri to test
  30991. * @return True if the uri is a base64 string or false otherwise
  30992. */
  30993. static IsBase64(uri: string): boolean;
  30994. /**
  30995. * Decode the given base64 uri.
  30996. * @param uri The uri to decode
  30997. * @return The decoded base64 data.
  30998. */
  30999. static DecodeBase64(uri: string): ArrayBuffer;
  31000. /**
  31001. * Gets the absolute url.
  31002. * @param url the input url
  31003. * @return the absolute url
  31004. */
  31005. static GetAbsoluteUrl(url: string): string;
  31006. /**
  31007. * No log
  31008. */
  31009. static readonly NoneLogLevel: number;
  31010. /**
  31011. * Only message logs
  31012. */
  31013. static readonly MessageLogLevel: number;
  31014. /**
  31015. * Only warning logs
  31016. */
  31017. static readonly WarningLogLevel: number;
  31018. /**
  31019. * Only error logs
  31020. */
  31021. static readonly ErrorLogLevel: number;
  31022. /**
  31023. * All logs
  31024. */
  31025. static readonly AllLogLevel: number;
  31026. /**
  31027. * Gets a value indicating the number of loading errors
  31028. * @ignorenaming
  31029. */
  31030. static readonly errorsCount: number;
  31031. /**
  31032. * Callback called when a new log is added
  31033. */
  31034. static OnNewCacheEntry: (entry: string) => void;
  31035. /**
  31036. * Log a message to the console
  31037. * @param message defines the message to log
  31038. */
  31039. static Log(message: string): void;
  31040. /**
  31041. * Write a warning message to the console
  31042. * @param message defines the message to log
  31043. */
  31044. static Warn(message: string): void;
  31045. /**
  31046. * Write an error message to the console
  31047. * @param message defines the message to log
  31048. */
  31049. static Error(message: string): void;
  31050. /**
  31051. * Gets current log cache (list of logs)
  31052. */
  31053. static readonly LogCache: string;
  31054. /**
  31055. * Clears the log cache
  31056. */
  31057. static ClearLogCache(): void;
  31058. /**
  31059. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31060. */
  31061. static LogLevels: number;
  31062. /**
  31063. * Checks if the loaded document was accessed via `file:`-Protocol.
  31064. * @returns boolean
  31065. */
  31066. static IsFileURL(): boolean;
  31067. /**
  31068. * Checks if the window object exists
  31069. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31070. */
  31071. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31072. /**
  31073. * No performance log
  31074. */
  31075. static readonly PerformanceNoneLogLevel: number;
  31076. /**
  31077. * Use user marks to log performance
  31078. */
  31079. static readonly PerformanceUserMarkLogLevel: number;
  31080. /**
  31081. * Log performance to the console
  31082. */
  31083. static readonly PerformanceConsoleLogLevel: number;
  31084. private static _performance;
  31085. /**
  31086. * Sets the current performance log level
  31087. */
  31088. static PerformanceLogLevel: number;
  31089. private static _StartPerformanceCounterDisabled;
  31090. private static _EndPerformanceCounterDisabled;
  31091. private static _StartUserMark;
  31092. private static _EndUserMark;
  31093. private static _StartPerformanceConsole;
  31094. private static _EndPerformanceConsole;
  31095. /**
  31096. * Starts a performance counter
  31097. */
  31098. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31099. /**
  31100. * Ends a specific performance coutner
  31101. */
  31102. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31103. /**
  31104. * Gets either window.performance.now() if supported or Date.now() else
  31105. */
  31106. static readonly Now: number;
  31107. /**
  31108. * This method will return the name of the class used to create the instance of the given object.
  31109. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31110. * @param object the object to get the class name from
  31111. * @param isType defines if the object is actually a type
  31112. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31113. */
  31114. static GetClassName(object: any, isType?: boolean): string;
  31115. /**
  31116. * Gets the first element of an array satisfying a given predicate
  31117. * @param array defines the array to browse
  31118. * @param predicate defines the predicate to use
  31119. * @returns null if not found or the element
  31120. */
  31121. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31122. /**
  31123. * This method will return the name of the full name of the class, including its owning module (if any).
  31124. * 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).
  31125. * @param object the object to get the class name from
  31126. * @param isType defines if the object is actually a type
  31127. * @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.
  31128. * @ignorenaming
  31129. */
  31130. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31131. /**
  31132. * Returns a promise that resolves after the given amount of time.
  31133. * @param delay Number of milliseconds to delay
  31134. * @returns Promise that resolves after the given amount of time
  31135. */
  31136. static DelayAsync(delay: number): Promise<void>;
  31137. /**
  31138. * Gets the current gradient from an array of IValueGradient
  31139. * @param ratio defines the current ratio to get
  31140. * @param gradients defines the array of IValueGradient
  31141. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31142. */
  31143. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31144. }
  31145. /**
  31146. * This class is used to track a performance counter which is number based.
  31147. * The user has access to many properties which give statistics of different nature.
  31148. *
  31149. * The implementer can track two kinds of Performance Counter: time and count.
  31150. * 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.
  31151. * 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.
  31152. */
  31153. export class PerfCounter {
  31154. /**
  31155. * Gets or sets a global boolean to turn on and off all the counters
  31156. */
  31157. static Enabled: boolean;
  31158. /**
  31159. * Returns the smallest value ever
  31160. */
  31161. readonly min: number;
  31162. /**
  31163. * Returns the biggest value ever
  31164. */
  31165. readonly max: number;
  31166. /**
  31167. * Returns the average value since the performance counter is running
  31168. */
  31169. readonly average: number;
  31170. /**
  31171. * Returns the average value of the last second the counter was monitored
  31172. */
  31173. readonly lastSecAverage: number;
  31174. /**
  31175. * Returns the current value
  31176. */
  31177. readonly current: number;
  31178. /**
  31179. * Gets the accumulated total
  31180. */
  31181. readonly total: number;
  31182. /**
  31183. * Gets the total value count
  31184. */
  31185. readonly count: number;
  31186. /**
  31187. * Creates a new counter
  31188. */
  31189. constructor();
  31190. /**
  31191. * Call this method to start monitoring a new frame.
  31192. * 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.
  31193. */
  31194. fetchNewFrame(): void;
  31195. /**
  31196. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31197. * @param newCount the count value to add to the monitored count
  31198. * @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.
  31199. */
  31200. addCount(newCount: number, fetchResult: boolean): void;
  31201. /**
  31202. * Start monitoring this performance counter
  31203. */
  31204. beginMonitoring(): void;
  31205. /**
  31206. * Compute the time lapsed since the previous beginMonitoring() call.
  31207. * @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
  31208. */
  31209. endMonitoring(newFrame?: boolean): void;
  31210. private _fetchResult;
  31211. private _startMonitoringTime;
  31212. private _min;
  31213. private _max;
  31214. private _average;
  31215. private _current;
  31216. private _totalValueCount;
  31217. private _totalAccumulated;
  31218. private _lastSecAverage;
  31219. private _lastSecAccumulated;
  31220. private _lastSecTime;
  31221. private _lastSecValueCount;
  31222. }
  31223. /**
  31224. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31225. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31226. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31227. * @param name The name of the class, case should be preserved
  31228. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31229. */
  31230. export function className(name: string, module?: string): (target: Object) => void;
  31231. /**
  31232. * An implementation of a loop for asynchronous functions.
  31233. */
  31234. export class AsyncLoop {
  31235. /**
  31236. * Defines the number of iterations for the loop
  31237. */
  31238. iterations: number;
  31239. /**
  31240. * Defines the current index of the loop.
  31241. */
  31242. index: number;
  31243. private _done;
  31244. private _fn;
  31245. private _successCallback;
  31246. /**
  31247. * Constructor.
  31248. * @param iterations the number of iterations.
  31249. * @param func the function to run each iteration
  31250. * @param successCallback the callback that will be called upon succesful execution
  31251. * @param offset starting offset.
  31252. */
  31253. constructor(
  31254. /**
  31255. * Defines the number of iterations for the loop
  31256. */
  31257. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31258. /**
  31259. * Execute the next iteration. Must be called after the last iteration was finished.
  31260. */
  31261. executeNext(): void;
  31262. /**
  31263. * Break the loop and run the success callback.
  31264. */
  31265. breakLoop(): void;
  31266. /**
  31267. * Create and run an async loop.
  31268. * @param iterations the number of iterations.
  31269. * @param fn the function to run each iteration
  31270. * @param successCallback the callback that will be called upon succesful execution
  31271. * @param offset starting offset.
  31272. * @returns the created async loop object
  31273. */
  31274. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31275. /**
  31276. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31277. * @param iterations total number of iterations
  31278. * @param syncedIterations number of synchronous iterations in each async iteration.
  31279. * @param fn the function to call each iteration.
  31280. * @param callback a success call back that will be called when iterating stops.
  31281. * @param breakFunction a break condition (optional)
  31282. * @param timeout timeout settings for the setTimeout function. default - 0.
  31283. * @returns the created async loop object
  31284. */
  31285. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31286. }
  31287. }
  31288. declare module BABYLON {
  31289. /** @hidden */
  31290. export interface ICollisionCoordinator {
  31291. createCollider(): Collider;
  31292. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31293. init(scene: Scene): void;
  31294. }
  31295. /** @hidden */
  31296. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31297. private _scene;
  31298. private _scaledPosition;
  31299. private _scaledVelocity;
  31300. private _finalPosition;
  31301. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31302. createCollider(): Collider;
  31303. init(scene: Scene): void;
  31304. private _collideWithWorld;
  31305. }
  31306. }
  31307. declare module BABYLON {
  31308. /**
  31309. * Class used to manage all inputs for the scene.
  31310. */
  31311. export class InputManager {
  31312. /** The distance in pixel that you have to move to prevent some events */
  31313. static DragMovementThreshold: number;
  31314. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31315. static LongPressDelay: number;
  31316. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31317. static DoubleClickDelay: number;
  31318. /** If you need to check double click without raising a single click at first click, enable this flag */
  31319. static ExclusiveDoubleClickMode: boolean;
  31320. private _wheelEventName;
  31321. private _onPointerMove;
  31322. private _onPointerDown;
  31323. private _onPointerUp;
  31324. private _initClickEvent;
  31325. private _initActionManager;
  31326. private _delayedSimpleClick;
  31327. private _delayedSimpleClickTimeout;
  31328. private _previousDelayedSimpleClickTimeout;
  31329. private _meshPickProceed;
  31330. private _previousButtonPressed;
  31331. private _currentPickResult;
  31332. private _previousPickResult;
  31333. private _totalPointersPressed;
  31334. private _doubleClickOccured;
  31335. private _pointerOverMesh;
  31336. private _pickedDownMesh;
  31337. private _pickedUpMesh;
  31338. private _pointerX;
  31339. private _pointerY;
  31340. private _unTranslatedPointerX;
  31341. private _unTranslatedPointerY;
  31342. private _startingPointerPosition;
  31343. private _previousStartingPointerPosition;
  31344. private _startingPointerTime;
  31345. private _previousStartingPointerTime;
  31346. private _pointerCaptures;
  31347. private _onKeyDown;
  31348. private _onKeyUp;
  31349. private _onCanvasFocusObserver;
  31350. private _onCanvasBlurObserver;
  31351. private _scene;
  31352. /**
  31353. * Creates a new InputManager
  31354. * @param scene defines the hosting scene
  31355. */
  31356. constructor(scene: Scene);
  31357. /**
  31358. * Gets the mesh that is currently under the pointer
  31359. */
  31360. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31361. /**
  31362. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31363. */
  31364. readonly unTranslatedPointer: Vector2;
  31365. /**
  31366. * Gets or sets the current on-screen X position of the pointer
  31367. */
  31368. pointerX: number;
  31369. /**
  31370. * Gets or sets the current on-screen Y position of the pointer
  31371. */
  31372. pointerY: number;
  31373. private _updatePointerPosition;
  31374. private _processPointerMove;
  31375. private _setRayOnPointerInfo;
  31376. private _checkPrePointerObservable;
  31377. /**
  31378. * Use this method to simulate a pointer move on a mesh
  31379. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31380. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31381. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31382. */
  31383. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31384. /**
  31385. * Use this method to simulate a pointer down on a mesh
  31386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31389. */
  31390. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31391. private _processPointerDown;
  31392. /** @hidden */ private _isPointerSwiping(): boolean;
  31393. /**
  31394. * Use this method to simulate a pointer up on a mesh
  31395. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31396. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31397. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31398. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31399. */
  31400. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31401. private _processPointerUp;
  31402. /**
  31403. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31404. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31405. * @returns true if the pointer was captured
  31406. */
  31407. isPointerCaptured(pointerId?: number): boolean;
  31408. /**
  31409. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31410. * @param attachUp defines if you want to attach events to pointerup
  31411. * @param attachDown defines if you want to attach events to pointerdown
  31412. * @param attachMove defines if you want to attach events to pointermove
  31413. */
  31414. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31415. /**
  31416. * Detaches all event handlers
  31417. */
  31418. detachControl(): void;
  31419. /**
  31420. * Force the value of meshUnderPointer
  31421. * @param mesh defines the mesh to use
  31422. */
  31423. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31424. /**
  31425. * Gets the mesh under the pointer
  31426. * @returns a Mesh or null if no mesh is under the pointer
  31427. */
  31428. getPointerOverMesh(): Nullable<AbstractMesh>;
  31429. }
  31430. }
  31431. declare module BABYLON {
  31432. /**
  31433. * This class defines the direct association between an animation and a target
  31434. */
  31435. export class TargetedAnimation {
  31436. /**
  31437. * Animation to perform
  31438. */
  31439. animation: Animation;
  31440. /**
  31441. * Target to animate
  31442. */
  31443. target: any;
  31444. /**
  31445. * Serialize the object
  31446. * @returns the JSON object representing the current entity
  31447. */
  31448. serialize(): any;
  31449. }
  31450. /**
  31451. * Use this class to create coordinated animations on multiple targets
  31452. */
  31453. export class AnimationGroup implements IDisposable {
  31454. /** The name of the animation group */
  31455. name: string;
  31456. private _scene;
  31457. private _targetedAnimations;
  31458. private _animatables;
  31459. private _from;
  31460. private _to;
  31461. private _isStarted;
  31462. private _isPaused;
  31463. private _speedRatio;
  31464. private _loopAnimation;
  31465. /**
  31466. * Gets or sets the unique id of the node
  31467. */
  31468. uniqueId: number;
  31469. /**
  31470. * This observable will notify when one animation have ended
  31471. */
  31472. onAnimationEndObservable: Observable<TargetedAnimation>;
  31473. /**
  31474. * Observer raised when one animation loops
  31475. */
  31476. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31477. /**
  31478. * This observable will notify when all animations have ended.
  31479. */
  31480. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31481. /**
  31482. * This observable will notify when all animations have paused.
  31483. */
  31484. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31485. /**
  31486. * This observable will notify when all animations are playing.
  31487. */
  31488. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31489. /**
  31490. * Gets the first frame
  31491. */
  31492. readonly from: number;
  31493. /**
  31494. * Gets the last frame
  31495. */
  31496. readonly to: number;
  31497. /**
  31498. * Define if the animations are started
  31499. */
  31500. readonly isStarted: boolean;
  31501. /**
  31502. * Gets a value indicating that the current group is playing
  31503. */
  31504. readonly isPlaying: boolean;
  31505. /**
  31506. * Gets or sets the speed ratio to use for all animations
  31507. */
  31508. /**
  31509. * Gets or sets the speed ratio to use for all animations
  31510. */
  31511. speedRatio: number;
  31512. /**
  31513. * Gets or sets if all animations should loop or not
  31514. */
  31515. loopAnimation: boolean;
  31516. /**
  31517. * Gets the targeted animations for this animation group
  31518. */
  31519. readonly targetedAnimations: Array<TargetedAnimation>;
  31520. /**
  31521. * returning the list of animatables controlled by this animation group.
  31522. */
  31523. readonly animatables: Array<Animatable>;
  31524. /**
  31525. * Instantiates a new Animation Group.
  31526. * This helps managing several animations at once.
  31527. * @see http://doc.babylonjs.com/how_to/group
  31528. * @param name Defines the name of the group
  31529. * @param scene Defines the scene the group belongs to
  31530. */
  31531. constructor(
  31532. /** The name of the animation group */
  31533. name: string, scene?: Nullable<Scene>);
  31534. /**
  31535. * Add an animation (with its target) in the group
  31536. * @param animation defines the animation we want to add
  31537. * @param target defines the target of the animation
  31538. * @returns the TargetedAnimation object
  31539. */
  31540. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31541. /**
  31542. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31543. * It can add constant keys at begin or end
  31544. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31545. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31546. * @returns the animation group
  31547. */
  31548. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31549. /**
  31550. * Start all animations on given targets
  31551. * @param loop defines if animations must loop
  31552. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31553. * @param from defines the from key (optional)
  31554. * @param to defines the to key (optional)
  31555. * @returns the current animation group
  31556. */
  31557. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31558. /**
  31559. * Pause all animations
  31560. * @returns the animation group
  31561. */
  31562. pause(): AnimationGroup;
  31563. /**
  31564. * Play all animations to initial state
  31565. * This function will start() the animations if they were not started or will restart() them if they were paused
  31566. * @param loop defines if animations must loop
  31567. * @returns the animation group
  31568. */
  31569. play(loop?: boolean): AnimationGroup;
  31570. /**
  31571. * Reset all animations to initial state
  31572. * @returns the animation group
  31573. */
  31574. reset(): AnimationGroup;
  31575. /**
  31576. * Restart animations from key 0
  31577. * @returns the animation group
  31578. */
  31579. restart(): AnimationGroup;
  31580. /**
  31581. * Stop all animations
  31582. * @returns the animation group
  31583. */
  31584. stop(): AnimationGroup;
  31585. /**
  31586. * Set animation weight for all animatables
  31587. * @param weight defines the weight to use
  31588. * @return the animationGroup
  31589. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31590. */
  31591. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31592. /**
  31593. * Synchronize and normalize all animatables with a source animatable
  31594. * @param root defines the root animatable to synchronize with
  31595. * @return the animationGroup
  31596. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31597. */
  31598. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31599. /**
  31600. * Goes to a specific frame in this animation group
  31601. * @param frame the frame number to go to
  31602. * @return the animationGroup
  31603. */
  31604. goToFrame(frame: number): AnimationGroup;
  31605. /**
  31606. * Dispose all associated resources
  31607. */
  31608. dispose(): void;
  31609. private _checkAnimationGroupEnded;
  31610. /**
  31611. * Clone the current animation group and returns a copy
  31612. * @param newName defines the name of the new group
  31613. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31614. * @returns the new aniamtion group
  31615. */
  31616. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31617. /**
  31618. * Serializes the animationGroup to an object
  31619. * @returns Serialized object
  31620. */
  31621. serialize(): any;
  31622. /**
  31623. * Returns a new AnimationGroup object parsed from the source provided.
  31624. * @param parsedAnimationGroup defines the source
  31625. * @param scene defines the scene that will receive the animationGroup
  31626. * @returns a new AnimationGroup
  31627. */
  31628. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31629. /**
  31630. * Returns the string "AnimationGroup"
  31631. * @returns "AnimationGroup"
  31632. */
  31633. getClassName(): string;
  31634. /**
  31635. * Creates a detailled string about the object
  31636. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31637. * @returns a string representing the object
  31638. */
  31639. toString(fullDetails?: boolean): string;
  31640. }
  31641. }
  31642. declare module BABYLON {
  31643. /**
  31644. * Define an interface for all classes that will hold resources
  31645. */
  31646. export interface IDisposable {
  31647. /**
  31648. * Releases all held resources
  31649. */
  31650. dispose(): void;
  31651. }
  31652. /** Interface defining initialization parameters for Scene class */
  31653. export interface SceneOptions {
  31654. /**
  31655. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31656. * It will improve performance when the number of geometries becomes important.
  31657. */
  31658. useGeometryUniqueIdsMap?: boolean;
  31659. /**
  31660. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31661. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31662. */
  31663. useMaterialMeshMap?: boolean;
  31664. /**
  31665. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31666. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31667. */
  31668. useClonedMeshhMap?: boolean;
  31669. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31670. virtual?: boolean;
  31671. }
  31672. /**
  31673. * Represents a scene to be rendered by the engine.
  31674. * @see http://doc.babylonjs.com/features/scene
  31675. */
  31676. export class Scene extends AbstractScene implements IAnimatable {
  31677. private static _uniqueIdCounter;
  31678. /** The fog is deactivated */
  31679. static readonly FOGMODE_NONE: number;
  31680. /** The fog density is following an exponential function */
  31681. static readonly FOGMODE_EXP: number;
  31682. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31683. static readonly FOGMODE_EXP2: number;
  31684. /** The fog density is following a linear function. */
  31685. static readonly FOGMODE_LINEAR: number;
  31686. /**
  31687. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31688. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31689. */
  31690. static MinDeltaTime: number;
  31691. /**
  31692. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31693. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31694. */
  31695. static MaxDeltaTime: number;
  31696. /**
  31697. * Factory used to create the default material.
  31698. * @param name The name of the material to create
  31699. * @param scene The scene to create the material for
  31700. * @returns The default material
  31701. */
  31702. static DefaultMaterialFactory(scene: Scene): Material;
  31703. /**
  31704. * Factory used to create the a collision coordinator.
  31705. * @returns The collision coordinator
  31706. */
  31707. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31708. /** @hidden */ private _inputManager: InputManager;
  31709. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31710. cameraToUseForPointers: Nullable<Camera>;
  31711. /** @hidden */ protected readonly _isScene: boolean;
  31712. /**
  31713. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31714. */
  31715. autoClear: boolean;
  31716. /**
  31717. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31718. */
  31719. autoClearDepthAndStencil: boolean;
  31720. /**
  31721. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31722. */
  31723. clearColor: Color4;
  31724. /**
  31725. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31726. */
  31727. ambientColor: Color3;
  31728. /**
  31729. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31730. * It should only be one of the following (if not the default embedded one):
  31731. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31732. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31733. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31734. * The material properties need to be setup according to the type of texture in use.
  31735. */
  31736. environmentBRDFTexture: BaseTexture;
  31737. /** @hidden */
  31738. protected _environmentTexture: Nullable<BaseTexture>;
  31739. /**
  31740. * Texture used in all pbr material as the reflection texture.
  31741. * As in the majority of the scene they are the same (exception for multi room and so on),
  31742. * this is easier to reference from here than from all the materials.
  31743. */
  31744. /**
  31745. * Texture used in all pbr material as the reflection texture.
  31746. * As in the majority of the scene they are the same (exception for multi room and so on),
  31747. * this is easier to set here than in all the materials.
  31748. */
  31749. environmentTexture: Nullable<BaseTexture>;
  31750. /** @hidden */
  31751. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31752. /**
  31753. * Default image processing configuration used either in the rendering
  31754. * Forward main pass or through the imageProcessingPostProcess if present.
  31755. * As in the majority of the scene they are the same (exception for multi camera),
  31756. * this is easier to reference from here than from all the materials and post process.
  31757. *
  31758. * No setter as we it is a shared configuration, you can set the values instead.
  31759. */
  31760. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31761. private _forceWireframe;
  31762. /**
  31763. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31764. */
  31765. forceWireframe: boolean;
  31766. private _forcePointsCloud;
  31767. /**
  31768. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31769. */
  31770. forcePointsCloud: boolean;
  31771. /**
  31772. * Gets or sets the active clipplane 1
  31773. */
  31774. clipPlane: Nullable<Plane>;
  31775. /**
  31776. * Gets or sets the active clipplane 2
  31777. */
  31778. clipPlane2: Nullable<Plane>;
  31779. /**
  31780. * Gets or sets the active clipplane 3
  31781. */
  31782. clipPlane3: Nullable<Plane>;
  31783. /**
  31784. * Gets or sets the active clipplane 4
  31785. */
  31786. clipPlane4: Nullable<Plane>;
  31787. /**
  31788. * Gets or sets a boolean indicating if animations are enabled
  31789. */
  31790. animationsEnabled: boolean;
  31791. private _animationPropertiesOverride;
  31792. /**
  31793. * Gets or sets the animation properties override
  31794. */
  31795. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31796. /**
  31797. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31798. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31799. */
  31800. useConstantAnimationDeltaTime: boolean;
  31801. /**
  31802. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31803. * Please note that it requires to run a ray cast through the scene on every frame
  31804. */
  31805. constantlyUpdateMeshUnderPointer: boolean;
  31806. /**
  31807. * Defines the HTML cursor to use when hovering over interactive elements
  31808. */
  31809. hoverCursor: string;
  31810. /**
  31811. * Defines the HTML default cursor to use (empty by default)
  31812. */
  31813. defaultCursor: string;
  31814. /**
  31815. * This is used to call preventDefault() on pointer down
  31816. * in order to block unwanted artifacts like system double clicks
  31817. */
  31818. preventDefaultOnPointerDown: boolean;
  31819. /**
  31820. * This is used to call preventDefault() on pointer up
  31821. * in order to block unwanted artifacts like system double clicks
  31822. */
  31823. preventDefaultOnPointerUp: boolean;
  31824. /**
  31825. * Gets or sets user defined metadata
  31826. */
  31827. metadata: any;
  31828. /**
  31829. * For internal use only. Please do not use.
  31830. */
  31831. reservedDataStore: any;
  31832. /**
  31833. * Gets the name of the plugin used to load this scene (null by default)
  31834. */
  31835. loadingPluginName: string;
  31836. /**
  31837. * Use this array to add regular expressions used to disable offline support for specific urls
  31838. */
  31839. disableOfflineSupportExceptionRules: RegExp[];
  31840. /**
  31841. * An event triggered when the scene is disposed.
  31842. */
  31843. onDisposeObservable: Observable<Scene>;
  31844. private _onDisposeObserver;
  31845. /** Sets a function to be executed when this scene is disposed. */
  31846. onDispose: () => void;
  31847. /**
  31848. * An event triggered before rendering the scene (right after animations and physics)
  31849. */
  31850. onBeforeRenderObservable: Observable<Scene>;
  31851. private _onBeforeRenderObserver;
  31852. /** Sets a function to be executed before rendering this scene */
  31853. beforeRender: Nullable<() => void>;
  31854. /**
  31855. * An event triggered after rendering the scene
  31856. */
  31857. onAfterRenderObservable: Observable<Scene>;
  31858. /**
  31859. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  31860. */
  31861. onAfterRenderCameraObservable: Observable<Camera>;
  31862. private _onAfterRenderObserver;
  31863. /** Sets a function to be executed after rendering this scene */
  31864. afterRender: Nullable<() => void>;
  31865. /**
  31866. * An event triggered before animating the scene
  31867. */
  31868. onBeforeAnimationsObservable: Observable<Scene>;
  31869. /**
  31870. * An event triggered after animations processing
  31871. */
  31872. onAfterAnimationsObservable: Observable<Scene>;
  31873. /**
  31874. * An event triggered before draw calls are ready to be sent
  31875. */
  31876. onBeforeDrawPhaseObservable: Observable<Scene>;
  31877. /**
  31878. * An event triggered after draw calls have been sent
  31879. */
  31880. onAfterDrawPhaseObservable: Observable<Scene>;
  31881. /**
  31882. * An event triggered when the scene is ready
  31883. */
  31884. onReadyObservable: Observable<Scene>;
  31885. /**
  31886. * An event triggered before rendering a camera
  31887. */
  31888. onBeforeCameraRenderObservable: Observable<Camera>;
  31889. private _onBeforeCameraRenderObserver;
  31890. /** Sets a function to be executed before rendering a camera*/
  31891. beforeCameraRender: () => void;
  31892. /**
  31893. * An event triggered after rendering a camera
  31894. */
  31895. onAfterCameraRenderObservable: Observable<Camera>;
  31896. private _onAfterCameraRenderObserver;
  31897. /** Sets a function to be executed after rendering a camera*/
  31898. afterCameraRender: () => void;
  31899. /**
  31900. * An event triggered when active meshes evaluation is about to start
  31901. */
  31902. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31903. /**
  31904. * An event triggered when active meshes evaluation is done
  31905. */
  31906. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31907. /**
  31908. * An event triggered when particles rendering is about to start
  31909. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31910. */
  31911. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31912. /**
  31913. * An event triggered when particles rendering is done
  31914. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31915. */
  31916. onAfterParticlesRenderingObservable: Observable<Scene>;
  31917. /**
  31918. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31919. */
  31920. onDataLoadedObservable: Observable<Scene>;
  31921. /**
  31922. * An event triggered when a camera is created
  31923. */
  31924. onNewCameraAddedObservable: Observable<Camera>;
  31925. /**
  31926. * An event triggered when a camera is removed
  31927. */
  31928. onCameraRemovedObservable: Observable<Camera>;
  31929. /**
  31930. * An event triggered when a light is created
  31931. */
  31932. onNewLightAddedObservable: Observable<Light>;
  31933. /**
  31934. * An event triggered when a light is removed
  31935. */
  31936. onLightRemovedObservable: Observable<Light>;
  31937. /**
  31938. * An event triggered when a geometry is created
  31939. */
  31940. onNewGeometryAddedObservable: Observable<Geometry>;
  31941. /**
  31942. * An event triggered when a geometry is removed
  31943. */
  31944. onGeometryRemovedObservable: Observable<Geometry>;
  31945. /**
  31946. * An event triggered when a transform node is created
  31947. */
  31948. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31949. /**
  31950. * An event triggered when a transform node is removed
  31951. */
  31952. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31953. /**
  31954. * An event triggered when a mesh is created
  31955. */
  31956. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31957. /**
  31958. * An event triggered when a mesh is removed
  31959. */
  31960. onMeshRemovedObservable: Observable<AbstractMesh>;
  31961. /**
  31962. * An event triggered when a skeleton is created
  31963. */
  31964. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31965. /**
  31966. * An event triggered when a skeleton is removed
  31967. */
  31968. onSkeletonRemovedObservable: Observable<Skeleton>;
  31969. /**
  31970. * An event triggered when a material is created
  31971. */
  31972. onNewMaterialAddedObservable: Observable<Material>;
  31973. /**
  31974. * An event triggered when a material is removed
  31975. */
  31976. onMaterialRemovedObservable: Observable<Material>;
  31977. /**
  31978. * An event triggered when a texture is created
  31979. */
  31980. onNewTextureAddedObservable: Observable<BaseTexture>;
  31981. /**
  31982. * An event triggered when a texture is removed
  31983. */
  31984. onTextureRemovedObservable: Observable<BaseTexture>;
  31985. /**
  31986. * An event triggered when render targets are about to be rendered
  31987. * Can happen multiple times per frame.
  31988. */
  31989. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31990. /**
  31991. * An event triggered when render targets were rendered.
  31992. * Can happen multiple times per frame.
  31993. */
  31994. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered before calculating deterministic simulation step
  31997. */
  31998. onBeforeStepObservable: Observable<Scene>;
  31999. /**
  32000. * An event triggered after calculating deterministic simulation step
  32001. */
  32002. onAfterStepObservable: Observable<Scene>;
  32003. /**
  32004. * An event triggered when the activeCamera property is updated
  32005. */
  32006. onActiveCameraChanged: Observable<Scene>;
  32007. /**
  32008. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32009. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32010. * 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)
  32011. */
  32012. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32013. /**
  32014. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32015. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32016. * 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)
  32017. */
  32018. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32019. /**
  32020. * This Observable will when a mesh has been imported into the scene.
  32021. */
  32022. onMeshImportedObservable: Observable<AbstractMesh>;
  32023. /**
  32024. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32025. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32026. */
  32027. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32028. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32029. /**
  32030. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32031. */
  32032. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32033. /**
  32034. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32035. */
  32036. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32037. /**
  32038. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32039. */
  32040. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32041. /** Callback called when a pointer move is detected */
  32042. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32043. /** Callback called when a pointer down is detected */
  32044. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32045. /** Callback called when a pointer up is detected */
  32046. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32047. /** Callback called when a pointer pick is detected */
  32048. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32049. /**
  32050. * 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).
  32051. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32052. */
  32053. onPrePointerObservable: Observable<PointerInfoPre>;
  32054. /**
  32055. * Observable event triggered each time an input event is received from the rendering canvas
  32056. */
  32057. onPointerObservable: Observable<PointerInfo>;
  32058. /**
  32059. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32060. */
  32061. readonly unTranslatedPointer: Vector2;
  32062. /**
  32063. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32064. */
  32065. static DragMovementThreshold: number;
  32066. /**
  32067. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32068. */
  32069. static LongPressDelay: number;
  32070. /**
  32071. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32072. */
  32073. static DoubleClickDelay: number;
  32074. /** If you need to check double click without raising a single click at first click, enable this flag */
  32075. static ExclusiveDoubleClickMode: boolean;
  32076. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32077. /**
  32078. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32079. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32080. */
  32081. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32082. /**
  32083. * Observable event triggered each time an keyboard event is received from the hosting window
  32084. */
  32085. onKeyboardObservable: Observable<KeyboardInfo>;
  32086. private _useRightHandedSystem;
  32087. /**
  32088. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32089. */
  32090. useRightHandedSystem: boolean;
  32091. private _timeAccumulator;
  32092. private _currentStepId;
  32093. private _currentInternalStep;
  32094. /**
  32095. * Sets the step Id used by deterministic lock step
  32096. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32097. * @param newStepId defines the step Id
  32098. */
  32099. setStepId(newStepId: number): void;
  32100. /**
  32101. * Gets the step Id used by deterministic lock step
  32102. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32103. * @returns the step Id
  32104. */
  32105. getStepId(): number;
  32106. /**
  32107. * Gets the internal step used by deterministic lock step
  32108. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32109. * @returns the internal step
  32110. */
  32111. getInternalStep(): number;
  32112. private _fogEnabled;
  32113. /**
  32114. * Gets or sets a boolean indicating if fog is enabled on this scene
  32115. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32116. * (Default is true)
  32117. */
  32118. fogEnabled: boolean;
  32119. private _fogMode;
  32120. /**
  32121. * Gets or sets the fog mode to use
  32122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32123. * | mode | value |
  32124. * | --- | --- |
  32125. * | FOGMODE_NONE | 0 |
  32126. * | FOGMODE_EXP | 1 |
  32127. * | FOGMODE_EXP2 | 2 |
  32128. * | FOGMODE_LINEAR | 3 |
  32129. */
  32130. fogMode: number;
  32131. /**
  32132. * Gets or sets the fog color to use
  32133. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32134. * (Default is Color3(0.2, 0.2, 0.3))
  32135. */
  32136. fogColor: Color3;
  32137. /**
  32138. * Gets or sets the fog density to use
  32139. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32140. * (Default is 0.1)
  32141. */
  32142. fogDensity: number;
  32143. /**
  32144. * Gets or sets the fog start distance to use
  32145. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32146. * (Default is 0)
  32147. */
  32148. fogStart: number;
  32149. /**
  32150. * Gets or sets the fog end distance to use
  32151. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32152. * (Default is 1000)
  32153. */
  32154. fogEnd: number;
  32155. private _shadowsEnabled;
  32156. /**
  32157. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32158. */
  32159. shadowsEnabled: boolean;
  32160. private _lightsEnabled;
  32161. /**
  32162. * Gets or sets a boolean indicating if lights are enabled on this scene
  32163. */
  32164. lightsEnabled: boolean;
  32165. /** All of the active cameras added to this scene. */
  32166. activeCameras: Camera[];
  32167. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32168. /** Gets or sets the current active camera */
  32169. activeCamera: Nullable<Camera>;
  32170. private _defaultMaterial;
  32171. /** The default material used on meshes when no material is affected */
  32172. /** The default material used on meshes when no material is affected */
  32173. defaultMaterial: Material;
  32174. private _texturesEnabled;
  32175. /**
  32176. * Gets or sets a boolean indicating if textures are enabled on this scene
  32177. */
  32178. texturesEnabled: boolean;
  32179. /**
  32180. * Gets or sets a boolean indicating if particles are enabled on this scene
  32181. */
  32182. particlesEnabled: boolean;
  32183. /**
  32184. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32185. */
  32186. spritesEnabled: boolean;
  32187. private _skeletonsEnabled;
  32188. /**
  32189. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32190. */
  32191. skeletonsEnabled: boolean;
  32192. /**
  32193. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32194. */
  32195. lensFlaresEnabled: boolean;
  32196. /**
  32197. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32199. */
  32200. collisionsEnabled: boolean;
  32201. private _collisionCoordinator;
  32202. /** @hidden */
  32203. readonly collisionCoordinator: ICollisionCoordinator;
  32204. /**
  32205. * Defines the gravity applied to this scene (used only for collisions)
  32206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32207. */
  32208. gravity: Vector3;
  32209. /**
  32210. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32211. */
  32212. postProcessesEnabled: boolean;
  32213. /**
  32214. * The list of postprocesses added to the scene
  32215. */
  32216. postProcesses: PostProcess[];
  32217. /**
  32218. * Gets the current postprocess manager
  32219. */
  32220. postProcessManager: PostProcessManager;
  32221. /**
  32222. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32223. */
  32224. renderTargetsEnabled: boolean;
  32225. /**
  32226. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32227. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32228. */
  32229. dumpNextRenderTargets: boolean;
  32230. /**
  32231. * The list of user defined render targets added to the scene
  32232. */
  32233. customRenderTargets: RenderTargetTexture[];
  32234. /**
  32235. * Defines if texture loading must be delayed
  32236. * If true, textures will only be loaded when they need to be rendered
  32237. */
  32238. useDelayedTextureLoading: boolean;
  32239. /**
  32240. * Gets the list of meshes imported to the scene through SceneLoader
  32241. */
  32242. importedMeshesFiles: String[];
  32243. /**
  32244. * Gets or sets a boolean indicating if probes are enabled on this scene
  32245. */
  32246. probesEnabled: boolean;
  32247. /**
  32248. * Gets or sets the current offline provider to use to store scene data
  32249. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32250. */
  32251. offlineProvider: IOfflineProvider;
  32252. /**
  32253. * Gets or sets the action manager associated with the scene
  32254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32255. */
  32256. actionManager: AbstractActionManager;
  32257. private _meshesForIntersections;
  32258. /**
  32259. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32260. */
  32261. proceduralTexturesEnabled: boolean;
  32262. private _engine;
  32263. private _totalVertices;
  32264. /** @hidden */ private _activeIndices: PerfCounter;
  32265. /** @hidden */ private _activeParticles: PerfCounter;
  32266. /** @hidden */ private _activeBones: PerfCounter;
  32267. private _animationRatio;
  32268. /** @hidden */ private _animationTimeLast: number;
  32269. /** @hidden */ private _animationTime: number;
  32270. /**
  32271. * Gets or sets a general scale for animation speed
  32272. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32273. */
  32274. animationTimeScale: number;
  32275. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32276. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32277. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32278. private _renderId;
  32279. private _frameId;
  32280. private _executeWhenReadyTimeoutId;
  32281. private _intermediateRendering;
  32282. private _viewUpdateFlag;
  32283. private _projectionUpdateFlag;
  32284. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32285. private _activeRequests;
  32286. /** @hidden */ private _pendingData: any[];
  32287. private _isDisposed;
  32288. /**
  32289. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32290. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32291. */
  32292. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32293. private _activeMeshes;
  32294. private _processedMaterials;
  32295. private _renderTargets;
  32296. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32297. private _activeSkeletons;
  32298. private _softwareSkinnedMeshes;
  32299. private _renderingManager;
  32300. /** @hidden */ private _activeAnimatables: Animatable[];
  32301. private _transformMatrix;
  32302. private _sceneUbo;
  32303. /** @hidden */ private _viewMatrix: Matrix;
  32304. private _projectionMatrix;
  32305. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32306. /** @hidden */ private _frustumPlanes: Plane[];
  32307. /**
  32308. * Gets the list of frustum planes (built from the active camera)
  32309. */
  32310. readonly frustumPlanes: Plane[];
  32311. /**
  32312. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32313. * This is useful if there are more lights that the maximum simulteanous authorized
  32314. */
  32315. requireLightSorting: boolean;
  32316. /** @hidden */
  32317. readonly useMaterialMeshMap: boolean;
  32318. /** @hidden */
  32319. readonly useClonedMeshhMap: boolean;
  32320. private _externalData;
  32321. private _uid;
  32322. /**
  32323. * @hidden
  32324. * Backing store of defined scene components.
  32325. */ private _components: ISceneComponent[];
  32326. /**
  32327. * @hidden
  32328. * Backing store of defined scene components.
  32329. */ private _serializableComponents: ISceneSerializableComponent[];
  32330. /**
  32331. * List of components to register on the next registration step.
  32332. */
  32333. private _transientComponents;
  32334. /**
  32335. * Registers the transient components if needed.
  32336. */
  32337. private _registerTransientComponents;
  32338. /**
  32339. * @hidden
  32340. * Add a component to the scene.
  32341. * Note that the ccomponent could be registered on th next frame if this is called after
  32342. * the register component stage.
  32343. * @param component Defines the component to add to the scene
  32344. */ private _addComponent(component: ISceneComponent): void;
  32345. /**
  32346. * @hidden
  32347. * Gets a component from the scene.
  32348. * @param name defines the name of the component to retrieve
  32349. * @returns the component or null if not present
  32350. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32351. /**
  32352. * @hidden
  32353. * Defines the actions happening before camera updates.
  32354. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32355. /**
  32356. * @hidden
  32357. * Defines the actions happening before clear the canvas.
  32358. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32359. /**
  32360. * @hidden
  32361. * Defines the actions when collecting render targets for the frame.
  32362. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32363. /**
  32364. * @hidden
  32365. * Defines the actions happening for one camera in the frame.
  32366. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32367. /**
  32368. * @hidden
  32369. * Defines the actions happening during the per mesh ready checks.
  32370. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32371. /**
  32372. * @hidden
  32373. * Defines the actions happening before evaluate active mesh checks.
  32374. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32375. /**
  32376. * @hidden
  32377. * Defines the actions happening during the evaluate sub mesh checks.
  32378. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32379. /**
  32380. * @hidden
  32381. * Defines the actions happening during the active mesh stage.
  32382. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32383. /**
  32384. * @hidden
  32385. * Defines the actions happening during the per camera render target step.
  32386. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32387. /**
  32388. * @hidden
  32389. * Defines the actions happening just before the active camera is drawing.
  32390. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32391. /**
  32392. * @hidden
  32393. * Defines the actions happening just before a render target is drawing.
  32394. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32395. /**
  32396. * @hidden
  32397. * Defines the actions happening just before a rendering group is drawing.
  32398. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32399. /**
  32400. * @hidden
  32401. * Defines the actions happening just before a mesh is drawing.
  32402. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32403. /**
  32404. * @hidden
  32405. * Defines the actions happening just after a mesh has been drawn.
  32406. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32407. /**
  32408. * @hidden
  32409. * Defines the actions happening just after a rendering group has been drawn.
  32410. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32411. /**
  32412. * @hidden
  32413. * Defines the actions happening just after the active camera has been drawn.
  32414. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32415. /**
  32416. * @hidden
  32417. * Defines the actions happening just after a render target has been drawn.
  32418. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32419. /**
  32420. * @hidden
  32421. * Defines the actions happening just after rendering all cameras and computing intersections.
  32422. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32423. /**
  32424. * @hidden
  32425. * Defines the actions happening when a pointer move event happens.
  32426. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32427. /**
  32428. * @hidden
  32429. * Defines the actions happening when a pointer down event happens.
  32430. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32431. /**
  32432. * @hidden
  32433. * Defines the actions happening when a pointer up event happens.
  32434. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32435. /**
  32436. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32437. */
  32438. private geometriesByUniqueId;
  32439. /**
  32440. * Creates a new Scene
  32441. * @param engine defines the engine to use to render this scene
  32442. * @param options defines the scene options
  32443. */
  32444. constructor(engine: Engine, options?: SceneOptions);
  32445. /**
  32446. * Gets a string idenfifying the name of the class
  32447. * @returns "Scene" string
  32448. */
  32449. getClassName(): string;
  32450. private _defaultMeshCandidates;
  32451. /**
  32452. * @hidden
  32453. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32454. private _defaultSubMeshCandidates;
  32455. /**
  32456. * @hidden
  32457. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32458. /**
  32459. * Sets the default candidate providers for the scene.
  32460. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32461. * and getCollidingSubMeshCandidates to their default function
  32462. */
  32463. setDefaultCandidateProviders(): void;
  32464. /**
  32465. * Gets the mesh that is currently under the pointer
  32466. */
  32467. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32468. /**
  32469. * Gets or sets the current on-screen X position of the pointer
  32470. */
  32471. pointerX: number;
  32472. /**
  32473. * Gets or sets the current on-screen Y position of the pointer
  32474. */
  32475. pointerY: number;
  32476. /**
  32477. * Gets the cached material (ie. the latest rendered one)
  32478. * @returns the cached material
  32479. */
  32480. getCachedMaterial(): Nullable<Material>;
  32481. /**
  32482. * Gets the cached effect (ie. the latest rendered one)
  32483. * @returns the cached effect
  32484. */
  32485. getCachedEffect(): Nullable<Effect>;
  32486. /**
  32487. * Gets the cached visibility state (ie. the latest rendered one)
  32488. * @returns the cached visibility state
  32489. */
  32490. getCachedVisibility(): Nullable<number>;
  32491. /**
  32492. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32493. * @param material defines the current material
  32494. * @param effect defines the current effect
  32495. * @param visibility defines the current visibility state
  32496. * @returns true if one parameter is not cached
  32497. */
  32498. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32499. /**
  32500. * Gets the engine associated with the scene
  32501. * @returns an Engine
  32502. */
  32503. getEngine(): Engine;
  32504. /**
  32505. * Gets the total number of vertices rendered per frame
  32506. * @returns the total number of vertices rendered per frame
  32507. */
  32508. getTotalVertices(): number;
  32509. /**
  32510. * Gets the performance counter for total vertices
  32511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32512. */
  32513. readonly totalVerticesPerfCounter: PerfCounter;
  32514. /**
  32515. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32516. * @returns the total number of active indices rendered per frame
  32517. */
  32518. getActiveIndices(): number;
  32519. /**
  32520. * Gets the performance counter for active indices
  32521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32522. */
  32523. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32524. /**
  32525. * Gets the total number of active particles rendered per frame
  32526. * @returns the total number of active particles rendered per frame
  32527. */
  32528. getActiveParticles(): number;
  32529. /**
  32530. * Gets the performance counter for active particles
  32531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32532. */
  32533. readonly activeParticlesPerfCounter: PerfCounter;
  32534. /**
  32535. * Gets the total number of active bones rendered per frame
  32536. * @returns the total number of active bones rendered per frame
  32537. */
  32538. getActiveBones(): number;
  32539. /**
  32540. * Gets the performance counter for active bones
  32541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32542. */
  32543. readonly activeBonesPerfCounter: PerfCounter;
  32544. /**
  32545. * Gets the array of active meshes
  32546. * @returns an array of AbstractMesh
  32547. */
  32548. getActiveMeshes(): SmartArray<AbstractMesh>;
  32549. /**
  32550. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32551. * @returns a number
  32552. */
  32553. getAnimationRatio(): number;
  32554. /**
  32555. * Gets an unique Id for the current render phase
  32556. * @returns a number
  32557. */
  32558. getRenderId(): number;
  32559. /**
  32560. * Gets an unique Id for the current frame
  32561. * @returns a number
  32562. */
  32563. getFrameId(): number;
  32564. /** Call this function if you want to manually increment the render Id*/
  32565. incrementRenderId(): void;
  32566. private _createUbo;
  32567. /**
  32568. * Use this method to simulate a pointer move on a mesh
  32569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32572. * @returns the current scene
  32573. */
  32574. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32575. /**
  32576. * Use this method to simulate a pointer down on a mesh
  32577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32580. * @returns the current scene
  32581. */
  32582. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32583. /**
  32584. * Use this method to simulate a pointer up on a mesh
  32585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32588. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32589. * @returns the current scene
  32590. */
  32591. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32592. /**
  32593. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32594. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32595. * @returns true if the pointer was captured
  32596. */
  32597. isPointerCaptured(pointerId?: number): boolean;
  32598. /**
  32599. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32600. * @param attachUp defines if you want to attach events to pointerup
  32601. * @param attachDown defines if you want to attach events to pointerdown
  32602. * @param attachMove defines if you want to attach events to pointermove
  32603. */
  32604. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32605. /** Detaches all event handlers*/
  32606. detachControl(): void;
  32607. /**
  32608. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32609. * Delay loaded resources are not taking in account
  32610. * @return true if all required resources are ready
  32611. */
  32612. isReady(): boolean;
  32613. /** Resets all cached information relative to material (including effect and visibility) */
  32614. resetCachedMaterial(): void;
  32615. /**
  32616. * Registers a function to be called before every frame render
  32617. * @param func defines the function to register
  32618. */
  32619. registerBeforeRender(func: () => void): void;
  32620. /**
  32621. * Unregisters a function called before every frame render
  32622. * @param func defines the function to unregister
  32623. */
  32624. unregisterBeforeRender(func: () => void): void;
  32625. /**
  32626. * Registers a function to be called after every frame render
  32627. * @param func defines the function to register
  32628. */
  32629. registerAfterRender(func: () => void): void;
  32630. /**
  32631. * Unregisters a function called after every frame render
  32632. * @param func defines the function to unregister
  32633. */
  32634. unregisterAfterRender(func: () => void): void;
  32635. private _executeOnceBeforeRender;
  32636. /**
  32637. * The provided function will run before render once and will be disposed afterwards.
  32638. * A timeout delay can be provided so that the function will be executed in N ms.
  32639. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32640. * @param func The function to be executed.
  32641. * @param timeout optional delay in ms
  32642. */
  32643. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32644. /** @hidden */ private _addPendingData(data: any): void;
  32645. /** @hidden */ private _removePendingData(data: any): void;
  32646. /**
  32647. * Returns the number of items waiting to be loaded
  32648. * @returns the number of items waiting to be loaded
  32649. */
  32650. getWaitingItemsCount(): number;
  32651. /**
  32652. * Returns a boolean indicating if the scene is still loading data
  32653. */
  32654. readonly isLoading: boolean;
  32655. /**
  32656. * Registers a function to be executed when the scene is ready
  32657. * @param {Function} func - the function to be executed
  32658. */
  32659. executeWhenReady(func: () => void): void;
  32660. /**
  32661. * Returns a promise that resolves when the scene is ready
  32662. * @returns A promise that resolves when the scene is ready
  32663. */
  32664. whenReadyAsync(): Promise<void>;
  32665. /** @hidden */ private _checkIsReady(): void;
  32666. /**
  32667. * Gets all animatable attached to the scene
  32668. */
  32669. readonly animatables: Animatable[];
  32670. /**
  32671. * Resets the last animation time frame.
  32672. * Useful to override when animations start running when loading a scene for the first time.
  32673. */
  32674. resetLastAnimationTimeFrame(): void;
  32675. /**
  32676. * Gets the current view matrix
  32677. * @returns a Matrix
  32678. */
  32679. getViewMatrix(): Matrix;
  32680. /**
  32681. * Gets the current projection matrix
  32682. * @returns a Matrix
  32683. */
  32684. getProjectionMatrix(): Matrix;
  32685. /**
  32686. * Gets the current transform matrix
  32687. * @returns a Matrix made of View * Projection
  32688. */
  32689. getTransformMatrix(): Matrix;
  32690. /**
  32691. * Sets the current transform matrix
  32692. * @param viewL defines the View matrix to use
  32693. * @param projectionL defines the Projection matrix to use
  32694. * @param viewR defines the right View matrix to use (if provided)
  32695. * @param projectionR defines the right Projection matrix to use (if provided)
  32696. */
  32697. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32698. /**
  32699. * Gets the uniform buffer used to store scene data
  32700. * @returns a UniformBuffer
  32701. */
  32702. getSceneUniformBuffer(): UniformBuffer;
  32703. /**
  32704. * Gets an unique (relatively to the current scene) Id
  32705. * @returns an unique number for the scene
  32706. */
  32707. getUniqueId(): number;
  32708. /**
  32709. * Add a mesh to the list of scene's meshes
  32710. * @param newMesh defines the mesh to add
  32711. * @param recursive if all child meshes should also be added to the scene
  32712. */
  32713. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32714. /**
  32715. * Remove a mesh for the list of scene's meshes
  32716. * @param toRemove defines the mesh to remove
  32717. * @param recursive if all child meshes should also be removed from the scene
  32718. * @returns the index where the mesh was in the mesh list
  32719. */
  32720. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32721. /**
  32722. * Add a transform node to the list of scene's transform nodes
  32723. * @param newTransformNode defines the transform node to add
  32724. */
  32725. addTransformNode(newTransformNode: TransformNode): void;
  32726. /**
  32727. * Remove a transform node for the list of scene's transform nodes
  32728. * @param toRemove defines the transform node to remove
  32729. * @returns the index where the transform node was in the transform node list
  32730. */
  32731. removeTransformNode(toRemove: TransformNode): number;
  32732. /**
  32733. * Remove a skeleton for the list of scene's skeletons
  32734. * @param toRemove defines the skeleton to remove
  32735. * @returns the index where the skeleton was in the skeleton list
  32736. */
  32737. removeSkeleton(toRemove: Skeleton): number;
  32738. /**
  32739. * Remove a morph target for the list of scene's morph targets
  32740. * @param toRemove defines the morph target to remove
  32741. * @returns the index where the morph target was in the morph target list
  32742. */
  32743. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32744. /**
  32745. * Remove a light for the list of scene's lights
  32746. * @param toRemove defines the light to remove
  32747. * @returns the index where the light was in the light list
  32748. */
  32749. removeLight(toRemove: Light): number;
  32750. /**
  32751. * Remove a camera for the list of scene's cameras
  32752. * @param toRemove defines the camera to remove
  32753. * @returns the index where the camera was in the camera list
  32754. */
  32755. removeCamera(toRemove: Camera): number;
  32756. /**
  32757. * Remove a particle system for the list of scene's particle systems
  32758. * @param toRemove defines the particle system to remove
  32759. * @returns the index where the particle system was in the particle system list
  32760. */
  32761. removeParticleSystem(toRemove: IParticleSystem): number;
  32762. /**
  32763. * Remove a animation for the list of scene's animations
  32764. * @param toRemove defines the animation to remove
  32765. * @returns the index where the animation was in the animation list
  32766. */
  32767. removeAnimation(toRemove: Animation): number;
  32768. /**
  32769. * Will stop the animation of the given target
  32770. * @param target - the target
  32771. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32772. * @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)
  32773. */
  32774. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32775. /**
  32776. * Removes the given animation group from this scene.
  32777. * @param toRemove The animation group to remove
  32778. * @returns The index of the removed animation group
  32779. */
  32780. removeAnimationGroup(toRemove: AnimationGroup): number;
  32781. /**
  32782. * Removes the given multi-material from this scene.
  32783. * @param toRemove The multi-material to remove
  32784. * @returns The index of the removed multi-material
  32785. */
  32786. removeMultiMaterial(toRemove: MultiMaterial): number;
  32787. /**
  32788. * Removes the given material from this scene.
  32789. * @param toRemove The material to remove
  32790. * @returns The index of the removed material
  32791. */
  32792. removeMaterial(toRemove: Material): number;
  32793. /**
  32794. * Removes the given action manager from this scene.
  32795. * @param toRemove The action manager to remove
  32796. * @returns The index of the removed action manager
  32797. */
  32798. removeActionManager(toRemove: AbstractActionManager): number;
  32799. /**
  32800. * Removes the given texture from this scene.
  32801. * @param toRemove The texture to remove
  32802. * @returns The index of the removed texture
  32803. */
  32804. removeTexture(toRemove: BaseTexture): number;
  32805. /**
  32806. * Adds the given light to this scene
  32807. * @param newLight The light to add
  32808. */
  32809. addLight(newLight: Light): void;
  32810. /**
  32811. * Sorts the list list based on light priorities
  32812. */
  32813. sortLightsByPriority(): void;
  32814. /**
  32815. * Adds the given camera to this scene
  32816. * @param newCamera The camera to add
  32817. */
  32818. addCamera(newCamera: Camera): void;
  32819. /**
  32820. * Adds the given skeleton to this scene
  32821. * @param newSkeleton The skeleton to add
  32822. */
  32823. addSkeleton(newSkeleton: Skeleton): void;
  32824. /**
  32825. * Adds the given particle system to this scene
  32826. * @param newParticleSystem The particle system to add
  32827. */
  32828. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32829. /**
  32830. * Adds the given animation to this scene
  32831. * @param newAnimation The animation to add
  32832. */
  32833. addAnimation(newAnimation: Animation): void;
  32834. /**
  32835. * Adds the given animation group to this scene.
  32836. * @param newAnimationGroup The animation group to add
  32837. */
  32838. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32839. /**
  32840. * Adds the given multi-material to this scene
  32841. * @param newMultiMaterial The multi-material to add
  32842. */
  32843. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32844. /**
  32845. * Adds the given material to this scene
  32846. * @param newMaterial The material to add
  32847. */
  32848. addMaterial(newMaterial: Material): void;
  32849. /**
  32850. * Adds the given morph target to this scene
  32851. * @param newMorphTargetManager The morph target to add
  32852. */
  32853. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32854. /**
  32855. * Adds the given geometry to this scene
  32856. * @param newGeometry The geometry to add
  32857. */
  32858. addGeometry(newGeometry: Geometry): void;
  32859. /**
  32860. * Adds the given action manager to this scene
  32861. * @param newActionManager The action manager to add
  32862. */
  32863. addActionManager(newActionManager: AbstractActionManager): void;
  32864. /**
  32865. * Adds the given texture to this scene.
  32866. * @param newTexture The texture to add
  32867. */
  32868. addTexture(newTexture: BaseTexture): void;
  32869. /**
  32870. * Switch active camera
  32871. * @param newCamera defines the new active camera
  32872. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32873. */
  32874. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32875. /**
  32876. * sets the active camera of the scene using its ID
  32877. * @param id defines the camera's ID
  32878. * @return the new active camera or null if none found.
  32879. */
  32880. setActiveCameraByID(id: string): Nullable<Camera>;
  32881. /**
  32882. * sets the active camera of the scene using its name
  32883. * @param name defines the camera's name
  32884. * @returns the new active camera or null if none found.
  32885. */
  32886. setActiveCameraByName(name: string): Nullable<Camera>;
  32887. /**
  32888. * get an animation group using its name
  32889. * @param name defines the material's name
  32890. * @return the animation group or null if none found.
  32891. */
  32892. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32893. /**
  32894. * Get a material using its unique id
  32895. * @param uniqueId defines the material's unique id
  32896. * @return the material or null if none found.
  32897. */
  32898. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32899. /**
  32900. * get a material using its id
  32901. * @param id defines the material's ID
  32902. * @return the material or null if none found.
  32903. */
  32904. getMaterialByID(id: string): Nullable<Material>;
  32905. /**
  32906. * Gets a the last added material using a given id
  32907. * @param id defines the material's ID
  32908. * @return the last material with the given id or null if none found.
  32909. */
  32910. getLastMaterialByID(id: string): Nullable<Material>;
  32911. /**
  32912. * Gets a material using its name
  32913. * @param name defines the material's name
  32914. * @return the material or null if none found.
  32915. */
  32916. getMaterialByName(name: string): Nullable<Material>;
  32917. /**
  32918. * Gets a camera using its id
  32919. * @param id defines the id to look for
  32920. * @returns the camera or null if not found
  32921. */
  32922. getCameraByID(id: string): Nullable<Camera>;
  32923. /**
  32924. * Gets a camera using its unique id
  32925. * @param uniqueId defines the unique id to look for
  32926. * @returns the camera or null if not found
  32927. */
  32928. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32929. /**
  32930. * Gets a camera using its name
  32931. * @param name defines the camera's name
  32932. * @return the camera or null if none found.
  32933. */
  32934. getCameraByName(name: string): Nullable<Camera>;
  32935. /**
  32936. * Gets a bone using its id
  32937. * @param id defines the bone's id
  32938. * @return the bone or null if not found
  32939. */
  32940. getBoneByID(id: string): Nullable<Bone>;
  32941. /**
  32942. * Gets a bone using its id
  32943. * @param name defines the bone's name
  32944. * @return the bone or null if not found
  32945. */
  32946. getBoneByName(name: string): Nullable<Bone>;
  32947. /**
  32948. * Gets a light node using its name
  32949. * @param name defines the the light's name
  32950. * @return the light or null if none found.
  32951. */
  32952. getLightByName(name: string): Nullable<Light>;
  32953. /**
  32954. * Gets a light node using its id
  32955. * @param id defines the light's id
  32956. * @return the light or null if none found.
  32957. */
  32958. getLightByID(id: string): Nullable<Light>;
  32959. /**
  32960. * Gets a light node using its scene-generated unique ID
  32961. * @param uniqueId defines the light's unique id
  32962. * @return the light or null if none found.
  32963. */
  32964. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32965. /**
  32966. * Gets a particle system by id
  32967. * @param id defines the particle system id
  32968. * @return the corresponding system or null if none found
  32969. */
  32970. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32971. /**
  32972. * Gets a geometry using its ID
  32973. * @param id defines the geometry's id
  32974. * @return the geometry or null if none found.
  32975. */
  32976. getGeometryByID(id: string): Nullable<Geometry>;
  32977. private _getGeometryByUniqueID;
  32978. /**
  32979. * Add a new geometry to this scene
  32980. * @param geometry defines the geometry to be added to the scene.
  32981. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32982. * @return a boolean defining if the geometry was added or not
  32983. */
  32984. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32985. /**
  32986. * Removes an existing geometry
  32987. * @param geometry defines the geometry to be removed from the scene
  32988. * @return a boolean defining if the geometry was removed or not
  32989. */
  32990. removeGeometry(geometry: Geometry): boolean;
  32991. /**
  32992. * Gets the list of geometries attached to the scene
  32993. * @returns an array of Geometry
  32994. */
  32995. getGeometries(): Geometry[];
  32996. /**
  32997. * Gets the first added mesh found of a given ID
  32998. * @param id defines the id to search for
  32999. * @return the mesh found or null if not found at all
  33000. */
  33001. getMeshByID(id: string): Nullable<AbstractMesh>;
  33002. /**
  33003. * Gets a list of meshes using their id
  33004. * @param id defines the id to search for
  33005. * @returns a list of meshes
  33006. */
  33007. getMeshesByID(id: string): Array<AbstractMesh>;
  33008. /**
  33009. * Gets the first added transform node found of a given ID
  33010. * @param id defines the id to search for
  33011. * @return the found transform node or null if not found at all.
  33012. */
  33013. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33014. /**
  33015. * Gets a transform node with its auto-generated unique id
  33016. * @param uniqueId efines the unique id to search for
  33017. * @return the found transform node or null if not found at all.
  33018. */
  33019. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33020. /**
  33021. * Gets a list of transform nodes using their id
  33022. * @param id defines the id to search for
  33023. * @returns a list of transform nodes
  33024. */
  33025. getTransformNodesByID(id: string): Array<TransformNode>;
  33026. /**
  33027. * Gets a mesh with its auto-generated unique id
  33028. * @param uniqueId defines the unique id to search for
  33029. * @return the found mesh or null if not found at all.
  33030. */
  33031. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33032. /**
  33033. * Gets a the last added mesh using a given id
  33034. * @param id defines the id to search for
  33035. * @return the found mesh or null if not found at all.
  33036. */
  33037. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33038. /**
  33039. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33040. * @param id defines the id to search for
  33041. * @return the found node or null if not found at all
  33042. */
  33043. getLastEntryByID(id: string): Nullable<Node>;
  33044. /**
  33045. * Gets a node (Mesh, Camera, Light) using a given id
  33046. * @param id defines the id to search for
  33047. * @return the found node or null if not found at all
  33048. */
  33049. getNodeByID(id: string): Nullable<Node>;
  33050. /**
  33051. * Gets a node (Mesh, Camera, Light) using a given name
  33052. * @param name defines the name to search for
  33053. * @return the found node or null if not found at all.
  33054. */
  33055. getNodeByName(name: string): Nullable<Node>;
  33056. /**
  33057. * Gets a mesh using a given name
  33058. * @param name defines the name to search for
  33059. * @return the found mesh or null if not found at all.
  33060. */
  33061. getMeshByName(name: string): Nullable<AbstractMesh>;
  33062. /**
  33063. * Gets a transform node using a given name
  33064. * @param name defines the name to search for
  33065. * @return the found transform node or null if not found at all.
  33066. */
  33067. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33068. /**
  33069. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33070. * @param id defines the id to search for
  33071. * @return the found skeleton or null if not found at all.
  33072. */
  33073. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33074. /**
  33075. * Gets a skeleton using a given auto generated unique id
  33076. * @param uniqueId defines the unique id to search for
  33077. * @return the found skeleton or null if not found at all.
  33078. */
  33079. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33080. /**
  33081. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33082. * @param id defines the id to search for
  33083. * @return the found skeleton or null if not found at all.
  33084. */
  33085. getSkeletonById(id: string): Nullable<Skeleton>;
  33086. /**
  33087. * Gets a skeleton using a given name
  33088. * @param name defines the name to search for
  33089. * @return the found skeleton or null if not found at all.
  33090. */
  33091. getSkeletonByName(name: string): Nullable<Skeleton>;
  33092. /**
  33093. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33094. * @param id defines the id to search for
  33095. * @return the found morph target manager or null if not found at all.
  33096. */
  33097. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33098. /**
  33099. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33100. * @param id defines the id to search for
  33101. * @return the found morph target or null if not found at all.
  33102. */
  33103. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33104. /**
  33105. * Gets a boolean indicating if the given mesh is active
  33106. * @param mesh defines the mesh to look for
  33107. * @returns true if the mesh is in the active list
  33108. */
  33109. isActiveMesh(mesh: AbstractMesh): boolean;
  33110. /**
  33111. * Return a unique id as a string which can serve as an identifier for the scene
  33112. */
  33113. readonly uid: string;
  33114. /**
  33115. * Add an externaly attached data from its key.
  33116. * This method call will fail and return false, if such key already exists.
  33117. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33118. * @param key the unique key that identifies the data
  33119. * @param data the data object to associate to the key for this Engine instance
  33120. * @return true if no such key were already present and the data was added successfully, false otherwise
  33121. */
  33122. addExternalData<T>(key: string, data: T): boolean;
  33123. /**
  33124. * Get an externaly attached data from its key
  33125. * @param key the unique key that identifies the data
  33126. * @return the associated data, if present (can be null), or undefined if not present
  33127. */
  33128. getExternalData<T>(key: string): Nullable<T>;
  33129. /**
  33130. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33131. * @param key the unique key that identifies the data
  33132. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33133. * @return the associated data, can be null if the factory returned null.
  33134. */
  33135. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33136. /**
  33137. * Remove an externaly attached data from the Engine instance
  33138. * @param key the unique key that identifies the data
  33139. * @return true if the data was successfully removed, false if it doesn't exist
  33140. */
  33141. removeExternalData(key: string): boolean;
  33142. private _evaluateSubMesh;
  33143. /**
  33144. * Clear the processed materials smart array preventing retention point in material dispose.
  33145. */
  33146. freeProcessedMaterials(): void;
  33147. private _preventFreeActiveMeshesAndRenderingGroups;
  33148. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33149. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33150. * when disposing several meshes in a row or a hierarchy of meshes.
  33151. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33152. */
  33153. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33154. /**
  33155. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33156. */
  33157. freeActiveMeshes(): void;
  33158. /**
  33159. * Clear the info related to rendering groups preventing retention points during dispose.
  33160. */
  33161. freeRenderingGroups(): void;
  33162. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33163. /**
  33164. * Lambda returning the list of potentially active meshes.
  33165. */
  33166. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33167. /**
  33168. * Lambda returning the list of potentially active sub meshes.
  33169. */
  33170. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33171. /**
  33172. * Lambda returning the list of potentially intersecting sub meshes.
  33173. */
  33174. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33175. /**
  33176. * Lambda returning the list of potentially colliding sub meshes.
  33177. */
  33178. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33179. private _activeMeshesFrozen;
  33180. /**
  33181. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33182. * @returns the current scene
  33183. */
  33184. freezeActiveMeshes(): Scene;
  33185. /**
  33186. * Use this function to restart evaluating active meshes on every frame
  33187. * @returns the current scene
  33188. */
  33189. unfreezeActiveMeshes(): Scene;
  33190. private _evaluateActiveMeshes;
  33191. private _activeMesh;
  33192. /**
  33193. * Update the transform matrix to update from the current active camera
  33194. * @param force defines a boolean used to force the update even if cache is up to date
  33195. */
  33196. updateTransformMatrix(force?: boolean): void;
  33197. private _bindFrameBuffer;
  33198. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33199. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33200. private _processSubCameras;
  33201. private _checkIntersections;
  33202. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33203. /**
  33204. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33205. */
  33206. getDeterministicFrameTime: () => number;
  33207. /** @hidden */ private _animate(): void;
  33208. /** Execute all animations (for a frame) */
  33209. animate(): void;
  33210. /**
  33211. * Render the scene
  33212. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33213. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33214. */
  33215. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33216. /**
  33217. * Freeze all materials
  33218. * A frozen material will not be updatable but should be faster to render
  33219. */
  33220. freezeMaterials(): void;
  33221. /**
  33222. * Unfreeze all materials
  33223. * A frozen material will not be updatable but should be faster to render
  33224. */
  33225. unfreezeMaterials(): void;
  33226. /**
  33227. * Releases all held ressources
  33228. */
  33229. dispose(): void;
  33230. /**
  33231. * Gets if the scene is already disposed
  33232. */
  33233. readonly isDisposed: boolean;
  33234. /**
  33235. * Call this function to reduce memory footprint of the scene.
  33236. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33237. */
  33238. clearCachedVertexData(): void;
  33239. /**
  33240. * This function will remove the local cached buffer data from texture.
  33241. * It will save memory but will prevent the texture from being rebuilt
  33242. */
  33243. cleanCachedTextureBuffer(): void;
  33244. /**
  33245. * Get the world extend vectors with an optional filter
  33246. *
  33247. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33248. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33249. */
  33250. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33251. min: Vector3;
  33252. max: Vector3;
  33253. };
  33254. /**
  33255. * Creates a ray that can be used to pick in the scene
  33256. * @param x defines the x coordinate of the origin (on-screen)
  33257. * @param y defines the y coordinate of the origin (on-screen)
  33258. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33259. * @param camera defines the camera to use for the picking
  33260. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33261. * @returns a Ray
  33262. */
  33263. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33264. /**
  33265. * Creates a ray that can be used to pick in the scene
  33266. * @param x defines the x coordinate of the origin (on-screen)
  33267. * @param y defines the y coordinate of the origin (on-screen)
  33268. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33269. * @param result defines the ray where to store the picking ray
  33270. * @param camera defines the camera to use for the picking
  33271. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33272. * @returns the current scene
  33273. */
  33274. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33275. /**
  33276. * Creates a ray that can be used to pick in the scene
  33277. * @param x defines the x coordinate of the origin (on-screen)
  33278. * @param y defines the y coordinate of the origin (on-screen)
  33279. * @param camera defines the camera to use for the picking
  33280. * @returns a Ray
  33281. */
  33282. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33283. /**
  33284. * Creates a ray that can be used to pick in the scene
  33285. * @param x defines the x coordinate of the origin (on-screen)
  33286. * @param y defines the y coordinate of the origin (on-screen)
  33287. * @param result defines the ray where to store the picking ray
  33288. * @param camera defines the camera to use for the picking
  33289. * @returns the current scene
  33290. */
  33291. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33292. /** Launch a ray to try to pick a mesh in the scene
  33293. * @param x position on screen
  33294. * @param y position on screen
  33295. * @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
  33296. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33297. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33298. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33299. * @returns a PickingInfo
  33300. */
  33301. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33302. /** Use the given ray to pick a mesh in the scene
  33303. * @param ray The ray to use to pick meshes
  33304. * @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
  33305. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33306. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33307. * @returns a PickingInfo
  33308. */
  33309. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33310. /**
  33311. * Launch a ray to try to pick a mesh in the scene
  33312. * @param x X position on screen
  33313. * @param y Y position on screen
  33314. * @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
  33315. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33316. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33317. * @returns an array of PickingInfo
  33318. */
  33319. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33320. /**
  33321. * Launch a ray to try to pick a mesh in the scene
  33322. * @param ray Ray to use
  33323. * @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
  33324. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33325. * @returns an array of PickingInfo
  33326. */
  33327. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33328. /**
  33329. * Force the value of meshUnderPointer
  33330. * @param mesh defines the mesh to use
  33331. */
  33332. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33333. /**
  33334. * Gets the mesh under the pointer
  33335. * @returns a Mesh or null if no mesh is under the pointer
  33336. */
  33337. getPointerOverMesh(): Nullable<AbstractMesh>;
  33338. /** @hidden */ private _rebuildGeometries(): void;
  33339. /** @hidden */ private _rebuildTextures(): void;
  33340. private _getByTags;
  33341. /**
  33342. * Get a list of meshes by tags
  33343. * @param tagsQuery defines the tags query to use
  33344. * @param forEach defines a predicate used to filter results
  33345. * @returns an array of Mesh
  33346. */
  33347. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33348. /**
  33349. * Get a list of cameras by tags
  33350. * @param tagsQuery defines the tags query to use
  33351. * @param forEach defines a predicate used to filter results
  33352. * @returns an array of Camera
  33353. */
  33354. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33355. /**
  33356. * Get a list of lights by tags
  33357. * @param tagsQuery defines the tags query to use
  33358. * @param forEach defines a predicate used to filter results
  33359. * @returns an array of Light
  33360. */
  33361. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33362. /**
  33363. * Get a list of materials by tags
  33364. * @param tagsQuery defines the tags query to use
  33365. * @param forEach defines a predicate used to filter results
  33366. * @returns an array of Material
  33367. */
  33368. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33369. /**
  33370. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33371. * This allowed control for front to back rendering or reversly depending of the special needs.
  33372. *
  33373. * @param renderingGroupId The rendering group id corresponding to its index
  33374. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33375. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33376. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33377. */
  33378. 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;
  33379. /**
  33380. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33381. *
  33382. * @param renderingGroupId The rendering group id corresponding to its index
  33383. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33384. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33385. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33386. */
  33387. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33388. /**
  33389. * Gets the current auto clear configuration for one rendering group of the rendering
  33390. * manager.
  33391. * @param index the rendering group index to get the information for
  33392. * @returns The auto clear setup for the requested rendering group
  33393. */
  33394. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33395. private _blockMaterialDirtyMechanism;
  33396. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33397. blockMaterialDirtyMechanism: boolean;
  33398. /**
  33399. * Will flag all materials as dirty to trigger new shader compilation
  33400. * @param flag defines the flag used to specify which material part must be marked as dirty
  33401. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33402. */
  33403. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33404. /** @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;
  33405. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33406. }
  33407. }
  33408. declare module BABYLON {
  33409. /**
  33410. * Set of assets to keep when moving a scene into an asset container.
  33411. */
  33412. export class KeepAssets extends AbstractScene {
  33413. }
  33414. /**
  33415. * Container with a set of assets that can be added or removed from a scene.
  33416. */
  33417. export class AssetContainer extends AbstractScene {
  33418. /**
  33419. * The scene the AssetContainer belongs to.
  33420. */
  33421. scene: Scene;
  33422. /**
  33423. * Instantiates an AssetContainer.
  33424. * @param scene The scene the AssetContainer belongs to.
  33425. */
  33426. constructor(scene: Scene);
  33427. /**
  33428. * Adds all the assets from the container to the scene.
  33429. */
  33430. addAllToScene(): void;
  33431. /**
  33432. * Removes all the assets in the container from the scene
  33433. */
  33434. removeAllFromScene(): void;
  33435. /**
  33436. * Disposes all the assets in the container
  33437. */
  33438. dispose(): void;
  33439. private _moveAssets;
  33440. /**
  33441. * Removes all the assets contained in the scene and adds them to the container.
  33442. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33443. */
  33444. moveAllFromScene(keepAssets?: KeepAssets): void;
  33445. /**
  33446. * 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.
  33447. * @returns the root mesh
  33448. */
  33449. createRootMesh(): Mesh;
  33450. }
  33451. }
  33452. declare module BABYLON {
  33453. /**
  33454. * Defines how the parser contract is defined.
  33455. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33456. */
  33457. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33458. /**
  33459. * Defines how the individual parser contract is defined.
  33460. * These parser can parse an individual asset
  33461. */
  33462. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33463. /**
  33464. * Base class of the scene acting as a container for the different elements composing a scene.
  33465. * This class is dynamically extended by the different components of the scene increasing
  33466. * flexibility and reducing coupling
  33467. */
  33468. export abstract class AbstractScene {
  33469. /**
  33470. * Stores the list of available parsers in the application.
  33471. */
  33472. private static _BabylonFileParsers;
  33473. /**
  33474. * Stores the list of available individual parsers in the application.
  33475. */
  33476. private static _IndividualBabylonFileParsers;
  33477. /**
  33478. * Adds a parser in the list of available ones
  33479. * @param name Defines the name of the parser
  33480. * @param parser Defines the parser to add
  33481. */
  33482. static AddParser(name: string, parser: BabylonFileParser): void;
  33483. /**
  33484. * Gets a general parser from the list of avaialble ones
  33485. * @param name Defines the name of the parser
  33486. * @returns the requested parser or null
  33487. */
  33488. static GetParser(name: string): Nullable<BabylonFileParser>;
  33489. /**
  33490. * Adds n individual parser in the list of available ones
  33491. * @param name Defines the name of the parser
  33492. * @param parser Defines the parser to add
  33493. */
  33494. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33495. /**
  33496. * Gets an individual parser from the list of avaialble ones
  33497. * @param name Defines the name of the parser
  33498. * @returns the requested parser or null
  33499. */
  33500. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33501. /**
  33502. * Parser json data and populate both a scene and its associated container object
  33503. * @param jsonData Defines the data to parse
  33504. * @param scene Defines the scene to parse the data for
  33505. * @param container Defines the container attached to the parsing sequence
  33506. * @param rootUrl Defines the root url of the data
  33507. */
  33508. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33509. /**
  33510. * Gets the list of root nodes (ie. nodes with no parent)
  33511. */
  33512. rootNodes: Node[];
  33513. /** All of the cameras added to this scene
  33514. * @see http://doc.babylonjs.com/babylon101/cameras
  33515. */
  33516. cameras: Camera[];
  33517. /**
  33518. * All of the lights added to this scene
  33519. * @see http://doc.babylonjs.com/babylon101/lights
  33520. */
  33521. lights: Light[];
  33522. /**
  33523. * All of the (abstract) meshes added to this scene
  33524. */
  33525. meshes: AbstractMesh[];
  33526. /**
  33527. * The list of skeletons added to the scene
  33528. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33529. */
  33530. skeletons: Skeleton[];
  33531. /**
  33532. * All of the particle systems added to this scene
  33533. * @see http://doc.babylonjs.com/babylon101/particles
  33534. */
  33535. particleSystems: IParticleSystem[];
  33536. /**
  33537. * Gets a list of Animations associated with the scene
  33538. */
  33539. animations: Animation[];
  33540. /**
  33541. * All of the animation groups added to this scene
  33542. * @see http://doc.babylonjs.com/how_to/group
  33543. */
  33544. animationGroups: AnimationGroup[];
  33545. /**
  33546. * All of the multi-materials added to this scene
  33547. * @see http://doc.babylonjs.com/how_to/multi_materials
  33548. */
  33549. multiMaterials: MultiMaterial[];
  33550. /**
  33551. * All of the materials added to this scene
  33552. * In the context of a Scene, it is not supposed to be modified manually.
  33553. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33554. * Note also that the order of the Material wihin the array is not significant and might change.
  33555. * @see http://doc.babylonjs.com/babylon101/materials
  33556. */
  33557. materials: Material[];
  33558. /**
  33559. * The list of morph target managers added to the scene
  33560. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33561. */
  33562. morphTargetManagers: MorphTargetManager[];
  33563. /**
  33564. * The list of geometries used in the scene.
  33565. */
  33566. geometries: Geometry[];
  33567. /**
  33568. * All of the tranform nodes added to this scene
  33569. * In the context of a Scene, it is not supposed to be modified manually.
  33570. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33571. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33572. * @see http://doc.babylonjs.com/how_to/transformnode
  33573. */
  33574. transformNodes: TransformNode[];
  33575. /**
  33576. * ActionManagers available on the scene.
  33577. */
  33578. actionManagers: AbstractActionManager[];
  33579. /**
  33580. * Textures to keep.
  33581. */
  33582. textures: BaseTexture[];
  33583. /**
  33584. * Environment texture for the scene
  33585. */
  33586. environmentTexture: Nullable<BaseTexture>;
  33587. }
  33588. }
  33589. declare module BABYLON {
  33590. /**
  33591. * Interface used to define options for Sound class
  33592. */
  33593. export interface ISoundOptions {
  33594. /**
  33595. * Does the sound autoplay once loaded.
  33596. */
  33597. autoplay?: boolean;
  33598. /**
  33599. * Does the sound loop after it finishes playing once.
  33600. */
  33601. loop?: boolean;
  33602. /**
  33603. * Sound's volume
  33604. */
  33605. volume?: number;
  33606. /**
  33607. * Is it a spatial sound?
  33608. */
  33609. spatialSound?: boolean;
  33610. /**
  33611. * Maximum distance to hear that sound
  33612. */
  33613. maxDistance?: number;
  33614. /**
  33615. * Uses user defined attenuation function
  33616. */
  33617. useCustomAttenuation?: boolean;
  33618. /**
  33619. * Define the roll off factor of spatial sounds.
  33620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33621. */
  33622. rolloffFactor?: number;
  33623. /**
  33624. * Define the reference distance the sound should be heard perfectly.
  33625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33626. */
  33627. refDistance?: number;
  33628. /**
  33629. * Define the distance attenuation model the sound will follow.
  33630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33631. */
  33632. distanceModel?: string;
  33633. /**
  33634. * Defines the playback speed (1 by default)
  33635. */
  33636. playbackRate?: number;
  33637. /**
  33638. * Defines if the sound is from a streaming source
  33639. */
  33640. streaming?: boolean;
  33641. /**
  33642. * Defines an optional length (in seconds) inside the sound file
  33643. */
  33644. length?: number;
  33645. /**
  33646. * Defines an optional offset (in seconds) inside the sound file
  33647. */
  33648. offset?: number;
  33649. /**
  33650. * If true, URLs will not be required to state the audio file codec to use.
  33651. */
  33652. skipCodecCheck?: boolean;
  33653. }
  33654. /**
  33655. * Defines a sound that can be played in the application.
  33656. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33658. */
  33659. export class Sound {
  33660. /**
  33661. * The name of the sound in the scene.
  33662. */
  33663. name: string;
  33664. /**
  33665. * Does the sound autoplay once loaded.
  33666. */
  33667. autoplay: boolean;
  33668. /**
  33669. * Does the sound loop after it finishes playing once.
  33670. */
  33671. loop: boolean;
  33672. /**
  33673. * Does the sound use a custom attenuation curve to simulate the falloff
  33674. * happening when the source gets further away from the camera.
  33675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33676. */
  33677. useCustomAttenuation: boolean;
  33678. /**
  33679. * The sound track id this sound belongs to.
  33680. */
  33681. soundTrackId: number;
  33682. /**
  33683. * Is this sound currently played.
  33684. */
  33685. isPlaying: boolean;
  33686. /**
  33687. * Is this sound currently paused.
  33688. */
  33689. isPaused: boolean;
  33690. /**
  33691. * Does this sound enables spatial sound.
  33692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33693. */
  33694. spatialSound: boolean;
  33695. /**
  33696. * Define the reference distance the sound should be heard perfectly.
  33697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33698. */
  33699. refDistance: number;
  33700. /**
  33701. * Define the roll off factor of spatial sounds.
  33702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33703. */
  33704. rolloffFactor: number;
  33705. /**
  33706. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33708. */
  33709. maxDistance: number;
  33710. /**
  33711. * Define the distance attenuation model the sound will follow.
  33712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33713. */
  33714. distanceModel: string;
  33715. /**
  33716. * @hidden
  33717. * Back Compat
  33718. **/
  33719. onended: () => any;
  33720. /**
  33721. * Observable event when the current playing sound finishes.
  33722. */
  33723. onEndedObservable: Observable<Sound>;
  33724. private _panningModel;
  33725. private _playbackRate;
  33726. private _streaming;
  33727. private _startTime;
  33728. private _startOffset;
  33729. private _position;
  33730. /** @hidden */ private _positionInEmitterSpace: boolean;
  33731. private _localDirection;
  33732. private _volume;
  33733. private _isReadyToPlay;
  33734. private _isDirectional;
  33735. private _readyToPlayCallback;
  33736. private _audioBuffer;
  33737. private _soundSource;
  33738. private _streamingSource;
  33739. private _soundPanner;
  33740. private _soundGain;
  33741. private _inputAudioNode;
  33742. private _outputAudioNode;
  33743. private _coneInnerAngle;
  33744. private _coneOuterAngle;
  33745. private _coneOuterGain;
  33746. private _scene;
  33747. private _connectedTransformNode;
  33748. private _customAttenuationFunction;
  33749. private _registerFunc;
  33750. private _isOutputConnected;
  33751. private _htmlAudioElement;
  33752. private _urlType;
  33753. private _length?;
  33754. private _offset?;
  33755. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33756. /**
  33757. * Create a sound and attach it to a scene
  33758. * @param name Name of your sound
  33759. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33760. * @param scene defines the scene the sound belongs to
  33761. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33762. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33763. */
  33764. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  33765. /**
  33766. * Release the sound and its associated resources
  33767. */
  33768. dispose(): void;
  33769. /**
  33770. * Gets if the sounds is ready to be played or not.
  33771. * @returns true if ready, otherwise false
  33772. */
  33773. isReady(): boolean;
  33774. private _soundLoaded;
  33775. /**
  33776. * Sets the data of the sound from an audiobuffer
  33777. * @param audioBuffer The audioBuffer containing the data
  33778. */
  33779. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33780. /**
  33781. * Updates the current sounds options such as maxdistance, loop...
  33782. * @param options A JSON object containing values named as the object properties
  33783. */
  33784. updateOptions(options: ISoundOptions): void;
  33785. private _createSpatialParameters;
  33786. private _updateSpatialParameters;
  33787. /**
  33788. * Switch the panning model to HRTF:
  33789. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33791. */
  33792. switchPanningModelToHRTF(): void;
  33793. /**
  33794. * Switch the panning model to Equal Power:
  33795. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33797. */
  33798. switchPanningModelToEqualPower(): void;
  33799. private _switchPanningModel;
  33800. /**
  33801. * Connect this sound to a sound track audio node like gain...
  33802. * @param soundTrackAudioNode the sound track audio node to connect to
  33803. */
  33804. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33805. /**
  33806. * Transform this sound into a directional source
  33807. * @param coneInnerAngle Size of the inner cone in degree
  33808. * @param coneOuterAngle Size of the outer cone in degree
  33809. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33810. */
  33811. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33812. /**
  33813. * Gets or sets the inner angle for the directional cone.
  33814. */
  33815. /**
  33816. * Gets or sets the inner angle for the directional cone.
  33817. */
  33818. directionalConeInnerAngle: number;
  33819. /**
  33820. * Gets or sets the outer angle for the directional cone.
  33821. */
  33822. /**
  33823. * Gets or sets the outer angle for the directional cone.
  33824. */
  33825. directionalConeOuterAngle: number;
  33826. /**
  33827. * Sets the position of the emitter if spatial sound is enabled
  33828. * @param newPosition Defines the new posisiton
  33829. */
  33830. setPosition(newPosition: Vector3): void;
  33831. /**
  33832. * Sets the local direction of the emitter if spatial sound is enabled
  33833. * @param newLocalDirection Defines the new local direction
  33834. */
  33835. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33836. private _updateDirection;
  33837. /** @hidden */
  33838. updateDistanceFromListener(): void;
  33839. /**
  33840. * Sets a new custom attenuation function for the sound.
  33841. * @param callback Defines the function used for the attenuation
  33842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33843. */
  33844. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33845. /**
  33846. * Play the sound
  33847. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33848. * @param offset (optional) Start the sound at a specific time in seconds
  33849. * @param length (optional) Sound duration (in seconds)
  33850. */
  33851. play(time?: number, offset?: number, length?: number): void;
  33852. private _onended;
  33853. /**
  33854. * Stop the sound
  33855. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33856. */
  33857. stop(time?: number): void;
  33858. /**
  33859. * Put the sound in pause
  33860. */
  33861. pause(): void;
  33862. /**
  33863. * Sets a dedicated volume for this sounds
  33864. * @param newVolume Define the new volume of the sound
  33865. * @param time Define time for gradual change to new volume
  33866. */
  33867. setVolume(newVolume: number, time?: number): void;
  33868. /**
  33869. * Set the sound play back rate
  33870. * @param newPlaybackRate Define the playback rate the sound should be played at
  33871. */
  33872. setPlaybackRate(newPlaybackRate: number): void;
  33873. /**
  33874. * Gets the volume of the sound.
  33875. * @returns the volume of the sound
  33876. */
  33877. getVolume(): number;
  33878. /**
  33879. * Attach the sound to a dedicated mesh
  33880. * @param transformNode The transform node to connect the sound with
  33881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33882. */
  33883. attachToMesh(transformNode: TransformNode): void;
  33884. /**
  33885. * Detach the sound from the previously attached mesh
  33886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33887. */
  33888. detachFromMesh(): void;
  33889. private _onRegisterAfterWorldMatrixUpdate;
  33890. /**
  33891. * Clone the current sound in the scene.
  33892. * @returns the new sound clone
  33893. */
  33894. clone(): Nullable<Sound>;
  33895. /**
  33896. * Gets the current underlying audio buffer containing the data
  33897. * @returns the audio buffer
  33898. */
  33899. getAudioBuffer(): Nullable<AudioBuffer>;
  33900. /**
  33901. * Serializes the Sound in a JSON representation
  33902. * @returns the JSON representation of the sound
  33903. */
  33904. serialize(): any;
  33905. /**
  33906. * Parse a JSON representation of a sound to innstantiate in a given scene
  33907. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33908. * @param scene Define the scene the new parsed sound should be created in
  33909. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33910. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33911. * @returns the newly parsed sound
  33912. */
  33913. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33914. }
  33915. }
  33916. declare module BABYLON {
  33917. /**
  33918. * This defines an action helpful to play a defined sound on a triggered action.
  33919. */
  33920. export class PlaySoundAction extends Action {
  33921. private _sound;
  33922. /**
  33923. * Instantiate the action
  33924. * @param triggerOptions defines the trigger options
  33925. * @param sound defines the sound to play
  33926. * @param condition defines the trigger related conditions
  33927. */
  33928. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33929. /** @hidden */ private _prepare(): void;
  33930. /**
  33931. * Execute the action and play the sound.
  33932. */
  33933. execute(): void;
  33934. /**
  33935. * Serializes the actions and its related information.
  33936. * @param parent defines the object to serialize in
  33937. * @returns the serialized object
  33938. */
  33939. serialize(parent: any): any;
  33940. }
  33941. /**
  33942. * This defines an action helpful to stop a defined sound on a triggered action.
  33943. */
  33944. export class StopSoundAction extends Action {
  33945. private _sound;
  33946. /**
  33947. * Instantiate the action
  33948. * @param triggerOptions defines the trigger options
  33949. * @param sound defines the sound to stop
  33950. * @param condition defines the trigger related conditions
  33951. */
  33952. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33953. /** @hidden */ private _prepare(): void;
  33954. /**
  33955. * Execute the action and stop the sound.
  33956. */
  33957. execute(): void;
  33958. /**
  33959. * Serializes the actions and its related information.
  33960. * @param parent defines the object to serialize in
  33961. * @returns the serialized object
  33962. */
  33963. serialize(parent: any): any;
  33964. }
  33965. }
  33966. declare module BABYLON {
  33967. /**
  33968. * This defines an action responsible to change the value of a property
  33969. * by interpolating between its current value and the newly set one once triggered.
  33970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33971. */
  33972. export class InterpolateValueAction extends Action {
  33973. /**
  33974. * Defines the path of the property where the value should be interpolated
  33975. */
  33976. propertyPath: string;
  33977. /**
  33978. * Defines the target value at the end of the interpolation.
  33979. */
  33980. value: any;
  33981. /**
  33982. * Defines the time it will take for the property to interpolate to the value.
  33983. */
  33984. duration: number;
  33985. /**
  33986. * Defines if the other scene animations should be stopped when the action has been triggered
  33987. */
  33988. stopOtherAnimations?: boolean;
  33989. /**
  33990. * Defines a callback raised once the interpolation animation has been done.
  33991. */
  33992. onInterpolationDone?: () => void;
  33993. /**
  33994. * Observable triggered once the interpolation animation has been done.
  33995. */
  33996. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33997. private _target;
  33998. private _effectiveTarget;
  33999. private _property;
  34000. /**
  34001. * Instantiate the action
  34002. * @param triggerOptions defines the trigger options
  34003. * @param target defines the object containing the value to interpolate
  34004. * @param propertyPath defines the path to the property in the target object
  34005. * @param value defines the target value at the end of the interpolation
  34006. * @param duration deines the time it will take for the property to interpolate to the value.
  34007. * @param condition defines the trigger related conditions
  34008. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34009. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34010. */
  34011. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34012. /** @hidden */ private _prepare(): void;
  34013. /**
  34014. * Execute the action starts the value interpolation.
  34015. */
  34016. execute(): void;
  34017. /**
  34018. * Serializes the actions and its related information.
  34019. * @param parent defines the object to serialize in
  34020. * @returns the serialized object
  34021. */
  34022. serialize(parent: any): any;
  34023. }
  34024. }
  34025. declare module BABYLON {
  34026. /**
  34027. * Options allowed during the creation of a sound track.
  34028. */
  34029. export interface ISoundTrackOptions {
  34030. /**
  34031. * The volume the sound track should take during creation
  34032. */
  34033. volume?: number;
  34034. /**
  34035. * Define if the sound track is the main sound track of the scene
  34036. */
  34037. mainTrack?: boolean;
  34038. }
  34039. /**
  34040. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34041. * It will be also used in a future release to apply effects on a specific track.
  34042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34043. */
  34044. export class SoundTrack {
  34045. /**
  34046. * The unique identifier of the sound track in the scene.
  34047. */
  34048. id: number;
  34049. /**
  34050. * The list of sounds included in the sound track.
  34051. */
  34052. soundCollection: Array<Sound>;
  34053. private _outputAudioNode;
  34054. private _scene;
  34055. private _isMainTrack;
  34056. private _connectedAnalyser;
  34057. private _options;
  34058. private _isInitialized;
  34059. /**
  34060. * Creates a new sound track.
  34061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34062. * @param scene Define the scene the sound track belongs to
  34063. * @param options
  34064. */
  34065. constructor(scene: Scene, options?: ISoundTrackOptions);
  34066. private _initializeSoundTrackAudioGraph;
  34067. /**
  34068. * Release the sound track and its associated resources
  34069. */
  34070. dispose(): void;
  34071. /**
  34072. * Adds a sound to this sound track
  34073. * @param sound define the cound to add
  34074. * @ignoreNaming
  34075. */
  34076. AddSound(sound: Sound): void;
  34077. /**
  34078. * Removes a sound to this sound track
  34079. * @param sound define the cound to remove
  34080. * @ignoreNaming
  34081. */
  34082. RemoveSound(sound: Sound): void;
  34083. /**
  34084. * Set a global volume for the full sound track.
  34085. * @param newVolume Define the new volume of the sound track
  34086. */
  34087. setVolume(newVolume: number): void;
  34088. /**
  34089. * Switch the panning model to HRTF:
  34090. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34092. */
  34093. switchPanningModelToHRTF(): void;
  34094. /**
  34095. * Switch the panning model to Equal Power:
  34096. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34098. */
  34099. switchPanningModelToEqualPower(): void;
  34100. /**
  34101. * Connect the sound track to an audio analyser allowing some amazing
  34102. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34104. * @param analyser The analyser to connect to the engine
  34105. */
  34106. connectToAnalyser(analyser: Analyser): void;
  34107. }
  34108. }
  34109. declare module BABYLON {
  34110. interface AbstractScene {
  34111. /**
  34112. * The list of sounds used in the scene.
  34113. */
  34114. sounds: Nullable<Array<Sound>>;
  34115. }
  34116. interface Scene {
  34117. /**
  34118. * @hidden
  34119. * Backing field
  34120. */ private _mainSoundTrack: SoundTrack;
  34121. /**
  34122. * The main sound track played by the scene.
  34123. * It cotains your primary collection of sounds.
  34124. */
  34125. mainSoundTrack: SoundTrack;
  34126. /**
  34127. * The list of sound tracks added to the scene
  34128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34129. */
  34130. soundTracks: Nullable<Array<SoundTrack>>;
  34131. /**
  34132. * Gets a sound using a given name
  34133. * @param name defines the name to search for
  34134. * @return the found sound or null if not found at all.
  34135. */
  34136. getSoundByName(name: string): Nullable<Sound>;
  34137. /**
  34138. * Gets or sets if audio support is enabled
  34139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34140. */
  34141. audioEnabled: boolean;
  34142. /**
  34143. * Gets or sets if audio will be output to headphones
  34144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34145. */
  34146. headphone: boolean;
  34147. }
  34148. /**
  34149. * Defines the sound scene component responsible to manage any sounds
  34150. * in a given scene.
  34151. */
  34152. export class AudioSceneComponent implements ISceneSerializableComponent {
  34153. /**
  34154. * The component name helpfull to identify the component in the list of scene components.
  34155. */
  34156. readonly name: string;
  34157. /**
  34158. * The scene the component belongs to.
  34159. */
  34160. scene: Scene;
  34161. private _audioEnabled;
  34162. /**
  34163. * Gets whether audio is enabled or not.
  34164. * Please use related enable/disable method to switch state.
  34165. */
  34166. readonly audioEnabled: boolean;
  34167. private _headphone;
  34168. /**
  34169. * Gets whether audio is outputing to headphone or not.
  34170. * Please use the according Switch methods to change output.
  34171. */
  34172. readonly headphone: boolean;
  34173. /**
  34174. * Creates a new instance of the component for the given scene
  34175. * @param scene Defines the scene to register the component in
  34176. */
  34177. constructor(scene: Scene);
  34178. /**
  34179. * Registers the component in a given scene
  34180. */
  34181. register(): void;
  34182. /**
  34183. * Rebuilds the elements related to this component in case of
  34184. * context lost for instance.
  34185. */
  34186. rebuild(): void;
  34187. /**
  34188. * Serializes the component data to the specified json object
  34189. * @param serializationObject The object to serialize to
  34190. */
  34191. serialize(serializationObject: any): void;
  34192. /**
  34193. * Adds all the elements from the container to the scene
  34194. * @param container the container holding the elements
  34195. */
  34196. addFromContainer(container: AbstractScene): void;
  34197. /**
  34198. * Removes all the elements in the container from the scene
  34199. * @param container contains the elements to remove
  34200. * @param dispose if the removed element should be disposed (default: false)
  34201. */
  34202. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34203. /**
  34204. * Disposes the component and the associated ressources.
  34205. */
  34206. dispose(): void;
  34207. /**
  34208. * Disables audio in the associated scene.
  34209. */
  34210. disableAudio(): void;
  34211. /**
  34212. * Enables audio in the associated scene.
  34213. */
  34214. enableAudio(): void;
  34215. /**
  34216. * Switch audio to headphone output.
  34217. */
  34218. switchAudioModeForHeadphones(): void;
  34219. /**
  34220. * Switch audio to normal speakers.
  34221. */
  34222. switchAudioModeForNormalSpeakers(): void;
  34223. private _afterRender;
  34224. }
  34225. }
  34226. declare module BABYLON {
  34227. /**
  34228. * Wraps one or more Sound objects and selects one with random weight for playback.
  34229. */
  34230. export class WeightedSound {
  34231. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34232. loop: boolean;
  34233. private _coneInnerAngle;
  34234. private _coneOuterAngle;
  34235. private _volume;
  34236. /** A Sound is currently playing. */
  34237. isPlaying: boolean;
  34238. /** A Sound is currently paused. */
  34239. isPaused: boolean;
  34240. private _sounds;
  34241. private _weights;
  34242. private _currentIndex?;
  34243. /**
  34244. * Creates a new WeightedSound from the list of sounds given.
  34245. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34246. * @param sounds Array of Sounds that will be selected from.
  34247. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34248. */
  34249. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34250. /**
  34251. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34252. */
  34253. /**
  34254. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34255. */
  34256. directionalConeInnerAngle: number;
  34257. /**
  34258. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34259. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34260. */
  34261. /**
  34262. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34263. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34264. */
  34265. directionalConeOuterAngle: number;
  34266. /**
  34267. * Playback volume.
  34268. */
  34269. /**
  34270. * Playback volume.
  34271. */
  34272. volume: number;
  34273. private _onended;
  34274. /**
  34275. * Suspend playback
  34276. */
  34277. pause(): void;
  34278. /**
  34279. * Stop playback
  34280. */
  34281. stop(): void;
  34282. /**
  34283. * Start playback.
  34284. * @param startOffset Position the clip head at a specific time in seconds.
  34285. */
  34286. play(startOffset?: number): void;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34293. */
  34294. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34295. /**
  34296. * Gets the name of the behavior.
  34297. */
  34298. readonly name: string;
  34299. /**
  34300. * The easing function used by animations
  34301. */
  34302. static EasingFunction: BackEase;
  34303. /**
  34304. * The easing mode used by animations
  34305. */
  34306. static EasingMode: number;
  34307. /**
  34308. * The duration of the animation, in milliseconds
  34309. */
  34310. transitionDuration: number;
  34311. /**
  34312. * Length of the distance animated by the transition when lower radius is reached
  34313. */
  34314. lowerRadiusTransitionRange: number;
  34315. /**
  34316. * Length of the distance animated by the transition when upper radius is reached
  34317. */
  34318. upperRadiusTransitionRange: number;
  34319. private _autoTransitionRange;
  34320. /**
  34321. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34322. */
  34323. /**
  34324. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34325. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34326. */
  34327. autoTransitionRange: boolean;
  34328. private _attachedCamera;
  34329. private _onAfterCheckInputsObserver;
  34330. private _onMeshTargetChangedObserver;
  34331. /**
  34332. * Initializes the behavior.
  34333. */
  34334. init(): void;
  34335. /**
  34336. * Attaches the behavior to its arc rotate camera.
  34337. * @param camera Defines the camera to attach the behavior to
  34338. */
  34339. attach(camera: ArcRotateCamera): void;
  34340. /**
  34341. * Detaches the behavior from its current arc rotate camera.
  34342. */
  34343. detach(): void;
  34344. private _radiusIsAnimating;
  34345. private _radiusBounceTransition;
  34346. private _animatables;
  34347. private _cachedWheelPrecision;
  34348. /**
  34349. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34350. * @param radiusLimit The limit to check against.
  34351. * @return Bool to indicate if at limit.
  34352. */
  34353. private _isRadiusAtLimit;
  34354. /**
  34355. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34356. * @param radiusDelta The delta by which to animate to. Can be negative.
  34357. */
  34358. private _applyBoundRadiusAnimation;
  34359. /**
  34360. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34361. */
  34362. protected _clearAnimationLocks(): void;
  34363. /**
  34364. * Stops and removes all animations that have been applied to the camera
  34365. */
  34366. stopAllAnimations(): void;
  34367. }
  34368. }
  34369. declare module BABYLON {
  34370. /**
  34371. * 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.
  34372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34373. */
  34374. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34375. /**
  34376. * Gets the name of the behavior.
  34377. */
  34378. readonly name: string;
  34379. private _mode;
  34380. private _radiusScale;
  34381. private _positionScale;
  34382. private _defaultElevation;
  34383. private _elevationReturnTime;
  34384. private _elevationReturnWaitTime;
  34385. private _zoomStopsAnimation;
  34386. private _framingTime;
  34387. /**
  34388. * The easing function used by animations
  34389. */
  34390. static EasingFunction: ExponentialEase;
  34391. /**
  34392. * The easing mode used by animations
  34393. */
  34394. static EasingMode: number;
  34395. /**
  34396. * Sets the current mode used by the behavior
  34397. */
  34398. /**
  34399. * Gets current mode used by the behavior.
  34400. */
  34401. mode: number;
  34402. /**
  34403. * Sets the scale applied to the radius (1 by default)
  34404. */
  34405. /**
  34406. * Gets the scale applied to the radius
  34407. */
  34408. radiusScale: number;
  34409. /**
  34410. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34411. */
  34412. /**
  34413. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34414. */
  34415. positionScale: number;
  34416. /**
  34417. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34418. * behaviour is triggered, in radians.
  34419. */
  34420. /**
  34421. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34422. * behaviour is triggered, in radians.
  34423. */
  34424. defaultElevation: number;
  34425. /**
  34426. * Sets the time (in milliseconds) taken to return to the default beta position.
  34427. * Negative value indicates camera should not return to default.
  34428. */
  34429. /**
  34430. * Gets the time (in milliseconds) taken to return to the default beta position.
  34431. * Negative value indicates camera should not return to default.
  34432. */
  34433. elevationReturnTime: number;
  34434. /**
  34435. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34436. */
  34437. /**
  34438. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34439. */
  34440. elevationReturnWaitTime: number;
  34441. /**
  34442. * Sets the flag that indicates if user zooming should stop animation.
  34443. */
  34444. /**
  34445. * Gets the flag that indicates if user zooming should stop animation.
  34446. */
  34447. zoomStopsAnimation: boolean;
  34448. /**
  34449. * Sets the transition time when framing the mesh, in milliseconds
  34450. */
  34451. /**
  34452. * Gets the transition time when framing the mesh, in milliseconds
  34453. */
  34454. framingTime: number;
  34455. /**
  34456. * Define if the behavior should automatically change the configured
  34457. * camera limits and sensibilities.
  34458. */
  34459. autoCorrectCameraLimitsAndSensibility: boolean;
  34460. private _onPrePointerObservableObserver;
  34461. private _onAfterCheckInputsObserver;
  34462. private _onMeshTargetChangedObserver;
  34463. private _attachedCamera;
  34464. private _isPointerDown;
  34465. private _lastInteractionTime;
  34466. /**
  34467. * Initializes the behavior.
  34468. */
  34469. init(): void;
  34470. /**
  34471. * Attaches the behavior to its arc rotate camera.
  34472. * @param camera Defines the camera to attach the behavior to
  34473. */
  34474. attach(camera: ArcRotateCamera): void;
  34475. /**
  34476. * Detaches the behavior from its current arc rotate camera.
  34477. */
  34478. detach(): void;
  34479. private _animatables;
  34480. private _betaIsAnimating;
  34481. private _betaTransition;
  34482. private _radiusTransition;
  34483. private _vectorTransition;
  34484. /**
  34485. * Targets the given mesh and updates zoom level accordingly.
  34486. * @param mesh The mesh to target.
  34487. * @param radius Optional. If a cached radius position already exists, overrides default.
  34488. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34491. */
  34492. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34493. /**
  34494. * Targets the given mesh with its children and updates zoom level accordingly.
  34495. * @param mesh The mesh to target.
  34496. * @param radius Optional. If a cached radius position already exists, overrides default.
  34497. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34498. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34499. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34500. */
  34501. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34502. /**
  34503. * Targets the given meshes with their children and updates zoom level accordingly.
  34504. * @param meshes The mesh to target.
  34505. * @param radius Optional. If a cached radius position already exists, overrides default.
  34506. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34507. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34508. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34509. */
  34510. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34511. /**
  34512. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34513. * @param minimumWorld Determines the smaller position of the bounding box extend
  34514. * @param maximumWorld Determines the bigger position of the bounding box extend
  34515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34517. */
  34518. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34519. /**
  34520. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34521. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34522. * frustum width.
  34523. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34524. * to fully enclose the mesh in the viewing frustum.
  34525. */
  34526. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34527. /**
  34528. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34529. * is automatically returned to its default position (expected to be above ground plane).
  34530. */
  34531. private _maintainCameraAboveGround;
  34532. /**
  34533. * Returns the frustum slope based on the canvas ratio and camera FOV
  34534. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34535. */
  34536. private _getFrustumSlope;
  34537. /**
  34538. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34539. */
  34540. private _clearAnimationLocks;
  34541. /**
  34542. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34543. */
  34544. private _applyUserInteraction;
  34545. /**
  34546. * Stops and removes all animations that have been applied to the camera
  34547. */
  34548. stopAllAnimations(): void;
  34549. /**
  34550. * Gets a value indicating if the user is moving the camera
  34551. */
  34552. readonly isUserIsMoving: boolean;
  34553. /**
  34554. * The camera can move all the way towards the mesh.
  34555. */
  34556. static IgnoreBoundsSizeMode: number;
  34557. /**
  34558. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34559. */
  34560. static FitFrustumSidesMode: number;
  34561. }
  34562. }
  34563. declare module BABYLON {
  34564. /**
  34565. * Base class for Camera Pointer Inputs.
  34566. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34567. * for example usage.
  34568. */
  34569. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34570. /**
  34571. * Defines the camera the input is attached to.
  34572. */
  34573. abstract camera: Camera;
  34574. /**
  34575. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34576. */
  34577. protected _altKey: boolean;
  34578. protected _ctrlKey: boolean;
  34579. protected _metaKey: boolean;
  34580. protected _shiftKey: boolean;
  34581. /**
  34582. * Which mouse buttons were pressed at time of last mouse event.
  34583. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34584. */
  34585. protected _buttonsPressed: number;
  34586. /**
  34587. * Defines the buttons associated with the input to handle camera move.
  34588. */
  34589. buttons: number[];
  34590. /**
  34591. * Attach the input controls to a specific dom element to get the input from.
  34592. * @param element Defines the element the controls should be listened from
  34593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34594. */
  34595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34596. /**
  34597. * Detach the current controls from the specified dom element.
  34598. * @param element Defines the element to stop listening the inputs from
  34599. */
  34600. detachControl(element: Nullable<HTMLElement>): void;
  34601. /**
  34602. * Gets the class name of the current input.
  34603. * @returns the class name
  34604. */
  34605. getClassName(): string;
  34606. /**
  34607. * Get the friendly name associated with the input class.
  34608. * @returns the input friendly name
  34609. */
  34610. getSimpleName(): string;
  34611. /**
  34612. * Called on pointer POINTERDOUBLETAP event.
  34613. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34614. */
  34615. protected onDoubleTap(type: string): void;
  34616. /**
  34617. * Called on pointer POINTERMOVE event if only a single touch is active.
  34618. * Override this method to provide functionality.
  34619. */
  34620. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34621. /**
  34622. * Called on pointer POINTERMOVE event if multiple touches are active.
  34623. * Override this method to provide functionality.
  34624. */
  34625. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34626. /**
  34627. * Called on JS contextmenu event.
  34628. * Override this method to provide functionality.
  34629. */
  34630. protected onContextMenu(evt: PointerEvent): void;
  34631. /**
  34632. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34633. * press.
  34634. * Override this method to provide functionality.
  34635. */
  34636. protected onButtonDown(evt: PointerEvent): void;
  34637. /**
  34638. * Called each time a new POINTERUP event occurs. Ie, for each button
  34639. * release.
  34640. * Override this method to provide functionality.
  34641. */
  34642. protected onButtonUp(evt: PointerEvent): void;
  34643. /**
  34644. * Called when window becomes inactive.
  34645. * Override this method to provide functionality.
  34646. */
  34647. protected onLostFocus(): void;
  34648. private _pointerInput;
  34649. private _observer;
  34650. private _onLostFocus;
  34651. private pointA;
  34652. private pointB;
  34653. }
  34654. }
  34655. declare module BABYLON {
  34656. /**
  34657. * Manage the pointers inputs to control an arc rotate camera.
  34658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34659. */
  34660. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34661. /**
  34662. * Defines the camera the input is attached to.
  34663. */
  34664. camera: ArcRotateCamera;
  34665. /**
  34666. * Gets the class name of the current input.
  34667. * @returns the class name
  34668. */
  34669. getClassName(): string;
  34670. /**
  34671. * Defines the buttons associated with the input to handle camera move.
  34672. */
  34673. buttons: number[];
  34674. /**
  34675. * Defines the pointer angular sensibility along the X axis or how fast is
  34676. * the camera rotating.
  34677. */
  34678. angularSensibilityX: number;
  34679. /**
  34680. * Defines the pointer angular sensibility along the Y axis or how fast is
  34681. * the camera rotating.
  34682. */
  34683. angularSensibilityY: number;
  34684. /**
  34685. * Defines the pointer pinch precision or how fast is the camera zooming.
  34686. */
  34687. pinchPrecision: number;
  34688. /**
  34689. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34690. * from 0.
  34691. * It defines the percentage of current camera.radius to use as delta when
  34692. * pinch zoom is used.
  34693. */
  34694. pinchDeltaPercentage: number;
  34695. /**
  34696. * Defines the pointer panning sensibility or how fast is the camera moving.
  34697. */
  34698. panningSensibility: number;
  34699. /**
  34700. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34701. */
  34702. multiTouchPanning: boolean;
  34703. /**
  34704. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34705. * zoom (pinch) through multitouch.
  34706. */
  34707. multiTouchPanAndZoom: boolean;
  34708. /**
  34709. * Revers pinch action direction.
  34710. */
  34711. pinchInwards: boolean;
  34712. private _isPanClick;
  34713. private _twoFingerActivityCount;
  34714. private _isPinching;
  34715. /**
  34716. * Called on pointer POINTERMOVE event if only a single touch is active.
  34717. */
  34718. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34719. /**
  34720. * Called on pointer POINTERDOUBLETAP event.
  34721. */
  34722. protected onDoubleTap(type: string): void;
  34723. /**
  34724. * Called on pointer POINTERMOVE event if multiple touches are active.
  34725. */
  34726. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34727. /**
  34728. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34729. * press.
  34730. */
  34731. protected onButtonDown(evt: PointerEvent): void;
  34732. /**
  34733. * Called each time a new POINTERUP event occurs. Ie, for each button
  34734. * release.
  34735. */
  34736. protected onButtonUp(evt: PointerEvent): void;
  34737. /**
  34738. * Called when window becomes inactive.
  34739. */
  34740. protected onLostFocus(): void;
  34741. }
  34742. }
  34743. declare module BABYLON {
  34744. /**
  34745. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34747. */
  34748. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34749. /**
  34750. * Defines the camera the input is attached to.
  34751. */
  34752. camera: ArcRotateCamera;
  34753. /**
  34754. * Defines the list of key codes associated with the up action (increase alpha)
  34755. */
  34756. keysUp: number[];
  34757. /**
  34758. * Defines the list of key codes associated with the down action (decrease alpha)
  34759. */
  34760. keysDown: number[];
  34761. /**
  34762. * Defines the list of key codes associated with the left action (increase beta)
  34763. */
  34764. keysLeft: number[];
  34765. /**
  34766. * Defines the list of key codes associated with the right action (decrease beta)
  34767. */
  34768. keysRight: number[];
  34769. /**
  34770. * Defines the list of key codes associated with the reset action.
  34771. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34772. */
  34773. keysReset: number[];
  34774. /**
  34775. * Defines the panning sensibility of the inputs.
  34776. * (How fast is the camera paning)
  34777. */
  34778. panningSensibility: number;
  34779. /**
  34780. * Defines the zooming sensibility of the inputs.
  34781. * (How fast is the camera zooming)
  34782. */
  34783. zoomingSensibility: number;
  34784. /**
  34785. * Defines wether maintaining the alt key down switch the movement mode from
  34786. * orientation to zoom.
  34787. */
  34788. useAltToZoom: boolean;
  34789. /**
  34790. * Rotation speed of the camera
  34791. */
  34792. angularSpeed: number;
  34793. private _keys;
  34794. private _ctrlPressed;
  34795. private _altPressed;
  34796. private _onCanvasBlurObserver;
  34797. private _onKeyboardObserver;
  34798. private _engine;
  34799. private _scene;
  34800. /**
  34801. * Attach the input controls to a specific dom element to get the input from.
  34802. * @param element Defines the element the controls should be listened from
  34803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34804. */
  34805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34806. /**
  34807. * Detach the current controls from the specified dom element.
  34808. * @param element Defines the element to stop listening the inputs from
  34809. */
  34810. detachControl(element: Nullable<HTMLElement>): void;
  34811. /**
  34812. * Update the current camera state depending on the inputs that have been used this frame.
  34813. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34814. */
  34815. checkInputs(): void;
  34816. /**
  34817. * Gets the class name of the current intput.
  34818. * @returns the class name
  34819. */
  34820. getClassName(): string;
  34821. /**
  34822. * Get the friendly name associated with the input class.
  34823. * @returns the input friendly name
  34824. */
  34825. getSimpleName(): string;
  34826. }
  34827. }
  34828. declare module BABYLON {
  34829. /**
  34830. * Manage the mouse wheel inputs to control an arc rotate camera.
  34831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34832. */
  34833. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34834. /**
  34835. * Defines the camera the input is attached to.
  34836. */
  34837. camera: ArcRotateCamera;
  34838. /**
  34839. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34840. */
  34841. wheelPrecision: number;
  34842. /**
  34843. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34844. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34845. */
  34846. wheelDeltaPercentage: number;
  34847. private _wheel;
  34848. private _observer;
  34849. private computeDeltaFromMouseWheelLegacyEvent;
  34850. /**
  34851. * Attach the input controls to a specific dom element to get the input from.
  34852. * @param element Defines the element the controls should be listened from
  34853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34854. */
  34855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34856. /**
  34857. * Detach the current controls from the specified dom element.
  34858. * @param element Defines the element to stop listening the inputs from
  34859. */
  34860. detachControl(element: Nullable<HTMLElement>): void;
  34861. /**
  34862. * Gets the class name of the current intput.
  34863. * @returns the class name
  34864. */
  34865. getClassName(): string;
  34866. /**
  34867. * Get the friendly name associated with the input class.
  34868. * @returns the input friendly name
  34869. */
  34870. getSimpleName(): string;
  34871. }
  34872. }
  34873. declare module BABYLON {
  34874. /**
  34875. * Default Inputs manager for the ArcRotateCamera.
  34876. * It groups all the default supported inputs for ease of use.
  34877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34878. */
  34879. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34880. /**
  34881. * Instantiates a new ArcRotateCameraInputsManager.
  34882. * @param camera Defines the camera the inputs belong to
  34883. */
  34884. constructor(camera: ArcRotateCamera);
  34885. /**
  34886. * Add mouse wheel input support to the input manager.
  34887. * @returns the current input manager
  34888. */
  34889. addMouseWheel(): ArcRotateCameraInputsManager;
  34890. /**
  34891. * Add pointers input support to the input manager.
  34892. * @returns the current input manager
  34893. */
  34894. addPointers(): ArcRotateCameraInputsManager;
  34895. /**
  34896. * Add keyboard input support to the input manager.
  34897. * @returns the current input manager
  34898. */
  34899. addKeyboard(): ArcRotateCameraInputsManager;
  34900. }
  34901. }
  34902. declare module BABYLON {
  34903. /**
  34904. * This represents an orbital type of camera.
  34905. *
  34906. * 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.
  34907. * 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.
  34908. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34909. */
  34910. export class ArcRotateCamera extends TargetCamera {
  34911. /**
  34912. * Defines the rotation angle of the camera along the longitudinal axis.
  34913. */
  34914. alpha: number;
  34915. /**
  34916. * Defines the rotation angle of the camera along the latitudinal axis.
  34917. */
  34918. beta: number;
  34919. /**
  34920. * Defines the radius of the camera from it s target point.
  34921. */
  34922. radius: number;
  34923. protected _target: Vector3;
  34924. protected _targetHost: Nullable<AbstractMesh>;
  34925. /**
  34926. * Defines the target point of the camera.
  34927. * The camera looks towards it form the radius distance.
  34928. */
  34929. target: Vector3;
  34930. /**
  34931. * Define the current local position of the camera in the scene
  34932. */
  34933. position: Vector3;
  34934. protected _upVector: Vector3;
  34935. protected _upToYMatrix: Matrix;
  34936. protected _YToUpMatrix: Matrix;
  34937. /**
  34938. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34939. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34940. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34941. */
  34942. upVector: Vector3;
  34943. /**
  34944. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34945. */
  34946. setMatUp(): void;
  34947. /**
  34948. * Current inertia value on the longitudinal axis.
  34949. * The bigger this number the longer it will take for the camera to stop.
  34950. */
  34951. inertialAlphaOffset: number;
  34952. /**
  34953. * Current inertia value on the latitudinal axis.
  34954. * The bigger this number the longer it will take for the camera to stop.
  34955. */
  34956. inertialBetaOffset: number;
  34957. /**
  34958. * Current inertia value on the radius axis.
  34959. * The bigger this number the longer it will take for the camera to stop.
  34960. */
  34961. inertialRadiusOffset: number;
  34962. /**
  34963. * Minimum allowed angle on the longitudinal axis.
  34964. * This can help limiting how the Camera is able to move in the scene.
  34965. */
  34966. lowerAlphaLimit: Nullable<number>;
  34967. /**
  34968. * Maximum allowed angle on the longitudinal axis.
  34969. * This can help limiting how the Camera is able to move in the scene.
  34970. */
  34971. upperAlphaLimit: Nullable<number>;
  34972. /**
  34973. * Minimum allowed angle on the latitudinal axis.
  34974. * This can help limiting how the Camera is able to move in the scene.
  34975. */
  34976. lowerBetaLimit: number;
  34977. /**
  34978. * Maximum allowed angle on the latitudinal axis.
  34979. * This can help limiting how the Camera is able to move in the scene.
  34980. */
  34981. upperBetaLimit: number;
  34982. /**
  34983. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34984. * This can help limiting how the Camera is able to move in the scene.
  34985. */
  34986. lowerRadiusLimit: Nullable<number>;
  34987. /**
  34988. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34989. * This can help limiting how the Camera is able to move in the scene.
  34990. */
  34991. upperRadiusLimit: Nullable<number>;
  34992. /**
  34993. * Defines the current inertia value used during panning of the camera along the X axis.
  34994. */
  34995. inertialPanningX: number;
  34996. /**
  34997. * Defines the current inertia value used during panning of the camera along the Y axis.
  34998. */
  34999. inertialPanningY: number;
  35000. /**
  35001. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35002. * Basically if your fingers moves away from more than this distance you will be considered
  35003. * in pinch mode.
  35004. */
  35005. pinchToPanMaxDistance: number;
  35006. /**
  35007. * Defines the maximum distance the camera can pan.
  35008. * This could help keeping the cammera always in your scene.
  35009. */
  35010. panningDistanceLimit: Nullable<number>;
  35011. /**
  35012. * Defines the target of the camera before paning.
  35013. */
  35014. panningOriginTarget: Vector3;
  35015. /**
  35016. * Defines the value of the inertia used during panning.
  35017. * 0 would mean stop inertia and one would mean no decelleration at all.
  35018. */
  35019. panningInertia: number;
  35020. /**
  35021. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35022. */
  35023. angularSensibilityX: number;
  35024. /**
  35025. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35026. */
  35027. angularSensibilityY: number;
  35028. /**
  35029. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35030. */
  35031. pinchPrecision: number;
  35032. /**
  35033. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35034. * It will be used instead of pinchDeltaPrecision if different from 0.
  35035. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35036. */
  35037. pinchDeltaPercentage: number;
  35038. /**
  35039. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35040. */
  35041. panningSensibility: number;
  35042. /**
  35043. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35044. */
  35045. keysUp: number[];
  35046. /**
  35047. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35048. */
  35049. keysDown: number[];
  35050. /**
  35051. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35052. */
  35053. keysLeft: number[];
  35054. /**
  35055. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35056. */
  35057. keysRight: number[];
  35058. /**
  35059. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35060. */
  35061. wheelPrecision: number;
  35062. /**
  35063. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35064. * It will be used instead of pinchDeltaPrecision if different from 0.
  35065. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35066. */
  35067. wheelDeltaPercentage: number;
  35068. /**
  35069. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35070. */
  35071. zoomOnFactor: number;
  35072. /**
  35073. * Defines a screen offset for the camera position.
  35074. */
  35075. targetScreenOffset: Vector2;
  35076. /**
  35077. * Allows the camera to be completely reversed.
  35078. * If false the camera can not arrive upside down.
  35079. */
  35080. allowUpsideDown: boolean;
  35081. /**
  35082. * Define if double tap/click is used to restore the previously saved state of the camera.
  35083. */
  35084. useInputToRestoreState: boolean;
  35085. /** @hidden */ private _viewMatrix: Matrix;
  35086. /** @hidden */ private _useCtrlForPanning: boolean;
  35087. /** @hidden */ private _panningMouseButton: number;
  35088. /**
  35089. * Defines the input associated to the camera.
  35090. */
  35091. inputs: ArcRotateCameraInputsManager;
  35092. /** @hidden */ private _reset: () => void;
  35093. /**
  35094. * Defines the allowed panning axis.
  35095. */
  35096. panningAxis: Vector3;
  35097. protected _localDirection: Vector3;
  35098. protected _transformedDirection: Vector3;
  35099. private _bouncingBehavior;
  35100. /**
  35101. * Gets the bouncing behavior of the camera if it has been enabled.
  35102. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35103. */
  35104. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35105. /**
  35106. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35108. */
  35109. useBouncingBehavior: boolean;
  35110. private _framingBehavior;
  35111. /**
  35112. * Gets the framing behavior of the camera if it has been enabled.
  35113. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35114. */
  35115. readonly framingBehavior: Nullable<FramingBehavior>;
  35116. /**
  35117. * Defines if the framing behavior of the camera is enabled on the camera.
  35118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35119. */
  35120. useFramingBehavior: boolean;
  35121. private _autoRotationBehavior;
  35122. /**
  35123. * Gets the auto rotation behavior of the camera if it has been enabled.
  35124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35125. */
  35126. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35127. /**
  35128. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35130. */
  35131. useAutoRotationBehavior: boolean;
  35132. /**
  35133. * Observable triggered when the mesh target has been changed on the camera.
  35134. */
  35135. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35136. /**
  35137. * Event raised when the camera is colliding with a mesh.
  35138. */
  35139. onCollide: (collidedMesh: AbstractMesh) => void;
  35140. /**
  35141. * Defines whether the camera should check collision with the objects oh the scene.
  35142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35143. */
  35144. checkCollisions: boolean;
  35145. /**
  35146. * Defines the collision radius of the camera.
  35147. * This simulates a sphere around the camera.
  35148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35149. */
  35150. collisionRadius: Vector3;
  35151. protected _collider: Collider;
  35152. protected _previousPosition: Vector3;
  35153. protected _collisionVelocity: Vector3;
  35154. protected _newPosition: Vector3;
  35155. protected _previousAlpha: number;
  35156. protected _previousBeta: number;
  35157. protected _previousRadius: number;
  35158. protected _collisionTriggered: boolean;
  35159. protected _targetBoundingCenter: Nullable<Vector3>;
  35160. private _computationVector;
  35161. /**
  35162. * Instantiates a new ArcRotateCamera in a given scene
  35163. * @param name Defines the name of the camera
  35164. * @param alpha Defines the camera rotation along the logitudinal axis
  35165. * @param beta Defines the camera rotation along the latitudinal axis
  35166. * @param radius Defines the camera distance from its target
  35167. * @param target Defines the camera target
  35168. * @param scene Defines the scene the camera belongs to
  35169. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35170. */
  35171. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35172. /** @hidden */ private _initCache(): void;
  35173. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35174. protected _getTargetPosition(): Vector3;
  35175. private _storedAlpha;
  35176. private _storedBeta;
  35177. private _storedRadius;
  35178. private _storedTarget;
  35179. /**
  35180. * Stores the current state of the camera (alpha, beta, radius and target)
  35181. * @returns the camera itself
  35182. */
  35183. storeState(): Camera;
  35184. /**
  35185. * @hidden
  35186. * Restored camera state. You must call storeState() first
  35187. */ private _restoreStateValues(): boolean;
  35188. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35189. /**
  35190. * Attached controls to the current camera.
  35191. * @param element Defines the element the controls should be listened from
  35192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35193. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35194. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35195. */
  35196. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35197. /**
  35198. * Detach the current controls from the camera.
  35199. * The camera will stop reacting to inputs.
  35200. * @param element Defines the element to stop listening the inputs from
  35201. */
  35202. detachControl(element: HTMLElement): void;
  35203. /** @hidden */ private _checkInputs(): void;
  35204. protected _checkLimits(): void;
  35205. /**
  35206. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35207. */
  35208. rebuildAnglesAndRadius(): void;
  35209. /**
  35210. * Use a position to define the current camera related information like aplha, beta and radius
  35211. * @param position Defines the position to set the camera at
  35212. */
  35213. setPosition(position: Vector3): void;
  35214. /**
  35215. * Defines the target the camera should look at.
  35216. * This will automatically adapt alpha beta and radius to fit within the new target.
  35217. * @param target Defines the new target as a Vector or a mesh
  35218. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35219. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35220. */
  35221. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35222. /** @hidden */ private _getViewMatrix(): Matrix;
  35223. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35224. /**
  35225. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35226. * @param meshes Defines the mesh to zoom on
  35227. * @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)
  35228. */
  35229. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35230. /**
  35231. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35232. * The target will be changed but the radius
  35233. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35234. * @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)
  35235. */
  35236. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35237. min: Vector3;
  35238. max: Vector3;
  35239. distance: number;
  35240. }, doNotUpdateMaxZ?: boolean): void;
  35241. /**
  35242. * @override
  35243. * Override Camera.createRigCamera
  35244. */
  35245. createRigCamera(name: string, cameraIndex: number): Camera;
  35246. /**
  35247. * @hidden
  35248. * @override
  35249. * Override Camera._updateRigCameras
  35250. */ private _updateRigCameras(): void;
  35251. /**
  35252. * Destroy the camera and release the current resources hold by it.
  35253. */
  35254. dispose(): void;
  35255. /**
  35256. * Gets the current object class name.
  35257. * @return the class name
  35258. */
  35259. getClassName(): string;
  35260. }
  35261. }
  35262. declare module BABYLON {
  35263. /**
  35264. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35266. */
  35267. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35268. /**
  35269. * Gets the name of the behavior.
  35270. */
  35271. readonly name: string;
  35272. private _zoomStopsAnimation;
  35273. private _idleRotationSpeed;
  35274. private _idleRotationWaitTime;
  35275. private _idleRotationSpinupTime;
  35276. /**
  35277. * Sets the flag that indicates if user zooming should stop animation.
  35278. */
  35279. /**
  35280. * Gets the flag that indicates if user zooming should stop animation.
  35281. */
  35282. zoomStopsAnimation: boolean;
  35283. /**
  35284. * Sets the default speed at which the camera rotates around the model.
  35285. */
  35286. /**
  35287. * Gets the default speed at which the camera rotates around the model.
  35288. */
  35289. idleRotationSpeed: number;
  35290. /**
  35291. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35292. */
  35293. /**
  35294. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35295. */
  35296. idleRotationWaitTime: number;
  35297. /**
  35298. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35299. */
  35300. /**
  35301. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35302. */
  35303. idleRotationSpinupTime: number;
  35304. /**
  35305. * Gets a value indicating if the camera is currently rotating because of this behavior
  35306. */
  35307. readonly rotationInProgress: boolean;
  35308. private _onPrePointerObservableObserver;
  35309. private _onAfterCheckInputsObserver;
  35310. private _attachedCamera;
  35311. private _isPointerDown;
  35312. private _lastFrameTime;
  35313. private _lastInteractionTime;
  35314. private _cameraRotationSpeed;
  35315. /**
  35316. * Initializes the behavior.
  35317. */
  35318. init(): void;
  35319. /**
  35320. * Attaches the behavior to its arc rotate camera.
  35321. * @param camera Defines the camera to attach the behavior to
  35322. */
  35323. attach(camera: ArcRotateCamera): void;
  35324. /**
  35325. * Detaches the behavior from its current arc rotate camera.
  35326. */
  35327. detach(): void;
  35328. /**
  35329. * Returns true if user is scrolling.
  35330. * @return true if user is scrolling.
  35331. */
  35332. private _userIsZooming;
  35333. private _lastFrameRadius;
  35334. private _shouldAnimationStopForInteraction;
  35335. /**
  35336. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35337. */
  35338. private _applyUserInteraction;
  35339. private _userIsMoving;
  35340. }
  35341. }
  35342. declare module BABYLON {
  35343. /**
  35344. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35345. */
  35346. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35347. private ui;
  35348. /**
  35349. * The name of the behavior
  35350. */
  35351. name: string;
  35352. /**
  35353. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35354. */
  35355. distanceAwayFromFace: number;
  35356. /**
  35357. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35358. */
  35359. distanceAwayFromBottomOfFace: number;
  35360. private _faceVectors;
  35361. private _target;
  35362. private _scene;
  35363. private _onRenderObserver;
  35364. private _tmpMatrix;
  35365. private _tmpVector;
  35366. /**
  35367. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35368. * @param ui The transform node that should be attched to the mesh
  35369. */
  35370. constructor(ui: TransformNode);
  35371. /**
  35372. * Initializes the behavior
  35373. */
  35374. init(): void;
  35375. private _closestFace;
  35376. private _zeroVector;
  35377. private _lookAtTmpMatrix;
  35378. private _lookAtToRef;
  35379. /**
  35380. * Attaches the AttachToBoxBehavior to the passed in mesh
  35381. * @param target The mesh that the specified node will be attached to
  35382. */
  35383. attach(target: Mesh): void;
  35384. /**
  35385. * Detaches the behavior from the mesh
  35386. */
  35387. detach(): void;
  35388. }
  35389. }
  35390. declare module BABYLON {
  35391. /**
  35392. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35393. */
  35394. export class FadeInOutBehavior implements Behavior<Mesh> {
  35395. /**
  35396. * Time in milliseconds to delay before fading in (Default: 0)
  35397. */
  35398. delay: number;
  35399. /**
  35400. * Time in milliseconds for the mesh to fade in (Default: 300)
  35401. */
  35402. fadeInTime: number;
  35403. private _millisecondsPerFrame;
  35404. private _hovered;
  35405. private _hoverValue;
  35406. private _ownerNode;
  35407. /**
  35408. * Instatiates the FadeInOutBehavior
  35409. */
  35410. constructor();
  35411. /**
  35412. * The name of the behavior
  35413. */
  35414. readonly name: string;
  35415. /**
  35416. * Initializes the behavior
  35417. */
  35418. init(): void;
  35419. /**
  35420. * Attaches the fade behavior on the passed in mesh
  35421. * @param ownerNode The mesh that will be faded in/out once attached
  35422. */
  35423. attach(ownerNode: Mesh): void;
  35424. /**
  35425. * Detaches the behavior from the mesh
  35426. */
  35427. detach(): void;
  35428. /**
  35429. * Triggers the mesh to begin fading in or out
  35430. * @param value if the object should fade in or out (true to fade in)
  35431. */
  35432. fadeIn(value: boolean): void;
  35433. private _update;
  35434. private _setAllVisibility;
  35435. }
  35436. }
  35437. declare module BABYLON {
  35438. /**
  35439. * Class containing a set of static utilities functions for managing Pivots
  35440. * @hidden
  35441. */
  35442. export class PivotTools {
  35443. private static _PivotCached;
  35444. private static _OldPivotPoint;
  35445. private static _PivotTranslation;
  35446. private static _PivotTmpVector;
  35447. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35448. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35449. }
  35450. }
  35451. declare module BABYLON {
  35452. /**
  35453. * Class containing static functions to help procedurally build meshes
  35454. */
  35455. export class PlaneBuilder {
  35456. /**
  35457. * Creates a plane mesh
  35458. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35459. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35460. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35462. * * 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
  35463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35464. * @param name defines the name of the mesh
  35465. * @param options defines the options used to create the mesh
  35466. * @param scene defines the hosting scene
  35467. * @returns the plane mesh
  35468. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35469. */
  35470. static CreatePlane(name: string, options: {
  35471. size?: number;
  35472. width?: number;
  35473. height?: number;
  35474. sideOrientation?: number;
  35475. frontUVs?: Vector4;
  35476. backUVs?: Vector4;
  35477. updatable?: boolean;
  35478. sourcePlane?: Plane;
  35479. }, scene?: Nullable<Scene>): Mesh;
  35480. }
  35481. }
  35482. declare module BABYLON {
  35483. /**
  35484. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35485. */
  35486. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35487. private static _AnyMouseID;
  35488. /**
  35489. * Abstract mesh the behavior is set on
  35490. */
  35491. attachedNode: AbstractMesh;
  35492. private _dragPlane;
  35493. private _scene;
  35494. private _pointerObserver;
  35495. private _beforeRenderObserver;
  35496. private static _planeScene;
  35497. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35498. /**
  35499. * 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)
  35500. */
  35501. maxDragAngle: number;
  35502. /**
  35503. * @hidden
  35504. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35505. /**
  35506. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35507. */
  35508. currentDraggingPointerID: number;
  35509. /**
  35510. * The last position where the pointer hit the drag plane in world space
  35511. */
  35512. lastDragPosition: Vector3;
  35513. /**
  35514. * If the behavior is currently in a dragging state
  35515. */
  35516. dragging: boolean;
  35517. /**
  35518. * 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)
  35519. */
  35520. dragDeltaRatio: number;
  35521. /**
  35522. * If the drag plane orientation should be updated during the dragging (Default: true)
  35523. */
  35524. updateDragPlane: boolean;
  35525. private _debugMode;
  35526. private _moving;
  35527. /**
  35528. * Fires each time the attached mesh is dragged with the pointer
  35529. * * delta between last drag position and current drag position in world space
  35530. * * dragDistance along the drag axis
  35531. * * dragPlaneNormal normal of the current drag plane used during the drag
  35532. * * dragPlanePoint in world space where the drag intersects the drag plane
  35533. */
  35534. onDragObservable: Observable<{
  35535. delta: Vector3;
  35536. dragPlanePoint: Vector3;
  35537. dragPlaneNormal: Vector3;
  35538. dragDistance: number;
  35539. pointerId: number;
  35540. }>;
  35541. /**
  35542. * Fires each time a drag begins (eg. mouse down on mesh)
  35543. */
  35544. onDragStartObservable: Observable<{
  35545. dragPlanePoint: Vector3;
  35546. pointerId: number;
  35547. }>;
  35548. /**
  35549. * Fires each time a drag ends (eg. mouse release after drag)
  35550. */
  35551. onDragEndObservable: Observable<{
  35552. dragPlanePoint: Vector3;
  35553. pointerId: number;
  35554. }>;
  35555. /**
  35556. * If the attached mesh should be moved when dragged
  35557. */
  35558. moveAttached: boolean;
  35559. /**
  35560. * If the drag behavior will react to drag events (Default: true)
  35561. */
  35562. enabled: boolean;
  35563. /**
  35564. * If pointer events should start and release the drag (Default: true)
  35565. */
  35566. startAndReleaseDragOnPointerEvents: boolean;
  35567. /**
  35568. * If camera controls should be detached during the drag
  35569. */
  35570. detachCameraControls: boolean;
  35571. /**
  35572. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35573. */
  35574. useObjectOrienationForDragging: boolean;
  35575. private _options;
  35576. /**
  35577. * Creates a pointer drag behavior that can be attached to a mesh
  35578. * @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)
  35579. */
  35580. constructor(options?: {
  35581. dragAxis?: Vector3;
  35582. dragPlaneNormal?: Vector3;
  35583. });
  35584. /**
  35585. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35586. */
  35587. validateDrag: (targetPosition: Vector3) => boolean;
  35588. /**
  35589. * The name of the behavior
  35590. */
  35591. readonly name: string;
  35592. /**
  35593. * Initializes the behavior
  35594. */
  35595. init(): void;
  35596. private _tmpVector;
  35597. private _alternatePickedPoint;
  35598. private _worldDragAxis;
  35599. private _targetPosition;
  35600. private _attachedElement;
  35601. /**
  35602. * Attaches the drag behavior the passed in mesh
  35603. * @param ownerNode The mesh that will be dragged around once attached
  35604. */
  35605. attach(ownerNode: AbstractMesh): void;
  35606. /**
  35607. * Force relase the drag action by code.
  35608. */
  35609. releaseDrag(): void;
  35610. private _startDragRay;
  35611. private _lastPointerRay;
  35612. /**
  35613. * Simulates the start of a pointer drag event on the behavior
  35614. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35615. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35616. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35617. */
  35618. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35619. private _startDrag;
  35620. private _dragDelta;
  35621. private _moveDrag;
  35622. private _pickWithRayOnDragPlane;
  35623. private _pointA;
  35624. private _pointB;
  35625. private _pointC;
  35626. private _lineA;
  35627. private _lineB;
  35628. private _localAxis;
  35629. private _lookAt;
  35630. private _updateDragPlanePosition;
  35631. /**
  35632. * Detaches the behavior from the mesh
  35633. */
  35634. detach(): void;
  35635. }
  35636. }
  35637. declare module BABYLON {
  35638. /**
  35639. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35640. */
  35641. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35642. private _dragBehaviorA;
  35643. private _dragBehaviorB;
  35644. private _startDistance;
  35645. private _initialScale;
  35646. private _targetScale;
  35647. private _ownerNode;
  35648. private _sceneRenderObserver;
  35649. /**
  35650. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35651. */
  35652. constructor();
  35653. /**
  35654. * The name of the behavior
  35655. */
  35656. readonly name: string;
  35657. /**
  35658. * Initializes the behavior
  35659. */
  35660. init(): void;
  35661. private _getCurrentDistance;
  35662. /**
  35663. * Attaches the scale behavior the passed in mesh
  35664. * @param ownerNode The mesh that will be scaled around once attached
  35665. */
  35666. attach(ownerNode: Mesh): void;
  35667. /**
  35668. * Detaches the behavior from the mesh
  35669. */
  35670. detach(): void;
  35671. }
  35672. }
  35673. declare module BABYLON {
  35674. /**
  35675. * 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
  35676. */
  35677. export class SixDofDragBehavior implements Behavior<Mesh> {
  35678. private static _virtualScene;
  35679. private _ownerNode;
  35680. private _sceneRenderObserver;
  35681. private _scene;
  35682. private _targetPosition;
  35683. private _virtualOriginMesh;
  35684. private _virtualDragMesh;
  35685. private _pointerObserver;
  35686. private _moving;
  35687. private _startingOrientation;
  35688. /**
  35689. * 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)
  35690. */
  35691. private zDragFactor;
  35692. /**
  35693. * If the object should rotate to face the drag origin
  35694. */
  35695. rotateDraggedObject: boolean;
  35696. /**
  35697. * If the behavior is currently in a dragging state
  35698. */
  35699. dragging: boolean;
  35700. /**
  35701. * 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)
  35702. */
  35703. dragDeltaRatio: number;
  35704. /**
  35705. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35706. */
  35707. currentDraggingPointerID: number;
  35708. /**
  35709. * If camera controls should be detached during the drag
  35710. */
  35711. detachCameraControls: boolean;
  35712. /**
  35713. * Fires each time a drag starts
  35714. */
  35715. onDragStartObservable: Observable<{}>;
  35716. /**
  35717. * Fires each time a drag ends (eg. mouse release after drag)
  35718. */
  35719. onDragEndObservable: Observable<{}>;
  35720. /**
  35721. * 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
  35722. */
  35723. constructor();
  35724. /**
  35725. * The name of the behavior
  35726. */
  35727. readonly name: string;
  35728. /**
  35729. * Initializes the behavior
  35730. */
  35731. init(): void;
  35732. /**
  35733. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  35734. */
  35735. private readonly _pointerCamera;
  35736. /**
  35737. * Attaches the scale behavior the passed in mesh
  35738. * @param ownerNode The mesh that will be scaled around once attached
  35739. */
  35740. attach(ownerNode: Mesh): void;
  35741. /**
  35742. * Detaches the behavior from the mesh
  35743. */
  35744. detach(): void;
  35745. }
  35746. }
  35747. declare module BABYLON {
  35748. /**
  35749. * Class used to apply inverse kinematics to bones
  35750. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35751. */
  35752. export class BoneIKController {
  35753. private static _tmpVecs;
  35754. private static _tmpQuat;
  35755. private static _tmpMats;
  35756. /**
  35757. * Gets or sets the target mesh
  35758. */
  35759. targetMesh: AbstractMesh;
  35760. /** Gets or sets the mesh used as pole */
  35761. poleTargetMesh: AbstractMesh;
  35762. /**
  35763. * Gets or sets the bone used as pole
  35764. */
  35765. poleTargetBone: Nullable<Bone>;
  35766. /**
  35767. * Gets or sets the target position
  35768. */
  35769. targetPosition: Vector3;
  35770. /**
  35771. * Gets or sets the pole target position
  35772. */
  35773. poleTargetPosition: Vector3;
  35774. /**
  35775. * Gets or sets the pole target local offset
  35776. */
  35777. poleTargetLocalOffset: Vector3;
  35778. /**
  35779. * Gets or sets the pole angle
  35780. */
  35781. poleAngle: number;
  35782. /**
  35783. * Gets or sets the mesh associated with the controller
  35784. */
  35785. mesh: AbstractMesh;
  35786. /**
  35787. * 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)
  35788. */
  35789. slerpAmount: number;
  35790. private _bone1Quat;
  35791. private _bone1Mat;
  35792. private _bone2Ang;
  35793. private _bone1;
  35794. private _bone2;
  35795. private _bone1Length;
  35796. private _bone2Length;
  35797. private _maxAngle;
  35798. private _maxReach;
  35799. private _rightHandedSystem;
  35800. private _bendAxis;
  35801. private _slerping;
  35802. private _adjustRoll;
  35803. /**
  35804. * Gets or sets maximum allowed angle
  35805. */
  35806. maxAngle: number;
  35807. /**
  35808. * Creates a new BoneIKController
  35809. * @param mesh defines the mesh to control
  35810. * @param bone defines the bone to control
  35811. * @param options defines options to set up the controller
  35812. */
  35813. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35814. targetMesh?: AbstractMesh;
  35815. poleTargetMesh?: AbstractMesh;
  35816. poleTargetBone?: Bone;
  35817. poleTargetLocalOffset?: Vector3;
  35818. poleAngle?: number;
  35819. bendAxis?: Vector3;
  35820. maxAngle?: number;
  35821. slerpAmount?: number;
  35822. });
  35823. private _setMaxAngle;
  35824. /**
  35825. * Force the controller to update the bones
  35826. */
  35827. update(): void;
  35828. }
  35829. }
  35830. declare module BABYLON {
  35831. /**
  35832. * Class used to make a bone look toward a point in space
  35833. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35834. */
  35835. export class BoneLookController {
  35836. private static _tmpVecs;
  35837. private static _tmpQuat;
  35838. private static _tmpMats;
  35839. /**
  35840. * The target Vector3 that the bone will look at
  35841. */
  35842. target: Vector3;
  35843. /**
  35844. * The mesh that the bone is attached to
  35845. */
  35846. mesh: AbstractMesh;
  35847. /**
  35848. * The bone that will be looking to the target
  35849. */
  35850. bone: Bone;
  35851. /**
  35852. * The up axis of the coordinate system that is used when the bone is rotated
  35853. */
  35854. upAxis: Vector3;
  35855. /**
  35856. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35857. */
  35858. upAxisSpace: Space;
  35859. /**
  35860. * Used to make an adjustment to the yaw of the bone
  35861. */
  35862. adjustYaw: number;
  35863. /**
  35864. * Used to make an adjustment to the pitch of the bone
  35865. */
  35866. adjustPitch: number;
  35867. /**
  35868. * Used to make an adjustment to the roll of the bone
  35869. */
  35870. adjustRoll: number;
  35871. /**
  35872. * 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)
  35873. */
  35874. slerpAmount: number;
  35875. private _minYaw;
  35876. private _maxYaw;
  35877. private _minPitch;
  35878. private _maxPitch;
  35879. private _minYawSin;
  35880. private _minYawCos;
  35881. private _maxYawSin;
  35882. private _maxYawCos;
  35883. private _midYawConstraint;
  35884. private _minPitchTan;
  35885. private _maxPitchTan;
  35886. private _boneQuat;
  35887. private _slerping;
  35888. private _transformYawPitch;
  35889. private _transformYawPitchInv;
  35890. private _firstFrameSkipped;
  35891. private _yawRange;
  35892. private _fowardAxis;
  35893. /**
  35894. * Gets or sets the minimum yaw angle that the bone can look to
  35895. */
  35896. minYaw: number;
  35897. /**
  35898. * Gets or sets the maximum yaw angle that the bone can look to
  35899. */
  35900. maxYaw: number;
  35901. /**
  35902. * Gets or sets the minimum pitch angle that the bone can look to
  35903. */
  35904. minPitch: number;
  35905. /**
  35906. * Gets or sets the maximum pitch angle that the bone can look to
  35907. */
  35908. maxPitch: number;
  35909. /**
  35910. * Create a BoneLookController
  35911. * @param mesh the mesh that the bone belongs to
  35912. * @param bone the bone that will be looking to the target
  35913. * @param target the target Vector3 to look at
  35914. * @param options optional settings:
  35915. * * maxYaw: the maximum angle the bone will yaw to
  35916. * * minYaw: the minimum angle the bone will yaw to
  35917. * * maxPitch: the maximum angle the bone will pitch to
  35918. * * minPitch: the minimum angle the bone will yaw to
  35919. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35920. * * upAxis: the up axis of the coordinate system
  35921. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35922. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35923. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35924. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35925. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35926. * * adjustRoll: used to make an adjustment to the roll of the bone
  35927. **/
  35928. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35929. maxYaw?: number;
  35930. minYaw?: number;
  35931. maxPitch?: number;
  35932. minPitch?: number;
  35933. slerpAmount?: number;
  35934. upAxis?: Vector3;
  35935. upAxisSpace?: Space;
  35936. yawAxis?: Vector3;
  35937. pitchAxis?: Vector3;
  35938. adjustYaw?: number;
  35939. adjustPitch?: number;
  35940. adjustRoll?: number;
  35941. });
  35942. /**
  35943. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35944. */
  35945. update(): void;
  35946. private _getAngleDiff;
  35947. private _getAngleBetween;
  35948. private _isAngleBetween;
  35949. }
  35950. }
  35951. declare module BABYLON {
  35952. /**
  35953. * Manage the gamepad inputs to control an arc rotate camera.
  35954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35955. */
  35956. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35957. /**
  35958. * Defines the camera the input is attached to.
  35959. */
  35960. camera: ArcRotateCamera;
  35961. /**
  35962. * Defines the gamepad the input is gathering event from.
  35963. */
  35964. gamepad: Nullable<Gamepad>;
  35965. /**
  35966. * Defines the gamepad rotation sensiblity.
  35967. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35968. */
  35969. gamepadRotationSensibility: number;
  35970. /**
  35971. * Defines the gamepad move sensiblity.
  35972. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35973. */
  35974. gamepadMoveSensibility: number;
  35975. private _onGamepadConnectedObserver;
  35976. private _onGamepadDisconnectedObserver;
  35977. /**
  35978. * Attach the input controls to a specific dom element to get the input from.
  35979. * @param element Defines the element the controls should be listened from
  35980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35981. */
  35982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35983. /**
  35984. * Detach the current controls from the specified dom element.
  35985. * @param element Defines the element to stop listening the inputs from
  35986. */
  35987. detachControl(element: Nullable<HTMLElement>): void;
  35988. /**
  35989. * Update the current camera state depending on the inputs that have been used this frame.
  35990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35991. */
  35992. checkInputs(): void;
  35993. /**
  35994. * Gets the class name of the current intput.
  35995. * @returns the class name
  35996. */
  35997. getClassName(): string;
  35998. /**
  35999. * Get the friendly name associated with the input class.
  36000. * @returns the input friendly name
  36001. */
  36002. getSimpleName(): string;
  36003. }
  36004. }
  36005. declare module BABYLON {
  36006. interface ArcRotateCameraInputsManager {
  36007. /**
  36008. * Add orientation input support to the input manager.
  36009. * @returns the current input manager
  36010. */
  36011. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36012. }
  36013. /**
  36014. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36016. */
  36017. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36018. /**
  36019. * Defines the camera the input is attached to.
  36020. */
  36021. camera: ArcRotateCamera;
  36022. /**
  36023. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36024. */
  36025. alphaCorrection: number;
  36026. /**
  36027. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36028. */
  36029. gammaCorrection: number;
  36030. private _alpha;
  36031. private _gamma;
  36032. private _dirty;
  36033. private _deviceOrientationHandler;
  36034. /**
  36035. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36036. */
  36037. constructor();
  36038. /**
  36039. * Attach the input controls to a specific dom element to get the input from.
  36040. * @param element Defines the element the controls should be listened from
  36041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36042. */
  36043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36044. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36045. /**
  36046. * Update the current camera state depending on the inputs that have been used this frame.
  36047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36048. */
  36049. checkInputs(): void;
  36050. /**
  36051. * Detach the current controls from the specified dom element.
  36052. * @param element Defines the element to stop listening the inputs from
  36053. */
  36054. detachControl(element: Nullable<HTMLElement>): void;
  36055. /**
  36056. * Gets the class name of the current intput.
  36057. * @returns the class name
  36058. */
  36059. getClassName(): string;
  36060. /**
  36061. * Get the friendly name associated with the input class.
  36062. * @returns the input friendly name
  36063. */
  36064. getSimpleName(): string;
  36065. }
  36066. }
  36067. declare module BABYLON {
  36068. /**
  36069. * Listen to mouse events to control the camera.
  36070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36071. */
  36072. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36073. /**
  36074. * Defines the camera the input is attached to.
  36075. */
  36076. camera: FlyCamera;
  36077. /**
  36078. * Defines if touch is enabled. (Default is true.)
  36079. */
  36080. touchEnabled: boolean;
  36081. /**
  36082. * Defines the buttons associated with the input to handle camera rotation.
  36083. */
  36084. buttons: number[];
  36085. /**
  36086. * Assign buttons for Yaw control.
  36087. */
  36088. buttonsYaw: number[];
  36089. /**
  36090. * Assign buttons for Pitch control.
  36091. */
  36092. buttonsPitch: number[];
  36093. /**
  36094. * Assign buttons for Roll control.
  36095. */
  36096. buttonsRoll: number[];
  36097. /**
  36098. * Detect if any button is being pressed while mouse is moved.
  36099. * -1 = Mouse locked.
  36100. * 0 = Left button.
  36101. * 1 = Middle Button.
  36102. * 2 = Right Button.
  36103. */
  36104. activeButton: number;
  36105. /**
  36106. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36107. * Higher values reduce its sensitivity.
  36108. */
  36109. angularSensibility: number;
  36110. private _mousemoveCallback;
  36111. private _observer;
  36112. private _rollObserver;
  36113. private previousPosition;
  36114. private noPreventDefault;
  36115. private element;
  36116. /**
  36117. * Listen to mouse events to control the camera.
  36118. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36120. */
  36121. constructor(touchEnabled?: boolean);
  36122. /**
  36123. * Attach the mouse control to the HTML DOM element.
  36124. * @param element Defines the element that listens to the input events.
  36125. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36126. */
  36127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36128. /**
  36129. * Detach the current controls from the specified dom element.
  36130. * @param element Defines the element to stop listening the inputs from
  36131. */
  36132. detachControl(element: Nullable<HTMLElement>): void;
  36133. /**
  36134. * Gets the class name of the current input.
  36135. * @returns the class name.
  36136. */
  36137. getClassName(): string;
  36138. /**
  36139. * Get the friendly name associated with the input class.
  36140. * @returns the input's friendly name.
  36141. */
  36142. getSimpleName(): string;
  36143. private _pointerInput;
  36144. private _onMouseMove;
  36145. /**
  36146. * Rotate camera by mouse offset.
  36147. */
  36148. private rotateCamera;
  36149. }
  36150. }
  36151. declare module BABYLON {
  36152. /**
  36153. * Default Inputs manager for the FlyCamera.
  36154. * It groups all the default supported inputs for ease of use.
  36155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36156. */
  36157. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36158. /**
  36159. * Instantiates a new FlyCameraInputsManager.
  36160. * @param camera Defines the camera the inputs belong to.
  36161. */
  36162. constructor(camera: FlyCamera);
  36163. /**
  36164. * Add keyboard input support to the input manager.
  36165. * @returns the new FlyCameraKeyboardMoveInput().
  36166. */
  36167. addKeyboard(): FlyCameraInputsManager;
  36168. /**
  36169. * Add mouse input support to the input manager.
  36170. * @param touchEnabled Enable touch screen support.
  36171. * @returns the new FlyCameraMouseInput().
  36172. */
  36173. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36174. }
  36175. }
  36176. declare module BABYLON {
  36177. /**
  36178. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36179. * such as in a 3D Space Shooter or a Flight Simulator.
  36180. */
  36181. export class FlyCamera extends TargetCamera {
  36182. /**
  36183. * Define the collision ellipsoid of the camera.
  36184. * This is helpful for simulating a camera body, like a player's body.
  36185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36186. */
  36187. ellipsoid: Vector3;
  36188. /**
  36189. * Define an offset for the position of the ellipsoid around the camera.
  36190. * This can be helpful if the camera is attached away from the player's body center,
  36191. * such as at its head.
  36192. */
  36193. ellipsoidOffset: Vector3;
  36194. /**
  36195. * Enable or disable collisions of the camera with the rest of the scene objects.
  36196. */
  36197. checkCollisions: boolean;
  36198. /**
  36199. * Enable or disable gravity on the camera.
  36200. */
  36201. applyGravity: boolean;
  36202. /**
  36203. * Define the current direction the camera is moving to.
  36204. */
  36205. cameraDirection: Vector3;
  36206. /**
  36207. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36208. * This overrides and empties cameraRotation.
  36209. */
  36210. rotationQuaternion: Quaternion;
  36211. /**
  36212. * Track Roll to maintain the wanted Rolling when looking around.
  36213. */ private _trackRoll: number;
  36214. /**
  36215. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36216. */
  36217. rollCorrect: number;
  36218. /**
  36219. * Mimic a banked turn, Rolling the camera when Yawing.
  36220. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36221. */
  36222. bankedTurn: boolean;
  36223. /**
  36224. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36225. */
  36226. bankedTurnLimit: number;
  36227. /**
  36228. * Value of 0 disables the banked Roll.
  36229. * Value of 1 is equal to the Yaw angle in radians.
  36230. */
  36231. bankedTurnMultiplier: number;
  36232. /**
  36233. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36234. */
  36235. inputs: FlyCameraInputsManager;
  36236. /**
  36237. * Gets the input sensibility for mouse input.
  36238. * Higher values reduce sensitivity.
  36239. */
  36240. /**
  36241. * Sets the input sensibility for a mouse input.
  36242. * Higher values reduce sensitivity.
  36243. */
  36244. angularSensibility: number;
  36245. /**
  36246. * Get the keys for camera movement forward.
  36247. */
  36248. /**
  36249. * Set the keys for camera movement forward.
  36250. */
  36251. keysForward: number[];
  36252. /**
  36253. * Get the keys for camera movement backward.
  36254. */
  36255. keysBackward: number[];
  36256. /**
  36257. * Get the keys for camera movement up.
  36258. */
  36259. /**
  36260. * Set the keys for camera movement up.
  36261. */
  36262. keysUp: number[];
  36263. /**
  36264. * Get the keys for camera movement down.
  36265. */
  36266. /**
  36267. * Set the keys for camera movement down.
  36268. */
  36269. keysDown: number[];
  36270. /**
  36271. * Get the keys for camera movement left.
  36272. */
  36273. /**
  36274. * Set the keys for camera movement left.
  36275. */
  36276. keysLeft: number[];
  36277. /**
  36278. * Set the keys for camera movement right.
  36279. */
  36280. /**
  36281. * Set the keys for camera movement right.
  36282. */
  36283. keysRight: number[];
  36284. /**
  36285. * Event raised when the camera collides with a mesh in the scene.
  36286. */
  36287. onCollide: (collidedMesh: AbstractMesh) => void;
  36288. private _collider;
  36289. private _needMoveForGravity;
  36290. private _oldPosition;
  36291. private _diffPosition;
  36292. private _newPosition;
  36293. /** @hidden */ private _localDirection: Vector3;
  36294. /** @hidden */ private _transformedDirection: Vector3;
  36295. /**
  36296. * Instantiates a FlyCamera.
  36297. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36298. * such as in a 3D Space Shooter or a Flight Simulator.
  36299. * @param name Define the name of the camera in the scene.
  36300. * @param position Define the starting position of the camera in the scene.
  36301. * @param scene Define the scene the camera belongs to.
  36302. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36303. */
  36304. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36305. /**
  36306. * Attach a control to the HTML DOM element.
  36307. * @param element Defines the element that listens to the input events.
  36308. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36309. */
  36310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36311. /**
  36312. * Detach a control from the HTML DOM element.
  36313. * The camera will stop reacting to that input.
  36314. * @param element Defines the element that listens to the input events.
  36315. */
  36316. detachControl(element: HTMLElement): void;
  36317. private _collisionMask;
  36318. /**
  36319. * Get the mask that the camera ignores in collision events.
  36320. */
  36321. /**
  36322. * Set the mask that the camera ignores in collision events.
  36323. */
  36324. collisionMask: number;
  36325. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36326. /** @hidden */
  36327. private _onCollisionPositionChange;
  36328. /** @hidden */ private _checkInputs(): void;
  36329. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36330. /** @hidden */ private _updatePosition(): void;
  36331. /**
  36332. * Restore the Roll to its target value at the rate specified.
  36333. * @param rate - Higher means slower restoring.
  36334. * @hidden
  36335. */
  36336. restoreRoll(rate: number): void;
  36337. /**
  36338. * Destroy the camera and release the current resources held by it.
  36339. */
  36340. dispose(): void;
  36341. /**
  36342. * Get the current object class name.
  36343. * @returns the class name.
  36344. */
  36345. getClassName(): string;
  36346. }
  36347. }
  36348. declare module BABYLON {
  36349. /**
  36350. * Listen to keyboard events to control the camera.
  36351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36352. */
  36353. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36354. /**
  36355. * Defines the camera the input is attached to.
  36356. */
  36357. camera: FlyCamera;
  36358. /**
  36359. * The list of keyboard keys used to control the forward move of the camera.
  36360. */
  36361. keysForward: number[];
  36362. /**
  36363. * The list of keyboard keys used to control the backward move of the camera.
  36364. */
  36365. keysBackward: number[];
  36366. /**
  36367. * The list of keyboard keys used to control the forward move of the camera.
  36368. */
  36369. keysUp: number[];
  36370. /**
  36371. * The list of keyboard keys used to control the backward move of the camera.
  36372. */
  36373. keysDown: number[];
  36374. /**
  36375. * The list of keyboard keys used to control the right strafe move of the camera.
  36376. */
  36377. keysRight: number[];
  36378. /**
  36379. * The list of keyboard keys used to control the left strafe move of the camera.
  36380. */
  36381. keysLeft: number[];
  36382. private _keys;
  36383. private _onCanvasBlurObserver;
  36384. private _onKeyboardObserver;
  36385. private _engine;
  36386. private _scene;
  36387. /**
  36388. * Attach the input controls to a specific dom element to get the input from.
  36389. * @param element Defines the element the controls should be listened from
  36390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36391. */
  36392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36393. /**
  36394. * Detach the current controls from the specified dom element.
  36395. * @param element Defines the element to stop listening the inputs from
  36396. */
  36397. detachControl(element: Nullable<HTMLElement>): void;
  36398. /**
  36399. * Gets the class name of the current intput.
  36400. * @returns the class name
  36401. */
  36402. getClassName(): string;
  36403. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36404. /**
  36405. * Get the friendly name associated with the input class.
  36406. * @returns the input friendly name
  36407. */
  36408. getSimpleName(): string;
  36409. /**
  36410. * Update the current camera state depending on the inputs that have been used this frame.
  36411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36412. */
  36413. checkInputs(): void;
  36414. }
  36415. }
  36416. declare module BABYLON {
  36417. /**
  36418. * Manage the mouse wheel inputs to control a follow camera.
  36419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36420. */
  36421. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36422. /**
  36423. * Defines the camera the input is attached to.
  36424. */
  36425. camera: FollowCamera;
  36426. /**
  36427. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36428. */
  36429. axisControlRadius: boolean;
  36430. /**
  36431. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36432. */
  36433. axisControlHeight: boolean;
  36434. /**
  36435. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36436. */
  36437. axisControlRotation: boolean;
  36438. /**
  36439. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36440. * relation to mouseWheel events.
  36441. */
  36442. wheelPrecision: number;
  36443. /**
  36444. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36445. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36446. */
  36447. wheelDeltaPercentage: number;
  36448. private _wheel;
  36449. private _observer;
  36450. /**
  36451. * Attach the input controls to a specific dom element to get the input from.
  36452. * @param element Defines the element the controls should be listened from
  36453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36454. */
  36455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36456. /**
  36457. * Detach the current controls from the specified dom element.
  36458. * @param element Defines the element to stop listening the inputs from
  36459. */
  36460. detachControl(element: Nullable<HTMLElement>): void;
  36461. /**
  36462. * Gets the class name of the current intput.
  36463. * @returns the class name
  36464. */
  36465. getClassName(): string;
  36466. /**
  36467. * Get the friendly name associated with the input class.
  36468. * @returns the input friendly name
  36469. */
  36470. getSimpleName(): string;
  36471. }
  36472. }
  36473. declare module BABYLON {
  36474. /**
  36475. * Manage the pointers inputs to control an follow camera.
  36476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36477. */
  36478. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36479. /**
  36480. * Defines the camera the input is attached to.
  36481. */
  36482. camera: FollowCamera;
  36483. /**
  36484. * Gets the class name of the current input.
  36485. * @returns the class name
  36486. */
  36487. getClassName(): string;
  36488. /**
  36489. * Defines the pointer angular sensibility along the X axis or how fast is
  36490. * the camera rotating.
  36491. * A negative number will reverse the axis direction.
  36492. */
  36493. angularSensibilityX: number;
  36494. /**
  36495. * Defines the pointer angular sensibility along the Y axis or how fast is
  36496. * the camera rotating.
  36497. * A negative number will reverse the axis direction.
  36498. */
  36499. angularSensibilityY: number;
  36500. /**
  36501. * Defines the pointer pinch precision or how fast is the camera zooming.
  36502. * A negative number will reverse the axis direction.
  36503. */
  36504. pinchPrecision: number;
  36505. /**
  36506. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36507. * from 0.
  36508. * It defines the percentage of current camera.radius to use as delta when
  36509. * pinch zoom is used.
  36510. */
  36511. pinchDeltaPercentage: number;
  36512. /**
  36513. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36514. */
  36515. axisXControlRadius: boolean;
  36516. /**
  36517. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36518. */
  36519. axisXControlHeight: boolean;
  36520. /**
  36521. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36522. */
  36523. axisXControlRotation: boolean;
  36524. /**
  36525. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36526. */
  36527. axisYControlRadius: boolean;
  36528. /**
  36529. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36530. */
  36531. axisYControlHeight: boolean;
  36532. /**
  36533. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36534. */
  36535. axisYControlRotation: boolean;
  36536. /**
  36537. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36538. */
  36539. axisPinchControlRadius: boolean;
  36540. /**
  36541. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36542. */
  36543. axisPinchControlHeight: boolean;
  36544. /**
  36545. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36546. */
  36547. axisPinchControlRotation: boolean;
  36548. /**
  36549. * Log error messages if basic misconfiguration has occurred.
  36550. */
  36551. warningEnable: boolean;
  36552. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36553. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36554. private _warningCounter;
  36555. private _warning;
  36556. }
  36557. }
  36558. declare module BABYLON {
  36559. /**
  36560. * Default Inputs manager for the FollowCamera.
  36561. * It groups all the default supported inputs for ease of use.
  36562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36563. */
  36564. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36565. /**
  36566. * Instantiates a new FollowCameraInputsManager.
  36567. * @param camera Defines the camera the inputs belong to
  36568. */
  36569. constructor(camera: FollowCamera);
  36570. /**
  36571. * Add keyboard input support to the input manager.
  36572. * @returns the current input manager
  36573. */
  36574. addKeyboard(): FollowCameraInputsManager;
  36575. /**
  36576. * Add mouse wheel input support to the input manager.
  36577. * @returns the current input manager
  36578. */
  36579. addMouseWheel(): FollowCameraInputsManager;
  36580. /**
  36581. * Add pointers input support to the input manager.
  36582. * @returns the current input manager
  36583. */
  36584. addPointers(): FollowCameraInputsManager;
  36585. /**
  36586. * Add orientation input support to the input manager.
  36587. * @returns the current input manager
  36588. */
  36589. addVRDeviceOrientation(): FollowCameraInputsManager;
  36590. }
  36591. }
  36592. declare module BABYLON {
  36593. /**
  36594. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36595. * an arc rotate version arcFollowCamera are available.
  36596. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36597. */
  36598. export class FollowCamera extends TargetCamera {
  36599. /**
  36600. * Distance the follow camera should follow an object at
  36601. */
  36602. radius: number;
  36603. /**
  36604. * Minimum allowed distance of the camera to the axis of rotation
  36605. * (The camera can not get closer).
  36606. * This can help limiting how the Camera is able to move in the scene.
  36607. */
  36608. lowerRadiusLimit: Nullable<number>;
  36609. /**
  36610. * Maximum allowed distance of the camera to the axis of rotation
  36611. * (The camera can not get further).
  36612. * This can help limiting how the Camera is able to move in the scene.
  36613. */
  36614. upperRadiusLimit: Nullable<number>;
  36615. /**
  36616. * Define a rotation offset between the camera and the object it follows
  36617. */
  36618. rotationOffset: number;
  36619. /**
  36620. * Minimum allowed angle to camera position relative to target object.
  36621. * This can help limiting how the Camera is able to move in the scene.
  36622. */
  36623. lowerRotationOffsetLimit: Nullable<number>;
  36624. /**
  36625. * Maximum allowed angle to camera position relative to target object.
  36626. * This can help limiting how the Camera is able to move in the scene.
  36627. */
  36628. upperRotationOffsetLimit: Nullable<number>;
  36629. /**
  36630. * Define a height offset between the camera and the object it follows.
  36631. * It can help following an object from the top (like a car chaing a plane)
  36632. */
  36633. heightOffset: number;
  36634. /**
  36635. * Minimum allowed height of camera position relative to target object.
  36636. * This can help limiting how the Camera is able to move in the scene.
  36637. */
  36638. lowerHeightOffsetLimit: Nullable<number>;
  36639. /**
  36640. * Maximum allowed height of camera position relative to target object.
  36641. * This can help limiting how the Camera is able to move in the scene.
  36642. */
  36643. upperHeightOffsetLimit: Nullable<number>;
  36644. /**
  36645. * Define how fast the camera can accelerate to follow it s target.
  36646. */
  36647. cameraAcceleration: number;
  36648. /**
  36649. * Define the speed limit of the camera following an object.
  36650. */
  36651. maxCameraSpeed: number;
  36652. /**
  36653. * Define the target of the camera.
  36654. */
  36655. lockedTarget: Nullable<AbstractMesh>;
  36656. /**
  36657. * Defines the input associated with the camera.
  36658. */
  36659. inputs: FollowCameraInputsManager;
  36660. /**
  36661. * Instantiates the follow camera.
  36662. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36663. * @param name Define the name of the camera in the scene
  36664. * @param position Define the position of the camera
  36665. * @param scene Define the scene the camera belong to
  36666. * @param lockedTarget Define the target of the camera
  36667. */
  36668. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36669. private _follow;
  36670. /**
  36671. * Attached controls to the current camera.
  36672. * @param element Defines the element the controls should be listened from
  36673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36674. */
  36675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36676. /**
  36677. * Detach the current controls from the camera.
  36678. * The camera will stop reacting to inputs.
  36679. * @param element Defines the element to stop listening the inputs from
  36680. */
  36681. detachControl(element: HTMLElement): void;
  36682. /** @hidden */ private _checkInputs(): void;
  36683. private _checkLimits;
  36684. /**
  36685. * Gets the camera class name.
  36686. * @returns the class name
  36687. */
  36688. getClassName(): string;
  36689. }
  36690. /**
  36691. * Arc Rotate version of the follow camera.
  36692. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36693. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36694. */
  36695. export class ArcFollowCamera extends TargetCamera {
  36696. /** The longitudinal angle of the camera */
  36697. alpha: number;
  36698. /** The latitudinal angle of the camera */
  36699. beta: number;
  36700. /** The radius of the camera from its target */
  36701. radius: number;
  36702. /** Define the camera target (the messh it should follow) */
  36703. target: Nullable<AbstractMesh>;
  36704. private _cartesianCoordinates;
  36705. /**
  36706. * Instantiates a new ArcFollowCamera
  36707. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36708. * @param name Define the name of the camera
  36709. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36710. * @param beta Define the rotation angle of the camera around the elevation axis
  36711. * @param radius Define the radius of the camera from its target point
  36712. * @param target Define the target of the camera
  36713. * @param scene Define the scene the camera belongs to
  36714. */
  36715. constructor(name: string,
  36716. /** The longitudinal angle of the camera */
  36717. alpha: number,
  36718. /** The latitudinal angle of the camera */
  36719. beta: number,
  36720. /** The radius of the camera from its target */
  36721. radius: number,
  36722. /** Define the camera target (the messh it should follow) */
  36723. target: Nullable<AbstractMesh>, scene: Scene);
  36724. private _follow;
  36725. /** @hidden */ private _checkInputs(): void;
  36726. /**
  36727. * Returns the class name of the object.
  36728. * It is mostly used internally for serialization purposes.
  36729. */
  36730. getClassName(): string;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * Manage the keyboard inputs to control the movement of a follow camera.
  36736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36737. */
  36738. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36739. /**
  36740. * Defines the camera the input is attached to.
  36741. */
  36742. camera: FollowCamera;
  36743. /**
  36744. * Defines the list of key codes associated with the up action (increase heightOffset)
  36745. */
  36746. keysHeightOffsetIncr: number[];
  36747. /**
  36748. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36749. */
  36750. keysHeightOffsetDecr: number[];
  36751. /**
  36752. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36753. */
  36754. keysHeightOffsetModifierAlt: boolean;
  36755. /**
  36756. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36757. */
  36758. keysHeightOffsetModifierCtrl: boolean;
  36759. /**
  36760. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36761. */
  36762. keysHeightOffsetModifierShift: boolean;
  36763. /**
  36764. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36765. */
  36766. keysRotationOffsetIncr: number[];
  36767. /**
  36768. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36769. */
  36770. keysRotationOffsetDecr: number[];
  36771. /**
  36772. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36773. */
  36774. keysRotationOffsetModifierAlt: boolean;
  36775. /**
  36776. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36777. */
  36778. keysRotationOffsetModifierCtrl: boolean;
  36779. /**
  36780. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36781. */
  36782. keysRotationOffsetModifierShift: boolean;
  36783. /**
  36784. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36785. */
  36786. keysRadiusIncr: number[];
  36787. /**
  36788. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36789. */
  36790. keysRadiusDecr: number[];
  36791. /**
  36792. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36793. */
  36794. keysRadiusModifierAlt: boolean;
  36795. /**
  36796. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36797. */
  36798. keysRadiusModifierCtrl: boolean;
  36799. /**
  36800. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36801. */
  36802. keysRadiusModifierShift: boolean;
  36803. /**
  36804. * Defines the rate of change of heightOffset.
  36805. */
  36806. heightSensibility: number;
  36807. /**
  36808. * Defines the rate of change of rotationOffset.
  36809. */
  36810. rotationSensibility: number;
  36811. /**
  36812. * Defines the rate of change of radius.
  36813. */
  36814. radiusSensibility: number;
  36815. private _keys;
  36816. private _ctrlPressed;
  36817. private _altPressed;
  36818. private _shiftPressed;
  36819. private _onCanvasBlurObserver;
  36820. private _onKeyboardObserver;
  36821. private _engine;
  36822. private _scene;
  36823. /**
  36824. * Attach the input controls to a specific dom element to get the input from.
  36825. * @param element Defines the element the controls should be listened from
  36826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36827. */
  36828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36829. /**
  36830. * Detach the current controls from the specified dom element.
  36831. * @param element Defines the element to stop listening the inputs from
  36832. */
  36833. detachControl(element: Nullable<HTMLElement>): void;
  36834. /**
  36835. * Update the current camera state depending on the inputs that have been used this frame.
  36836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36837. */
  36838. checkInputs(): void;
  36839. /**
  36840. * Gets the class name of the current input.
  36841. * @returns the class name
  36842. */
  36843. getClassName(): string;
  36844. /**
  36845. * Get the friendly name associated with the input class.
  36846. * @returns the input friendly name
  36847. */
  36848. getSimpleName(): string;
  36849. /**
  36850. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36851. * allow modification of the heightOffset value.
  36852. */
  36853. private _modifierHeightOffset;
  36854. /**
  36855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36856. * allow modification of the rotationOffset value.
  36857. */
  36858. private _modifierRotationOffset;
  36859. /**
  36860. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36861. * allow modification of the radius value.
  36862. */
  36863. private _modifierRadius;
  36864. }
  36865. }
  36866. declare module BABYLON {
  36867. interface FreeCameraInputsManager {
  36868. /**
  36869. * @hidden
  36870. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36871. /**
  36872. * Add orientation input support to the input manager.
  36873. * @returns the current input manager
  36874. */
  36875. addDeviceOrientation(): FreeCameraInputsManager;
  36876. }
  36877. /**
  36878. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36879. * Screen rotation is taken into account.
  36880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36881. */
  36882. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36883. private _camera;
  36884. private _screenOrientationAngle;
  36885. private _constantTranform;
  36886. private _screenQuaternion;
  36887. private _alpha;
  36888. private _beta;
  36889. private _gamma;
  36890. /**
  36891. * Can be used to detect if a device orientation sensor is availible on a device
  36892. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  36893. * @returns a promise that will resolve on orientation change
  36894. */
  36895. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  36896. /**
  36897. * @hidden
  36898. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  36899. /**
  36900. * Instantiates a new input
  36901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36902. */
  36903. constructor();
  36904. /**
  36905. * Define the camera controlled by the input.
  36906. */
  36907. camera: FreeCamera;
  36908. /**
  36909. * Attach the input controls to a specific dom element to get the input from.
  36910. * @param element Defines the element the controls should be listened from
  36911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36912. */
  36913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36914. private _orientationChanged;
  36915. private _deviceOrientation;
  36916. /**
  36917. * Detach the current controls from the specified dom element.
  36918. * @param element Defines the element to stop listening the inputs from
  36919. */
  36920. detachControl(element: Nullable<HTMLElement>): void;
  36921. /**
  36922. * Update the current camera state depending on the inputs that have been used this frame.
  36923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36924. */
  36925. checkInputs(): void;
  36926. /**
  36927. * Gets the class name of the current intput.
  36928. * @returns the class name
  36929. */
  36930. getClassName(): string;
  36931. /**
  36932. * Get the friendly name associated with the input class.
  36933. * @returns the input friendly name
  36934. */
  36935. getSimpleName(): string;
  36936. }
  36937. }
  36938. declare module BABYLON {
  36939. /**
  36940. * Manage the gamepad inputs to control a free camera.
  36941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36942. */
  36943. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36944. /**
  36945. * Define the camera the input is attached to.
  36946. */
  36947. camera: FreeCamera;
  36948. /**
  36949. * Define the Gamepad controlling the input
  36950. */
  36951. gamepad: Nullable<Gamepad>;
  36952. /**
  36953. * Defines the gamepad rotation sensiblity.
  36954. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36955. */
  36956. gamepadAngularSensibility: number;
  36957. /**
  36958. * Defines the gamepad move sensiblity.
  36959. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36960. */
  36961. gamepadMoveSensibility: number;
  36962. private _onGamepadConnectedObserver;
  36963. private _onGamepadDisconnectedObserver;
  36964. private _cameraTransform;
  36965. private _deltaTransform;
  36966. private _vector3;
  36967. private _vector2;
  36968. /**
  36969. * Attach the input controls to a specific dom element to get the input from.
  36970. * @param element Defines the element the controls should be listened from
  36971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36972. */
  36973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36974. /**
  36975. * Detach the current controls from the specified dom element.
  36976. * @param element Defines the element to stop listening the inputs from
  36977. */
  36978. detachControl(element: Nullable<HTMLElement>): void;
  36979. /**
  36980. * Update the current camera state depending on the inputs that have been used this frame.
  36981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36982. */
  36983. checkInputs(): void;
  36984. /**
  36985. * Gets the class name of the current intput.
  36986. * @returns the class name
  36987. */
  36988. getClassName(): string;
  36989. /**
  36990. * Get the friendly name associated with the input class.
  36991. * @returns the input friendly name
  36992. */
  36993. getSimpleName(): string;
  36994. }
  36995. }
  36996. declare module BABYLON {
  36997. /**
  36998. * Defines the potential axis of a Joystick
  36999. */
  37000. export enum JoystickAxis {
  37001. /** X axis */
  37002. X = 0,
  37003. /** Y axis */
  37004. Y = 1,
  37005. /** Z axis */
  37006. Z = 2
  37007. }
  37008. /**
  37009. * Class used to define virtual joystick (used in touch mode)
  37010. */
  37011. export class VirtualJoystick {
  37012. /**
  37013. * Gets or sets a boolean indicating that left and right values must be inverted
  37014. */
  37015. reverseLeftRight: boolean;
  37016. /**
  37017. * Gets or sets a boolean indicating that up and down values must be inverted
  37018. */
  37019. reverseUpDown: boolean;
  37020. /**
  37021. * Gets the offset value for the position (ie. the change of the position value)
  37022. */
  37023. deltaPosition: Vector3;
  37024. /**
  37025. * Gets a boolean indicating if the virtual joystick was pressed
  37026. */
  37027. pressed: boolean;
  37028. /**
  37029. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37030. */
  37031. static Canvas: Nullable<HTMLCanvasElement>;
  37032. private static _globalJoystickIndex;
  37033. private static vjCanvasContext;
  37034. private static vjCanvasWidth;
  37035. private static vjCanvasHeight;
  37036. private static halfWidth;
  37037. private _action;
  37038. private _axisTargetedByLeftAndRight;
  37039. private _axisTargetedByUpAndDown;
  37040. private _joystickSensibility;
  37041. private _inversedSensibility;
  37042. private _joystickPointerID;
  37043. private _joystickColor;
  37044. private _joystickPointerPos;
  37045. private _joystickPreviousPointerPos;
  37046. private _joystickPointerStartPos;
  37047. private _deltaJoystickVector;
  37048. private _leftJoystick;
  37049. private _touches;
  37050. private _onPointerDownHandlerRef;
  37051. private _onPointerMoveHandlerRef;
  37052. private _onPointerUpHandlerRef;
  37053. private _onResize;
  37054. /**
  37055. * Creates a new virtual joystick
  37056. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37057. */
  37058. constructor(leftJoystick?: boolean);
  37059. /**
  37060. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37061. * @param newJoystickSensibility defines the new sensibility
  37062. */
  37063. setJoystickSensibility(newJoystickSensibility: number): void;
  37064. private _onPointerDown;
  37065. private _onPointerMove;
  37066. private _onPointerUp;
  37067. /**
  37068. * Change the color of the virtual joystick
  37069. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37070. */
  37071. setJoystickColor(newColor: string): void;
  37072. /**
  37073. * Defines a callback to call when the joystick is touched
  37074. * @param action defines the callback
  37075. */
  37076. setActionOnTouch(action: () => any): void;
  37077. /**
  37078. * Defines which axis you'd like to control for left & right
  37079. * @param axis defines the axis to use
  37080. */
  37081. setAxisForLeftRight(axis: JoystickAxis): void;
  37082. /**
  37083. * Defines which axis you'd like to control for up & down
  37084. * @param axis defines the axis to use
  37085. */
  37086. setAxisForUpDown(axis: JoystickAxis): void;
  37087. private _drawVirtualJoystick;
  37088. /**
  37089. * Release internal HTML canvas
  37090. */
  37091. releaseCanvas(): void;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. interface FreeCameraInputsManager {
  37096. /**
  37097. * Add virtual joystick input support to the input manager.
  37098. * @returns the current input manager
  37099. */
  37100. addVirtualJoystick(): FreeCameraInputsManager;
  37101. }
  37102. /**
  37103. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37105. */
  37106. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37107. /**
  37108. * Defines the camera the input is attached to.
  37109. */
  37110. camera: FreeCamera;
  37111. private _leftjoystick;
  37112. private _rightjoystick;
  37113. /**
  37114. * Gets the left stick of the virtual joystick.
  37115. * @returns The virtual Joystick
  37116. */
  37117. getLeftJoystick(): VirtualJoystick;
  37118. /**
  37119. * Gets the right stick of the virtual joystick.
  37120. * @returns The virtual Joystick
  37121. */
  37122. getRightJoystick(): VirtualJoystick;
  37123. /**
  37124. * Update the current camera state depending on the inputs that have been used this frame.
  37125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37126. */
  37127. checkInputs(): void;
  37128. /**
  37129. * Attach the input controls to a specific dom element to get the input from.
  37130. * @param element Defines the element the controls should be listened from
  37131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37132. */
  37133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37134. /**
  37135. * Detach the current controls from the specified dom element.
  37136. * @param element Defines the element to stop listening the inputs from
  37137. */
  37138. detachControl(element: Nullable<HTMLElement>): void;
  37139. /**
  37140. * Gets the class name of the current intput.
  37141. * @returns the class name
  37142. */
  37143. getClassName(): string;
  37144. /**
  37145. * Get the friendly name associated with the input class.
  37146. * @returns the input friendly name
  37147. */
  37148. getSimpleName(): string;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. /**
  37153. * This represents a FPS type of camera controlled by touch.
  37154. * This is like a universal camera minus the Gamepad controls.
  37155. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37156. */
  37157. export class TouchCamera extends FreeCamera {
  37158. /**
  37159. * Defines the touch sensibility for rotation.
  37160. * The higher the faster.
  37161. */
  37162. touchAngularSensibility: number;
  37163. /**
  37164. * Defines the touch sensibility for move.
  37165. * The higher the faster.
  37166. */
  37167. touchMoveSensibility: number;
  37168. /**
  37169. * Instantiates a new touch camera.
  37170. * This represents a FPS type of camera controlled by touch.
  37171. * This is like a universal camera minus the Gamepad controls.
  37172. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37173. * @param name Define the name of the camera in the scene
  37174. * @param position Define the start position of the camera in the scene
  37175. * @param scene Define the scene the camera belongs to
  37176. */
  37177. constructor(name: string, position: Vector3, scene: Scene);
  37178. /**
  37179. * Gets the current object class name.
  37180. * @return the class name
  37181. */
  37182. getClassName(): string;
  37183. /** @hidden */ private _setupInputs(): void;
  37184. }
  37185. }
  37186. declare module BABYLON {
  37187. /**
  37188. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37189. * being tilted forward or back and left or right.
  37190. */
  37191. export class DeviceOrientationCamera extends FreeCamera {
  37192. private _initialQuaternion;
  37193. private _quaternionCache;
  37194. private _tmpDragQuaternion;
  37195. /**
  37196. * Creates a new device orientation camera
  37197. * @param name The name of the camera
  37198. * @param position The start position camera
  37199. * @param scene The scene the camera belongs to
  37200. */
  37201. constructor(name: string, position: Vector3, scene: Scene);
  37202. /**
  37203. * @hidden
  37204. * Disabled pointer input on first orientation sensor update (Default: true)
  37205. */ private _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37206. private _dragFactor;
  37207. /**
  37208. * Enabled turning on the y axis when the orientation sensor is active
  37209. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37210. */
  37211. enableHorizontalDragging(dragFactor?: number): void;
  37212. /**
  37213. * Gets the current instance class name ("DeviceOrientationCamera").
  37214. * This helps avoiding instanceof at run time.
  37215. * @returns the class name
  37216. */
  37217. getClassName(): string;
  37218. /**
  37219. * @hidden
  37220. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37221. */ private _checkInputs(): void;
  37222. /**
  37223. * Reset the camera to its default orientation on the specified axis only.
  37224. * @param axis The axis to reset
  37225. */
  37226. resetToCurrentRotation(axis?: Axis): void;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /**
  37231. * Defines supported buttons for XBox360 compatible gamepads
  37232. */
  37233. export enum Xbox360Button {
  37234. /** A */
  37235. A = 0,
  37236. /** B */
  37237. B = 1,
  37238. /** X */
  37239. X = 2,
  37240. /** Y */
  37241. Y = 3,
  37242. /** Start */
  37243. Start = 4,
  37244. /** Back */
  37245. Back = 5,
  37246. /** Left button */
  37247. LB = 6,
  37248. /** Right button */
  37249. RB = 7,
  37250. /** Left stick */
  37251. LeftStick = 8,
  37252. /** Right stick */
  37253. RightStick = 9
  37254. }
  37255. /** Defines values for XBox360 DPad */
  37256. export enum Xbox360Dpad {
  37257. /** Up */
  37258. Up = 0,
  37259. /** Down */
  37260. Down = 1,
  37261. /** Left */
  37262. Left = 2,
  37263. /** Right */
  37264. Right = 3
  37265. }
  37266. /**
  37267. * Defines a XBox360 gamepad
  37268. */
  37269. export class Xbox360Pad extends Gamepad {
  37270. private _leftTrigger;
  37271. private _rightTrigger;
  37272. private _onlefttriggerchanged;
  37273. private _onrighttriggerchanged;
  37274. private _onbuttondown;
  37275. private _onbuttonup;
  37276. private _ondpaddown;
  37277. private _ondpadup;
  37278. /** Observable raised when a button is pressed */
  37279. onButtonDownObservable: Observable<Xbox360Button>;
  37280. /** Observable raised when a button is released */
  37281. onButtonUpObservable: Observable<Xbox360Button>;
  37282. /** Observable raised when a pad is pressed */
  37283. onPadDownObservable: Observable<Xbox360Dpad>;
  37284. /** Observable raised when a pad is released */
  37285. onPadUpObservable: Observable<Xbox360Dpad>;
  37286. private _buttonA;
  37287. private _buttonB;
  37288. private _buttonX;
  37289. private _buttonY;
  37290. private _buttonBack;
  37291. private _buttonStart;
  37292. private _buttonLB;
  37293. private _buttonRB;
  37294. private _buttonLeftStick;
  37295. private _buttonRightStick;
  37296. private _dPadUp;
  37297. private _dPadDown;
  37298. private _dPadLeft;
  37299. private _dPadRight;
  37300. private _isXboxOnePad;
  37301. /**
  37302. * Creates a new XBox360 gamepad object
  37303. * @param id defines the id of this gamepad
  37304. * @param index defines its index
  37305. * @param gamepad defines the internal HTML gamepad object
  37306. * @param xboxOne defines if it is a XBox One gamepad
  37307. */
  37308. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37309. /**
  37310. * Defines the callback to call when left trigger is pressed
  37311. * @param callback defines the callback to use
  37312. */
  37313. onlefttriggerchanged(callback: (value: number) => void): void;
  37314. /**
  37315. * Defines the callback to call when right trigger is pressed
  37316. * @param callback defines the callback to use
  37317. */
  37318. onrighttriggerchanged(callback: (value: number) => void): void;
  37319. /**
  37320. * Gets the left trigger value
  37321. */
  37322. /**
  37323. * Sets the left trigger value
  37324. */
  37325. leftTrigger: number;
  37326. /**
  37327. * Gets the right trigger value
  37328. */
  37329. /**
  37330. * Sets the right trigger value
  37331. */
  37332. rightTrigger: number;
  37333. /**
  37334. * Defines the callback to call when a button is pressed
  37335. * @param callback defines the callback to use
  37336. */
  37337. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37338. /**
  37339. * Defines the callback to call when a button is released
  37340. * @param callback defines the callback to use
  37341. */
  37342. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37343. /**
  37344. * Defines the callback to call when a pad is pressed
  37345. * @param callback defines the callback to use
  37346. */
  37347. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37348. /**
  37349. * Defines the callback to call when a pad is released
  37350. * @param callback defines the callback to use
  37351. */
  37352. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37353. private _setButtonValue;
  37354. private _setDPadValue;
  37355. /**
  37356. * Gets the value of the `A` button
  37357. */
  37358. /**
  37359. * Sets the value of the `A` button
  37360. */
  37361. buttonA: number;
  37362. /**
  37363. * Gets the value of the `B` button
  37364. */
  37365. /**
  37366. * Sets the value of the `B` button
  37367. */
  37368. buttonB: number;
  37369. /**
  37370. * Gets the value of the `X` button
  37371. */
  37372. /**
  37373. * Sets the value of the `X` button
  37374. */
  37375. buttonX: number;
  37376. /**
  37377. * Gets the value of the `Y` button
  37378. */
  37379. /**
  37380. * Sets the value of the `Y` button
  37381. */
  37382. buttonY: number;
  37383. /**
  37384. * Gets the value of the `Start` button
  37385. */
  37386. /**
  37387. * Sets the value of the `Start` button
  37388. */
  37389. buttonStart: number;
  37390. /**
  37391. * Gets the value of the `Back` button
  37392. */
  37393. /**
  37394. * Sets the value of the `Back` button
  37395. */
  37396. buttonBack: number;
  37397. /**
  37398. * Gets the value of the `Left` button
  37399. */
  37400. /**
  37401. * Sets the value of the `Left` button
  37402. */
  37403. buttonLB: number;
  37404. /**
  37405. * Gets the value of the `Right` button
  37406. */
  37407. /**
  37408. * Sets the value of the `Right` button
  37409. */
  37410. buttonRB: number;
  37411. /**
  37412. * Gets the value of the Left joystick
  37413. */
  37414. /**
  37415. * Sets the value of the Left joystick
  37416. */
  37417. buttonLeftStick: number;
  37418. /**
  37419. * Gets the value of the Right joystick
  37420. */
  37421. /**
  37422. * Sets the value of the Right joystick
  37423. */
  37424. buttonRightStick: number;
  37425. /**
  37426. * Gets the value of D-pad up
  37427. */
  37428. /**
  37429. * Sets the value of D-pad up
  37430. */
  37431. dPadUp: number;
  37432. /**
  37433. * Gets the value of D-pad down
  37434. */
  37435. /**
  37436. * Sets the value of D-pad down
  37437. */
  37438. dPadDown: number;
  37439. /**
  37440. * Gets the value of D-pad left
  37441. */
  37442. /**
  37443. * Sets the value of D-pad left
  37444. */
  37445. dPadLeft: number;
  37446. /**
  37447. * Gets the value of D-pad right
  37448. */
  37449. /**
  37450. * Sets the value of D-pad right
  37451. */
  37452. dPadRight: number;
  37453. /**
  37454. * Force the gamepad to synchronize with device values
  37455. */
  37456. update(): void;
  37457. /**
  37458. * Disposes the gamepad
  37459. */
  37460. dispose(): void;
  37461. }
  37462. }
  37463. declare module BABYLON {
  37464. /**
  37465. * Manager for handling gamepads
  37466. */
  37467. export class GamepadManager {
  37468. private _scene?;
  37469. private _babylonGamepads;
  37470. private _oneGamepadConnected;
  37471. /** @hidden */ private _isMonitoring: boolean;
  37472. private _gamepadEventSupported;
  37473. private _gamepadSupport;
  37474. /**
  37475. * observable to be triggered when the gamepad controller has been connected
  37476. */
  37477. onGamepadConnectedObservable: Observable<Gamepad>;
  37478. /**
  37479. * observable to be triggered when the gamepad controller has been disconnected
  37480. */
  37481. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37482. private _onGamepadConnectedEvent;
  37483. private _onGamepadDisconnectedEvent;
  37484. /**
  37485. * Initializes the gamepad manager
  37486. * @param _scene BabylonJS scene
  37487. */
  37488. constructor(_scene?: Scene | undefined);
  37489. /**
  37490. * The gamepads in the game pad manager
  37491. */
  37492. readonly gamepads: Gamepad[];
  37493. /**
  37494. * Get the gamepad controllers based on type
  37495. * @param type The type of gamepad controller
  37496. * @returns Nullable gamepad
  37497. */
  37498. getGamepadByType(type?: number): Nullable<Gamepad>;
  37499. /**
  37500. * Disposes the gamepad manager
  37501. */
  37502. dispose(): void;
  37503. private _addNewGamepad;
  37504. private _startMonitoringGamepads;
  37505. private _stopMonitoringGamepads;
  37506. /** @hidden */ private _checkGamepadsStatus(): void;
  37507. private _updateGamepadObjects;
  37508. }
  37509. }
  37510. declare module BABYLON {
  37511. interface Scene {
  37512. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  37513. /**
  37514. * Gets the gamepad manager associated with the scene
  37515. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37516. */
  37517. gamepadManager: GamepadManager;
  37518. }
  37519. /**
  37520. * Interface representing a free camera inputs manager
  37521. */
  37522. interface FreeCameraInputsManager {
  37523. /**
  37524. * Adds gamepad input support to the FreeCameraInputsManager.
  37525. * @returns the FreeCameraInputsManager
  37526. */
  37527. addGamepad(): FreeCameraInputsManager;
  37528. }
  37529. /**
  37530. * Interface representing an arc rotate camera inputs manager
  37531. */
  37532. interface ArcRotateCameraInputsManager {
  37533. /**
  37534. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37535. * @returns the camera inputs manager
  37536. */
  37537. addGamepad(): ArcRotateCameraInputsManager;
  37538. }
  37539. /**
  37540. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37541. */
  37542. export class GamepadSystemSceneComponent implements ISceneComponent {
  37543. /**
  37544. * The component name helpfull to identify the component in the list of scene components.
  37545. */
  37546. readonly name: string;
  37547. /**
  37548. * The scene the component belongs to.
  37549. */
  37550. scene: Scene;
  37551. /**
  37552. * Creates a new instance of the component for the given scene
  37553. * @param scene Defines the scene to register the component in
  37554. */
  37555. constructor(scene: Scene);
  37556. /**
  37557. * Registers the component in a given scene
  37558. */
  37559. register(): void;
  37560. /**
  37561. * Rebuilds the elements related to this component in case of
  37562. * context lost for instance.
  37563. */
  37564. rebuild(): void;
  37565. /**
  37566. * Disposes the component and the associated ressources
  37567. */
  37568. dispose(): void;
  37569. private _beforeCameraUpdate;
  37570. }
  37571. }
  37572. declare module BABYLON {
  37573. /**
  37574. * 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,
  37575. * which still works and will still be found in many Playgrounds.
  37576. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37577. */
  37578. export class UniversalCamera extends TouchCamera {
  37579. /**
  37580. * Defines the gamepad rotation sensiblity.
  37581. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37582. */
  37583. gamepadAngularSensibility: number;
  37584. /**
  37585. * Defines the gamepad move sensiblity.
  37586. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37587. */
  37588. gamepadMoveSensibility: number;
  37589. /**
  37590. * 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,
  37591. * which still works and will still be found in many Playgrounds.
  37592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37593. * @param name Define the name of the camera in the scene
  37594. * @param position Define the start position of the camera in the scene
  37595. * @param scene Define the scene the camera belongs to
  37596. */
  37597. constructor(name: string, position: Vector3, scene: Scene);
  37598. /**
  37599. * Gets the current object class name.
  37600. * @return the class name
  37601. */
  37602. getClassName(): string;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * This represents a FPS type of camera. This is only here for back compat purpose.
  37608. * Please use the UniversalCamera instead as both are identical.
  37609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37610. */
  37611. export class GamepadCamera extends UniversalCamera {
  37612. /**
  37613. * Instantiates a new Gamepad Camera
  37614. * This represents a FPS type of camera. This is only here for back compat purpose.
  37615. * Please use the UniversalCamera instead as both are identical.
  37616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37617. * @param name Define the name of the camera in the scene
  37618. * @param position Define the start position of the camera in the scene
  37619. * @param scene Define the scene the camera belongs to
  37620. */
  37621. constructor(name: string, position: Vector3, scene: Scene);
  37622. /**
  37623. * Gets the current object class name.
  37624. * @return the class name
  37625. */
  37626. getClassName(): string;
  37627. }
  37628. }
  37629. declare module BABYLON {
  37630. /** @hidden */
  37631. export var passPixelShader: {
  37632. name: string;
  37633. shader: string;
  37634. };
  37635. }
  37636. declare module BABYLON {
  37637. /** @hidden */
  37638. export var passCubePixelShader: {
  37639. name: string;
  37640. shader: string;
  37641. };
  37642. }
  37643. declare module BABYLON {
  37644. /**
  37645. * PassPostProcess which produces an output the same as it's input
  37646. */
  37647. export class PassPostProcess extends PostProcess {
  37648. /**
  37649. * Creates the PassPostProcess
  37650. * @param name The name of the effect.
  37651. * @param options The required width/height ratio to downsize to before computing the render pass.
  37652. * @param camera The camera to apply the render pass to.
  37653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37654. * @param engine The engine which the post process will be applied. (default: current engine)
  37655. * @param reusable If the post process can be reused on the same frame. (default: false)
  37656. * @param textureType The type of texture to be used when performing the post processing.
  37657. * @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)
  37658. */
  37659. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37660. }
  37661. /**
  37662. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37663. */
  37664. export class PassCubePostProcess extends PostProcess {
  37665. private _face;
  37666. /**
  37667. * Gets or sets the cube face to display.
  37668. * * 0 is +X
  37669. * * 1 is -X
  37670. * * 2 is +Y
  37671. * * 3 is -Y
  37672. * * 4 is +Z
  37673. * * 5 is -Z
  37674. */
  37675. face: number;
  37676. /**
  37677. * Creates the PassCubePostProcess
  37678. * @param name The name of the effect.
  37679. * @param options The required width/height ratio to downsize to before computing the render pass.
  37680. * @param camera The camera to apply the render pass to.
  37681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37682. * @param engine The engine which the post process will be applied. (default: current engine)
  37683. * @param reusable If the post process can be reused on the same frame. (default: false)
  37684. * @param textureType The type of texture to be used when performing the post processing.
  37685. * @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)
  37686. */
  37687. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37688. }
  37689. }
  37690. declare module BABYLON {
  37691. /** @hidden */
  37692. export var anaglyphPixelShader: {
  37693. name: string;
  37694. shader: string;
  37695. };
  37696. }
  37697. declare module BABYLON {
  37698. /**
  37699. * Postprocess used to generate anaglyphic rendering
  37700. */
  37701. export class AnaglyphPostProcess extends PostProcess {
  37702. private _passedProcess;
  37703. /**
  37704. * Creates a new AnaglyphPostProcess
  37705. * @param name defines postprocess name
  37706. * @param options defines creation options or target ratio scale
  37707. * @param rigCameras defines cameras using this postprocess
  37708. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37709. * @param engine defines hosting engine
  37710. * @param reusable defines if the postprocess will be reused multiple times per frame
  37711. */
  37712. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37713. }
  37714. }
  37715. declare module BABYLON {
  37716. /**
  37717. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37718. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37719. */
  37720. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37721. /**
  37722. * Creates a new AnaglyphArcRotateCamera
  37723. * @param name defines camera name
  37724. * @param alpha defines alpha angle (in radians)
  37725. * @param beta defines beta angle (in radians)
  37726. * @param radius defines radius
  37727. * @param target defines camera target
  37728. * @param interaxialDistance defines distance between each color axis
  37729. * @param scene defines the hosting scene
  37730. */
  37731. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37732. /**
  37733. * Gets camera class name
  37734. * @returns AnaglyphArcRotateCamera
  37735. */
  37736. getClassName(): string;
  37737. }
  37738. }
  37739. declare module BABYLON {
  37740. /**
  37741. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37742. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37743. */
  37744. export class AnaglyphFreeCamera extends FreeCamera {
  37745. /**
  37746. * Creates a new AnaglyphFreeCamera
  37747. * @param name defines camera name
  37748. * @param position defines initial position
  37749. * @param interaxialDistance defines distance between each color axis
  37750. * @param scene defines the hosting scene
  37751. */
  37752. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37753. /**
  37754. * Gets camera class name
  37755. * @returns AnaglyphFreeCamera
  37756. */
  37757. getClassName(): string;
  37758. }
  37759. }
  37760. declare module BABYLON {
  37761. /**
  37762. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37763. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37764. */
  37765. export class AnaglyphGamepadCamera extends GamepadCamera {
  37766. /**
  37767. * Creates a new AnaglyphGamepadCamera
  37768. * @param name defines camera name
  37769. * @param position defines initial position
  37770. * @param interaxialDistance defines distance between each color axis
  37771. * @param scene defines the hosting scene
  37772. */
  37773. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37774. /**
  37775. * Gets camera class name
  37776. * @returns AnaglyphGamepadCamera
  37777. */
  37778. getClassName(): string;
  37779. }
  37780. }
  37781. declare module BABYLON {
  37782. /**
  37783. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37784. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37785. */
  37786. export class AnaglyphUniversalCamera extends UniversalCamera {
  37787. /**
  37788. * Creates a new AnaglyphUniversalCamera
  37789. * @param name defines camera name
  37790. * @param position defines initial position
  37791. * @param interaxialDistance defines distance between each color axis
  37792. * @param scene defines the hosting scene
  37793. */
  37794. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37795. /**
  37796. * Gets camera class name
  37797. * @returns AnaglyphUniversalCamera
  37798. */
  37799. getClassName(): string;
  37800. }
  37801. }
  37802. declare module BABYLON {
  37803. /** @hidden */
  37804. export var stereoscopicInterlacePixelShader: {
  37805. name: string;
  37806. shader: string;
  37807. };
  37808. }
  37809. declare module BABYLON {
  37810. /**
  37811. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37812. */
  37813. export class StereoscopicInterlacePostProcess extends PostProcess {
  37814. private _stepSize;
  37815. private _passedProcess;
  37816. /**
  37817. * Initializes a StereoscopicInterlacePostProcess
  37818. * @param name The name of the effect.
  37819. * @param rigCameras The rig cameras to be appled to the post process
  37820. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37822. * @param engine The engine which the post process will be applied. (default: current engine)
  37823. * @param reusable If the post process can be reused on the same frame. (default: false)
  37824. */
  37825. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37826. }
  37827. }
  37828. declare module BABYLON {
  37829. /**
  37830. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37831. * @see http://doc.babylonjs.com/features/cameras
  37832. */
  37833. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37834. /**
  37835. * Creates a new StereoscopicArcRotateCamera
  37836. * @param name defines camera name
  37837. * @param alpha defines alpha angle (in radians)
  37838. * @param beta defines beta angle (in radians)
  37839. * @param radius defines radius
  37840. * @param target defines camera target
  37841. * @param interaxialDistance defines distance between each color axis
  37842. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37843. * @param scene defines the hosting scene
  37844. */
  37845. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37846. /**
  37847. * Gets camera class name
  37848. * @returns StereoscopicArcRotateCamera
  37849. */
  37850. getClassName(): string;
  37851. }
  37852. }
  37853. declare module BABYLON {
  37854. /**
  37855. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37856. * @see http://doc.babylonjs.com/features/cameras
  37857. */
  37858. export class StereoscopicFreeCamera extends FreeCamera {
  37859. /**
  37860. * Creates a new StereoscopicFreeCamera
  37861. * @param name defines camera name
  37862. * @param position defines initial position
  37863. * @param interaxialDistance defines distance between each color axis
  37864. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37865. * @param scene defines the hosting scene
  37866. */
  37867. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37868. /**
  37869. * Gets camera class name
  37870. * @returns StereoscopicFreeCamera
  37871. */
  37872. getClassName(): string;
  37873. }
  37874. }
  37875. declare module BABYLON {
  37876. /**
  37877. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37878. * @see http://doc.babylonjs.com/features/cameras
  37879. */
  37880. export class StereoscopicGamepadCamera extends GamepadCamera {
  37881. /**
  37882. * Creates a new StereoscopicGamepadCamera
  37883. * @param name defines camera name
  37884. * @param position defines initial position
  37885. * @param interaxialDistance defines distance between each color axis
  37886. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37887. * @param scene defines the hosting scene
  37888. */
  37889. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37890. /**
  37891. * Gets camera class name
  37892. * @returns StereoscopicGamepadCamera
  37893. */
  37894. getClassName(): string;
  37895. }
  37896. }
  37897. declare module BABYLON {
  37898. /**
  37899. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37900. * @see http://doc.babylonjs.com/features/cameras
  37901. */
  37902. export class StereoscopicUniversalCamera extends UniversalCamera {
  37903. /**
  37904. * Creates a new StereoscopicUniversalCamera
  37905. * @param name defines camera name
  37906. * @param position defines initial position
  37907. * @param interaxialDistance defines distance between each color axis
  37908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37909. * @param scene defines the hosting scene
  37910. */
  37911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37912. /**
  37913. * Gets camera class name
  37914. * @returns StereoscopicUniversalCamera
  37915. */
  37916. getClassName(): string;
  37917. }
  37918. }
  37919. declare module BABYLON {
  37920. /**
  37921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37922. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37923. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37924. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37925. */
  37926. export class VirtualJoysticksCamera extends FreeCamera {
  37927. /**
  37928. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37929. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37930. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37931. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37932. * @param name Define the name of the camera in the scene
  37933. * @param position Define the start position of the camera in the scene
  37934. * @param scene Define the scene the camera belongs to
  37935. */
  37936. constructor(name: string, position: Vector3, scene: Scene);
  37937. /**
  37938. * Gets the current object class name.
  37939. * @return the class name
  37940. */
  37941. getClassName(): string;
  37942. }
  37943. }
  37944. declare module BABYLON {
  37945. /**
  37946. * This represents all the required metrics to create a VR camera.
  37947. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37948. */
  37949. export class VRCameraMetrics {
  37950. /**
  37951. * Define the horizontal resolution off the screen.
  37952. */
  37953. hResolution: number;
  37954. /**
  37955. * Define the vertical resolution off the screen.
  37956. */
  37957. vResolution: number;
  37958. /**
  37959. * Define the horizontal screen size.
  37960. */
  37961. hScreenSize: number;
  37962. /**
  37963. * Define the vertical screen size.
  37964. */
  37965. vScreenSize: number;
  37966. /**
  37967. * Define the vertical screen center position.
  37968. */
  37969. vScreenCenter: number;
  37970. /**
  37971. * Define the distance of the eyes to the screen.
  37972. */
  37973. eyeToScreenDistance: number;
  37974. /**
  37975. * Define the distance between both lenses
  37976. */
  37977. lensSeparationDistance: number;
  37978. /**
  37979. * Define the distance between both viewer's eyes.
  37980. */
  37981. interpupillaryDistance: number;
  37982. /**
  37983. * Define the distortion factor of the VR postprocess.
  37984. * Please, touch with care.
  37985. */
  37986. distortionK: number[];
  37987. /**
  37988. * Define the chromatic aberration correction factors for the VR post process.
  37989. */
  37990. chromaAbCorrection: number[];
  37991. /**
  37992. * Define the scale factor of the post process.
  37993. * The smaller the better but the slower.
  37994. */
  37995. postProcessScaleFactor: number;
  37996. /**
  37997. * Define an offset for the lens center.
  37998. */
  37999. lensCenterOffset: number;
  38000. /**
  38001. * Define if the current vr camera should compensate the distortion of the lense or not.
  38002. */
  38003. compensateDistortion: boolean;
  38004. /**
  38005. * Defines if multiview should be enabled when rendering (Default: false)
  38006. */
  38007. multiviewEnabled: boolean;
  38008. /**
  38009. * Gets the rendering aspect ratio based on the provided resolutions.
  38010. */
  38011. readonly aspectRatio: number;
  38012. /**
  38013. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38014. */
  38015. readonly aspectRatioFov: number;
  38016. /**
  38017. * @hidden
  38018. */
  38019. readonly leftHMatrix: Matrix;
  38020. /**
  38021. * @hidden
  38022. */
  38023. readonly rightHMatrix: Matrix;
  38024. /**
  38025. * @hidden
  38026. */
  38027. readonly leftPreViewMatrix: Matrix;
  38028. /**
  38029. * @hidden
  38030. */
  38031. readonly rightPreViewMatrix: Matrix;
  38032. /**
  38033. * Get the default VRMetrics based on the most generic setup.
  38034. * @returns the default vr metrics
  38035. */
  38036. static GetDefault(): VRCameraMetrics;
  38037. }
  38038. }
  38039. declare module BABYLON {
  38040. /** @hidden */
  38041. export var vrDistortionCorrectionPixelShader: {
  38042. name: string;
  38043. shader: string;
  38044. };
  38045. }
  38046. declare module BABYLON {
  38047. /**
  38048. * VRDistortionCorrectionPostProcess used for mobile VR
  38049. */
  38050. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38051. private _isRightEye;
  38052. private _distortionFactors;
  38053. private _postProcessScaleFactor;
  38054. private _lensCenterOffset;
  38055. private _scaleIn;
  38056. private _scaleFactor;
  38057. private _lensCenter;
  38058. /**
  38059. * Initializes the VRDistortionCorrectionPostProcess
  38060. * @param name The name of the effect.
  38061. * @param camera The camera to apply the render pass to.
  38062. * @param isRightEye If this is for the right eye distortion
  38063. * @param vrMetrics All the required metrics for the VR camera
  38064. */
  38065. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38071. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38072. */
  38073. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38074. /**
  38075. * Creates a new VRDeviceOrientationArcRotateCamera
  38076. * @param name defines camera name
  38077. * @param alpha defines the camera rotation along the logitudinal axis
  38078. * @param beta defines the camera rotation along the latitudinal axis
  38079. * @param radius defines the camera distance from its target
  38080. * @param target defines the camera target
  38081. * @param scene defines the scene the camera belongs to
  38082. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38083. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38084. */
  38085. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38086. /**
  38087. * Gets camera class name
  38088. * @returns VRDeviceOrientationArcRotateCamera
  38089. */
  38090. getClassName(): string;
  38091. }
  38092. }
  38093. declare module BABYLON {
  38094. /**
  38095. * Camera used to simulate VR rendering (based on FreeCamera)
  38096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38097. */
  38098. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38099. /**
  38100. * Creates a new VRDeviceOrientationFreeCamera
  38101. * @param name defines camera name
  38102. * @param position defines the start position of the camera
  38103. * @param scene defines the scene the camera belongs to
  38104. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38105. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38106. */
  38107. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38108. /**
  38109. * Gets camera class name
  38110. * @returns VRDeviceOrientationFreeCamera
  38111. */
  38112. getClassName(): string;
  38113. }
  38114. }
  38115. declare module BABYLON {
  38116. /**
  38117. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38118. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38119. */
  38120. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38121. /**
  38122. * Creates a new VRDeviceOrientationGamepadCamera
  38123. * @param name defines camera name
  38124. * @param position defines the start position of the camera
  38125. * @param scene defines the scene the camera belongs to
  38126. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38127. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38128. */
  38129. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38130. /**
  38131. * Gets camera class name
  38132. * @returns VRDeviceOrientationGamepadCamera
  38133. */
  38134. getClassName(): string;
  38135. }
  38136. }
  38137. declare module BABYLON {
  38138. /**
  38139. * Base class of materials working in push mode in babylon JS
  38140. * @hidden
  38141. */
  38142. export class PushMaterial extends Material {
  38143. protected _activeEffect: Effect;
  38144. protected _normalMatrix: Matrix;
  38145. /**
  38146. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38147. * This means that the material can keep using a previous shader while a new one is being compiled.
  38148. * This is mostly used when shader parallel compilation is supported (true by default)
  38149. */
  38150. allowShaderHotSwapping: boolean;
  38151. constructor(name: string, scene: Scene);
  38152. getEffect(): Effect;
  38153. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38154. /**
  38155. * Binds the given world matrix to the active effect
  38156. *
  38157. * @param world the matrix to bind
  38158. */
  38159. bindOnlyWorldMatrix(world: Matrix): void;
  38160. /**
  38161. * Binds the given normal matrix to the active effect
  38162. *
  38163. * @param normalMatrix the matrix to bind
  38164. */
  38165. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38166. bind(world: Matrix, mesh?: Mesh): void;
  38167. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38168. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38169. }
  38170. }
  38171. declare module BABYLON {
  38172. /**
  38173. * This groups all the flags used to control the materials channel.
  38174. */
  38175. export class MaterialFlags {
  38176. private static _DiffuseTextureEnabled;
  38177. /**
  38178. * Are diffuse textures enabled in the application.
  38179. */
  38180. static DiffuseTextureEnabled: boolean;
  38181. private static _AmbientTextureEnabled;
  38182. /**
  38183. * Are ambient textures enabled in the application.
  38184. */
  38185. static AmbientTextureEnabled: boolean;
  38186. private static _OpacityTextureEnabled;
  38187. /**
  38188. * Are opacity textures enabled in the application.
  38189. */
  38190. static OpacityTextureEnabled: boolean;
  38191. private static _ReflectionTextureEnabled;
  38192. /**
  38193. * Are reflection textures enabled in the application.
  38194. */
  38195. static ReflectionTextureEnabled: boolean;
  38196. private static _EmissiveTextureEnabled;
  38197. /**
  38198. * Are emissive textures enabled in the application.
  38199. */
  38200. static EmissiveTextureEnabled: boolean;
  38201. private static _SpecularTextureEnabled;
  38202. /**
  38203. * Are specular textures enabled in the application.
  38204. */
  38205. static SpecularTextureEnabled: boolean;
  38206. private static _BumpTextureEnabled;
  38207. /**
  38208. * Are bump textures enabled in the application.
  38209. */
  38210. static BumpTextureEnabled: boolean;
  38211. private static _LightmapTextureEnabled;
  38212. /**
  38213. * Are lightmap textures enabled in the application.
  38214. */
  38215. static LightmapTextureEnabled: boolean;
  38216. private static _RefractionTextureEnabled;
  38217. /**
  38218. * Are refraction textures enabled in the application.
  38219. */
  38220. static RefractionTextureEnabled: boolean;
  38221. private static _ColorGradingTextureEnabled;
  38222. /**
  38223. * Are color grading textures enabled in the application.
  38224. */
  38225. static ColorGradingTextureEnabled: boolean;
  38226. private static _FresnelEnabled;
  38227. /**
  38228. * Are fresnels enabled in the application.
  38229. */
  38230. static FresnelEnabled: boolean;
  38231. private static _ClearCoatTextureEnabled;
  38232. /**
  38233. * Are clear coat textures enabled in the application.
  38234. */
  38235. static ClearCoatTextureEnabled: boolean;
  38236. private static _ClearCoatBumpTextureEnabled;
  38237. /**
  38238. * Are clear coat bump textures enabled in the application.
  38239. */
  38240. static ClearCoatBumpTextureEnabled: boolean;
  38241. private static _ClearCoatTintTextureEnabled;
  38242. /**
  38243. * Are clear coat tint textures enabled in the application.
  38244. */
  38245. static ClearCoatTintTextureEnabled: boolean;
  38246. private static _SheenTextureEnabled;
  38247. /**
  38248. * Are sheen textures enabled in the application.
  38249. */
  38250. static SheenTextureEnabled: boolean;
  38251. private static _AnisotropicTextureEnabled;
  38252. /**
  38253. * Are anisotropic textures enabled in the application.
  38254. */
  38255. static AnisotropicTextureEnabled: boolean;
  38256. private static _ThicknessTextureEnabled;
  38257. /**
  38258. * Are thickness textures enabled in the application.
  38259. */
  38260. static ThicknessTextureEnabled: boolean;
  38261. }
  38262. }
  38263. declare module BABYLON {
  38264. /** @hidden */
  38265. export var defaultFragmentDeclaration: {
  38266. name: string;
  38267. shader: string;
  38268. };
  38269. }
  38270. declare module BABYLON {
  38271. /** @hidden */
  38272. export var defaultUboDeclaration: {
  38273. name: string;
  38274. shader: string;
  38275. };
  38276. }
  38277. declare module BABYLON {
  38278. /** @hidden */
  38279. export var lightFragmentDeclaration: {
  38280. name: string;
  38281. shader: string;
  38282. };
  38283. }
  38284. declare module BABYLON {
  38285. /** @hidden */
  38286. export var lightUboDeclaration: {
  38287. name: string;
  38288. shader: string;
  38289. };
  38290. }
  38291. declare module BABYLON {
  38292. /** @hidden */
  38293. export var lightsFragmentFunctions: {
  38294. name: string;
  38295. shader: string;
  38296. };
  38297. }
  38298. declare module BABYLON {
  38299. /** @hidden */
  38300. export var shadowsFragmentFunctions: {
  38301. name: string;
  38302. shader: string;
  38303. };
  38304. }
  38305. declare module BABYLON {
  38306. /** @hidden */
  38307. export var fresnelFunction: {
  38308. name: string;
  38309. shader: string;
  38310. };
  38311. }
  38312. declare module BABYLON {
  38313. /** @hidden */
  38314. export var reflectionFunction: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module BABYLON {
  38320. /** @hidden */
  38321. export var bumpFragmentFunctions: {
  38322. name: string;
  38323. shader: string;
  38324. };
  38325. }
  38326. declare module BABYLON {
  38327. /** @hidden */
  38328. export var logDepthDeclaration: {
  38329. name: string;
  38330. shader: string;
  38331. };
  38332. }
  38333. declare module BABYLON {
  38334. /** @hidden */
  38335. export var bumpFragment: {
  38336. name: string;
  38337. shader: string;
  38338. };
  38339. }
  38340. declare module BABYLON {
  38341. /** @hidden */
  38342. export var depthPrePass: {
  38343. name: string;
  38344. shader: string;
  38345. };
  38346. }
  38347. declare module BABYLON {
  38348. /** @hidden */
  38349. export var lightFragment: {
  38350. name: string;
  38351. shader: string;
  38352. };
  38353. }
  38354. declare module BABYLON {
  38355. /** @hidden */
  38356. export var logDepthFragment: {
  38357. name: string;
  38358. shader: string;
  38359. };
  38360. }
  38361. declare module BABYLON {
  38362. /** @hidden */
  38363. export var defaultPixelShader: {
  38364. name: string;
  38365. shader: string;
  38366. };
  38367. }
  38368. declare module BABYLON {
  38369. /** @hidden */
  38370. export var defaultVertexDeclaration: {
  38371. name: string;
  38372. shader: string;
  38373. };
  38374. }
  38375. declare module BABYLON {
  38376. /** @hidden */
  38377. export var bumpVertexDeclaration: {
  38378. name: string;
  38379. shader: string;
  38380. };
  38381. }
  38382. declare module BABYLON {
  38383. /** @hidden */
  38384. export var bumpVertex: {
  38385. name: string;
  38386. shader: string;
  38387. };
  38388. }
  38389. declare module BABYLON {
  38390. /** @hidden */
  38391. export var fogVertex: {
  38392. name: string;
  38393. shader: string;
  38394. };
  38395. }
  38396. declare module BABYLON {
  38397. /** @hidden */
  38398. export var shadowsVertex: {
  38399. name: string;
  38400. shader: string;
  38401. };
  38402. }
  38403. declare module BABYLON {
  38404. /** @hidden */
  38405. export var pointCloudVertex: {
  38406. name: string;
  38407. shader: string;
  38408. };
  38409. }
  38410. declare module BABYLON {
  38411. /** @hidden */
  38412. export var logDepthVertex: {
  38413. name: string;
  38414. shader: string;
  38415. };
  38416. }
  38417. declare module BABYLON {
  38418. /** @hidden */
  38419. export var defaultVertexShader: {
  38420. name: string;
  38421. shader: string;
  38422. };
  38423. }
  38424. declare module BABYLON {
  38425. /** @hidden */
  38426. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38427. MAINUV1: boolean;
  38428. MAINUV2: boolean;
  38429. DIFFUSE: boolean;
  38430. DIFFUSEDIRECTUV: number;
  38431. AMBIENT: boolean;
  38432. AMBIENTDIRECTUV: number;
  38433. OPACITY: boolean;
  38434. OPACITYDIRECTUV: number;
  38435. OPACITYRGB: boolean;
  38436. REFLECTION: boolean;
  38437. EMISSIVE: boolean;
  38438. EMISSIVEDIRECTUV: number;
  38439. SPECULAR: boolean;
  38440. SPECULARDIRECTUV: number;
  38441. BUMP: boolean;
  38442. BUMPDIRECTUV: number;
  38443. PARALLAX: boolean;
  38444. PARALLAXOCCLUSION: boolean;
  38445. SPECULAROVERALPHA: boolean;
  38446. CLIPPLANE: boolean;
  38447. CLIPPLANE2: boolean;
  38448. CLIPPLANE3: boolean;
  38449. CLIPPLANE4: boolean;
  38450. ALPHATEST: boolean;
  38451. DEPTHPREPASS: boolean;
  38452. ALPHAFROMDIFFUSE: boolean;
  38453. POINTSIZE: boolean;
  38454. FOG: boolean;
  38455. SPECULARTERM: boolean;
  38456. DIFFUSEFRESNEL: boolean;
  38457. OPACITYFRESNEL: boolean;
  38458. REFLECTIONFRESNEL: boolean;
  38459. REFRACTIONFRESNEL: boolean;
  38460. EMISSIVEFRESNEL: boolean;
  38461. FRESNEL: boolean;
  38462. NORMAL: boolean;
  38463. UV1: boolean;
  38464. UV2: boolean;
  38465. VERTEXCOLOR: boolean;
  38466. VERTEXALPHA: boolean;
  38467. NUM_BONE_INFLUENCERS: number;
  38468. BonesPerMesh: number;
  38469. BONETEXTURE: boolean;
  38470. INSTANCES: boolean;
  38471. GLOSSINESS: boolean;
  38472. ROUGHNESS: boolean;
  38473. EMISSIVEASILLUMINATION: boolean;
  38474. LINKEMISSIVEWITHDIFFUSE: boolean;
  38475. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38476. LIGHTMAP: boolean;
  38477. LIGHTMAPDIRECTUV: number;
  38478. OBJECTSPACE_NORMALMAP: boolean;
  38479. USELIGHTMAPASSHADOWMAP: boolean;
  38480. REFLECTIONMAP_3D: boolean;
  38481. REFLECTIONMAP_SPHERICAL: boolean;
  38482. REFLECTIONMAP_PLANAR: boolean;
  38483. REFLECTIONMAP_CUBIC: boolean;
  38484. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38485. REFLECTIONMAP_PROJECTION: boolean;
  38486. REFLECTIONMAP_SKYBOX: boolean;
  38487. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38488. REFLECTIONMAP_EXPLICIT: boolean;
  38489. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38490. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38491. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38492. INVERTCUBICMAP: boolean;
  38493. LOGARITHMICDEPTH: boolean;
  38494. REFRACTION: boolean;
  38495. REFRACTIONMAP_3D: boolean;
  38496. REFLECTIONOVERALPHA: boolean;
  38497. TWOSIDEDLIGHTING: boolean;
  38498. SHADOWFLOAT: boolean;
  38499. MORPHTARGETS: boolean;
  38500. MORPHTARGETS_NORMAL: boolean;
  38501. MORPHTARGETS_TANGENT: boolean;
  38502. MORPHTARGETS_UV: boolean;
  38503. NUM_MORPH_INFLUENCERS: number;
  38504. NONUNIFORMSCALING: boolean;
  38505. PREMULTIPLYALPHA: boolean;
  38506. IMAGEPROCESSING: boolean;
  38507. VIGNETTE: boolean;
  38508. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38509. VIGNETTEBLENDMODEOPAQUE: boolean;
  38510. TONEMAPPING: boolean;
  38511. TONEMAPPING_ACES: boolean;
  38512. CONTRAST: boolean;
  38513. COLORCURVES: boolean;
  38514. COLORGRADING: boolean;
  38515. COLORGRADING3D: boolean;
  38516. SAMPLER3DGREENDEPTH: boolean;
  38517. SAMPLER3DBGRMAP: boolean;
  38518. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38519. MULTIVIEW: boolean;
  38520. /**
  38521. * If the reflection texture on this material is in linear color space
  38522. * @hidden
  38523. */
  38524. IS_REFLECTION_LINEAR: boolean;
  38525. /**
  38526. * If the refraction texture on this material is in linear color space
  38527. * @hidden
  38528. */
  38529. IS_REFRACTION_LINEAR: boolean;
  38530. EXPOSURE: boolean;
  38531. constructor();
  38532. setReflectionMode(modeToEnable: string): void;
  38533. }
  38534. /**
  38535. * This is the default material used in Babylon. It is the best trade off between quality
  38536. * and performances.
  38537. * @see http://doc.babylonjs.com/babylon101/materials
  38538. */
  38539. export class StandardMaterial extends PushMaterial {
  38540. private _diffuseTexture;
  38541. /**
  38542. * The basic texture of the material as viewed under a light.
  38543. */
  38544. diffuseTexture: Nullable<BaseTexture>;
  38545. private _ambientTexture;
  38546. /**
  38547. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38548. */
  38549. ambientTexture: Nullable<BaseTexture>;
  38550. private _opacityTexture;
  38551. /**
  38552. * Define the transparency of the material from a texture.
  38553. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38554. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38555. */
  38556. opacityTexture: Nullable<BaseTexture>;
  38557. private _reflectionTexture;
  38558. /**
  38559. * Define the texture used to display the reflection.
  38560. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38561. */
  38562. reflectionTexture: Nullable<BaseTexture>;
  38563. private _emissiveTexture;
  38564. /**
  38565. * Define texture of the material as if self lit.
  38566. * This will be mixed in the final result even in the absence of light.
  38567. */
  38568. emissiveTexture: Nullable<BaseTexture>;
  38569. private _specularTexture;
  38570. /**
  38571. * Define how the color and intensity of the highlight given by the light in the material.
  38572. */
  38573. specularTexture: Nullable<BaseTexture>;
  38574. private _bumpTexture;
  38575. /**
  38576. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38577. * 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.
  38578. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38579. */
  38580. bumpTexture: Nullable<BaseTexture>;
  38581. private _lightmapTexture;
  38582. /**
  38583. * Complex lighting can be computationally expensive to compute at runtime.
  38584. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38585. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38586. */
  38587. lightmapTexture: Nullable<BaseTexture>;
  38588. private _refractionTexture;
  38589. /**
  38590. * Define the texture used to display the refraction.
  38591. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38592. */
  38593. refractionTexture: Nullable<BaseTexture>;
  38594. /**
  38595. * The color of the material lit by the environmental background lighting.
  38596. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38597. */
  38598. ambientColor: Color3;
  38599. /**
  38600. * The basic color of the material as viewed under a light.
  38601. */
  38602. diffuseColor: Color3;
  38603. /**
  38604. * Define how the color and intensity of the highlight given by the light in the material.
  38605. */
  38606. specularColor: Color3;
  38607. /**
  38608. * Define the color of the material as if self lit.
  38609. * This will be mixed in the final result even in the absence of light.
  38610. */
  38611. emissiveColor: Color3;
  38612. /**
  38613. * Defines how sharp are the highlights in the material.
  38614. * The bigger the value the sharper giving a more glossy feeling to the result.
  38615. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38616. */
  38617. specularPower: number;
  38618. private _useAlphaFromDiffuseTexture;
  38619. /**
  38620. * Does the transparency come from the diffuse texture alpha channel.
  38621. */
  38622. useAlphaFromDiffuseTexture: boolean;
  38623. private _useEmissiveAsIllumination;
  38624. /**
  38625. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38626. */
  38627. useEmissiveAsIllumination: boolean;
  38628. private _linkEmissiveWithDiffuse;
  38629. /**
  38630. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38631. * the emissive level when the final color is close to one.
  38632. */
  38633. linkEmissiveWithDiffuse: boolean;
  38634. private _useSpecularOverAlpha;
  38635. /**
  38636. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38637. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38638. */
  38639. useSpecularOverAlpha: boolean;
  38640. private _useReflectionOverAlpha;
  38641. /**
  38642. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38643. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38644. */
  38645. useReflectionOverAlpha: boolean;
  38646. private _disableLighting;
  38647. /**
  38648. * Does lights from the scene impacts this material.
  38649. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38650. */
  38651. disableLighting: boolean;
  38652. private _useObjectSpaceNormalMap;
  38653. /**
  38654. * Allows using an object space normal map (instead of tangent space).
  38655. */
  38656. useObjectSpaceNormalMap: boolean;
  38657. private _useParallax;
  38658. /**
  38659. * Is parallax enabled or not.
  38660. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38661. */
  38662. useParallax: boolean;
  38663. private _useParallaxOcclusion;
  38664. /**
  38665. * Is parallax occlusion enabled or not.
  38666. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38667. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38668. */
  38669. useParallaxOcclusion: boolean;
  38670. /**
  38671. * 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.
  38672. */
  38673. parallaxScaleBias: number;
  38674. private _roughness;
  38675. /**
  38676. * Helps to define how blurry the reflections should appears in the material.
  38677. */
  38678. roughness: number;
  38679. /**
  38680. * In case of refraction, define the value of the index of refraction.
  38681. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38682. */
  38683. indexOfRefraction: number;
  38684. /**
  38685. * Invert the refraction texture alongside the y axis.
  38686. * It can be useful with procedural textures or probe for instance.
  38687. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38688. */
  38689. invertRefractionY: boolean;
  38690. /**
  38691. * Defines the alpha limits in alpha test mode.
  38692. */
  38693. alphaCutOff: number;
  38694. private _useLightmapAsShadowmap;
  38695. /**
  38696. * In case of light mapping, define whether the map contains light or shadow informations.
  38697. */
  38698. useLightmapAsShadowmap: boolean;
  38699. private _diffuseFresnelParameters;
  38700. /**
  38701. * Define the diffuse fresnel parameters of the material.
  38702. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38703. */
  38704. diffuseFresnelParameters: FresnelParameters;
  38705. private _opacityFresnelParameters;
  38706. /**
  38707. * Define the opacity fresnel parameters of the material.
  38708. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38709. */
  38710. opacityFresnelParameters: FresnelParameters;
  38711. private _reflectionFresnelParameters;
  38712. /**
  38713. * Define the reflection fresnel parameters of the material.
  38714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38715. */
  38716. reflectionFresnelParameters: FresnelParameters;
  38717. private _refractionFresnelParameters;
  38718. /**
  38719. * Define the refraction fresnel parameters of the material.
  38720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38721. */
  38722. refractionFresnelParameters: FresnelParameters;
  38723. private _emissiveFresnelParameters;
  38724. /**
  38725. * Define the emissive fresnel parameters of the material.
  38726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38727. */
  38728. emissiveFresnelParameters: FresnelParameters;
  38729. private _useReflectionFresnelFromSpecular;
  38730. /**
  38731. * If true automatically deducts the fresnels values from the material specularity.
  38732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38733. */
  38734. useReflectionFresnelFromSpecular: boolean;
  38735. private _useGlossinessFromSpecularMapAlpha;
  38736. /**
  38737. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38738. */
  38739. useGlossinessFromSpecularMapAlpha: boolean;
  38740. private _maxSimultaneousLights;
  38741. /**
  38742. * Defines the maximum number of lights that can be used in the material
  38743. */
  38744. maxSimultaneousLights: number;
  38745. private _invertNormalMapX;
  38746. /**
  38747. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38748. */
  38749. invertNormalMapX: boolean;
  38750. private _invertNormalMapY;
  38751. /**
  38752. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38753. */
  38754. invertNormalMapY: boolean;
  38755. private _twoSidedLighting;
  38756. /**
  38757. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38758. */
  38759. twoSidedLighting: boolean;
  38760. /**
  38761. * Default configuration related to image processing available in the standard Material.
  38762. */
  38763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38764. /**
  38765. * Gets the image processing configuration used either in this material.
  38766. */
  38767. /**
  38768. * Sets the Default image processing configuration used either in the this material.
  38769. *
  38770. * If sets to null, the scene one is in use.
  38771. */
  38772. imageProcessingConfiguration: ImageProcessingConfiguration;
  38773. /**
  38774. * Keep track of the image processing observer to allow dispose and replace.
  38775. */
  38776. private _imageProcessingObserver;
  38777. /**
  38778. * Attaches a new image processing configuration to the Standard Material.
  38779. * @param configuration
  38780. */
  38781. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38782. /**
  38783. * Gets wether the color curves effect is enabled.
  38784. */
  38785. /**
  38786. * Sets wether the color curves effect is enabled.
  38787. */
  38788. cameraColorCurvesEnabled: boolean;
  38789. /**
  38790. * Gets wether the color grading effect is enabled.
  38791. */
  38792. /**
  38793. * Gets wether the color grading effect is enabled.
  38794. */
  38795. cameraColorGradingEnabled: boolean;
  38796. /**
  38797. * Gets wether tonemapping is enabled or not.
  38798. */
  38799. /**
  38800. * Sets wether tonemapping is enabled or not
  38801. */
  38802. cameraToneMappingEnabled: boolean;
  38803. /**
  38804. * The camera exposure used on this material.
  38805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38806. * This corresponds to a photographic exposure.
  38807. */
  38808. /**
  38809. * The camera exposure used on this material.
  38810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38811. * This corresponds to a photographic exposure.
  38812. */
  38813. cameraExposure: number;
  38814. /**
  38815. * Gets The camera contrast used on this material.
  38816. */
  38817. /**
  38818. * Sets The camera contrast used on this material.
  38819. */
  38820. cameraContrast: number;
  38821. /**
  38822. * Gets the Color Grading 2D Lookup Texture.
  38823. */
  38824. /**
  38825. * Sets the Color Grading 2D Lookup Texture.
  38826. */
  38827. cameraColorGradingTexture: Nullable<BaseTexture>;
  38828. /**
  38829. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38830. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38831. * 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;
  38832. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38833. */
  38834. /**
  38835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38837. * 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;
  38838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38839. */
  38840. cameraColorCurves: Nullable<ColorCurves>;
  38841. /**
  38842. * Custom callback helping to override the default shader used in the material.
  38843. */
  38844. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38845. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38846. protected _worldViewProjectionMatrix: Matrix;
  38847. protected _globalAmbientColor: Color3;
  38848. protected _useLogarithmicDepth: boolean;
  38849. /**
  38850. * Instantiates a new standard material.
  38851. * This is the default material used in Babylon. It is the best trade off between quality
  38852. * and performances.
  38853. * @see http://doc.babylonjs.com/babylon101/materials
  38854. * @param name Define the name of the material in the scene
  38855. * @param scene Define the scene the material belong to
  38856. */
  38857. constructor(name: string, scene: Scene);
  38858. /**
  38859. * Gets a boolean indicating that current material needs to register RTT
  38860. */
  38861. readonly hasRenderTargetTextures: boolean;
  38862. /**
  38863. * Gets the current class name of the material e.g. "StandardMaterial"
  38864. * Mainly use in serialization.
  38865. * @returns the class name
  38866. */
  38867. getClassName(): string;
  38868. /**
  38869. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38870. * You can try switching to logarithmic depth.
  38871. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38872. */
  38873. useLogarithmicDepth: boolean;
  38874. /**
  38875. * Specifies if the material will require alpha blending
  38876. * @returns a boolean specifying if alpha blending is needed
  38877. */
  38878. needAlphaBlending(): boolean;
  38879. /**
  38880. * Specifies if this material should be rendered in alpha test mode
  38881. * @returns a boolean specifying if an alpha test is needed.
  38882. */
  38883. needAlphaTesting(): boolean;
  38884. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38885. /**
  38886. * Get the texture used for alpha test purpose.
  38887. * @returns the diffuse texture in case of the standard material.
  38888. */
  38889. getAlphaTestTexture(): Nullable<BaseTexture>;
  38890. /**
  38891. * Get if the submesh is ready to be used and all its information available.
  38892. * Child classes can use it to update shaders
  38893. * @param mesh defines the mesh to check
  38894. * @param subMesh defines which submesh to check
  38895. * @param useInstances specifies that instances should be used
  38896. * @returns a boolean indicating that the submesh is ready or not
  38897. */
  38898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38899. /**
  38900. * Builds the material UBO layouts.
  38901. * Used internally during the effect preparation.
  38902. */
  38903. buildUniformLayout(): void;
  38904. /**
  38905. * Unbinds the material from the mesh
  38906. */
  38907. unbind(): void;
  38908. /**
  38909. * Binds the submesh to this material by preparing the effect and shader to draw
  38910. * @param world defines the world transformation matrix
  38911. * @param mesh defines the mesh containing the submesh
  38912. * @param subMesh defines the submesh to bind the material to
  38913. */
  38914. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38915. /**
  38916. * Get the list of animatables in the material.
  38917. * @returns the list of animatables object used in the material
  38918. */
  38919. getAnimatables(): IAnimatable[];
  38920. /**
  38921. * Gets the active textures from the material
  38922. * @returns an array of textures
  38923. */
  38924. getActiveTextures(): BaseTexture[];
  38925. /**
  38926. * Specifies if the material uses a texture
  38927. * @param texture defines the texture to check against the material
  38928. * @returns a boolean specifying if the material uses the texture
  38929. */
  38930. hasTexture(texture: BaseTexture): boolean;
  38931. /**
  38932. * Disposes the material
  38933. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38934. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38935. */
  38936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38937. /**
  38938. * Makes a duplicate of the material, and gives it a new name
  38939. * @param name defines the new name for the duplicated material
  38940. * @returns the cloned material
  38941. */
  38942. clone(name: string): StandardMaterial;
  38943. /**
  38944. * Serializes this material in a JSON representation
  38945. * @returns the serialized material object
  38946. */
  38947. serialize(): any;
  38948. /**
  38949. * Creates a standard material from parsed material data
  38950. * @param source defines the JSON representation of the material
  38951. * @param scene defines the hosting scene
  38952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38953. * @returns a new standard material
  38954. */
  38955. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38956. /**
  38957. * Are diffuse textures enabled in the application.
  38958. */
  38959. static DiffuseTextureEnabled: boolean;
  38960. /**
  38961. * Are ambient textures enabled in the application.
  38962. */
  38963. static AmbientTextureEnabled: boolean;
  38964. /**
  38965. * Are opacity textures enabled in the application.
  38966. */
  38967. static OpacityTextureEnabled: boolean;
  38968. /**
  38969. * Are reflection textures enabled in the application.
  38970. */
  38971. static ReflectionTextureEnabled: boolean;
  38972. /**
  38973. * Are emissive textures enabled in the application.
  38974. */
  38975. static EmissiveTextureEnabled: boolean;
  38976. /**
  38977. * Are specular textures enabled in the application.
  38978. */
  38979. static SpecularTextureEnabled: boolean;
  38980. /**
  38981. * Are bump textures enabled in the application.
  38982. */
  38983. static BumpTextureEnabled: boolean;
  38984. /**
  38985. * Are lightmap textures enabled in the application.
  38986. */
  38987. static LightmapTextureEnabled: boolean;
  38988. /**
  38989. * Are refraction textures enabled in the application.
  38990. */
  38991. static RefractionTextureEnabled: boolean;
  38992. /**
  38993. * Are color grading textures enabled in the application.
  38994. */
  38995. static ColorGradingTextureEnabled: boolean;
  38996. /**
  38997. * Are fresnels enabled in the application.
  38998. */
  38999. static FresnelEnabled: boolean;
  39000. }
  39001. }
  39002. declare module BABYLON {
  39003. /**
  39004. * A class extending Texture allowing drawing on a texture
  39005. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39006. */
  39007. export class DynamicTexture extends Texture {
  39008. private _generateMipMaps;
  39009. private _canvas;
  39010. private _context;
  39011. private _engine;
  39012. /**
  39013. * Creates a DynamicTexture
  39014. * @param name defines the name of the texture
  39015. * @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
  39016. * @param scene defines the scene where you want the texture
  39017. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39018. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39019. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39020. */
  39021. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39022. /**
  39023. * Get the current class name of the texture useful for serialization or dynamic coding.
  39024. * @returns "DynamicTexture"
  39025. */
  39026. getClassName(): string;
  39027. /**
  39028. * Gets the current state of canRescale
  39029. */
  39030. readonly canRescale: boolean;
  39031. private _recreate;
  39032. /**
  39033. * Scales the texture
  39034. * @param ratio the scale factor to apply to both width and height
  39035. */
  39036. scale(ratio: number): void;
  39037. /**
  39038. * Resizes the texture
  39039. * @param width the new width
  39040. * @param height the new height
  39041. */
  39042. scaleTo(width: number, height: number): void;
  39043. /**
  39044. * Gets the context of the canvas used by the texture
  39045. * @returns the canvas context of the dynamic texture
  39046. */
  39047. getContext(): CanvasRenderingContext2D;
  39048. /**
  39049. * Clears the texture
  39050. */
  39051. clear(): void;
  39052. /**
  39053. * Updates the texture
  39054. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39055. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39056. */
  39057. update(invertY?: boolean, premulAlpha?: boolean): void;
  39058. /**
  39059. * Draws text onto the texture
  39060. * @param text defines the text to be drawn
  39061. * @param x defines the placement of the text from the left
  39062. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39063. * @param font defines the font to be used with font-style, font-size, font-name
  39064. * @param color defines the color used for the text
  39065. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39066. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39067. * @param update defines whether texture is immediately update (default is true)
  39068. */
  39069. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39070. /**
  39071. * Clones the texture
  39072. * @returns the clone of the texture.
  39073. */
  39074. clone(): DynamicTexture;
  39075. /**
  39076. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39077. * @returns a serialized dynamic texture object
  39078. */
  39079. serialize(): any;
  39080. /** @hidden */ private _rebuild(): void;
  39081. }
  39082. }
  39083. declare module BABYLON {
  39084. /** @hidden */
  39085. export var imageProcessingPixelShader: {
  39086. name: string;
  39087. shader: string;
  39088. };
  39089. }
  39090. declare module BABYLON {
  39091. /**
  39092. * ImageProcessingPostProcess
  39093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39094. */
  39095. export class ImageProcessingPostProcess extends PostProcess {
  39096. /**
  39097. * Default configuration related to image processing available in the PBR Material.
  39098. */
  39099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39100. /**
  39101. * Gets the image processing configuration used either in this material.
  39102. */
  39103. /**
  39104. * Sets the Default image processing configuration used either in the this material.
  39105. *
  39106. * If sets to null, the scene one is in use.
  39107. */
  39108. imageProcessingConfiguration: ImageProcessingConfiguration;
  39109. /**
  39110. * Keep track of the image processing observer to allow dispose and replace.
  39111. */
  39112. private _imageProcessingObserver;
  39113. /**
  39114. * Attaches a new image processing configuration to the PBR Material.
  39115. * @param configuration
  39116. */
  39117. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39118. /**
  39119. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39120. */
  39121. /**
  39122. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39123. */
  39124. colorCurves: Nullable<ColorCurves>;
  39125. /**
  39126. * Gets wether the color curves effect is enabled.
  39127. */
  39128. /**
  39129. * Sets wether the color curves effect is enabled.
  39130. */
  39131. colorCurvesEnabled: boolean;
  39132. /**
  39133. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39134. */
  39135. /**
  39136. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39137. */
  39138. colorGradingTexture: Nullable<BaseTexture>;
  39139. /**
  39140. * Gets wether the color grading effect is enabled.
  39141. */
  39142. /**
  39143. * Gets wether the color grading effect is enabled.
  39144. */
  39145. colorGradingEnabled: boolean;
  39146. /**
  39147. * Gets exposure used in the effect.
  39148. */
  39149. /**
  39150. * Sets exposure used in the effect.
  39151. */
  39152. exposure: number;
  39153. /**
  39154. * Gets wether tonemapping is enabled or not.
  39155. */
  39156. /**
  39157. * Sets wether tonemapping is enabled or not
  39158. */
  39159. toneMappingEnabled: boolean;
  39160. /**
  39161. * Gets the type of tone mapping effect.
  39162. */
  39163. /**
  39164. * Sets the type of tone mapping effect.
  39165. */
  39166. toneMappingType: number;
  39167. /**
  39168. * Gets contrast used in the effect.
  39169. */
  39170. /**
  39171. * Sets contrast used in the effect.
  39172. */
  39173. contrast: number;
  39174. /**
  39175. * Gets Vignette stretch size.
  39176. */
  39177. /**
  39178. * Sets Vignette stretch size.
  39179. */
  39180. vignetteStretch: number;
  39181. /**
  39182. * Gets Vignette centre X Offset.
  39183. */
  39184. /**
  39185. * Sets Vignette centre X Offset.
  39186. */
  39187. vignetteCentreX: number;
  39188. /**
  39189. * Gets Vignette centre Y Offset.
  39190. */
  39191. /**
  39192. * Sets Vignette centre Y Offset.
  39193. */
  39194. vignetteCentreY: number;
  39195. /**
  39196. * Gets Vignette weight or intensity of the vignette effect.
  39197. */
  39198. /**
  39199. * Sets Vignette weight or intensity of the vignette effect.
  39200. */
  39201. vignetteWeight: number;
  39202. /**
  39203. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39204. * if vignetteEnabled is set to true.
  39205. */
  39206. /**
  39207. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39208. * if vignetteEnabled is set to true.
  39209. */
  39210. vignetteColor: Color4;
  39211. /**
  39212. * Gets Camera field of view used by the Vignette effect.
  39213. */
  39214. /**
  39215. * Sets Camera field of view used by the Vignette effect.
  39216. */
  39217. vignetteCameraFov: number;
  39218. /**
  39219. * Gets the vignette blend mode allowing different kind of effect.
  39220. */
  39221. /**
  39222. * Sets the vignette blend mode allowing different kind of effect.
  39223. */
  39224. vignetteBlendMode: number;
  39225. /**
  39226. * Gets wether the vignette effect is enabled.
  39227. */
  39228. /**
  39229. * Sets wether the vignette effect is enabled.
  39230. */
  39231. vignetteEnabled: boolean;
  39232. private _fromLinearSpace;
  39233. /**
  39234. * Gets wether the input of the processing is in Gamma or Linear Space.
  39235. */
  39236. /**
  39237. * Sets wether the input of the processing is in Gamma or Linear Space.
  39238. */
  39239. fromLinearSpace: boolean;
  39240. /**
  39241. * Defines cache preventing GC.
  39242. */
  39243. private _defines;
  39244. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39245. /**
  39246. * "ImageProcessingPostProcess"
  39247. * @returns "ImageProcessingPostProcess"
  39248. */
  39249. getClassName(): string;
  39250. protected _updateParameters(): void;
  39251. dispose(camera?: Camera): void;
  39252. }
  39253. }
  39254. declare module BABYLON {
  39255. /**
  39256. * Class containing static functions to help procedurally build meshes
  39257. */
  39258. export class GroundBuilder {
  39259. /**
  39260. * Creates a ground mesh
  39261. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39262. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39264. * @param name defines the name of the mesh
  39265. * @param options defines the options used to create the mesh
  39266. * @param scene defines the hosting scene
  39267. * @returns the ground mesh
  39268. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39269. */
  39270. static CreateGround(name: string, options: {
  39271. width?: number;
  39272. height?: number;
  39273. subdivisions?: number;
  39274. subdivisionsX?: number;
  39275. subdivisionsY?: number;
  39276. updatable?: boolean;
  39277. }, scene: any): Mesh;
  39278. /**
  39279. * Creates a tiled ground mesh
  39280. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39281. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39282. * * 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
  39283. * * 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
  39284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39285. * @param name defines the name of the mesh
  39286. * @param options defines the options used to create the mesh
  39287. * @param scene defines the hosting scene
  39288. * @returns the tiled ground mesh
  39289. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39290. */
  39291. static CreateTiledGround(name: string, options: {
  39292. xmin: number;
  39293. zmin: number;
  39294. xmax: number;
  39295. zmax: number;
  39296. subdivisions?: {
  39297. w: number;
  39298. h: number;
  39299. };
  39300. precision?: {
  39301. w: number;
  39302. h: number;
  39303. };
  39304. updatable?: boolean;
  39305. }, scene?: Nullable<Scene>): Mesh;
  39306. /**
  39307. * Creates a ground mesh from a height map
  39308. * * The parameter `url` sets the URL of the height map image resource.
  39309. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39310. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39311. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39312. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39313. * * 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.
  39314. * * 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).
  39315. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39317. * @param name defines the name of the mesh
  39318. * @param url defines the url to the height map
  39319. * @param options defines the options used to create the mesh
  39320. * @param scene defines the hosting scene
  39321. * @returns the ground mesh
  39322. * @see https://doc.babylonjs.com/babylon101/height_map
  39323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39324. */
  39325. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39326. width?: number;
  39327. height?: number;
  39328. subdivisions?: number;
  39329. minHeight?: number;
  39330. maxHeight?: number;
  39331. colorFilter?: Color3;
  39332. alphaFilter?: number;
  39333. updatable?: boolean;
  39334. onReady?: (mesh: GroundMesh) => void;
  39335. }, scene?: Nullable<Scene>): GroundMesh;
  39336. }
  39337. }
  39338. declare module BABYLON {
  39339. /**
  39340. * Class containing static functions to help procedurally build meshes
  39341. */
  39342. export class TorusBuilder {
  39343. /**
  39344. * Creates a torus mesh
  39345. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39346. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39347. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39349. * * 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
  39350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39351. * @param name defines the name of the mesh
  39352. * @param options defines the options used to create the mesh
  39353. * @param scene defines the hosting scene
  39354. * @returns the torus mesh
  39355. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39356. */
  39357. static CreateTorus(name: string, options: {
  39358. diameter?: number;
  39359. thickness?: number;
  39360. tessellation?: number;
  39361. updatable?: boolean;
  39362. sideOrientation?: number;
  39363. frontUVs?: Vector4;
  39364. backUVs?: Vector4;
  39365. }, scene: any): Mesh;
  39366. }
  39367. }
  39368. declare module BABYLON {
  39369. /**
  39370. * Class containing static functions to help procedurally build meshes
  39371. */
  39372. export class CylinderBuilder {
  39373. /**
  39374. * Creates a cylinder or a cone mesh
  39375. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39376. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39377. * * 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.
  39378. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39379. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39380. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39381. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39382. * * 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).
  39383. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39384. * * 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).
  39385. * * 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
  39386. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39387. * * 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
  39388. * * 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.
  39389. * * If `enclose` is false, a ring surface is one element.
  39390. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39391. * * 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
  39392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39393. * * 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
  39394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39395. * @param name defines the name of the mesh
  39396. * @param options defines the options used to create the mesh
  39397. * @param scene defines the hosting scene
  39398. * @returns the cylinder mesh
  39399. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39400. */
  39401. static CreateCylinder(name: string, options: {
  39402. height?: number;
  39403. diameterTop?: number;
  39404. diameterBottom?: number;
  39405. diameter?: number;
  39406. tessellation?: number;
  39407. subdivisions?: number;
  39408. arc?: number;
  39409. faceColors?: Color4[];
  39410. faceUV?: Vector4[];
  39411. updatable?: boolean;
  39412. hasRings?: boolean;
  39413. enclose?: boolean;
  39414. cap?: number;
  39415. sideOrientation?: number;
  39416. frontUVs?: Vector4;
  39417. backUVs?: Vector4;
  39418. }, scene: any): Mesh;
  39419. }
  39420. }
  39421. declare module BABYLON {
  39422. /**
  39423. * Options to modify the vr teleportation behavior.
  39424. */
  39425. export interface VRTeleportationOptions {
  39426. /**
  39427. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39428. */
  39429. floorMeshName?: string;
  39430. /**
  39431. * A list of meshes to be used as the teleportation floor. (default: empty)
  39432. */
  39433. floorMeshes?: Mesh[];
  39434. }
  39435. /**
  39436. * Options to modify the vr experience helper's behavior.
  39437. */
  39438. export interface VRExperienceHelperOptions extends WebVROptions {
  39439. /**
  39440. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39441. */
  39442. createDeviceOrientationCamera?: boolean;
  39443. /**
  39444. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39445. */
  39446. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39447. /**
  39448. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39449. */
  39450. laserToggle?: boolean;
  39451. /**
  39452. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39453. */
  39454. floorMeshes?: Mesh[];
  39455. /**
  39456. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39457. */
  39458. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39459. }
  39460. /**
  39461. * Event containing information after VR has been entered
  39462. */
  39463. export class OnAfterEnteringVRObservableEvent {
  39464. /**
  39465. * If entering vr was successful
  39466. */
  39467. success: boolean;
  39468. }
  39469. /**
  39470. * Helps to quickly add VR support to an existing scene.
  39471. * See http://doc.babylonjs.com/how_to/webvr_helper
  39472. */
  39473. export class VRExperienceHelper {
  39474. /** Options to modify the vr experience helper's behavior. */
  39475. webVROptions: VRExperienceHelperOptions;
  39476. private _scene;
  39477. private _position;
  39478. private _btnVR;
  39479. private _btnVRDisplayed;
  39480. private _webVRsupported;
  39481. private _webVRready;
  39482. private _webVRrequesting;
  39483. private _webVRpresenting;
  39484. private _hasEnteredVR;
  39485. private _fullscreenVRpresenting;
  39486. private _canvas;
  39487. private _webVRCamera;
  39488. private _vrDeviceOrientationCamera;
  39489. private _deviceOrientationCamera;
  39490. private _existingCamera;
  39491. private _onKeyDown;
  39492. private _onVrDisplayPresentChange;
  39493. private _onVRDisplayChanged;
  39494. private _onVRRequestPresentStart;
  39495. private _onVRRequestPresentComplete;
  39496. /**
  39497. * Observable raised right before entering VR.
  39498. */
  39499. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39500. /**
  39501. * Observable raised when entering VR has completed.
  39502. */
  39503. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39504. /**
  39505. * Observable raised when exiting VR.
  39506. */
  39507. onExitingVRObservable: Observable<VRExperienceHelper>;
  39508. /**
  39509. * Observable raised when controller mesh is loaded.
  39510. */
  39511. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39512. /** Return this.onEnteringVRObservable
  39513. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39514. */
  39515. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39516. /** Return this.onExitingVRObservable
  39517. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39518. */
  39519. readonly onExitingVR: Observable<VRExperienceHelper>;
  39520. /** Return this.onControllerMeshLoadedObservable
  39521. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39522. */
  39523. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39524. private _rayLength;
  39525. private _useCustomVRButton;
  39526. private _teleportationRequested;
  39527. private _teleportActive;
  39528. private _floorMeshName;
  39529. private _floorMeshesCollection;
  39530. private _rotationAllowed;
  39531. private _teleportBackwardsVector;
  39532. private _teleportationTarget;
  39533. private _isDefaultTeleportationTarget;
  39534. private _postProcessMove;
  39535. private _teleportationFillColor;
  39536. private _teleportationBorderColor;
  39537. private _rotationAngle;
  39538. private _haloCenter;
  39539. private _cameraGazer;
  39540. private _padSensibilityUp;
  39541. private _padSensibilityDown;
  39542. private _leftController;
  39543. private _rightController;
  39544. /**
  39545. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39546. */
  39547. onNewMeshSelected: Observable<AbstractMesh>;
  39548. /**
  39549. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39550. */
  39551. onNewMeshPicked: Observable<PickingInfo>;
  39552. private _circleEase;
  39553. /**
  39554. * Observable raised before camera teleportation
  39555. */
  39556. onBeforeCameraTeleport: Observable<Vector3>;
  39557. /**
  39558. * Observable raised after camera teleportation
  39559. */
  39560. onAfterCameraTeleport: Observable<Vector3>;
  39561. /**
  39562. * Observable raised when current selected mesh gets unselected
  39563. */
  39564. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39565. private _raySelectionPredicate;
  39566. /**
  39567. * To be optionaly changed by user to define custom ray selection
  39568. */
  39569. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39570. /**
  39571. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39572. */
  39573. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39574. /**
  39575. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39576. */
  39577. teleportationEnabled: boolean;
  39578. private _defaultHeight;
  39579. private _teleportationInitialized;
  39580. private _interactionsEnabled;
  39581. private _interactionsRequested;
  39582. private _displayGaze;
  39583. private _displayLaserPointer;
  39584. /**
  39585. * The mesh used to display where the user is going to teleport.
  39586. */
  39587. /**
  39588. * Sets the mesh to be used to display where the user is going to teleport.
  39589. */
  39590. teleportationTarget: Mesh;
  39591. /**
  39592. * 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
  39593. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39594. * See http://doc.babylonjs.com/resources/baking_transformations
  39595. */
  39596. gazeTrackerMesh: Mesh;
  39597. /**
  39598. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39599. */
  39600. updateGazeTrackerScale: boolean;
  39601. /**
  39602. * If the gaze trackers color should be updated when selecting meshes
  39603. */
  39604. updateGazeTrackerColor: boolean;
  39605. /**
  39606. * The gaze tracking mesh corresponding to the left controller
  39607. */
  39608. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39609. /**
  39610. * The gaze tracking mesh corresponding to the right controller
  39611. */
  39612. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39613. /**
  39614. * If the ray of the gaze should be displayed.
  39615. */
  39616. /**
  39617. * Sets if the ray of the gaze should be displayed.
  39618. */
  39619. displayGaze: boolean;
  39620. /**
  39621. * If the ray of the LaserPointer should be displayed.
  39622. */
  39623. /**
  39624. * Sets if the ray of the LaserPointer should be displayed.
  39625. */
  39626. displayLaserPointer: boolean;
  39627. /**
  39628. * The deviceOrientationCamera used as the camera when not in VR.
  39629. */
  39630. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39631. /**
  39632. * Based on the current WebVR support, returns the current VR camera used.
  39633. */
  39634. readonly currentVRCamera: Nullable<Camera>;
  39635. /**
  39636. * The webVRCamera which is used when in VR.
  39637. */
  39638. readonly webVRCamera: WebVRFreeCamera;
  39639. /**
  39640. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39641. */
  39642. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39643. private readonly _teleportationRequestInitiated;
  39644. /**
  39645. * Defines wether or not Pointer lock should be requested when switching to
  39646. * full screen.
  39647. */
  39648. requestPointerLockOnFullScreen: boolean;
  39649. /**
  39650. * Instantiates a VRExperienceHelper.
  39651. * Helps to quickly add VR support to an existing scene.
  39652. * @param scene The scene the VRExperienceHelper belongs to.
  39653. * @param webVROptions Options to modify the vr experience helper's behavior.
  39654. */
  39655. constructor(scene: Scene,
  39656. /** Options to modify the vr experience helper's behavior. */
  39657. webVROptions?: VRExperienceHelperOptions);
  39658. private _onDefaultMeshLoaded;
  39659. private _onResize;
  39660. private _onFullscreenChange;
  39661. /**
  39662. * Gets a value indicating if we are currently in VR mode.
  39663. */
  39664. readonly isInVRMode: boolean;
  39665. private onVrDisplayPresentChange;
  39666. private onVRDisplayChanged;
  39667. private moveButtonToBottomRight;
  39668. private displayVRButton;
  39669. private updateButtonVisibility;
  39670. private _cachedAngularSensibility;
  39671. /**
  39672. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39673. * Otherwise, will use the fullscreen API.
  39674. */
  39675. enterVR(): void;
  39676. /**
  39677. * Attempt to exit VR, or fullscreen.
  39678. */
  39679. exitVR(): void;
  39680. /**
  39681. * The position of the vr experience helper.
  39682. */
  39683. /**
  39684. * Sets the position of the vr experience helper.
  39685. */
  39686. position: Vector3;
  39687. /**
  39688. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39689. */
  39690. enableInteractions(): void;
  39691. private readonly _noControllerIsActive;
  39692. private beforeRender;
  39693. private _isTeleportationFloor;
  39694. /**
  39695. * Adds a floor mesh to be used for teleportation.
  39696. * @param floorMesh the mesh to be used for teleportation.
  39697. */
  39698. addFloorMesh(floorMesh: Mesh): void;
  39699. /**
  39700. * Removes a floor mesh from being used for teleportation.
  39701. * @param floorMesh the mesh to be removed.
  39702. */
  39703. removeFloorMesh(floorMesh: Mesh): void;
  39704. /**
  39705. * Enables interactions and teleportation using the VR controllers and gaze.
  39706. * @param vrTeleportationOptions options to modify teleportation behavior.
  39707. */
  39708. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39709. private _onNewGamepadConnected;
  39710. private _tryEnableInteractionOnController;
  39711. private _onNewGamepadDisconnected;
  39712. private _enableInteractionOnController;
  39713. private _checkTeleportWithRay;
  39714. private _checkRotate;
  39715. private _checkTeleportBackwards;
  39716. private _enableTeleportationOnController;
  39717. private _createTeleportationCircles;
  39718. private _displayTeleportationTarget;
  39719. private _hideTeleportationTarget;
  39720. private _rotateCamera;
  39721. private _moveTeleportationSelectorTo;
  39722. private _workingVector;
  39723. private _workingQuaternion;
  39724. private _workingMatrix;
  39725. /**
  39726. * Teleports the users feet to the desired location
  39727. * @param location The location where the user's feet should be placed
  39728. */
  39729. teleportCamera(location: Vector3): void;
  39730. private _convertNormalToDirectionOfRay;
  39731. private _castRayAndSelectObject;
  39732. private _notifySelectedMeshUnselected;
  39733. /**
  39734. * Sets the color of the laser ray from the vr controllers.
  39735. * @param color new color for the ray.
  39736. */
  39737. changeLaserColor(color: Color3): void;
  39738. /**
  39739. * Sets the color of the ray from the vr headsets gaze.
  39740. * @param color new color for the ray.
  39741. */
  39742. changeGazeColor(color: Color3): void;
  39743. /**
  39744. * Exits VR and disposes of the vr experience helper
  39745. */
  39746. dispose(): void;
  39747. /**
  39748. * Gets the name of the VRExperienceHelper class
  39749. * @returns "VRExperienceHelper"
  39750. */
  39751. getClassName(): string;
  39752. }
  39753. }
  39754. declare module BABYLON {
  39755. /**
  39756. * Manages an XRSession
  39757. * @see https://doc.babylonjs.com/how_to/webxr
  39758. */
  39759. export class WebXRSessionManager implements IDisposable {
  39760. private scene;
  39761. /**
  39762. * Fires every time a new xrFrame arrives which can be used to update the camera
  39763. */
  39764. onXRFrameObservable: Observable<any>;
  39765. /**
  39766. * Fires when the xr session is ended either by the device or manually done
  39767. */
  39768. onXRSessionEnded: Observable<any>;
  39769. /** @hidden */ private _xrSession: XRSession;
  39770. /** @hidden */ private _frameOfReference: XRFrameOfReference;
  39771. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39772. /** @hidden */ private _currentXRFrame: Nullable<XRFrame>;
  39773. private _xrNavigator;
  39774. private _xrDevice;
  39775. private _tmpMatrix;
  39776. /**
  39777. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39778. * @param scene The scene which the session should be created for
  39779. */
  39780. constructor(scene: Scene);
  39781. /**
  39782. * Initializes the manager
  39783. * After initialization enterXR can be called to start an XR session
  39784. * @returns Promise which resolves after it is initialized
  39785. */
  39786. initializeAsync(): Promise<void>;
  39787. /**
  39788. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39789. * @param sessionCreationOptions xr options to create the session with
  39790. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39791. * @returns Promise which resolves after it enters XR
  39792. */
  39793. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39794. /**
  39795. * Stops the xrSession and restores the renderloop
  39796. * @returns Promise which resolves after it exits XR
  39797. */
  39798. exitXRAsync(): Promise<void>;
  39799. /**
  39800. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39801. * @param ray ray to cast into the environment
  39802. * @returns Promise which resolves with a collision point in the environment if it exists
  39803. */
  39804. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39805. /**
  39806. * Checks if a session would be supported for the creation options specified
  39807. * @param options creation options to check if they are supported
  39808. * @returns true if supported
  39809. */
  39810. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39811. /**
  39812. * @hidden
  39813. * Converts the render layer of xrSession to a render target
  39814. * @param session session to create render target for
  39815. * @param scene scene the new render target should be created for
  39816. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39817. /**
  39818. * Disposes of the session manager
  39819. */
  39820. dispose(): void;
  39821. }
  39822. }
  39823. declare module BABYLON {
  39824. /**
  39825. * WebXR Camera which holds the views for the xrSession
  39826. * @see https://doc.babylonjs.com/how_to/webxr
  39827. */
  39828. export class WebXRCamera extends FreeCamera {
  39829. private static _TmpMatrix;
  39830. /**
  39831. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39832. * @param name the name of the camera
  39833. * @param scene the scene to add the camera to
  39834. */
  39835. constructor(name: string, scene: Scene);
  39836. private _updateNumberOfRigCameras;
  39837. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  39838. /**
  39839. * Updates the cameras position from the current pose information of the XR session
  39840. * @param xrSessionManager the session containing pose information
  39841. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39842. */
  39843. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39844. }
  39845. }
  39846. declare module BABYLON {
  39847. /**
  39848. * States of the webXR experience
  39849. */
  39850. export enum WebXRState {
  39851. /**
  39852. * Transitioning to being in XR mode
  39853. */
  39854. ENTERING_XR = 0,
  39855. /**
  39856. * Transitioning to non XR mode
  39857. */
  39858. EXITING_XR = 1,
  39859. /**
  39860. * In XR mode and presenting
  39861. */
  39862. IN_XR = 2,
  39863. /**
  39864. * Not entered XR mode
  39865. */
  39866. NOT_IN_XR = 3
  39867. }
  39868. /**
  39869. * Helper class used to enable XR
  39870. * @see https://doc.babylonjs.com/how_to/webxr
  39871. */
  39872. export class WebXRExperienceHelper implements IDisposable {
  39873. private scene;
  39874. /**
  39875. * 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
  39876. */
  39877. container: AbstractMesh;
  39878. /**
  39879. * Camera used to render xr content
  39880. */
  39881. camera: WebXRCamera;
  39882. /**
  39883. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39884. */
  39885. state: WebXRState;
  39886. private _setState;
  39887. private static _TmpVector;
  39888. /**
  39889. * Fires when the state of the experience helper has changed
  39890. */
  39891. onStateChangedObservable: Observable<WebXRState>;
  39892. /** @hidden */ private _sessionManager: WebXRSessionManager;
  39893. private _nonVRCamera;
  39894. private _originalSceneAutoClear;
  39895. private _supported;
  39896. /**
  39897. * Creates the experience helper
  39898. * @param scene the scene to attach the experience helper to
  39899. * @returns a promise for the experience helper
  39900. */
  39901. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39902. /**
  39903. * Creates a WebXRExperienceHelper
  39904. * @param scene The scene the helper should be created in
  39905. */
  39906. private constructor();
  39907. /**
  39908. * Exits XR mode and returns the scene to its original state
  39909. * @returns promise that resolves after xr mode has exited
  39910. */
  39911. exitXRAsync(): Promise<void>;
  39912. /**
  39913. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39914. * @param sessionCreationOptions options for the XR session
  39915. * @param frameOfReference frame of reference of the XR session
  39916. * @returns promise that resolves after xr mode has entered
  39917. */
  39918. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39919. /**
  39920. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39921. * @param ray ray to cast into the environment
  39922. * @returns Promise which resolves with a collision point in the environment if it exists
  39923. */
  39924. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39925. /**
  39926. * Updates the global position of the camera by moving the camera's container
  39927. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39928. * @param position The desired global position of the camera
  39929. */
  39930. setPositionOfCameraUsingContainer(position: Vector3): void;
  39931. /**
  39932. * Rotates the xr camera by rotating the camera's container around the camera's position
  39933. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39934. * @param rotation the desired quaternion rotation to apply to the camera
  39935. */
  39936. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39937. /**
  39938. * Checks if the creation options are supported by the xr session
  39939. * @param options creation options
  39940. * @returns true if supported
  39941. */
  39942. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39943. /**
  39944. * Disposes of the experience helper
  39945. */
  39946. dispose(): void;
  39947. }
  39948. }
  39949. declare module BABYLON {
  39950. /**
  39951. * Button which can be used to enter a different mode of XR
  39952. */
  39953. export class WebXREnterExitUIButton {
  39954. /** button element */
  39955. element: HTMLElement;
  39956. /** XR initialization options for the button */
  39957. initializationOptions: XRSessionCreationOptions;
  39958. /**
  39959. * Creates a WebXREnterExitUIButton
  39960. * @param element button element
  39961. * @param initializationOptions XR initialization options for the button
  39962. */
  39963. constructor(
  39964. /** button element */
  39965. element: HTMLElement,
  39966. /** XR initialization options for the button */
  39967. initializationOptions: XRSessionCreationOptions);
  39968. /**
  39969. * Overwritable function which can be used to update the button's visuals when the state changes
  39970. * @param activeButton the current active button in the UI
  39971. */
  39972. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39973. }
  39974. /**
  39975. * Options to create the webXR UI
  39976. */
  39977. export class WebXREnterExitUIOptions {
  39978. /**
  39979. * Context to enter xr with
  39980. */
  39981. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39982. /**
  39983. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39984. */
  39985. customButtons?: Array<WebXREnterExitUIButton>;
  39986. }
  39987. /**
  39988. * UI to allow the user to enter/exit XR mode
  39989. */
  39990. export class WebXREnterExitUI implements IDisposable {
  39991. private scene;
  39992. private _overlay;
  39993. private _buttons;
  39994. private _activeButton;
  39995. /**
  39996. * Fired every time the active button is changed.
  39997. *
  39998. * When xr is entered via a button that launches xr that button will be the callback parameter
  39999. *
  40000. * When exiting xr the callback parameter will be null)
  40001. */
  40002. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40003. /**
  40004. * Creates UI to allow the user to enter/exit XR mode
  40005. * @param scene the scene to add the ui to
  40006. * @param helper the xr experience helper to enter/exit xr with
  40007. * @param options options to configure the UI
  40008. * @returns the created ui
  40009. */
  40010. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40011. private constructor();
  40012. private _updateButtons;
  40013. /**
  40014. * Disposes of the object
  40015. */
  40016. dispose(): void;
  40017. }
  40018. }
  40019. declare module BABYLON {
  40020. /**
  40021. * Represents an XR input
  40022. */
  40023. export class WebXRController {
  40024. /**
  40025. * 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
  40026. */
  40027. grip?: AbstractMesh;
  40028. /**
  40029. * Pointer which can be used to select objects or attach a visible laser to
  40030. */
  40031. pointer: AbstractMesh;
  40032. /**
  40033. * Creates the controller
  40034. * @see https://doc.babylonjs.com/how_to/webxr
  40035. * @param scene the scene which the controller should be associated to
  40036. */
  40037. constructor(scene: Scene);
  40038. /**
  40039. * Disposes of the object
  40040. */
  40041. dispose(): void;
  40042. }
  40043. /**
  40044. * XR input used to track XR inputs such as controllers/rays
  40045. */
  40046. export class WebXRInput implements IDisposable {
  40047. private helper;
  40048. /**
  40049. * XR controllers being tracked
  40050. */
  40051. controllers: Array<WebXRController>;
  40052. private _tmpMatrix;
  40053. private _frameObserver;
  40054. /**
  40055. * Initializes the WebXRInput
  40056. * @param helper experience helper which the input should be created for
  40057. */
  40058. constructor(helper: WebXRExperienceHelper);
  40059. /**
  40060. * Disposes of the object
  40061. */
  40062. dispose(): void;
  40063. }
  40064. }
  40065. declare module BABYLON {
  40066. /**
  40067. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40068. */
  40069. export class WebXRManagedOutputCanvas implements IDisposable {
  40070. private _canvas;
  40071. /**
  40072. * xrpresent context of the canvas which can be used to display/mirror xr content
  40073. */
  40074. canvasContext: Nullable<WebGLRenderingContext>;
  40075. /**
  40076. * Initializes the canvas to be added/removed upon entering/exiting xr
  40077. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40078. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40079. */
  40080. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40081. /**
  40082. * Disposes of the object
  40083. */
  40084. dispose(): void;
  40085. private _setManagedOutputCanvas;
  40086. private _addCanvas;
  40087. private _removeCanvas;
  40088. }
  40089. }
  40090. declare module BABYLON {
  40091. /**
  40092. * Contains an array of blocks representing the octree
  40093. */
  40094. export interface IOctreeContainer<T> {
  40095. /**
  40096. * Blocks within the octree
  40097. */
  40098. blocks: Array<OctreeBlock<T>>;
  40099. }
  40100. /**
  40101. * Class used to store a cell in an octree
  40102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40103. */
  40104. export class OctreeBlock<T> {
  40105. /**
  40106. * Gets the content of the current block
  40107. */
  40108. entries: T[];
  40109. /**
  40110. * Gets the list of block children
  40111. */
  40112. blocks: Array<OctreeBlock<T>>;
  40113. private _depth;
  40114. private _maxDepth;
  40115. private _capacity;
  40116. private _minPoint;
  40117. private _maxPoint;
  40118. private _boundingVectors;
  40119. private _creationFunc;
  40120. /**
  40121. * Creates a new block
  40122. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40123. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40124. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40125. * @param depth defines the current depth of this block in the octree
  40126. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40127. * @param creationFunc defines a callback to call when an element is added to the block
  40128. */
  40129. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40130. /**
  40131. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40132. */
  40133. readonly capacity: number;
  40134. /**
  40135. * Gets the minimum vector (in world space) of the block's bounding box
  40136. */
  40137. readonly minPoint: Vector3;
  40138. /**
  40139. * Gets the maximum vector (in world space) of the block's bounding box
  40140. */
  40141. readonly maxPoint: Vector3;
  40142. /**
  40143. * Add a new element to this block
  40144. * @param entry defines the element to add
  40145. */
  40146. addEntry(entry: T): void;
  40147. /**
  40148. * Remove an element from this block
  40149. * @param entry defines the element to remove
  40150. */
  40151. removeEntry(entry: T): void;
  40152. /**
  40153. * Add an array of elements to this block
  40154. * @param entries defines the array of elements to add
  40155. */
  40156. addEntries(entries: T[]): void;
  40157. /**
  40158. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40159. * @param frustumPlanes defines the frustum planes to test
  40160. * @param selection defines the array to store current content if selection is positive
  40161. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40162. */
  40163. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40164. /**
  40165. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40166. * @param sphereCenter defines the bounding sphere center
  40167. * @param sphereRadius defines the bounding sphere radius
  40168. * @param selection defines the array to store current content if selection is positive
  40169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40170. */
  40171. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40172. /**
  40173. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40174. * @param ray defines the ray to test with
  40175. * @param selection defines the array to store current content if selection is positive
  40176. */
  40177. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40178. /**
  40179. * Subdivide the content into child blocks (this block will then be empty)
  40180. */
  40181. createInnerBlocks(): void;
  40182. /**
  40183. * @hidden
  40184. */ 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;
  40185. }
  40186. }
  40187. declare module BABYLON {
  40188. /**
  40189. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40191. */
  40192. export class Octree<T> {
  40193. /** 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.) */
  40194. maxDepth: number;
  40195. /**
  40196. * Blocks within the octree containing objects
  40197. */
  40198. blocks: Array<OctreeBlock<T>>;
  40199. /**
  40200. * Content stored in the octree
  40201. */
  40202. dynamicContent: T[];
  40203. private _maxBlockCapacity;
  40204. private _selectionContent;
  40205. private _creationFunc;
  40206. /**
  40207. * Creates a octree
  40208. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40209. * @param creationFunc function to be used to instatiate the octree
  40210. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40211. * @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.)
  40212. */
  40213. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40214. /** 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.) */
  40215. maxDepth?: number);
  40216. /**
  40217. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40218. * @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);
  40219. * @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);
  40220. * @param entries meshes to be added to the octree blocks
  40221. */
  40222. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40223. /**
  40224. * Adds a mesh to the octree
  40225. * @param entry Mesh to add to the octree
  40226. */
  40227. addMesh(entry: T): void;
  40228. /**
  40229. * Remove an element from the octree
  40230. * @param entry defines the element to remove
  40231. */
  40232. removeMesh(entry: T): void;
  40233. /**
  40234. * Selects an array of meshes within the frustum
  40235. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40236. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40237. * @returns array of meshes within the frustum
  40238. */
  40239. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40240. /**
  40241. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40242. * @param sphereCenter defines the bounding sphere center
  40243. * @param sphereRadius defines the bounding sphere radius
  40244. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40245. * @returns an array of objects that intersect the sphere
  40246. */
  40247. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40248. /**
  40249. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40250. * @param ray defines the ray to test with
  40251. * @returns array of intersected objects
  40252. */
  40253. intersectsRay(ray: Ray): SmartArray<T>;
  40254. /**
  40255. * Adds a mesh into the octree block if it intersects the block
  40256. */
  40257. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40258. /**
  40259. * Adds a submesh into the octree block if it intersects the block
  40260. */
  40261. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40262. }
  40263. }
  40264. declare module BABYLON {
  40265. interface Scene {
  40266. /**
  40267. * @hidden
  40268. * Backing Filed
  40269. */ private _selectionOctree: Octree<AbstractMesh>;
  40270. /**
  40271. * Gets the octree used to boost mesh selection (picking)
  40272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40273. */
  40274. selectionOctree: Octree<AbstractMesh>;
  40275. /**
  40276. * Creates or updates the octree used to boost selection (picking)
  40277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40278. * @param maxCapacity defines the maximum capacity per leaf
  40279. * @param maxDepth defines the maximum depth of the octree
  40280. * @returns an octree of AbstractMesh
  40281. */
  40282. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40283. }
  40284. interface AbstractMesh {
  40285. /**
  40286. * @hidden
  40287. * Backing Field
  40288. */ private _submeshesOctree: Octree<SubMesh>;
  40289. /**
  40290. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40291. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40292. * @param maxCapacity defines the maximum size of each block (64 by default)
  40293. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40294. * @returns the new octree
  40295. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40296. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40297. */
  40298. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40299. }
  40300. /**
  40301. * Defines the octree scene component responsible to manage any octrees
  40302. * in a given scene.
  40303. */
  40304. export class OctreeSceneComponent {
  40305. /**
  40306. * The component name help to identify the component in the list of scene components.
  40307. */
  40308. readonly name: string;
  40309. /**
  40310. * The scene the component belongs to.
  40311. */
  40312. scene: Scene;
  40313. /**
  40314. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40315. */
  40316. readonly checksIsEnabled: boolean;
  40317. /**
  40318. * Creates a new instance of the component for the given scene
  40319. * @param scene Defines the scene to register the component in
  40320. */
  40321. constructor(scene: Scene);
  40322. /**
  40323. * Registers the component in a given scene
  40324. */
  40325. register(): void;
  40326. /**
  40327. * Return the list of active meshes
  40328. * @returns the list of active meshes
  40329. */
  40330. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40331. /**
  40332. * Return the list of active sub meshes
  40333. * @param mesh The mesh to get the candidates sub meshes from
  40334. * @returns the list of active sub meshes
  40335. */
  40336. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40337. private _tempRay;
  40338. /**
  40339. * Return the list of sub meshes intersecting with a given local ray
  40340. * @param mesh defines the mesh to find the submesh for
  40341. * @param localRay defines the ray in local space
  40342. * @returns the list of intersecting sub meshes
  40343. */
  40344. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40345. /**
  40346. * Return the list of sub meshes colliding with a collider
  40347. * @param mesh defines the mesh to find the submesh for
  40348. * @param collider defines the collider to evaluate the collision against
  40349. * @returns the list of colliding sub meshes
  40350. */
  40351. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40352. /**
  40353. * Rebuilds the elements related to this component in case of
  40354. * context lost for instance.
  40355. */
  40356. rebuild(): void;
  40357. /**
  40358. * Disposes the component and the associated ressources.
  40359. */
  40360. dispose(): void;
  40361. }
  40362. }
  40363. declare module BABYLON {
  40364. /**
  40365. * Renders a layer on top of an existing scene
  40366. */
  40367. export class UtilityLayerRenderer implements IDisposable {
  40368. /** the original scene that will be rendered on top of */
  40369. originalScene: Scene;
  40370. private _pointerCaptures;
  40371. private _lastPointerEvents;
  40372. private static _DefaultUtilityLayer;
  40373. private static _DefaultKeepDepthUtilityLayer;
  40374. private _sharedGizmoLight;
  40375. private _renderCamera;
  40376. /**
  40377. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  40378. * @returns the camera that is used when rendering the utility layer
  40379. */
  40380. getRenderCamera(): Nullable<Camera>;
  40381. /**
  40382. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  40383. * @param cam the camera that should be used when rendering the utility layer
  40384. */
  40385. setRenderCamera(cam: Nullable<Camera>): void;
  40386. /**
  40387. * @hidden
  40388. * Light which used by gizmos to get light shading
  40389. */ private _getSharedGizmoLight(): HemisphericLight;
  40390. /**
  40391. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40392. */
  40393. pickUtilitySceneFirst: boolean;
  40394. /**
  40395. * 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)
  40396. */
  40397. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40398. /**
  40399. * 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)
  40400. */
  40401. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40402. /**
  40403. * The scene that is rendered on top of the original scene
  40404. */
  40405. utilityLayerScene: Scene;
  40406. /**
  40407. * If the utility layer should automatically be rendered on top of existing scene
  40408. */
  40409. shouldRender: boolean;
  40410. /**
  40411. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40412. */
  40413. onlyCheckPointerDownEvents: boolean;
  40414. /**
  40415. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40416. */
  40417. processAllEvents: boolean;
  40418. /**
  40419. * Observable raised when the pointer move from the utility layer scene to the main scene
  40420. */
  40421. onPointerOutObservable: Observable<number>;
  40422. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40423. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40424. private _afterRenderObserver;
  40425. private _sceneDisposeObserver;
  40426. private _originalPointerObserver;
  40427. /**
  40428. * Instantiates a UtilityLayerRenderer
  40429. * @param originalScene the original scene that will be rendered on top of
  40430. * @param handleEvents boolean indicating if the utility layer should handle events
  40431. */
  40432. constructor(
  40433. /** the original scene that will be rendered on top of */
  40434. originalScene: Scene, handleEvents?: boolean);
  40435. private _notifyObservers;
  40436. /**
  40437. * Renders the utility layers scene on top of the original scene
  40438. */
  40439. render(): void;
  40440. /**
  40441. * Disposes of the renderer
  40442. */
  40443. dispose(): void;
  40444. private _updateCamera;
  40445. }
  40446. }
  40447. declare module BABYLON {
  40448. /**
  40449. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40450. */
  40451. export class Gizmo implements IDisposable {
  40452. /** The utility layer the gizmo will be added to */
  40453. gizmoLayer: UtilityLayerRenderer;
  40454. /**
  40455. * The root mesh of the gizmo
  40456. */ private _rootMesh: Mesh;
  40457. private _attachedMesh;
  40458. /**
  40459. * Ratio for the scale of the gizmo (Default: 1)
  40460. */
  40461. scaleRatio: number;
  40462. /**
  40463. * If a custom mesh has been set (Default: false)
  40464. */
  40465. protected _customMeshSet: boolean;
  40466. /**
  40467. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40468. * * When set, interactions will be enabled
  40469. */
  40470. attachedMesh: Nullable<AbstractMesh>;
  40471. /**
  40472. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40473. * @param mesh The mesh to replace the default mesh of the gizmo
  40474. */
  40475. setCustomMesh(mesh: Mesh): void;
  40476. /**
  40477. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40478. */
  40479. updateGizmoRotationToMatchAttachedMesh: boolean;
  40480. /**
  40481. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40482. */
  40483. updateGizmoPositionToMatchAttachedMesh: boolean;
  40484. /**
  40485. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40486. */
  40487. protected _updateScale: boolean;
  40488. protected _interactionsEnabled: boolean;
  40489. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40490. private _beforeRenderObserver;
  40491. private _tempVector;
  40492. /**
  40493. * Creates a gizmo
  40494. * @param gizmoLayer The utility layer the gizmo will be added to
  40495. */
  40496. constructor(
  40497. /** The utility layer the gizmo will be added to */
  40498. gizmoLayer?: UtilityLayerRenderer);
  40499. /**
  40500. * Updates the gizmo to match the attached mesh's position/rotation
  40501. */
  40502. protected _update(): void;
  40503. /**
  40504. * Disposes of the gizmo
  40505. */
  40506. dispose(): void;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Single plane drag gizmo
  40512. */
  40513. export class PlaneDragGizmo extends Gizmo {
  40514. /**
  40515. * Drag behavior responsible for the gizmos dragging interactions
  40516. */
  40517. dragBehavior: PointerDragBehavior;
  40518. private _pointerObserver;
  40519. /**
  40520. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40521. */
  40522. snapDistance: number;
  40523. /**
  40524. * Event that fires each time the gizmo snaps to a new location.
  40525. * * snapDistance is the the change in distance
  40526. */
  40527. onSnapObservable: Observable<{
  40528. snapDistance: number;
  40529. }>;
  40530. private _plane;
  40531. private _coloredMaterial;
  40532. private _hoverMaterial;
  40533. private _isEnabled;
  40534. private _parent;
  40535. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  40536. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40537. /**
  40538. * Creates a PlaneDragGizmo
  40539. * @param gizmoLayer The utility layer the gizmo will be added to
  40540. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  40541. * @param color The color of the gizmo
  40542. */
  40543. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  40544. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40545. /**
  40546. * If the gizmo is enabled
  40547. */
  40548. isEnabled: boolean;
  40549. /**
  40550. * Disposes of the gizmo
  40551. */
  40552. dispose(): void;
  40553. }
  40554. }
  40555. declare module BABYLON {
  40556. /**
  40557. * Gizmo that enables dragging a mesh along 3 axis
  40558. */
  40559. export class PositionGizmo extends Gizmo {
  40560. /**
  40561. * Internal gizmo used for interactions on the x axis
  40562. */
  40563. xGizmo: AxisDragGizmo;
  40564. /**
  40565. * Internal gizmo used for interactions on the y axis
  40566. */
  40567. yGizmo: AxisDragGizmo;
  40568. /**
  40569. * Internal gizmo used for interactions on the z axis
  40570. */
  40571. zGizmo: AxisDragGizmo;
  40572. /**
  40573. * Internal gizmo used for interactions on the yz plane
  40574. */
  40575. xPlaneGizmo: PlaneDragGizmo;
  40576. /**
  40577. * Internal gizmo used for interactions on the xz plane
  40578. */
  40579. yPlaneGizmo: PlaneDragGizmo;
  40580. /**
  40581. * Internal gizmo used for interactions on the xy plane
  40582. */
  40583. zPlaneGizmo: PlaneDragGizmo;
  40584. /**
  40585. * private variables
  40586. */
  40587. private _meshAttached;
  40588. private _updateGizmoRotationToMatchAttachedMesh;
  40589. private _snapDistance;
  40590. private _scaleRatio;
  40591. /** Fires an event when any of it's sub gizmos are dragged */
  40592. onDragStartObservable: Observable<{}>;
  40593. /** Fires an event when any of it's sub gizmos are released from dragging */
  40594. onDragEndObservable: Observable<{}>;
  40595. /**
  40596. * If set to true, planar drag is enabled
  40597. */
  40598. private _planarGizmoEnabled;
  40599. attachedMesh: Nullable<AbstractMesh>;
  40600. /**
  40601. * Creates a PositionGizmo
  40602. * @param gizmoLayer The utility layer the gizmo will be added to
  40603. */
  40604. constructor(gizmoLayer?: UtilityLayerRenderer);
  40605. /**
  40606. * If the planar drag gizmo is enabled
  40607. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  40608. */
  40609. planarGizmoEnabled: boolean;
  40610. updateGizmoRotationToMatchAttachedMesh: boolean;
  40611. /**
  40612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40613. */
  40614. snapDistance: number;
  40615. /**
  40616. * Ratio for the scale of the gizmo (Default: 1)
  40617. */
  40618. scaleRatio: number;
  40619. /**
  40620. * Disposes of the gizmo
  40621. */
  40622. dispose(): void;
  40623. /**
  40624. * CustomMeshes are not supported by this gizmo
  40625. * @param mesh The mesh to replace the default mesh of the gizmo
  40626. */
  40627. setCustomMesh(mesh: Mesh): void;
  40628. }
  40629. }
  40630. declare module BABYLON {
  40631. /**
  40632. * Single axis drag gizmo
  40633. */
  40634. export class AxisDragGizmo extends Gizmo {
  40635. /**
  40636. * Drag behavior responsible for the gizmos dragging interactions
  40637. */
  40638. dragBehavior: PointerDragBehavior;
  40639. private _pointerObserver;
  40640. /**
  40641. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40642. */
  40643. snapDistance: number;
  40644. /**
  40645. * Event that fires each time the gizmo snaps to a new location.
  40646. * * snapDistance is the the change in distance
  40647. */
  40648. onSnapObservable: Observable<{
  40649. snapDistance: number;
  40650. }>;
  40651. private _isEnabled;
  40652. private _parent;
  40653. private _arrow;
  40654. private _coloredMaterial;
  40655. private _hoverMaterial;
  40656. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40657. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40658. /**
  40659. * Creates an AxisDragGizmo
  40660. * @param gizmoLayer The utility layer the gizmo will be added to
  40661. * @param dragAxis The axis which the gizmo will be able to drag on
  40662. * @param color The color of the gizmo
  40663. */
  40664. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  40665. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40666. /**
  40667. * If the gizmo is enabled
  40668. */
  40669. isEnabled: boolean;
  40670. /**
  40671. * Disposes of the gizmo
  40672. */
  40673. dispose(): void;
  40674. }
  40675. }
  40676. declare module BABYLON.Debug {
  40677. /**
  40678. * The Axes viewer will show 3 axes in a specific point in space
  40679. */
  40680. export class AxesViewer {
  40681. private _xAxis;
  40682. private _yAxis;
  40683. private _zAxis;
  40684. private _scaleLinesFactor;
  40685. private _instanced;
  40686. /**
  40687. * Gets the hosting scene
  40688. */
  40689. scene: Scene;
  40690. /**
  40691. * Gets or sets a number used to scale line length
  40692. */
  40693. scaleLines: number;
  40694. /** Gets the node hierarchy used to render x-axis */
  40695. readonly xAxis: TransformNode;
  40696. /** Gets the node hierarchy used to render y-axis */
  40697. readonly yAxis: TransformNode;
  40698. /** Gets the node hierarchy used to render z-axis */
  40699. readonly zAxis: TransformNode;
  40700. /**
  40701. * Creates a new AxesViewer
  40702. * @param scene defines the hosting scene
  40703. * @param scaleLines defines a number used to scale line length (1 by default)
  40704. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40705. * @param xAxis defines the node hierarchy used to render the x-axis
  40706. * @param yAxis defines the node hierarchy used to render the y-axis
  40707. * @param zAxis defines the node hierarchy used to render the z-axis
  40708. */
  40709. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40710. /**
  40711. * Force the viewer to update
  40712. * @param position defines the position of the viewer
  40713. * @param xaxis defines the x axis of the viewer
  40714. * @param yaxis defines the y axis of the viewer
  40715. * @param zaxis defines the z axis of the viewer
  40716. */
  40717. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40718. /**
  40719. * Creates an instance of this axes viewer.
  40720. * @returns a new axes viewer with instanced meshes
  40721. */
  40722. createInstance(): AxesViewer;
  40723. /** Releases resources */
  40724. dispose(): void;
  40725. private static _SetRenderingGroupId;
  40726. }
  40727. }
  40728. declare module BABYLON.Debug {
  40729. /**
  40730. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40731. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40732. */
  40733. export class BoneAxesViewer extends AxesViewer {
  40734. /**
  40735. * Gets or sets the target mesh where to display the axes viewer
  40736. */
  40737. mesh: Nullable<Mesh>;
  40738. /**
  40739. * Gets or sets the target bone where to display the axes viewer
  40740. */
  40741. bone: Nullable<Bone>;
  40742. /** Gets current position */
  40743. pos: Vector3;
  40744. /** Gets direction of X axis */
  40745. xaxis: Vector3;
  40746. /** Gets direction of Y axis */
  40747. yaxis: Vector3;
  40748. /** Gets direction of Z axis */
  40749. zaxis: Vector3;
  40750. /**
  40751. * Creates a new BoneAxesViewer
  40752. * @param scene defines the hosting scene
  40753. * @param bone defines the target bone
  40754. * @param mesh defines the target mesh
  40755. * @param scaleLines defines a scaling factor for line length (1 by default)
  40756. */
  40757. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40758. /**
  40759. * Force the viewer to update
  40760. */
  40761. update(): void;
  40762. /** Releases resources */
  40763. dispose(): void;
  40764. }
  40765. }
  40766. declare module BABYLON {
  40767. /**
  40768. * Interface used to define scene explorer extensibility option
  40769. */
  40770. export interface IExplorerExtensibilityOption {
  40771. /**
  40772. * Define the option label
  40773. */
  40774. label: string;
  40775. /**
  40776. * Defines the action to execute on click
  40777. */
  40778. action: (entity: any) => void;
  40779. }
  40780. /**
  40781. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40782. */
  40783. export interface IExplorerExtensibilityGroup {
  40784. /**
  40785. * Defines a predicate to test if a given type mut be extended
  40786. */
  40787. predicate: (entity: any) => boolean;
  40788. /**
  40789. * Gets the list of options added to a type
  40790. */
  40791. entries: IExplorerExtensibilityOption[];
  40792. }
  40793. /**
  40794. * Interface used to define the options to use to create the Inspector
  40795. */
  40796. export interface IInspectorOptions {
  40797. /**
  40798. * Display in overlay mode (default: false)
  40799. */
  40800. overlay?: boolean;
  40801. /**
  40802. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40803. */
  40804. globalRoot?: HTMLElement;
  40805. /**
  40806. * Display the Scene explorer
  40807. */
  40808. showExplorer?: boolean;
  40809. /**
  40810. * Display the property inspector
  40811. */
  40812. showInspector?: boolean;
  40813. /**
  40814. * Display in embed mode (both panes on the right)
  40815. */
  40816. embedMode?: boolean;
  40817. /**
  40818. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40819. */
  40820. handleResize?: boolean;
  40821. /**
  40822. * Allow the panes to popup (default: true)
  40823. */
  40824. enablePopup?: boolean;
  40825. /**
  40826. * Allow the panes to be closed by users (default: true)
  40827. */
  40828. enableClose?: boolean;
  40829. /**
  40830. * Optional list of extensibility entries
  40831. */
  40832. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40833. /**
  40834. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40835. */
  40836. inspectorURL?: string;
  40837. }
  40838. interface Scene {
  40839. /**
  40840. * @hidden
  40841. * Backing field
  40842. */ private _debugLayer: DebugLayer;
  40843. /**
  40844. * Gets the debug layer (aka Inspector) associated with the scene
  40845. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40846. */
  40847. debugLayer: DebugLayer;
  40848. }
  40849. /**
  40850. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40851. * what is happening in your scene
  40852. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40853. */
  40854. export class DebugLayer {
  40855. /**
  40856. * Define the url to get the inspector script from.
  40857. * By default it uses the babylonjs CDN.
  40858. * @ignoreNaming
  40859. */
  40860. static InspectorURL: string;
  40861. private _scene;
  40862. private BJSINSPECTOR;
  40863. private _onPropertyChangedObservable?;
  40864. /**
  40865. * Observable triggered when a property is changed through the inspector.
  40866. */
  40867. readonly onPropertyChangedObservable: any;
  40868. /**
  40869. * Instantiates a new debug layer.
  40870. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40871. * what is happening in your scene
  40872. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40873. * @param scene Defines the scene to inspect
  40874. */
  40875. constructor(scene: Scene);
  40876. /** Creates the inspector window. */
  40877. private _createInspector;
  40878. /**
  40879. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40880. * @param entity defines the entity to select
  40881. * @param lineContainerTitle defines the specific block to highlight
  40882. */
  40883. select(entity: any, lineContainerTitle?: string): void;
  40884. /** Get the inspector from bundle or global */
  40885. private _getGlobalInspector;
  40886. /**
  40887. * Get if the inspector is visible or not.
  40888. * @returns true if visible otherwise, false
  40889. */
  40890. isVisible(): boolean;
  40891. /**
  40892. * Hide the inspector and close its window.
  40893. */
  40894. hide(): void;
  40895. /**
  40896. * Launch the debugLayer.
  40897. * @param config Define the configuration of the inspector
  40898. * @return a promise fulfilled when the debug layer is visible
  40899. */
  40900. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40901. }
  40902. }
  40903. declare module BABYLON {
  40904. /**
  40905. * Class containing static functions to help procedurally build meshes
  40906. */
  40907. export class BoxBuilder {
  40908. /**
  40909. * Creates a box mesh
  40910. * * The parameter `size` sets the size (float) of each box side (default 1)
  40911. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40912. * * 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)
  40913. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40915. * * 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
  40916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40918. * @param name defines the name of the mesh
  40919. * @param options defines the options used to create the mesh
  40920. * @param scene defines the hosting scene
  40921. * @returns the box mesh
  40922. */
  40923. static CreateBox(name: string, options: {
  40924. size?: number;
  40925. width?: number;
  40926. height?: number;
  40927. depth?: number;
  40928. faceUV?: Vector4[];
  40929. faceColors?: Color4[];
  40930. sideOrientation?: number;
  40931. frontUVs?: Vector4;
  40932. backUVs?: Vector4;
  40933. wrap?: boolean;
  40934. topBaseAt?: number;
  40935. bottomBaseAt?: number;
  40936. updatable?: boolean;
  40937. }, scene?: Nullable<Scene>): Mesh;
  40938. }
  40939. }
  40940. declare module BABYLON {
  40941. /**
  40942. * Class containing static functions to help procedurally build meshes
  40943. */
  40944. export class SphereBuilder {
  40945. /**
  40946. * Creates a sphere mesh
  40947. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40948. * * 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`)
  40949. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40950. * * 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
  40951. * * 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)
  40952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40953. * * 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
  40954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40955. * @param name defines the name of the mesh
  40956. * @param options defines the options used to create the mesh
  40957. * @param scene defines the hosting scene
  40958. * @returns the sphere mesh
  40959. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40960. */
  40961. static CreateSphere(name: string, options: {
  40962. segments?: number;
  40963. diameter?: number;
  40964. diameterX?: number;
  40965. diameterY?: number;
  40966. diameterZ?: number;
  40967. arc?: number;
  40968. slice?: number;
  40969. sideOrientation?: number;
  40970. frontUVs?: Vector4;
  40971. backUVs?: Vector4;
  40972. updatable?: boolean;
  40973. }, scene: any): Mesh;
  40974. }
  40975. }
  40976. declare module BABYLON.Debug {
  40977. /**
  40978. * Used to show the physics impostor around the specific mesh
  40979. */
  40980. export class PhysicsViewer {
  40981. /** @hidden */
  40982. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40983. /** @hidden */
  40984. protected _meshes: Array<Nullable<AbstractMesh>>;
  40985. /** @hidden */
  40986. protected _scene: Nullable<Scene>;
  40987. /** @hidden */
  40988. protected _numMeshes: number;
  40989. /** @hidden */
  40990. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40991. private _renderFunction;
  40992. private _utilityLayer;
  40993. private _debugBoxMesh;
  40994. private _debugSphereMesh;
  40995. private _debugCylinderMesh;
  40996. private _debugMaterial;
  40997. private _debugMeshMeshes;
  40998. /**
  40999. * Creates a new PhysicsViewer
  41000. * @param scene defines the hosting scene
  41001. */
  41002. constructor(scene: Scene);
  41003. /** @hidden */
  41004. protected _updateDebugMeshes(): void;
  41005. /**
  41006. * Renders a specified physic impostor
  41007. * @param impostor defines the impostor to render
  41008. * @param targetMesh defines the mesh represented by the impostor
  41009. * @returns the new debug mesh used to render the impostor
  41010. */
  41011. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41012. /**
  41013. * Hides a specified physic impostor
  41014. * @param impostor defines the impostor to hide
  41015. */
  41016. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41017. private _getDebugMaterial;
  41018. private _getDebugBoxMesh;
  41019. private _getDebugSphereMesh;
  41020. private _getDebugCylinderMesh;
  41021. private _getDebugMeshMesh;
  41022. private _getDebugMesh;
  41023. /** Releases all resources */
  41024. dispose(): void;
  41025. }
  41026. }
  41027. declare module BABYLON {
  41028. /**
  41029. * Class containing static functions to help procedurally build meshes
  41030. */
  41031. export class LinesBuilder {
  41032. /**
  41033. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41034. * * 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
  41035. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41036. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41037. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41038. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41039. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41040. * * 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
  41041. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41044. * @param name defines the name of the new line system
  41045. * @param options defines the options used to create the line system
  41046. * @param scene defines the hosting scene
  41047. * @returns a new line system mesh
  41048. */
  41049. static CreateLineSystem(name: string, options: {
  41050. lines: Vector3[][];
  41051. updatable?: boolean;
  41052. instance?: Nullable<LinesMesh>;
  41053. colors?: Nullable<Color4[][]>;
  41054. useVertexAlpha?: boolean;
  41055. }, scene: Nullable<Scene>): LinesMesh;
  41056. /**
  41057. * Creates a line mesh
  41058. * 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
  41059. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41060. * * The parameter `points` is an array successive Vector3
  41061. * * 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
  41062. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41063. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41064. * * When updating an instance, remember that only point positions can change, not the number of points
  41065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41067. * @param name defines the name of the new line system
  41068. * @param options defines the options used to create the line system
  41069. * @param scene defines the hosting scene
  41070. * @returns a new line mesh
  41071. */
  41072. static CreateLines(name: string, options: {
  41073. points: Vector3[];
  41074. updatable?: boolean;
  41075. instance?: Nullable<LinesMesh>;
  41076. colors?: Color4[];
  41077. useVertexAlpha?: boolean;
  41078. }, scene?: Nullable<Scene>): LinesMesh;
  41079. /**
  41080. * Creates a dashed line mesh
  41081. * * 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
  41082. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41083. * * The parameter `points` is an array successive Vector3
  41084. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41085. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41086. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41087. * * 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
  41088. * * When updating an instance, remember that only point positions can change, not the number of points
  41089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41090. * @param name defines the name of the mesh
  41091. * @param options defines the options used to create the mesh
  41092. * @param scene defines the hosting scene
  41093. * @returns the dashed line mesh
  41094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41095. */
  41096. static CreateDashedLines(name: string, options: {
  41097. points: Vector3[];
  41098. dashSize?: number;
  41099. gapSize?: number;
  41100. dashNb?: number;
  41101. updatable?: boolean;
  41102. instance?: LinesMesh;
  41103. }, scene?: Nullable<Scene>): LinesMesh;
  41104. }
  41105. }
  41106. declare module BABYLON {
  41107. /**
  41108. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41109. * in order to better appreciate the issue one might have.
  41110. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41111. */
  41112. export class RayHelper {
  41113. /**
  41114. * Defines the ray we are currently tryin to visualize.
  41115. */
  41116. ray: Nullable<Ray>;
  41117. private _renderPoints;
  41118. private _renderLine;
  41119. private _renderFunction;
  41120. private _scene;
  41121. private _updateToMeshFunction;
  41122. private _attachedToMesh;
  41123. private _meshSpaceDirection;
  41124. private _meshSpaceOrigin;
  41125. /**
  41126. * Helper function to create a colored helper in a scene in one line.
  41127. * @param ray Defines the ray we are currently tryin to visualize
  41128. * @param scene Defines the scene the ray is used in
  41129. * @param color Defines the color we want to see the ray in
  41130. * @returns The newly created ray helper.
  41131. */
  41132. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41133. /**
  41134. * Instantiate a new ray helper.
  41135. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41136. * in order to better appreciate the issue one might have.
  41137. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41138. * @param ray Defines the ray we are currently tryin to visualize
  41139. */
  41140. constructor(ray: Ray);
  41141. /**
  41142. * Shows the ray we are willing to debug.
  41143. * @param scene Defines the scene the ray needs to be rendered in
  41144. * @param color Defines the color the ray needs to be rendered in
  41145. */
  41146. show(scene: Scene, color?: Color3): void;
  41147. /**
  41148. * Hides the ray we are debugging.
  41149. */
  41150. hide(): void;
  41151. private _render;
  41152. /**
  41153. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41154. * @param mesh Defines the mesh we want the helper attached to
  41155. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41156. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41157. * @param length Defines the length of the ray
  41158. */
  41159. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41160. /**
  41161. * Detach the ray helper from the mesh it has previously been attached to.
  41162. */
  41163. detachFromMesh(): void;
  41164. private _updateToMesh;
  41165. /**
  41166. * Dispose the helper and release its associated resources.
  41167. */
  41168. dispose(): void;
  41169. }
  41170. }
  41171. declare module BABYLON.Debug {
  41172. /**
  41173. * Class used to render a debug view of a given skeleton
  41174. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41175. */
  41176. export class SkeletonViewer {
  41177. /** defines the skeleton to render */
  41178. skeleton: Skeleton;
  41179. /** defines the mesh attached to the skeleton */
  41180. mesh: AbstractMesh;
  41181. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41182. autoUpdateBonesMatrices: boolean;
  41183. /** defines the rendering group id to use with the viewer */
  41184. renderingGroupId: number;
  41185. /** Gets or sets the color used to render the skeleton */
  41186. color: Color3;
  41187. private _scene;
  41188. private _debugLines;
  41189. private _debugMesh;
  41190. private _isEnabled;
  41191. private _renderFunction;
  41192. private _utilityLayer;
  41193. /**
  41194. * Returns the mesh used to render the bones
  41195. */
  41196. readonly debugMesh: Nullable<LinesMesh>;
  41197. /**
  41198. * Creates a new SkeletonViewer
  41199. * @param skeleton defines the skeleton to render
  41200. * @param mesh defines the mesh attached to the skeleton
  41201. * @param scene defines the hosting scene
  41202. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41203. * @param renderingGroupId defines the rendering group id to use with the viewer
  41204. */
  41205. constructor(
  41206. /** defines the skeleton to render */
  41207. skeleton: Skeleton,
  41208. /** defines the mesh attached to the skeleton */
  41209. mesh: AbstractMesh, scene: Scene,
  41210. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41211. autoUpdateBonesMatrices?: boolean,
  41212. /** defines the rendering group id to use with the viewer */
  41213. renderingGroupId?: number);
  41214. /** Gets or sets a boolean indicating if the viewer is enabled */
  41215. isEnabled: boolean;
  41216. private _getBonePosition;
  41217. private _getLinesForBonesWithLength;
  41218. private _getLinesForBonesNoLength;
  41219. /** Update the viewer to sync with current skeleton state */
  41220. update(): void;
  41221. /** Release associated resources */
  41222. dispose(): void;
  41223. }
  41224. }
  41225. declare module BABYLON {
  41226. /**
  41227. * Options to create the null engine
  41228. */
  41229. export class NullEngineOptions {
  41230. /**
  41231. * Render width (Default: 512)
  41232. */
  41233. renderWidth: number;
  41234. /**
  41235. * Render height (Default: 256)
  41236. */
  41237. renderHeight: number;
  41238. /**
  41239. * Texture size (Default: 512)
  41240. */
  41241. textureSize: number;
  41242. /**
  41243. * If delta time between frames should be constant
  41244. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41245. */
  41246. deterministicLockstep: boolean;
  41247. /**
  41248. * Maximum about of steps between frames (Default: 4)
  41249. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41250. */
  41251. lockstepMaxSteps: number;
  41252. }
  41253. /**
  41254. * The null engine class provides support for headless version of babylon.js.
  41255. * This can be used in server side scenario or for testing purposes
  41256. */
  41257. export class NullEngine extends Engine {
  41258. private _options;
  41259. /**
  41260. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41261. */
  41262. isDeterministicLockStep(): boolean;
  41263. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41264. getLockstepMaxSteps(): number;
  41265. /**
  41266. * Sets hardware scaling, used to save performance if needed
  41267. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41268. */
  41269. getHardwareScalingLevel(): number;
  41270. constructor(options?: NullEngineOptions);
  41271. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41272. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41273. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41274. getRenderWidth(useScreen?: boolean): number;
  41275. getRenderHeight(useScreen?: boolean): number;
  41276. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41277. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41278. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41279. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41280. bindSamplers(effect: Effect): void;
  41281. enableEffect(effect: Effect): void;
  41282. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41283. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41284. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41285. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41286. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41287. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41288. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41289. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41290. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41291. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41292. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41293. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41294. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41295. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41296. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41297. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41298. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41299. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41300. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41301. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41302. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41303. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41304. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41305. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41306. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41307. bindBuffers(vertexBuffers: {
  41308. [key: string]: VertexBuffer;
  41309. }, indexBuffer: DataBuffer, effect: Effect): void;
  41310. wipeCaches(bruteForce?: boolean): void;
  41311. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41312. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41313. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41314. /** @hidden */ private _createTexture(): WebGLTexture;
  41315. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  41316. 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;
  41317. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41318. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41319. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41321. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41322. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41323. areAllEffectsReady(): boolean;
  41324. /**
  41325. * @hidden
  41326. * Get the current error code of the webGL context
  41327. * @returns the error code
  41328. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41329. */
  41330. getError(): number;
  41331. /** @hidden */ private _getUnpackAlignement(): number;
  41332. /** @hidden */ private _unpackFlipY(value: boolean): void;
  41333. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41334. /**
  41335. * Updates a dynamic vertex buffer.
  41336. * @param vertexBuffer the vertex buffer to update
  41337. * @param data the data used to update the vertex buffer
  41338. * @param byteOffset the byte offset of the data (optional)
  41339. * @param byteLength the byte length of the data (optional)
  41340. */
  41341. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41342. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  41343. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  41344. releaseEffects(): void;
  41345. displayLoadingUI(): void;
  41346. hideLoadingUI(): void;
  41347. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41348. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41349. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41350. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /** @hidden */
  41355. export class _OcclusionDataStorage {
  41356. /** @hidden */
  41357. occlusionInternalRetryCounter: number;
  41358. /** @hidden */
  41359. isOcclusionQueryInProgress: boolean;
  41360. /** @hidden */
  41361. isOccluded: boolean;
  41362. /** @hidden */
  41363. occlusionRetryCount: number;
  41364. /** @hidden */
  41365. occlusionType: number;
  41366. /** @hidden */
  41367. occlusionQueryAlgorithmType: number;
  41368. }
  41369. interface Engine {
  41370. /**
  41371. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41372. * @return the new query
  41373. */
  41374. createQuery(): WebGLQuery;
  41375. /**
  41376. * Delete and release a webGL query
  41377. * @param query defines the query to delete
  41378. * @return the current engine
  41379. */
  41380. deleteQuery(query: WebGLQuery): Engine;
  41381. /**
  41382. * Check if a given query has resolved and got its value
  41383. * @param query defines the query to check
  41384. * @returns true if the query got its value
  41385. */
  41386. isQueryResultAvailable(query: WebGLQuery): boolean;
  41387. /**
  41388. * Gets the value of a given query
  41389. * @param query defines the query to check
  41390. * @returns the value of the query
  41391. */
  41392. getQueryResult(query: WebGLQuery): number;
  41393. /**
  41394. * Initiates an occlusion query
  41395. * @param algorithmType defines the algorithm to use
  41396. * @param query defines the query to use
  41397. * @returns the current engine
  41398. * @see http://doc.babylonjs.com/features/occlusionquery
  41399. */
  41400. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41401. /**
  41402. * Ends an occlusion query
  41403. * @see http://doc.babylonjs.com/features/occlusionquery
  41404. * @param algorithmType defines the algorithm to use
  41405. * @returns the current engine
  41406. */
  41407. endOcclusionQuery(algorithmType: number): Engine;
  41408. /**
  41409. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41410. * Please note that only one query can be issued at a time
  41411. * @returns a time token used to track the time span
  41412. */
  41413. startTimeQuery(): Nullable<_TimeToken>;
  41414. /**
  41415. * Ends a time query
  41416. * @param token defines the token used to measure the time span
  41417. * @returns the time spent (in ns)
  41418. */
  41419. endTimeQuery(token: _TimeToken): int;
  41420. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  41421. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  41422. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  41423. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  41424. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  41425. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  41426. }
  41427. interface AbstractMesh {
  41428. /**
  41429. * Backing filed
  41430. * @hidden
  41431. */ private __occlusionDataStorage: _OcclusionDataStorage;
  41432. /**
  41433. * Access property
  41434. * @hidden
  41435. */ private _occlusionDataStorage: _OcclusionDataStorage;
  41436. /**
  41437. * 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.
  41438. * The default value is -1 which means don't break the query and wait till the result
  41439. * @see http://doc.babylonjs.com/features/occlusionquery
  41440. */
  41441. occlusionRetryCount: number;
  41442. /**
  41443. * 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:
  41444. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41445. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41446. * * 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.
  41447. * @see http://doc.babylonjs.com/features/occlusionquery
  41448. */
  41449. occlusionType: number;
  41450. /**
  41451. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41452. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41453. * * 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.
  41454. * @see http://doc.babylonjs.com/features/occlusionquery
  41455. */
  41456. occlusionQueryAlgorithmType: number;
  41457. /**
  41458. * 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
  41459. * @see http://doc.babylonjs.com/features/occlusionquery
  41460. */
  41461. isOccluded: boolean;
  41462. /**
  41463. * Flag to check the progress status of the query
  41464. * @see http://doc.babylonjs.com/features/occlusionquery
  41465. */
  41466. isOcclusionQueryInProgress: boolean;
  41467. }
  41468. }
  41469. declare module BABYLON {
  41470. /** @hidden */
  41471. export var _forceTransformFeedbackToBundle: boolean;
  41472. interface Engine {
  41473. /**
  41474. * Creates a webGL transform feedback object
  41475. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41476. * @returns the webGL transform feedback object
  41477. */
  41478. createTransformFeedback(): WebGLTransformFeedback;
  41479. /**
  41480. * Delete a webGL transform feedback object
  41481. * @param value defines the webGL transform feedback object to delete
  41482. */
  41483. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41484. /**
  41485. * Bind a webGL transform feedback object to the webgl context
  41486. * @param value defines the webGL transform feedback object to bind
  41487. */
  41488. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41489. /**
  41490. * Begins a transform feedback operation
  41491. * @param usePoints defines if points or triangles must be used
  41492. */
  41493. beginTransformFeedback(usePoints: boolean): void;
  41494. /**
  41495. * Ends a transform feedback operation
  41496. */
  41497. endTransformFeedback(): void;
  41498. /**
  41499. * Specify the varyings to use with transform feedback
  41500. * @param program defines the associated webGL program
  41501. * @param value defines the list of strings representing the varying names
  41502. */
  41503. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41504. /**
  41505. * Bind a webGL buffer for a transform feedback operation
  41506. * @param value defines the webGL buffer to bind
  41507. */
  41508. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41509. }
  41510. }
  41511. declare module BABYLON {
  41512. /**
  41513. * Creation options of the multi render target texture.
  41514. */
  41515. export interface IMultiRenderTargetOptions {
  41516. /**
  41517. * Define if the texture needs to create mip maps after render.
  41518. */
  41519. generateMipMaps?: boolean;
  41520. /**
  41521. * Define the types of all the draw buffers we want to create
  41522. */
  41523. types?: number[];
  41524. /**
  41525. * Define the sampling modes of all the draw buffers we want to create
  41526. */
  41527. samplingModes?: number[];
  41528. /**
  41529. * Define if a depth buffer is required
  41530. */
  41531. generateDepthBuffer?: boolean;
  41532. /**
  41533. * Define if a stencil buffer is required
  41534. */
  41535. generateStencilBuffer?: boolean;
  41536. /**
  41537. * Define if a depth texture is required instead of a depth buffer
  41538. */
  41539. generateDepthTexture?: boolean;
  41540. /**
  41541. * Define the number of desired draw buffers
  41542. */
  41543. textureCount?: number;
  41544. /**
  41545. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41546. */
  41547. doNotChangeAspectRatio?: boolean;
  41548. /**
  41549. * Define the default type of the buffers we are creating
  41550. */
  41551. defaultType?: number;
  41552. }
  41553. /**
  41554. * A multi render target, like a render target provides the ability to render to a texture.
  41555. * Unlike the render target, it can render to several draw buffers in one draw.
  41556. * This is specially interesting in deferred rendering or for any effects requiring more than
  41557. * just one color from a single pass.
  41558. */
  41559. export class MultiRenderTarget extends RenderTargetTexture {
  41560. private _internalTextures;
  41561. private _textures;
  41562. private _multiRenderTargetOptions;
  41563. /**
  41564. * Get if draw buffers are currently supported by the used hardware and browser.
  41565. */
  41566. readonly isSupported: boolean;
  41567. /**
  41568. * Get the list of textures generated by the multi render target.
  41569. */
  41570. readonly textures: Texture[];
  41571. /**
  41572. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41573. */
  41574. readonly depthTexture: Texture;
  41575. /**
  41576. * Set the wrapping mode on U of all the textures we are rendering to.
  41577. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41578. */
  41579. wrapU: number;
  41580. /**
  41581. * Set the wrapping mode on V of all the textures we are rendering to.
  41582. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41583. */
  41584. wrapV: number;
  41585. /**
  41586. * Instantiate a new multi render target texture.
  41587. * A multi render target, like a render target provides the ability to render to a texture.
  41588. * Unlike the render target, it can render to several draw buffers in one draw.
  41589. * This is specially interesting in deferred rendering or for any effects requiring more than
  41590. * just one color from a single pass.
  41591. * @param name Define the name of the texture
  41592. * @param size Define the size of the buffers to render to
  41593. * @param count Define the number of target we are rendering into
  41594. * @param scene Define the scene the texture belongs to
  41595. * @param options Define the options used to create the multi render target
  41596. */
  41597. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41598. /** @hidden */ private _rebuild(): void;
  41599. private _createInternalTextures;
  41600. private _createTextures;
  41601. /**
  41602. * Define the number of samples used if MSAA is enabled.
  41603. */
  41604. samples: number;
  41605. /**
  41606. * Resize all the textures in the multi render target.
  41607. * Be carrefull as it will recreate all the data in the new texture.
  41608. * @param size Define the new size
  41609. */
  41610. resize(size: any): void;
  41611. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41612. /**
  41613. * Dispose the render targets and their associated resources
  41614. */
  41615. dispose(): void;
  41616. /**
  41617. * Release all the underlying texture used as draw buffers.
  41618. */
  41619. releaseInternalTextures(): void;
  41620. }
  41621. }
  41622. declare module BABYLON {
  41623. interface Engine {
  41624. /**
  41625. * Unbind a list of render target textures from the webGL context
  41626. * This is used only when drawBuffer extension or webGL2 are active
  41627. * @param textures defines the render target textures to unbind
  41628. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41629. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41630. */
  41631. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41632. /**
  41633. * Create a multi render target texture
  41634. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41635. * @param size defines the size of the texture
  41636. * @param options defines the creation options
  41637. * @returns the cube texture as an InternalTexture
  41638. */
  41639. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41640. /**
  41641. * Update the sample count for a given multiple render target texture
  41642. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41643. * @param textures defines the textures to update
  41644. * @param samples defines the sample count to set
  41645. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41646. */
  41647. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41648. }
  41649. }
  41650. declare module BABYLON {
  41651. /**
  41652. * Gather the list of clipboard event types as constants.
  41653. */
  41654. export class ClipboardEventTypes {
  41655. /**
  41656. * The clipboard event is fired when a copy command is active (pressed).
  41657. */
  41658. static readonly COPY: number;
  41659. /**
  41660. * The clipboard event is fired when a cut command is active (pressed).
  41661. */
  41662. static readonly CUT: number;
  41663. /**
  41664. * The clipboard event is fired when a paste command is active (pressed).
  41665. */
  41666. static readonly PASTE: number;
  41667. }
  41668. /**
  41669. * This class is used to store clipboard related info for the onClipboardObservable event.
  41670. */
  41671. export class ClipboardInfo {
  41672. /**
  41673. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41674. */
  41675. type: number;
  41676. /**
  41677. * Defines the related dom event
  41678. */
  41679. event: ClipboardEvent;
  41680. /**
  41681. *Creates an instance of ClipboardInfo.
  41682. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41683. * @param event Defines the related dom event
  41684. */
  41685. constructor(
  41686. /**
  41687. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41688. */
  41689. type: number,
  41690. /**
  41691. * Defines the related dom event
  41692. */
  41693. event: ClipboardEvent);
  41694. /**
  41695. * Get the clipboard event's type from the keycode.
  41696. * @param keyCode Defines the keyCode for the current keyboard event.
  41697. * @return {number}
  41698. */
  41699. static GetTypeFromCharacter(keyCode: number): number;
  41700. }
  41701. }
  41702. declare module BABYLON {
  41703. /**
  41704. * Class used to represent data loading progression
  41705. */
  41706. export class SceneLoaderProgressEvent {
  41707. /** defines if data length to load can be evaluated */
  41708. readonly lengthComputable: boolean;
  41709. /** defines the loaded data length */
  41710. readonly loaded: number;
  41711. /** defines the data length to load */
  41712. readonly total: number;
  41713. /**
  41714. * Create a new progress event
  41715. * @param lengthComputable defines if data length to load can be evaluated
  41716. * @param loaded defines the loaded data length
  41717. * @param total defines the data length to load
  41718. */
  41719. constructor(
  41720. /** defines if data length to load can be evaluated */
  41721. lengthComputable: boolean,
  41722. /** defines the loaded data length */
  41723. loaded: number,
  41724. /** defines the data length to load */
  41725. total: number);
  41726. /**
  41727. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41728. * @param event defines the source event
  41729. * @returns a new SceneLoaderProgressEvent
  41730. */
  41731. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41732. }
  41733. /**
  41734. * Interface used by SceneLoader plugins to define supported file extensions
  41735. */
  41736. export interface ISceneLoaderPluginExtensions {
  41737. /**
  41738. * Defines the list of supported extensions
  41739. */
  41740. [extension: string]: {
  41741. isBinary: boolean;
  41742. };
  41743. }
  41744. /**
  41745. * Interface used by SceneLoader plugin factory
  41746. */
  41747. export interface ISceneLoaderPluginFactory {
  41748. /**
  41749. * Defines the name of the factory
  41750. */
  41751. name: string;
  41752. /**
  41753. * Function called to create a new plugin
  41754. * @return the new plugin
  41755. */
  41756. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41757. /**
  41758. * Boolean indicating if the plugin can direct load specific data
  41759. */
  41760. canDirectLoad?: (data: string) => boolean;
  41761. }
  41762. /**
  41763. * Interface used to define a SceneLoader plugin
  41764. */
  41765. export interface ISceneLoaderPlugin {
  41766. /**
  41767. * The friendly name of this plugin.
  41768. */
  41769. name: string;
  41770. /**
  41771. * The file extensions supported by this plugin.
  41772. */
  41773. extensions: string | ISceneLoaderPluginExtensions;
  41774. /**
  41775. * Import meshes into a scene.
  41776. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41777. * @param scene The scene to import into
  41778. * @param data The data to import
  41779. * @param rootUrl The root url for scene and resources
  41780. * @param meshes The meshes array to import into
  41781. * @param particleSystems The particle systems array to import into
  41782. * @param skeletons The skeletons array to import into
  41783. * @param onError The callback when import fails
  41784. * @returns True if successful or false otherwise
  41785. */
  41786. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41787. /**
  41788. * Load into a scene.
  41789. * @param scene The scene to load into
  41790. * @param data The data to import
  41791. * @param rootUrl The root url for scene and resources
  41792. * @param onError The callback when import fails
  41793. * @returns true if successful or false otherwise
  41794. */
  41795. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41796. /**
  41797. * The callback that returns true if the data can be directly loaded.
  41798. */
  41799. canDirectLoad?: (data: string) => boolean;
  41800. /**
  41801. * The callback that allows custom handling of the root url based on the response url.
  41802. */
  41803. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41804. /**
  41805. * Load into an asset container.
  41806. * @param scene The scene to load into
  41807. * @param data The data to import
  41808. * @param rootUrl The root url for scene and resources
  41809. * @param onError The callback when import fails
  41810. * @returns The loaded asset container
  41811. */
  41812. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41813. }
  41814. /**
  41815. * Interface used to define an async SceneLoader plugin
  41816. */
  41817. export interface ISceneLoaderPluginAsync {
  41818. /**
  41819. * The friendly name of this plugin.
  41820. */
  41821. name: string;
  41822. /**
  41823. * The file extensions supported by this plugin.
  41824. */
  41825. extensions: string | ISceneLoaderPluginExtensions;
  41826. /**
  41827. * Import meshes into a scene.
  41828. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41829. * @param scene The scene to import into
  41830. * @param data The data to import
  41831. * @param rootUrl The root url for scene and resources
  41832. * @param onProgress The callback when the load progresses
  41833. * @param fileName Defines the name of the file to load
  41834. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41835. */
  41836. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41837. meshes: AbstractMesh[];
  41838. particleSystems: IParticleSystem[];
  41839. skeletons: Skeleton[];
  41840. animationGroups: AnimationGroup[];
  41841. }>;
  41842. /**
  41843. * Load into a scene.
  41844. * @param scene The scene to load into
  41845. * @param data The data to import
  41846. * @param rootUrl The root url for scene and resources
  41847. * @param onProgress The callback when the load progresses
  41848. * @param fileName Defines the name of the file to load
  41849. * @returns Nothing
  41850. */
  41851. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41852. /**
  41853. * The callback that returns true if the data can be directly loaded.
  41854. */
  41855. canDirectLoad?: (data: string) => boolean;
  41856. /**
  41857. * The callback that allows custom handling of the root url based on the response url.
  41858. */
  41859. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41860. /**
  41861. * Load into an asset container.
  41862. * @param scene The scene to load into
  41863. * @param data The data to import
  41864. * @param rootUrl The root url for scene and resources
  41865. * @param onProgress The callback when the load progresses
  41866. * @param fileName Defines the name of the file to load
  41867. * @returns The loaded asset container
  41868. */
  41869. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41870. }
  41871. /**
  41872. * Class used to load scene from various file formats using registered plugins
  41873. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41874. */
  41875. export class SceneLoader {
  41876. /**
  41877. * No logging while loading
  41878. */
  41879. static readonly NO_LOGGING: number;
  41880. /**
  41881. * Minimal logging while loading
  41882. */
  41883. static readonly MINIMAL_LOGGING: number;
  41884. /**
  41885. * Summary logging while loading
  41886. */
  41887. static readonly SUMMARY_LOGGING: number;
  41888. /**
  41889. * Detailled logging while loading
  41890. */
  41891. static readonly DETAILED_LOGGING: number;
  41892. /**
  41893. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41894. */
  41895. static ForceFullSceneLoadingForIncremental: boolean;
  41896. /**
  41897. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41898. */
  41899. static ShowLoadingScreen: boolean;
  41900. /**
  41901. * Defines the current logging level (while loading the scene)
  41902. * @ignorenaming
  41903. */
  41904. static loggingLevel: number;
  41905. /**
  41906. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41907. */
  41908. static CleanBoneMatrixWeights: boolean;
  41909. /**
  41910. * Event raised when a plugin is used to load a scene
  41911. */
  41912. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41913. private static _registeredPlugins;
  41914. private static _getDefaultPlugin;
  41915. private static _getPluginForExtension;
  41916. private static _getPluginForDirectLoad;
  41917. private static _getPluginForFilename;
  41918. private static _getDirectLoad;
  41919. private static _loadData;
  41920. private static _getFileInfo;
  41921. /**
  41922. * Gets a plugin that can load the given extension
  41923. * @param extension defines the extension to load
  41924. * @returns a plugin or null if none works
  41925. */
  41926. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41927. /**
  41928. * Gets a boolean indicating that the given extension can be loaded
  41929. * @param extension defines the extension to load
  41930. * @returns true if the extension is supported
  41931. */
  41932. static IsPluginForExtensionAvailable(extension: string): boolean;
  41933. /**
  41934. * Adds a new plugin to the list of registered plugins
  41935. * @param plugin defines the plugin to add
  41936. */
  41937. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41938. /**
  41939. * Import meshes into a scene
  41940. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41941. * @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)
  41942. * @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)
  41943. * @param scene the instance of BABYLON.Scene to append to
  41944. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41945. * @param onProgress a callback with a progress event for each file being loaded
  41946. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41947. * @param pluginExtension the extension used to determine the plugin
  41948. * @returns The loaded plugin
  41949. */
  41950. 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>;
  41951. /**
  41952. * Import meshes into a scene
  41953. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41954. * @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)
  41955. * @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)
  41956. * @param scene the instance of BABYLON.Scene to append to
  41957. * @param onProgress a callback with a progress event for each file being loaded
  41958. * @param pluginExtension the extension used to determine the plugin
  41959. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41960. */
  41961. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41962. meshes: AbstractMesh[];
  41963. particleSystems: IParticleSystem[];
  41964. skeletons: Skeleton[];
  41965. animationGroups: AnimationGroup[];
  41966. }>;
  41967. /**
  41968. * Load a scene
  41969. * @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)
  41970. * @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)
  41971. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41972. * @param onSuccess a callback with the scene when import succeeds
  41973. * @param onProgress a callback with a progress event for each file being loaded
  41974. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41975. * @param pluginExtension the extension used to determine the plugin
  41976. * @returns The loaded plugin
  41977. */
  41978. 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>;
  41979. /**
  41980. * Load a scene
  41981. * @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)
  41982. * @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)
  41983. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41984. * @param onProgress a callback with a progress event for each file being loaded
  41985. * @param pluginExtension the extension used to determine the plugin
  41986. * @returns The loaded scene
  41987. */
  41988. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41989. /**
  41990. * Append a scene
  41991. * @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)
  41992. * @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)
  41993. * @param scene is the instance of BABYLON.Scene to append to
  41994. * @param onSuccess a callback with the scene when import succeeds
  41995. * @param onProgress a callback with a progress event for each file being loaded
  41996. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41997. * @param pluginExtension the extension used to determine the plugin
  41998. * @returns The loaded plugin
  41999. */
  42000. 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>;
  42001. /**
  42002. * Append a scene
  42003. * @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)
  42004. * @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)
  42005. * @param scene is the instance of BABYLON.Scene to append to
  42006. * @param onProgress a callback with a progress event for each file being loaded
  42007. * @param pluginExtension the extension used to determine the plugin
  42008. * @returns The given scene
  42009. */
  42010. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42011. /**
  42012. * Load a scene into an asset container
  42013. * @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)
  42014. * @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)
  42015. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42016. * @param onSuccess a callback with the scene when import succeeds
  42017. * @param onProgress a callback with a progress event for each file being loaded
  42018. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42019. * @param pluginExtension the extension used to determine the plugin
  42020. * @returns The loaded plugin
  42021. */
  42022. 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>;
  42023. /**
  42024. * Load a scene into an asset container
  42025. * @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)
  42026. * @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)
  42027. * @param scene is the instance of Scene to append to
  42028. * @param onProgress a callback with a progress event for each file being loaded
  42029. * @param pluginExtension the extension used to determine the plugin
  42030. * @returns The loaded asset container
  42031. */
  42032. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42033. }
  42034. }
  42035. declare module BABYLON {
  42036. /**
  42037. * Google Daydream controller
  42038. */
  42039. export class DaydreamController extends WebVRController {
  42040. /**
  42041. * Base Url for the controller model.
  42042. */
  42043. static MODEL_BASE_URL: string;
  42044. /**
  42045. * File name for the controller model.
  42046. */
  42047. static MODEL_FILENAME: string;
  42048. /**
  42049. * Gamepad Id prefix used to identify Daydream Controller.
  42050. */
  42051. static readonly GAMEPAD_ID_PREFIX: string;
  42052. /**
  42053. * Creates a new DaydreamController from a gamepad
  42054. * @param vrGamepad the gamepad that the controller should be created from
  42055. */
  42056. constructor(vrGamepad: any);
  42057. /**
  42058. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42059. * @param scene scene in which to add meshes
  42060. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42061. */
  42062. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42063. /**
  42064. * Called once for each button that changed state since the last frame
  42065. * @param buttonIdx Which button index changed
  42066. * @param state New state of the button
  42067. * @param changes Which properties on the state changed since last frame
  42068. */
  42069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42070. }
  42071. }
  42072. declare module BABYLON {
  42073. /**
  42074. * Gear VR Controller
  42075. */
  42076. export class GearVRController extends WebVRController {
  42077. /**
  42078. * Base Url for the controller model.
  42079. */
  42080. static MODEL_BASE_URL: string;
  42081. /**
  42082. * File name for the controller model.
  42083. */
  42084. static MODEL_FILENAME: string;
  42085. /**
  42086. * Gamepad Id prefix used to identify this controller.
  42087. */
  42088. static readonly GAMEPAD_ID_PREFIX: string;
  42089. private readonly _buttonIndexToObservableNameMap;
  42090. /**
  42091. * Creates a new GearVRController from a gamepad
  42092. * @param vrGamepad the gamepad that the controller should be created from
  42093. */
  42094. constructor(vrGamepad: any);
  42095. /**
  42096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42097. * @param scene scene in which to add meshes
  42098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42099. */
  42100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42101. /**
  42102. * Called once for each button that changed state since the last frame
  42103. * @param buttonIdx Which button index changed
  42104. * @param state New state of the button
  42105. * @param changes Which properties on the state changed since last frame
  42106. */
  42107. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42108. }
  42109. }
  42110. declare module BABYLON {
  42111. /**
  42112. * Generic Controller
  42113. */
  42114. export class GenericController extends WebVRController {
  42115. /**
  42116. * Base Url for the controller model.
  42117. */
  42118. static readonly MODEL_BASE_URL: string;
  42119. /**
  42120. * File name for the controller model.
  42121. */
  42122. static readonly MODEL_FILENAME: string;
  42123. /**
  42124. * Creates a new GenericController from a gamepad
  42125. * @param vrGamepad the gamepad that the controller should be created from
  42126. */
  42127. constructor(vrGamepad: any);
  42128. /**
  42129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42130. * @param scene scene in which to add meshes
  42131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42132. */
  42133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42134. /**
  42135. * Called once for each button that changed state since the last frame
  42136. * @param buttonIdx Which button index changed
  42137. * @param state New state of the button
  42138. * @param changes Which properties on the state changed since last frame
  42139. */
  42140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42141. }
  42142. }
  42143. declare module BABYLON {
  42144. /**
  42145. * Oculus Touch Controller
  42146. */
  42147. export class OculusTouchController extends WebVRController {
  42148. /**
  42149. * Base Url for the controller model.
  42150. */
  42151. static MODEL_BASE_URL: string;
  42152. /**
  42153. * File name for the left controller model.
  42154. */
  42155. static MODEL_LEFT_FILENAME: string;
  42156. /**
  42157. * File name for the right controller model.
  42158. */
  42159. static MODEL_RIGHT_FILENAME: string;
  42160. /**
  42161. * Base Url for the Quest controller model.
  42162. */
  42163. static QUEST_MODEL_BASE_URL: string;
  42164. /**
  42165. * @hidden
  42166. * If the controllers are running on a device that needs the updated Quest controller models
  42167. */ private static _IsQuest: boolean;
  42168. /**
  42169. * Fired when the secondary trigger on this controller is modified
  42170. */
  42171. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42172. /**
  42173. * Fired when the thumb rest on this controller is modified
  42174. */
  42175. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42176. /**
  42177. * Creates a new OculusTouchController from a gamepad
  42178. * @param vrGamepad the gamepad that the controller should be created from
  42179. */
  42180. constructor(vrGamepad: any);
  42181. /**
  42182. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42183. * @param scene scene in which to add meshes
  42184. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42185. */
  42186. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42187. /**
  42188. * Fired when the A button on this controller is modified
  42189. */
  42190. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42191. /**
  42192. * Fired when the B button on this controller is modified
  42193. */
  42194. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42195. /**
  42196. * Fired when the X button on this controller is modified
  42197. */
  42198. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42199. /**
  42200. * Fired when the Y button on this controller is modified
  42201. */
  42202. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42203. /**
  42204. * Called once for each button that changed state since the last frame
  42205. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42206. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42207. * 2) secondary trigger (same)
  42208. * 3) A (right) X (left), touch, pressed = value
  42209. * 4) B / Y
  42210. * 5) thumb rest
  42211. * @param buttonIdx Which button index changed
  42212. * @param state New state of the button
  42213. * @param changes Which properties on the state changed since last frame
  42214. */
  42215. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Vive Controller
  42221. */
  42222. export class ViveController extends WebVRController {
  42223. /**
  42224. * Base Url for the controller model.
  42225. */
  42226. static MODEL_BASE_URL: string;
  42227. /**
  42228. * File name for the controller model.
  42229. */
  42230. static MODEL_FILENAME: string;
  42231. /**
  42232. * Creates a new ViveController from a gamepad
  42233. * @param vrGamepad the gamepad that the controller should be created from
  42234. */
  42235. constructor(vrGamepad: any);
  42236. /**
  42237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42238. * @param scene scene in which to add meshes
  42239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42240. */
  42241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42242. /**
  42243. * Fired when the left button on this controller is modified
  42244. */
  42245. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42246. /**
  42247. * Fired when the right button on this controller is modified
  42248. */
  42249. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42250. /**
  42251. * Fired when the menu button on this controller is modified
  42252. */
  42253. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42254. /**
  42255. * Called once for each button that changed state since the last frame
  42256. * Vive mapping:
  42257. * 0: touchpad
  42258. * 1: trigger
  42259. * 2: left AND right buttons
  42260. * 3: menu button
  42261. * @param buttonIdx Which button index changed
  42262. * @param state New state of the button
  42263. * @param changes Which properties on the state changed since last frame
  42264. */
  42265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42266. }
  42267. }
  42268. declare module BABYLON {
  42269. /**
  42270. * Defines the WindowsMotionController object that the state of the windows motion controller
  42271. */
  42272. export class WindowsMotionController extends WebVRController {
  42273. /**
  42274. * The base url used to load the left and right controller models
  42275. */
  42276. static MODEL_BASE_URL: string;
  42277. /**
  42278. * The name of the left controller model file
  42279. */
  42280. static MODEL_LEFT_FILENAME: string;
  42281. /**
  42282. * The name of the right controller model file
  42283. */
  42284. static MODEL_RIGHT_FILENAME: string;
  42285. /**
  42286. * The controller name prefix for this controller type
  42287. */
  42288. static readonly GAMEPAD_ID_PREFIX: string;
  42289. /**
  42290. * The controller id pattern for this controller type
  42291. */
  42292. private static readonly GAMEPAD_ID_PATTERN;
  42293. private _loadedMeshInfo;
  42294. private readonly _mapping;
  42295. /**
  42296. * Fired when the trackpad on this controller is clicked
  42297. */
  42298. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42299. /**
  42300. * Fired when the trackpad on this controller is modified
  42301. */
  42302. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42303. /**
  42304. * The current x and y values of this controller's trackpad
  42305. */
  42306. trackpad: StickValues;
  42307. /**
  42308. * Creates a new WindowsMotionController from a gamepad
  42309. * @param vrGamepad the gamepad that the controller should be created from
  42310. */
  42311. constructor(vrGamepad: any);
  42312. /**
  42313. * Fired when the trigger on this controller is modified
  42314. */
  42315. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42316. /**
  42317. * Fired when the menu button on this controller is modified
  42318. */
  42319. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Fired when the grip button on this controller is modified
  42322. */
  42323. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42324. /**
  42325. * Fired when the thumbstick button on this controller is modified
  42326. */
  42327. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42328. /**
  42329. * Fired when the touchpad button on this controller is modified
  42330. */
  42331. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42332. /**
  42333. * Fired when the touchpad values on this controller are modified
  42334. */
  42335. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42336. private _updateTrackpad;
  42337. /**
  42338. * Called once per frame by the engine.
  42339. */
  42340. update(): void;
  42341. /**
  42342. * Called once for each button that changed state since the last frame
  42343. * @param buttonIdx Which button index changed
  42344. * @param state New state of the button
  42345. * @param changes Which properties on the state changed since last frame
  42346. */
  42347. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42348. /**
  42349. * Moves the buttons on the controller mesh based on their current state
  42350. * @param buttonName the name of the button to move
  42351. * @param buttonValue the value of the button which determines the buttons new position
  42352. */
  42353. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42354. /**
  42355. * Moves the axis on the controller mesh based on its current state
  42356. * @param axis the index of the axis
  42357. * @param axisValue the value of the axis which determines the meshes new position
  42358. * @hidden
  42359. */
  42360. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42361. /**
  42362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42363. * @param scene scene in which to add meshes
  42364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42365. */
  42366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42367. /**
  42368. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42369. * can be transformed by button presses and axes values, based on this._mapping.
  42370. *
  42371. * @param scene scene in which the meshes exist
  42372. * @param meshes list of meshes that make up the controller model to process
  42373. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42374. */
  42375. private processModel;
  42376. private createMeshInfo;
  42377. /**
  42378. * Gets the ray of the controller in the direction the controller is pointing
  42379. * @param length the length the resulting ray should be
  42380. * @returns a ray in the direction the controller is pointing
  42381. */
  42382. getForwardRay(length?: number): Ray;
  42383. /**
  42384. * Disposes of the controller
  42385. */
  42386. dispose(): void;
  42387. }
  42388. }
  42389. declare module BABYLON {
  42390. /**
  42391. * Class containing static functions to help procedurally build meshes
  42392. */
  42393. export class PolyhedronBuilder {
  42394. /**
  42395. * Creates a polyhedron mesh
  42396. * * 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
  42397. * * The parameter `size` (positive float, default 1) sets the polygon size
  42398. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42399. * * 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`
  42400. * * 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
  42401. * * 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)`)
  42402. * * 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
  42403. * * 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
  42404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42405. * * 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
  42406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42407. * @param name defines the name of the mesh
  42408. * @param options defines the options used to create the mesh
  42409. * @param scene defines the hosting scene
  42410. * @returns the polyhedron mesh
  42411. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42412. */
  42413. static CreatePolyhedron(name: string, options: {
  42414. type?: number;
  42415. size?: number;
  42416. sizeX?: number;
  42417. sizeY?: number;
  42418. sizeZ?: number;
  42419. custom?: any;
  42420. faceUV?: Vector4[];
  42421. faceColors?: Color4[];
  42422. flat?: boolean;
  42423. updatable?: boolean;
  42424. sideOrientation?: number;
  42425. frontUVs?: Vector4;
  42426. backUVs?: Vector4;
  42427. }, scene?: Nullable<Scene>): Mesh;
  42428. }
  42429. }
  42430. declare module BABYLON {
  42431. /**
  42432. * Gizmo that enables scaling a mesh along 3 axis
  42433. */
  42434. export class ScaleGizmo extends Gizmo {
  42435. /**
  42436. * Internal gizmo used for interactions on the x axis
  42437. */
  42438. xGizmo: AxisScaleGizmo;
  42439. /**
  42440. * Internal gizmo used for interactions on the y axis
  42441. */
  42442. yGizmo: AxisScaleGizmo;
  42443. /**
  42444. * Internal gizmo used for interactions on the z axis
  42445. */
  42446. zGizmo: AxisScaleGizmo;
  42447. /**
  42448. * Internal gizmo used to scale all axis equally
  42449. */
  42450. uniformScaleGizmo: AxisScaleGizmo;
  42451. private _meshAttached;
  42452. private _updateGizmoRotationToMatchAttachedMesh;
  42453. private _snapDistance;
  42454. private _scaleRatio;
  42455. private _uniformScalingMesh;
  42456. private _octahedron;
  42457. /** Fires an event when any of it's sub gizmos are dragged */
  42458. onDragStartObservable: Observable<{}>;
  42459. /** Fires an event when any of it's sub gizmos are released from dragging */
  42460. onDragEndObservable: Observable<{}>;
  42461. attachedMesh: Nullable<AbstractMesh>;
  42462. /**
  42463. * Creates a ScaleGizmo
  42464. * @param gizmoLayer The utility layer the gizmo will be added to
  42465. */
  42466. constructor(gizmoLayer?: UtilityLayerRenderer);
  42467. updateGizmoRotationToMatchAttachedMesh: boolean;
  42468. /**
  42469. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42470. */
  42471. snapDistance: number;
  42472. /**
  42473. * Ratio for the scale of the gizmo (Default: 1)
  42474. */
  42475. scaleRatio: number;
  42476. /**
  42477. * Disposes of the gizmo
  42478. */
  42479. dispose(): void;
  42480. }
  42481. }
  42482. declare module BABYLON {
  42483. /**
  42484. * Single axis scale gizmo
  42485. */
  42486. export class AxisScaleGizmo extends Gizmo {
  42487. /**
  42488. * Drag behavior responsible for the gizmos dragging interactions
  42489. */
  42490. dragBehavior: PointerDragBehavior;
  42491. private _pointerObserver;
  42492. /**
  42493. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42494. */
  42495. snapDistance: number;
  42496. /**
  42497. * Event that fires each time the gizmo snaps to a new location.
  42498. * * snapDistance is the the change in distance
  42499. */
  42500. onSnapObservable: Observable<{
  42501. snapDistance: number;
  42502. }>;
  42503. /**
  42504. * If the scaling operation should be done on all axis (default: false)
  42505. */
  42506. uniformScaling: boolean;
  42507. private _isEnabled;
  42508. private _parent;
  42509. private _arrow;
  42510. private _coloredMaterial;
  42511. private _hoverMaterial;
  42512. /**
  42513. * Creates an AxisScaleGizmo
  42514. * @param gizmoLayer The utility layer the gizmo will be added to
  42515. * @param dragAxis The axis which the gizmo will be able to scale on
  42516. * @param color The color of the gizmo
  42517. */
  42518. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  42519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42520. /**
  42521. * If the gizmo is enabled
  42522. */
  42523. isEnabled: boolean;
  42524. /**
  42525. * Disposes of the gizmo
  42526. */
  42527. dispose(): void;
  42528. /**
  42529. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42530. * @param mesh The mesh to replace the default mesh of the gizmo
  42531. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42532. */
  42533. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42534. }
  42535. }
  42536. declare module BABYLON {
  42537. /**
  42538. * Bounding box gizmo
  42539. */
  42540. export class BoundingBoxGizmo extends Gizmo {
  42541. private _lineBoundingBox;
  42542. private _rotateSpheresParent;
  42543. private _scaleBoxesParent;
  42544. private _boundingDimensions;
  42545. private _renderObserver;
  42546. private _pointerObserver;
  42547. private _scaleDragSpeed;
  42548. private _tmpQuaternion;
  42549. private _tmpVector;
  42550. private _tmpRotationMatrix;
  42551. /**
  42552. * 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)
  42553. */
  42554. ignoreChildren: boolean;
  42555. /**
  42556. * 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)
  42557. */
  42558. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42559. /**
  42560. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42561. */
  42562. rotationSphereSize: number;
  42563. /**
  42564. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42565. */
  42566. scaleBoxSize: number;
  42567. /**
  42568. * 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)
  42569. */
  42570. fixedDragMeshScreenSize: boolean;
  42571. /**
  42572. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42573. */
  42574. fixedDragMeshScreenSizeDistanceFactor: number;
  42575. /**
  42576. * Fired when a rotation sphere or scale box is dragged
  42577. */
  42578. onDragStartObservable: Observable<{}>;
  42579. /**
  42580. * Fired when a scale box is dragged
  42581. */
  42582. onScaleBoxDragObservable: Observable<{}>;
  42583. /**
  42584. * Fired when a scale box drag is ended
  42585. */
  42586. onScaleBoxDragEndObservable: Observable<{}>;
  42587. /**
  42588. * Fired when a rotation sphere is dragged
  42589. */
  42590. onRotationSphereDragObservable: Observable<{}>;
  42591. /**
  42592. * Fired when a rotation sphere drag is ended
  42593. */
  42594. onRotationSphereDragEndObservable: Observable<{}>;
  42595. /**
  42596. * 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)
  42597. */
  42598. scalePivot: Nullable<Vector3>;
  42599. /**
  42600. * Mesh used as a pivot to rotate the attached mesh
  42601. */
  42602. private _anchorMesh;
  42603. private _existingMeshScale;
  42604. private _dragMesh;
  42605. private pointerDragBehavior;
  42606. private coloredMaterial;
  42607. private hoverColoredMaterial;
  42608. /**
  42609. * Sets the color of the bounding box gizmo
  42610. * @param color the color to set
  42611. */
  42612. setColor(color: Color3): void;
  42613. /**
  42614. * Creates an BoundingBoxGizmo
  42615. * @param gizmoLayer The utility layer the gizmo will be added to
  42616. * @param color The color of the gizmo
  42617. */
  42618. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42619. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42620. private _selectNode;
  42621. /**
  42622. * Updates the bounding box information for the Gizmo
  42623. */
  42624. updateBoundingBox(): void;
  42625. private _updateRotationSpheres;
  42626. private _updateScaleBoxes;
  42627. /**
  42628. * Enables rotation on the specified axis and disables rotation on the others
  42629. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42630. */
  42631. setEnabledRotationAxis(axis: string): void;
  42632. /**
  42633. * Enables/disables scaling
  42634. * @param enable if scaling should be enabled
  42635. */
  42636. setEnabledScaling(enable: boolean): void;
  42637. private _updateDummy;
  42638. /**
  42639. * Enables a pointer drag behavior on the bounding box of the gizmo
  42640. */
  42641. enableDragBehavior(): void;
  42642. /**
  42643. * Disposes of the gizmo
  42644. */
  42645. dispose(): void;
  42646. /**
  42647. * 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)
  42648. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42649. * @returns the bounding box mesh with the passed in mesh as a child
  42650. */
  42651. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42652. /**
  42653. * CustomMeshes are not supported by this gizmo
  42654. * @param mesh The mesh to replace the default mesh of the gizmo
  42655. */
  42656. setCustomMesh(mesh: Mesh): void;
  42657. }
  42658. }
  42659. declare module BABYLON {
  42660. /**
  42661. * Single plane rotation gizmo
  42662. */
  42663. export class PlaneRotationGizmo extends Gizmo {
  42664. /**
  42665. * Drag behavior responsible for the gizmos dragging interactions
  42666. */
  42667. dragBehavior: PointerDragBehavior;
  42668. private _pointerObserver;
  42669. /**
  42670. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42671. */
  42672. snapDistance: number;
  42673. /**
  42674. * Event that fires each time the gizmo snaps to a new location.
  42675. * * snapDistance is the the change in distance
  42676. */
  42677. onSnapObservable: Observable<{
  42678. snapDistance: number;
  42679. }>;
  42680. private _isEnabled;
  42681. private _parent;
  42682. /**
  42683. * Creates a PlaneRotationGizmo
  42684. * @param gizmoLayer The utility layer the gizmo will be added to
  42685. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42686. * @param color The color of the gizmo
  42687. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42688. */
  42689. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  42690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42691. /**
  42692. * If the gizmo is enabled
  42693. */
  42694. isEnabled: boolean;
  42695. /**
  42696. * Disposes of the gizmo
  42697. */
  42698. dispose(): void;
  42699. }
  42700. }
  42701. declare module BABYLON {
  42702. /**
  42703. * Gizmo that enables rotating a mesh along 3 axis
  42704. */
  42705. export class RotationGizmo extends Gizmo {
  42706. /**
  42707. * Internal gizmo used for interactions on the x axis
  42708. */
  42709. xGizmo: PlaneRotationGizmo;
  42710. /**
  42711. * Internal gizmo used for interactions on the y axis
  42712. */
  42713. yGizmo: PlaneRotationGizmo;
  42714. /**
  42715. * Internal gizmo used for interactions on the z axis
  42716. */
  42717. zGizmo: PlaneRotationGizmo;
  42718. /** Fires an event when any of it's sub gizmos are dragged */
  42719. onDragStartObservable: Observable<{}>;
  42720. /** Fires an event when any of it's sub gizmos are released from dragging */
  42721. onDragEndObservable: Observable<{}>;
  42722. private _meshAttached;
  42723. attachedMesh: Nullable<AbstractMesh>;
  42724. /**
  42725. * Creates a RotationGizmo
  42726. * @param gizmoLayer The utility layer the gizmo will be added to
  42727. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42728. */
  42729. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42730. updateGizmoRotationToMatchAttachedMesh: boolean;
  42731. /**
  42732. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42733. */
  42734. snapDistance: number;
  42735. /**
  42736. * Ratio for the scale of the gizmo (Default: 1)
  42737. */
  42738. scaleRatio: number;
  42739. /**
  42740. * Disposes of the gizmo
  42741. */
  42742. dispose(): void;
  42743. /**
  42744. * CustomMeshes are not supported by this gizmo
  42745. * @param mesh The mesh to replace the default mesh of the gizmo
  42746. */
  42747. setCustomMesh(mesh: Mesh): void;
  42748. }
  42749. }
  42750. declare module BABYLON {
  42751. /**
  42752. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42753. */
  42754. export class GizmoManager implements IDisposable {
  42755. private scene;
  42756. /**
  42757. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42758. */
  42759. gizmos: {
  42760. positionGizmo: Nullable<PositionGizmo>;
  42761. rotationGizmo: Nullable<RotationGizmo>;
  42762. scaleGizmo: Nullable<ScaleGizmo>;
  42763. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42764. };
  42765. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42766. clearGizmoOnEmptyPointerEvent: boolean;
  42767. /** Fires an event when the manager is attached to a mesh */
  42768. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42769. private _gizmosEnabled;
  42770. private _pointerObserver;
  42771. private _attachedMesh;
  42772. private _boundingBoxColor;
  42773. private _defaultUtilityLayer;
  42774. private _defaultKeepDepthUtilityLayer;
  42775. /**
  42776. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42777. */
  42778. boundingBoxDragBehavior: SixDofDragBehavior;
  42779. /**
  42780. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42781. */
  42782. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42783. /**
  42784. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42785. */
  42786. usePointerToAttachGizmos: boolean;
  42787. /**
  42788. * Utility layer that the bounding box gizmo belongs to
  42789. */
  42790. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  42791. /**
  42792. * Utility layer that all gizmos besides bounding box belong to
  42793. */
  42794. readonly utilityLayer: UtilityLayerRenderer;
  42795. /**
  42796. * Instatiates a gizmo manager
  42797. * @param scene the scene to overlay the gizmos on top of
  42798. */
  42799. constructor(scene: Scene);
  42800. /**
  42801. * Attaches a set of gizmos to the specified mesh
  42802. * @param mesh The mesh the gizmo's should be attached to
  42803. */
  42804. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42805. /**
  42806. * If the position gizmo is enabled
  42807. */
  42808. positionGizmoEnabled: boolean;
  42809. /**
  42810. * If the rotation gizmo is enabled
  42811. */
  42812. rotationGizmoEnabled: boolean;
  42813. /**
  42814. * If the scale gizmo is enabled
  42815. */
  42816. scaleGizmoEnabled: boolean;
  42817. /**
  42818. * If the boundingBox gizmo is enabled
  42819. */
  42820. boundingBoxGizmoEnabled: boolean;
  42821. /**
  42822. * Disposes of the gizmo manager
  42823. */
  42824. dispose(): void;
  42825. }
  42826. }
  42827. declare module BABYLON {
  42828. /**
  42829. * A directional light is defined by a direction (what a surprise!).
  42830. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42831. * 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.
  42832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42833. */
  42834. export class DirectionalLight extends ShadowLight {
  42835. private _shadowFrustumSize;
  42836. /**
  42837. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42838. */
  42839. /**
  42840. * Specifies a fix frustum size for the shadow generation.
  42841. */
  42842. shadowFrustumSize: number;
  42843. private _shadowOrthoScale;
  42844. /**
  42845. * Gets the shadow projection scale against the optimal computed one.
  42846. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42847. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42848. */
  42849. /**
  42850. * Sets the shadow projection scale against the optimal computed one.
  42851. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42852. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42853. */
  42854. shadowOrthoScale: number;
  42855. /**
  42856. * Automatically compute the projection matrix to best fit (including all the casters)
  42857. * on each frame.
  42858. */
  42859. autoUpdateExtends: boolean;
  42860. private _orthoLeft;
  42861. private _orthoRight;
  42862. private _orthoTop;
  42863. private _orthoBottom;
  42864. /**
  42865. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42866. * The directional light is emitted from everywhere in the given direction.
  42867. * It can cast shadows.
  42868. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42869. * @param name The friendly name of the light
  42870. * @param direction The direction of the light
  42871. * @param scene The scene the light belongs to
  42872. */
  42873. constructor(name: string, direction: Vector3, scene: Scene);
  42874. /**
  42875. * Returns the string "DirectionalLight".
  42876. * @return The class name
  42877. */
  42878. getClassName(): string;
  42879. /**
  42880. * Returns the integer 1.
  42881. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42882. */
  42883. getTypeID(): number;
  42884. /**
  42885. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42886. * Returns the DirectionalLight Shadow projection matrix.
  42887. */
  42888. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42889. /**
  42890. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42891. * Returns the DirectionalLight Shadow projection matrix.
  42892. */
  42893. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42894. /**
  42895. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42896. * Returns the DirectionalLight Shadow projection matrix.
  42897. */
  42898. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42899. protected _buildUniformLayout(): void;
  42900. /**
  42901. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42902. * @param effect The effect to update
  42903. * @param lightIndex The index of the light in the effect to update
  42904. * @returns The directional light
  42905. */
  42906. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42907. /**
  42908. * Gets the minZ used for shadow according to both the scene and the light.
  42909. *
  42910. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42911. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42912. * @param activeCamera The camera we are returning the min for
  42913. * @returns the depth min z
  42914. */
  42915. getDepthMinZ(activeCamera: Camera): number;
  42916. /**
  42917. * Gets the maxZ used for shadow according to both the scene and the light.
  42918. *
  42919. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42920. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42921. * @param activeCamera The camera we are returning the max for
  42922. * @returns the depth max z
  42923. */
  42924. getDepthMaxZ(activeCamera: Camera): number;
  42925. /**
  42926. * Prepares the list of defines specific to the light type.
  42927. * @param defines the list of defines
  42928. * @param lightIndex defines the index of the light for the effect
  42929. */
  42930. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42931. }
  42932. }
  42933. declare module BABYLON {
  42934. /**
  42935. * Class containing static functions to help procedurally build meshes
  42936. */
  42937. export class HemisphereBuilder {
  42938. /**
  42939. * Creates a hemisphere mesh
  42940. * @param name defines the name of the mesh
  42941. * @param options defines the options used to create the mesh
  42942. * @param scene defines the hosting scene
  42943. * @returns the hemisphere mesh
  42944. */
  42945. static CreateHemisphere(name: string, options: {
  42946. segments?: number;
  42947. diameter?: number;
  42948. sideOrientation?: number;
  42949. }, scene: any): Mesh;
  42950. }
  42951. }
  42952. declare module BABYLON {
  42953. /**
  42954. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42955. * These values define a cone of light starting from the position, emitting toward the direction.
  42956. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42957. * and the exponent defines the speed of the decay of the light with distance (reach).
  42958. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42959. */
  42960. export class SpotLight extends ShadowLight {
  42961. private _angle;
  42962. private _innerAngle;
  42963. private _cosHalfAngle;
  42964. private _lightAngleScale;
  42965. private _lightAngleOffset;
  42966. /**
  42967. * Gets the cone angle of the spot light in Radians.
  42968. */
  42969. /**
  42970. * Sets the cone angle of the spot light in Radians.
  42971. */
  42972. angle: number;
  42973. /**
  42974. * Only used in gltf falloff mode, this defines the angle where
  42975. * the directional falloff will start before cutting at angle which could be seen
  42976. * as outer angle.
  42977. */
  42978. /**
  42979. * Only used in gltf falloff mode, this defines the angle where
  42980. * the directional falloff will start before cutting at angle which could be seen
  42981. * as outer angle.
  42982. */
  42983. innerAngle: number;
  42984. private _shadowAngleScale;
  42985. /**
  42986. * Allows scaling the angle of the light for shadow generation only.
  42987. */
  42988. /**
  42989. * Allows scaling the angle of the light for shadow generation only.
  42990. */
  42991. shadowAngleScale: number;
  42992. /**
  42993. * The light decay speed with the distance from the emission spot.
  42994. */
  42995. exponent: number;
  42996. private _projectionTextureMatrix;
  42997. /**
  42998. * Allows reading the projecton texture
  42999. */
  43000. readonly projectionTextureMatrix: Matrix;
  43001. protected _projectionTextureLightNear: number;
  43002. /**
  43003. * Gets the near clip of the Spotlight for texture projection.
  43004. */
  43005. /**
  43006. * Sets the near clip of the Spotlight for texture projection.
  43007. */
  43008. projectionTextureLightNear: number;
  43009. protected _projectionTextureLightFar: number;
  43010. /**
  43011. * Gets the far clip of the Spotlight for texture projection.
  43012. */
  43013. /**
  43014. * Sets the far clip of the Spotlight for texture projection.
  43015. */
  43016. projectionTextureLightFar: number;
  43017. protected _projectionTextureUpDirection: Vector3;
  43018. /**
  43019. * Gets the Up vector of the Spotlight for texture projection.
  43020. */
  43021. /**
  43022. * Sets the Up vector of the Spotlight for texture projection.
  43023. */
  43024. projectionTextureUpDirection: Vector3;
  43025. private _projectionTexture;
  43026. /**
  43027. * Gets the projection texture of the light.
  43028. */
  43029. /**
  43030. * Sets the projection texture of the light.
  43031. */
  43032. projectionTexture: Nullable<BaseTexture>;
  43033. private _projectionTextureViewLightDirty;
  43034. private _projectionTextureProjectionLightDirty;
  43035. private _projectionTextureDirty;
  43036. private _projectionTextureViewTargetVector;
  43037. private _projectionTextureViewLightMatrix;
  43038. private _projectionTextureProjectionLightMatrix;
  43039. private _projectionTextureScalingMatrix;
  43040. /**
  43041. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43042. * It can cast shadows.
  43043. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43044. * @param name The light friendly name
  43045. * @param position The position of the spot light in the scene
  43046. * @param direction The direction of the light in the scene
  43047. * @param angle The cone angle of the light in Radians
  43048. * @param exponent The light decay speed with the distance from the emission spot
  43049. * @param scene The scene the lights belongs to
  43050. */
  43051. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43052. /**
  43053. * Returns the string "SpotLight".
  43054. * @returns the class name
  43055. */
  43056. getClassName(): string;
  43057. /**
  43058. * Returns the integer 2.
  43059. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43060. */
  43061. getTypeID(): number;
  43062. /**
  43063. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43064. */
  43065. protected _setDirection(value: Vector3): void;
  43066. /**
  43067. * Overrides the position setter to recompute the projection texture view light Matrix.
  43068. */
  43069. protected _setPosition(value: Vector3): void;
  43070. /**
  43071. * 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.
  43072. * Returns the SpotLight.
  43073. */
  43074. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43075. protected _computeProjectionTextureViewLightMatrix(): void;
  43076. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43077. /**
  43078. * Main function for light texture projection matrix computing.
  43079. */
  43080. protected _computeProjectionTextureMatrix(): void;
  43081. protected _buildUniformLayout(): void;
  43082. private _computeAngleValues;
  43083. /**
  43084. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43085. * @param effect The effect to update
  43086. * @param lightIndex The index of the light in the effect to update
  43087. * @returns The spot light
  43088. */
  43089. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43090. /**
  43091. * Disposes the light and the associated resources.
  43092. */
  43093. dispose(): void;
  43094. /**
  43095. * Prepares the list of defines specific to the light type.
  43096. * @param defines the list of defines
  43097. * @param lightIndex defines the index of the light for the effect
  43098. */
  43099. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43100. }
  43101. }
  43102. declare module BABYLON {
  43103. /**
  43104. * Gizmo that enables viewing a light
  43105. */
  43106. export class LightGizmo extends Gizmo {
  43107. private _lightMesh;
  43108. private _material;
  43109. private cachedPosition;
  43110. private cachedForward;
  43111. /**
  43112. * Creates a LightGizmo
  43113. * @param gizmoLayer The utility layer the gizmo will be added to
  43114. */
  43115. constructor(gizmoLayer?: UtilityLayerRenderer);
  43116. private _light;
  43117. /**
  43118. * The light that the gizmo is attached to
  43119. */
  43120. light: Nullable<Light>;
  43121. /**
  43122. * @hidden
  43123. * Updates the gizmo to match the attached mesh's position/rotation
  43124. */
  43125. protected _update(): void;
  43126. private static _Scale;
  43127. /**
  43128. * Creates the lines for a light mesh
  43129. */
  43130. private static _createLightLines;
  43131. /**
  43132. * Disposes of the light gizmo
  43133. */
  43134. dispose(): void;
  43135. private static _CreateHemisphericLightMesh;
  43136. private static _CreatePointLightMesh;
  43137. private static _CreateSpotLightMesh;
  43138. private static _CreateDirectionalLightMesh;
  43139. }
  43140. }
  43141. declare module BABYLON {
  43142. /** @hidden */
  43143. export var backgroundFragmentDeclaration: {
  43144. name: string;
  43145. shader: string;
  43146. };
  43147. }
  43148. declare module BABYLON {
  43149. /** @hidden */
  43150. export var backgroundUboDeclaration: {
  43151. name: string;
  43152. shader: string;
  43153. };
  43154. }
  43155. declare module BABYLON {
  43156. /** @hidden */
  43157. export var backgroundPixelShader: {
  43158. name: string;
  43159. shader: string;
  43160. };
  43161. }
  43162. declare module BABYLON {
  43163. /** @hidden */
  43164. export var backgroundVertexDeclaration: {
  43165. name: string;
  43166. shader: string;
  43167. };
  43168. }
  43169. declare module BABYLON {
  43170. /** @hidden */
  43171. export var backgroundVertexShader: {
  43172. name: string;
  43173. shader: string;
  43174. };
  43175. }
  43176. declare module BABYLON {
  43177. /**
  43178. * Background material used to create an efficient environement around your scene.
  43179. */
  43180. export class BackgroundMaterial extends PushMaterial {
  43181. /**
  43182. * Standard reflectance value at parallel view angle.
  43183. */
  43184. static StandardReflectance0: number;
  43185. /**
  43186. * Standard reflectance value at grazing angle.
  43187. */
  43188. static StandardReflectance90: number;
  43189. protected _primaryColor: Color3;
  43190. /**
  43191. * Key light Color (multiply against the environement texture)
  43192. */
  43193. primaryColor: Color3;
  43194. protected __perceptualColor: Nullable<Color3>;
  43195. /**
  43196. * Experimental Internal Use Only.
  43197. *
  43198. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43199. * This acts as a helper to set the primary color to a more "human friendly" value.
  43200. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43201. * output color as close as possible from the chosen value.
  43202. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43203. * part of lighting setup.)
  43204. */ private _perceptualColor: Nullable<Color3>;
  43205. protected _primaryColorShadowLevel: float;
  43206. /**
  43207. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43208. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43209. */
  43210. primaryColorShadowLevel: float;
  43211. protected _primaryColorHighlightLevel: float;
  43212. /**
  43213. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43214. * The primary color is used at the level chosen to define what the white area would look.
  43215. */
  43216. primaryColorHighlightLevel: float;
  43217. protected _reflectionTexture: Nullable<BaseTexture>;
  43218. /**
  43219. * Reflection Texture used in the material.
  43220. * Should be author in a specific way for the best result (refer to the documentation).
  43221. */
  43222. reflectionTexture: Nullable<BaseTexture>;
  43223. protected _reflectionBlur: float;
  43224. /**
  43225. * Reflection Texture level of blur.
  43226. *
  43227. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43228. * texture twice.
  43229. */
  43230. reflectionBlur: float;
  43231. protected _diffuseTexture: Nullable<BaseTexture>;
  43232. /**
  43233. * Diffuse Texture used in the material.
  43234. * Should be author in a specific way for the best result (refer to the documentation).
  43235. */
  43236. diffuseTexture: Nullable<BaseTexture>;
  43237. protected _shadowLights: Nullable<IShadowLight[]>;
  43238. /**
  43239. * Specify the list of lights casting shadow on the material.
  43240. * All scene shadow lights will be included if null.
  43241. */
  43242. shadowLights: Nullable<IShadowLight[]>;
  43243. protected _shadowLevel: float;
  43244. /**
  43245. * Helps adjusting the shadow to a softer level if required.
  43246. * 0 means black shadows and 1 means no shadows.
  43247. */
  43248. shadowLevel: float;
  43249. protected _sceneCenter: Vector3;
  43250. /**
  43251. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43252. * It is usually zero but might be interesting to modify according to your setup.
  43253. */
  43254. sceneCenter: Vector3;
  43255. protected _opacityFresnel: boolean;
  43256. /**
  43257. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43258. * This helps ensuring a nice transition when the camera goes under the ground.
  43259. */
  43260. opacityFresnel: boolean;
  43261. protected _reflectionFresnel: boolean;
  43262. /**
  43263. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43264. * This helps adding a mirror texture on the ground.
  43265. */
  43266. reflectionFresnel: boolean;
  43267. protected _reflectionFalloffDistance: number;
  43268. /**
  43269. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43270. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43271. */
  43272. reflectionFalloffDistance: number;
  43273. protected _reflectionAmount: number;
  43274. /**
  43275. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43276. */
  43277. reflectionAmount: number;
  43278. protected _reflectionReflectance0: number;
  43279. /**
  43280. * This specifies the weight of the reflection at grazing angle.
  43281. */
  43282. reflectionReflectance0: number;
  43283. protected _reflectionReflectance90: number;
  43284. /**
  43285. * This specifies the weight of the reflection at a perpendicular point of view.
  43286. */
  43287. reflectionReflectance90: number;
  43288. /**
  43289. * Sets the reflection reflectance fresnel values according to the default standard
  43290. * empirically know to work well :-)
  43291. */
  43292. reflectionStandardFresnelWeight: number;
  43293. protected _useRGBColor: boolean;
  43294. /**
  43295. * Helps to directly use the maps channels instead of their level.
  43296. */
  43297. useRGBColor: boolean;
  43298. protected _enableNoise: boolean;
  43299. /**
  43300. * This helps reducing the banding effect that could occur on the background.
  43301. */
  43302. enableNoise: boolean;
  43303. /**
  43304. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43305. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43306. * Recommended to be keep at 1.0 except for special cases.
  43307. */
  43308. fovMultiplier: number;
  43309. private _fovMultiplier;
  43310. /**
  43311. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43312. */
  43313. useEquirectangularFOV: boolean;
  43314. private _maxSimultaneousLights;
  43315. /**
  43316. * Number of Simultaneous lights allowed on the material.
  43317. */
  43318. maxSimultaneousLights: int;
  43319. /**
  43320. * Default configuration related to image processing available in the Background Material.
  43321. */
  43322. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43323. /**
  43324. * Keep track of the image processing observer to allow dispose and replace.
  43325. */
  43326. private _imageProcessingObserver;
  43327. /**
  43328. * Attaches a new image processing configuration to the PBR Material.
  43329. * @param configuration (if null the scene configuration will be use)
  43330. */
  43331. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43332. /**
  43333. * Gets the image processing configuration used either in this material.
  43334. */
  43335. /**
  43336. * Sets the Default image processing configuration used either in the this material.
  43337. *
  43338. * If sets to null, the scene one is in use.
  43339. */
  43340. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43341. /**
  43342. * Gets wether the color curves effect is enabled.
  43343. */
  43344. /**
  43345. * Sets wether the color curves effect is enabled.
  43346. */
  43347. cameraColorCurvesEnabled: boolean;
  43348. /**
  43349. * Gets wether the color grading effect is enabled.
  43350. */
  43351. /**
  43352. * Gets wether the color grading effect is enabled.
  43353. */
  43354. cameraColorGradingEnabled: boolean;
  43355. /**
  43356. * Gets wether tonemapping is enabled or not.
  43357. */
  43358. /**
  43359. * Sets wether tonemapping is enabled or not
  43360. */
  43361. cameraToneMappingEnabled: boolean;
  43362. /**
  43363. * The camera exposure used on this material.
  43364. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43365. * This corresponds to a photographic exposure.
  43366. */
  43367. /**
  43368. * The camera exposure used on this material.
  43369. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43370. * This corresponds to a photographic exposure.
  43371. */
  43372. cameraExposure: float;
  43373. /**
  43374. * Gets The camera contrast used on this material.
  43375. */
  43376. /**
  43377. * Sets The camera contrast used on this material.
  43378. */
  43379. cameraContrast: float;
  43380. /**
  43381. * Gets the Color Grading 2D Lookup Texture.
  43382. */
  43383. /**
  43384. * Sets the Color Grading 2D Lookup Texture.
  43385. */
  43386. cameraColorGradingTexture: Nullable<BaseTexture>;
  43387. /**
  43388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43390. * 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;
  43391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43392. */
  43393. /**
  43394. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43395. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43396. * 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;
  43397. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43398. */
  43399. cameraColorCurves: Nullable<ColorCurves>;
  43400. /**
  43401. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43402. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43403. */
  43404. switchToBGR: boolean;
  43405. private _renderTargets;
  43406. private _reflectionControls;
  43407. private _white;
  43408. private _primaryShadowColor;
  43409. private _primaryHighlightColor;
  43410. /**
  43411. * Instantiates a Background Material in the given scene
  43412. * @param name The friendly name of the material
  43413. * @param scene The scene to add the material to
  43414. */
  43415. constructor(name: string, scene: Scene);
  43416. /**
  43417. * Gets a boolean indicating that current material needs to register RTT
  43418. */
  43419. readonly hasRenderTargetTextures: boolean;
  43420. /**
  43421. * The entire material has been created in order to prevent overdraw.
  43422. * @returns false
  43423. */
  43424. needAlphaTesting(): boolean;
  43425. /**
  43426. * The entire material has been created in order to prevent overdraw.
  43427. * @returns true if blending is enable
  43428. */
  43429. needAlphaBlending(): boolean;
  43430. /**
  43431. * Checks wether the material is ready to be rendered for a given mesh.
  43432. * @param mesh The mesh to render
  43433. * @param subMesh The submesh to check against
  43434. * @param useInstances Specify wether or not the material is used with instances
  43435. * @returns true if all the dependencies are ready (Textures, Effects...)
  43436. */
  43437. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43438. /**
  43439. * Compute the primary color according to the chosen perceptual color.
  43440. */
  43441. private _computePrimaryColorFromPerceptualColor;
  43442. /**
  43443. * Compute the highlights and shadow colors according to their chosen levels.
  43444. */
  43445. private _computePrimaryColors;
  43446. /**
  43447. * Build the uniform buffer used in the material.
  43448. */
  43449. buildUniformLayout(): void;
  43450. /**
  43451. * Unbind the material.
  43452. */
  43453. unbind(): void;
  43454. /**
  43455. * Bind only the world matrix to the material.
  43456. * @param world The world matrix to bind.
  43457. */
  43458. bindOnlyWorldMatrix(world: Matrix): void;
  43459. /**
  43460. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43461. * @param world The world matrix to bind.
  43462. * @param subMesh The submesh to bind for.
  43463. */
  43464. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43465. /**
  43466. * Dispose the material.
  43467. * @param forceDisposeEffect Force disposal of the associated effect.
  43468. * @param forceDisposeTextures Force disposal of the associated textures.
  43469. */
  43470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43471. /**
  43472. * Clones the material.
  43473. * @param name The cloned name.
  43474. * @returns The cloned material.
  43475. */
  43476. clone(name: string): BackgroundMaterial;
  43477. /**
  43478. * Serializes the current material to its JSON representation.
  43479. * @returns The JSON representation.
  43480. */
  43481. serialize(): any;
  43482. /**
  43483. * Gets the class name of the material
  43484. * @returns "BackgroundMaterial"
  43485. */
  43486. getClassName(): string;
  43487. /**
  43488. * Parse a JSON input to create back a background material.
  43489. * @param source The JSON data to parse
  43490. * @param scene The scene to create the parsed material in
  43491. * @param rootUrl The root url of the assets the material depends upon
  43492. * @returns the instantiated BackgroundMaterial.
  43493. */
  43494. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43495. }
  43496. }
  43497. declare module BABYLON {
  43498. /**
  43499. * Represents the different options available during the creation of
  43500. * a Environment helper.
  43501. *
  43502. * This can control the default ground, skybox and image processing setup of your scene.
  43503. */
  43504. export interface IEnvironmentHelperOptions {
  43505. /**
  43506. * Specifies wether or not to create a ground.
  43507. * True by default.
  43508. */
  43509. createGround: boolean;
  43510. /**
  43511. * Specifies the ground size.
  43512. * 15 by default.
  43513. */
  43514. groundSize: number;
  43515. /**
  43516. * The texture used on the ground for the main color.
  43517. * Comes from the BabylonJS CDN by default.
  43518. *
  43519. * Remarks: Can be either a texture or a url.
  43520. */
  43521. groundTexture: string | BaseTexture;
  43522. /**
  43523. * The color mixed in the ground texture by default.
  43524. * BabylonJS clearColor by default.
  43525. */
  43526. groundColor: Color3;
  43527. /**
  43528. * Specifies the ground opacity.
  43529. * 1 by default.
  43530. */
  43531. groundOpacity: number;
  43532. /**
  43533. * Enables the ground to receive shadows.
  43534. * True by default.
  43535. */
  43536. enableGroundShadow: boolean;
  43537. /**
  43538. * Helps preventing the shadow to be fully black on the ground.
  43539. * 0.5 by default.
  43540. */
  43541. groundShadowLevel: number;
  43542. /**
  43543. * Creates a mirror texture attach to the ground.
  43544. * false by default.
  43545. */
  43546. enableGroundMirror: boolean;
  43547. /**
  43548. * Specifies the ground mirror size ratio.
  43549. * 0.3 by default as the default kernel is 64.
  43550. */
  43551. groundMirrorSizeRatio: number;
  43552. /**
  43553. * Specifies the ground mirror blur kernel size.
  43554. * 64 by default.
  43555. */
  43556. groundMirrorBlurKernel: number;
  43557. /**
  43558. * Specifies the ground mirror visibility amount.
  43559. * 1 by default
  43560. */
  43561. groundMirrorAmount: number;
  43562. /**
  43563. * Specifies the ground mirror reflectance weight.
  43564. * This uses the standard weight of the background material to setup the fresnel effect
  43565. * of the mirror.
  43566. * 1 by default.
  43567. */
  43568. groundMirrorFresnelWeight: number;
  43569. /**
  43570. * Specifies the ground mirror Falloff distance.
  43571. * This can helps reducing the size of the reflection.
  43572. * 0 by Default.
  43573. */
  43574. groundMirrorFallOffDistance: number;
  43575. /**
  43576. * Specifies the ground mirror texture type.
  43577. * Unsigned Int by Default.
  43578. */
  43579. groundMirrorTextureType: number;
  43580. /**
  43581. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43582. * the shown objects.
  43583. */
  43584. groundYBias: number;
  43585. /**
  43586. * Specifies wether or not to create a skybox.
  43587. * True by default.
  43588. */
  43589. createSkybox: boolean;
  43590. /**
  43591. * Specifies the skybox size.
  43592. * 20 by default.
  43593. */
  43594. skyboxSize: number;
  43595. /**
  43596. * The texture used on the skybox for the main color.
  43597. * Comes from the BabylonJS CDN by default.
  43598. *
  43599. * Remarks: Can be either a texture or a url.
  43600. */
  43601. skyboxTexture: string | BaseTexture;
  43602. /**
  43603. * The color mixed in the skybox texture by default.
  43604. * BabylonJS clearColor by default.
  43605. */
  43606. skyboxColor: Color3;
  43607. /**
  43608. * The background rotation around the Y axis of the scene.
  43609. * This helps aligning the key lights of your scene with the background.
  43610. * 0 by default.
  43611. */
  43612. backgroundYRotation: number;
  43613. /**
  43614. * Compute automatically the size of the elements to best fit with the scene.
  43615. */
  43616. sizeAuto: boolean;
  43617. /**
  43618. * Default position of the rootMesh if autoSize is not true.
  43619. */
  43620. rootPosition: Vector3;
  43621. /**
  43622. * Sets up the image processing in the scene.
  43623. * true by default.
  43624. */
  43625. setupImageProcessing: boolean;
  43626. /**
  43627. * The texture used as your environment texture in the scene.
  43628. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43629. *
  43630. * Remarks: Can be either a texture or a url.
  43631. */
  43632. environmentTexture: string | BaseTexture;
  43633. /**
  43634. * The value of the exposure to apply to the scene.
  43635. * 0.6 by default if setupImageProcessing is true.
  43636. */
  43637. cameraExposure: number;
  43638. /**
  43639. * The value of the contrast to apply to the scene.
  43640. * 1.6 by default if setupImageProcessing is true.
  43641. */
  43642. cameraContrast: number;
  43643. /**
  43644. * Specifies wether or not tonemapping should be enabled in the scene.
  43645. * true by default if setupImageProcessing is true.
  43646. */
  43647. toneMappingEnabled: boolean;
  43648. }
  43649. /**
  43650. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43651. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43652. * It also helps with the default setup of your imageProcessing configuration.
  43653. */
  43654. export class EnvironmentHelper {
  43655. /**
  43656. * Default ground texture URL.
  43657. */
  43658. private static _groundTextureCDNUrl;
  43659. /**
  43660. * Default skybox texture URL.
  43661. */
  43662. private static _skyboxTextureCDNUrl;
  43663. /**
  43664. * Default environment texture URL.
  43665. */
  43666. private static _environmentTextureCDNUrl;
  43667. /**
  43668. * Creates the default options for the helper.
  43669. */
  43670. private static _getDefaultOptions;
  43671. private _rootMesh;
  43672. /**
  43673. * Gets the root mesh created by the helper.
  43674. */
  43675. readonly rootMesh: Mesh;
  43676. private _skybox;
  43677. /**
  43678. * Gets the skybox created by the helper.
  43679. */
  43680. readonly skybox: Nullable<Mesh>;
  43681. private _skyboxTexture;
  43682. /**
  43683. * Gets the skybox texture created by the helper.
  43684. */
  43685. readonly skyboxTexture: Nullable<BaseTexture>;
  43686. private _skyboxMaterial;
  43687. /**
  43688. * Gets the skybox material created by the helper.
  43689. */
  43690. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43691. private _ground;
  43692. /**
  43693. * Gets the ground mesh created by the helper.
  43694. */
  43695. readonly ground: Nullable<Mesh>;
  43696. private _groundTexture;
  43697. /**
  43698. * Gets the ground texture created by the helper.
  43699. */
  43700. readonly groundTexture: Nullable<BaseTexture>;
  43701. private _groundMirror;
  43702. /**
  43703. * Gets the ground mirror created by the helper.
  43704. */
  43705. readonly groundMirror: Nullable<MirrorTexture>;
  43706. /**
  43707. * Gets the ground mirror render list to helps pushing the meshes
  43708. * you wish in the ground reflection.
  43709. */
  43710. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43711. private _groundMaterial;
  43712. /**
  43713. * Gets the ground material created by the helper.
  43714. */
  43715. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43716. /**
  43717. * Stores the creation options.
  43718. */
  43719. private readonly _scene;
  43720. private _options;
  43721. /**
  43722. * This observable will be notified with any error during the creation of the environment,
  43723. * mainly texture creation errors.
  43724. */
  43725. onErrorObservable: Observable<{
  43726. message?: string;
  43727. exception?: any;
  43728. }>;
  43729. /**
  43730. * constructor
  43731. * @param options Defines the options we want to customize the helper
  43732. * @param scene The scene to add the material to
  43733. */
  43734. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43735. /**
  43736. * Updates the background according to the new options
  43737. * @param options
  43738. */
  43739. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43740. /**
  43741. * Sets the primary color of all the available elements.
  43742. * @param color the main color to affect to the ground and the background
  43743. */
  43744. setMainColor(color: Color3): void;
  43745. /**
  43746. * Setup the image processing according to the specified options.
  43747. */
  43748. private _setupImageProcessing;
  43749. /**
  43750. * Setup the environment texture according to the specified options.
  43751. */
  43752. private _setupEnvironmentTexture;
  43753. /**
  43754. * Setup the background according to the specified options.
  43755. */
  43756. private _setupBackground;
  43757. /**
  43758. * Get the scene sizes according to the setup.
  43759. */
  43760. private _getSceneSize;
  43761. /**
  43762. * Setup the ground according to the specified options.
  43763. */
  43764. private _setupGround;
  43765. /**
  43766. * Setup the ground material according to the specified options.
  43767. */
  43768. private _setupGroundMaterial;
  43769. /**
  43770. * Setup the ground diffuse texture according to the specified options.
  43771. */
  43772. private _setupGroundDiffuseTexture;
  43773. /**
  43774. * Setup the ground mirror texture according to the specified options.
  43775. */
  43776. private _setupGroundMirrorTexture;
  43777. /**
  43778. * Setup the ground to receive the mirror texture.
  43779. */
  43780. private _setupMirrorInGroundMaterial;
  43781. /**
  43782. * Setup the skybox according to the specified options.
  43783. */
  43784. private _setupSkybox;
  43785. /**
  43786. * Setup the skybox material according to the specified options.
  43787. */
  43788. private _setupSkyboxMaterial;
  43789. /**
  43790. * Setup the skybox reflection texture according to the specified options.
  43791. */
  43792. private _setupSkyboxReflectionTexture;
  43793. private _errorHandler;
  43794. /**
  43795. * Dispose all the elements created by the Helper.
  43796. */
  43797. dispose(): void;
  43798. }
  43799. }
  43800. declare module BABYLON {
  43801. /**
  43802. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43803. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43804. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43805. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43806. */
  43807. export class PhotoDome extends TransformNode {
  43808. /**
  43809. * Define the image as a Monoscopic panoramic 360 image.
  43810. */
  43811. static readonly MODE_MONOSCOPIC: number;
  43812. /**
  43813. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43814. */
  43815. static readonly MODE_TOPBOTTOM: number;
  43816. /**
  43817. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43818. */
  43819. static readonly MODE_SIDEBYSIDE: number;
  43820. private _useDirectMapping;
  43821. /**
  43822. * The texture being displayed on the sphere
  43823. */
  43824. protected _photoTexture: Texture;
  43825. /**
  43826. * Gets or sets the texture being displayed on the sphere
  43827. */
  43828. photoTexture: Texture;
  43829. /**
  43830. * Observable raised when an error occured while loading the 360 image
  43831. */
  43832. onLoadErrorObservable: Observable<string>;
  43833. /**
  43834. * The skybox material
  43835. */
  43836. protected _material: BackgroundMaterial;
  43837. /**
  43838. * The surface used for the skybox
  43839. */
  43840. protected _mesh: Mesh;
  43841. /**
  43842. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43843. * Also see the options.resolution property.
  43844. */
  43845. fovMultiplier: number;
  43846. private _imageMode;
  43847. /**
  43848. * Gets or set the current video mode for the video. It can be:
  43849. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  43850. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43851. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43852. */
  43853. imageMode: number;
  43854. /**
  43855. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43856. * @param name Element's name, child elements will append suffixes for their own names.
  43857. * @param urlsOfPhoto defines the url of the photo to display
  43858. * @param options defines an object containing optional or exposed sub element properties
  43859. * @param onError defines a callback called when an error occured while loading the texture
  43860. */
  43861. constructor(name: string, urlOfPhoto: string, options: {
  43862. resolution?: number;
  43863. size?: number;
  43864. useDirectMapping?: boolean;
  43865. faceForward?: boolean;
  43866. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43867. private _onBeforeCameraRenderObserver;
  43868. private _changeImageMode;
  43869. /**
  43870. * Releases resources associated with this node.
  43871. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43872. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43873. */
  43874. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43875. }
  43876. }
  43877. declare module BABYLON {
  43878. /** @hidden */
  43879. export var rgbdDecodePixelShader: {
  43880. name: string;
  43881. shader: string;
  43882. };
  43883. }
  43884. declare module BABYLON {
  43885. /**
  43886. * Class used to host texture specific utilities
  43887. */
  43888. export class BRDFTextureTools {
  43889. /**
  43890. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43891. * @param texture the texture to expand.
  43892. */
  43893. private static _ExpandDefaultBRDFTexture;
  43894. /**
  43895. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43896. * @param scene defines the hosting scene
  43897. * @returns the environment BRDF texture
  43898. */
  43899. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43900. private static _environmentBRDFBase64Texture;
  43901. }
  43902. }
  43903. declare module BABYLON {
  43904. /**
  43905. * @hidden
  43906. */
  43907. export interface IMaterialClearCoatDefines {
  43908. CLEARCOAT: boolean;
  43909. CLEARCOAT_DEFAULTIOR: boolean;
  43910. CLEARCOAT_TEXTURE: boolean;
  43911. CLEARCOAT_TEXTUREDIRECTUV: number;
  43912. CLEARCOAT_BUMP: boolean;
  43913. CLEARCOAT_BUMPDIRECTUV: number;
  43914. CLEARCOAT_TINT: boolean;
  43915. CLEARCOAT_TINT_TEXTURE: boolean;
  43916. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43917. /** @hidden */ private _areTexturesDirty: boolean;
  43918. }
  43919. /**
  43920. * Define the code related to the clear coat parameters of the pbr material.
  43921. */
  43922. export class PBRClearCoatConfiguration {
  43923. /**
  43924. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43925. * The default fits with a polyurethane material.
  43926. */
  43927. private static readonly _DefaultIndexOfRefraction;
  43928. private _isEnabled;
  43929. /**
  43930. * Defines if the clear coat is enabled in the material.
  43931. */
  43932. isEnabled: boolean;
  43933. /**
  43934. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43935. */
  43936. intensity: number;
  43937. /**
  43938. * Defines the clear coat layer roughness.
  43939. */
  43940. roughness: number;
  43941. private _indexOfRefraction;
  43942. /**
  43943. * Defines the index of refraction of the clear coat.
  43944. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43945. * The default fits with a polyurethane material.
  43946. * Changing the default value is more performance intensive.
  43947. */
  43948. indexOfRefraction: number;
  43949. private _texture;
  43950. /**
  43951. * Stores the clear coat values in a texture.
  43952. */
  43953. texture: Nullable<BaseTexture>;
  43954. private _bumpTexture;
  43955. /**
  43956. * Define the clear coat specific bump texture.
  43957. */
  43958. bumpTexture: Nullable<BaseTexture>;
  43959. private _isTintEnabled;
  43960. /**
  43961. * Defines if the clear coat tint is enabled in the material.
  43962. */
  43963. isTintEnabled: boolean;
  43964. /**
  43965. * Defines the clear coat tint of the material.
  43966. * This is only use if tint is enabled
  43967. */
  43968. tintColor: Color3;
  43969. /**
  43970. * Defines the distance at which the tint color should be found in the
  43971. * clear coat media.
  43972. * This is only use if tint is enabled
  43973. */
  43974. tintColorAtDistance: number;
  43975. /**
  43976. * Defines the clear coat layer thickness.
  43977. * This is only use if tint is enabled
  43978. */
  43979. tintThickness: number;
  43980. private _tintTexture;
  43981. /**
  43982. * Stores the clear tint values in a texture.
  43983. * rgb is tint
  43984. * a is a thickness factor
  43985. */
  43986. tintTexture: Nullable<BaseTexture>;
  43987. /** @hidden */
  43988. private _internalMarkAllSubMeshesAsTexturesDirty;
  43989. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43990. /**
  43991. * Instantiate a new istance of clear coat configuration.
  43992. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43993. */
  43994. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43995. /**
  43996. * Gets wehter the submesh is ready to be used or not.
  43997. * @param defines the list of "defines" to update.
  43998. * @param scene defines the scene the material belongs to.
  43999. * @param engine defines the engine the material belongs to.
  44000. * @param disableBumpMap defines wether the material disables bump or not.
  44001. * @returns - boolean indicating that the submesh is ready or not.
  44002. */
  44003. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44004. /**
  44005. * Checks to see if a texture is used in the material.
  44006. * @param defines the list of "defines" to update.
  44007. * @param scene defines the scene to the material belongs to.
  44008. */
  44009. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44010. /**
  44011. * Binds the material data.
  44012. * @param uniformBuffer defines the Uniform buffer to fill in.
  44013. * @param scene defines the scene the material belongs to.
  44014. * @param engine defines the engine the material belongs to.
  44015. * @param disableBumpMap defines wether the material disables bump or not.
  44016. * @param isFrozen defines wether the material is frozen or not.
  44017. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44018. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44019. */
  44020. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44021. /**
  44022. * Checks to see if a texture is used in the material.
  44023. * @param texture - Base texture to use.
  44024. * @returns - Boolean specifying if a texture is used in the material.
  44025. */
  44026. hasTexture(texture: BaseTexture): boolean;
  44027. /**
  44028. * Returns an array of the actively used textures.
  44029. * @param activeTextures Array of BaseTextures
  44030. */
  44031. getActiveTextures(activeTextures: BaseTexture[]): void;
  44032. /**
  44033. * Returns the animatable textures.
  44034. * @param animatables Array of animatable textures.
  44035. */
  44036. getAnimatables(animatables: IAnimatable[]): void;
  44037. /**
  44038. * Disposes the resources of the material.
  44039. * @param forceDisposeTextures - Forces the disposal of all textures.
  44040. */
  44041. dispose(forceDisposeTextures?: boolean): void;
  44042. /**
  44043. * Get the current class name of the texture useful for serialization or dynamic coding.
  44044. * @returns "PBRClearCoatConfiguration"
  44045. */
  44046. getClassName(): string;
  44047. /**
  44048. * Add fallbacks to the effect fallbacks list.
  44049. * @param defines defines the Base texture to use.
  44050. * @param fallbacks defines the current fallback list.
  44051. * @param currentRank defines the current fallback rank.
  44052. * @returns the new fallback rank.
  44053. */
  44054. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44055. /**
  44056. * Add the required uniforms to the current list.
  44057. * @param uniforms defines the current uniform list.
  44058. */
  44059. static AddUniforms(uniforms: string[]): void;
  44060. /**
  44061. * Add the required samplers to the current list.
  44062. * @param samplers defines the current sampler list.
  44063. */
  44064. static AddSamplers(samplers: string[]): void;
  44065. /**
  44066. * Add the required uniforms to the current buffer.
  44067. * @param uniformBuffer defines the current uniform buffer.
  44068. */
  44069. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44070. /**
  44071. * Makes a duplicate of the current configuration into another one.
  44072. * @param clearCoatConfiguration define the config where to copy the info
  44073. */
  44074. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44075. /**
  44076. * Serializes this clear coat configuration.
  44077. * @returns - An object with the serialized config.
  44078. */
  44079. serialize(): any;
  44080. /**
  44081. * Parses a anisotropy Configuration from a serialized object.
  44082. * @param source - Serialized object.
  44083. * @param scene Defines the scene we are parsing for
  44084. * @param rootUrl Defines the rootUrl to load from
  44085. */
  44086. parse(source: any, scene: Scene, rootUrl: string): void;
  44087. }
  44088. }
  44089. declare module BABYLON {
  44090. /**
  44091. * @hidden
  44092. */
  44093. export interface IMaterialAnisotropicDefines {
  44094. ANISOTROPIC: boolean;
  44095. ANISOTROPIC_TEXTURE: boolean;
  44096. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44097. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  44098. }
  44099. /**
  44100. * Define the code related to the anisotropic parameters of the pbr material.
  44101. */
  44102. export class PBRAnisotropicConfiguration {
  44103. private _isEnabled;
  44104. /**
  44105. * Defines if the anisotropy is enabled in the material.
  44106. */
  44107. isEnabled: boolean;
  44108. /**
  44109. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44110. */
  44111. intensity: number;
  44112. /**
  44113. * Defines if the effect is along the tangents, bitangents or in between.
  44114. * By default, the effect is "strectching" the highlights along the tangents.
  44115. */
  44116. direction: Vector2;
  44117. private _texture;
  44118. /**
  44119. * Stores the anisotropy values in a texture.
  44120. * rg is direction (like normal from -1 to 1)
  44121. * b is a intensity
  44122. */
  44123. texture: Nullable<BaseTexture>;
  44124. /** @hidden */
  44125. private _internalMarkAllSubMeshesAsTexturesDirty;
  44126. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44127. /**
  44128. * Instantiate a new istance of anisotropy configuration.
  44129. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44130. */
  44131. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44132. /**
  44133. * Specifies that the submesh is ready to be used.
  44134. * @param defines the list of "defines" to update.
  44135. * @param scene defines the scene the material belongs to.
  44136. * @returns - boolean indicating that the submesh is ready or not.
  44137. */
  44138. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44139. /**
  44140. * Checks to see if a texture is used in the material.
  44141. * @param defines the list of "defines" to update.
  44142. * @param mesh the mesh we are preparing the defines for.
  44143. * @param scene defines the scene the material belongs to.
  44144. */
  44145. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44146. /**
  44147. * Binds the material data.
  44148. * @param uniformBuffer defines the Uniform buffer to fill in.
  44149. * @param scene defines the scene the material belongs to.
  44150. * @param isFrozen defines wether the material is frozen or not.
  44151. */
  44152. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44153. /**
  44154. * Checks to see if a texture is used in the material.
  44155. * @param texture - Base texture to use.
  44156. * @returns - Boolean specifying if a texture is used in the material.
  44157. */
  44158. hasTexture(texture: BaseTexture): boolean;
  44159. /**
  44160. * Returns an array of the actively used textures.
  44161. * @param activeTextures Array of BaseTextures
  44162. */
  44163. getActiveTextures(activeTextures: BaseTexture[]): void;
  44164. /**
  44165. * Returns the animatable textures.
  44166. * @param animatables Array of animatable textures.
  44167. */
  44168. getAnimatables(animatables: IAnimatable[]): void;
  44169. /**
  44170. * Disposes the resources of the material.
  44171. * @param forceDisposeTextures - Forces the disposal of all textures.
  44172. */
  44173. dispose(forceDisposeTextures?: boolean): void;
  44174. /**
  44175. * Get the current class name of the texture useful for serialization or dynamic coding.
  44176. * @returns "PBRAnisotropicConfiguration"
  44177. */
  44178. getClassName(): string;
  44179. /**
  44180. * Add fallbacks to the effect fallbacks list.
  44181. * @param defines defines the Base texture to use.
  44182. * @param fallbacks defines the current fallback list.
  44183. * @param currentRank defines the current fallback rank.
  44184. * @returns the new fallback rank.
  44185. */
  44186. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44187. /**
  44188. * Add the required uniforms to the current list.
  44189. * @param uniforms defines the current uniform list.
  44190. */
  44191. static AddUniforms(uniforms: string[]): void;
  44192. /**
  44193. * Add the required uniforms to the current buffer.
  44194. * @param uniformBuffer defines the current uniform buffer.
  44195. */
  44196. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44197. /**
  44198. * Add the required samplers to the current list.
  44199. * @param samplers defines the current sampler list.
  44200. */
  44201. static AddSamplers(samplers: string[]): void;
  44202. /**
  44203. * Makes a duplicate of the current configuration into another one.
  44204. * @param anisotropicConfiguration define the config where to copy the info
  44205. */
  44206. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44207. /**
  44208. * Serializes this anisotropy configuration.
  44209. * @returns - An object with the serialized config.
  44210. */
  44211. serialize(): any;
  44212. /**
  44213. * Parses a anisotropy Configuration from a serialized object.
  44214. * @param source - Serialized object.
  44215. * @param scene Defines the scene we are parsing for
  44216. * @param rootUrl Defines the rootUrl to load from
  44217. */
  44218. parse(source: any, scene: Scene, rootUrl: string): void;
  44219. }
  44220. }
  44221. declare module BABYLON {
  44222. /**
  44223. * @hidden
  44224. */
  44225. export interface IMaterialBRDFDefines {
  44226. BRDF_V_HEIGHT_CORRELATED: boolean;
  44227. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44228. SPHERICAL_HARMONICS: boolean;
  44229. /** @hidden */ private _areMiscDirty: boolean;
  44230. }
  44231. /**
  44232. * Define the code related to the BRDF parameters of the pbr material.
  44233. */
  44234. export class PBRBRDFConfiguration {
  44235. /**
  44236. * Default value used for the energy conservation.
  44237. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44238. */
  44239. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44240. /**
  44241. * Default value used for the Smith Visibility Height Correlated mode.
  44242. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44243. */
  44244. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44245. /**
  44246. * Default value used for the IBL diffuse part.
  44247. * This can help switching back to the polynomials mode globally which is a tiny bit
  44248. * less GPU intensive at the drawback of a lower quality.
  44249. */
  44250. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44251. private _useEnergyConservation;
  44252. /**
  44253. * Defines if the material uses energy conservation.
  44254. */
  44255. useEnergyConservation: boolean;
  44256. private _useSmithVisibilityHeightCorrelated;
  44257. /**
  44258. * LEGACY Mode set to false
  44259. * Defines if the material uses height smith correlated visibility term.
  44260. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44261. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44262. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44263. * Not relying on height correlated will also disable energy conservation.
  44264. */
  44265. useSmithVisibilityHeightCorrelated: boolean;
  44266. private _useSphericalHarmonics;
  44267. /**
  44268. * LEGACY Mode set to false
  44269. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44270. * diffuse part of the IBL.
  44271. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44272. * to the ground truth.
  44273. */
  44274. useSphericalHarmonics: boolean;
  44275. /** @hidden */
  44276. private _internalMarkAllSubMeshesAsMiscDirty;
  44277. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  44278. /**
  44279. * Instantiate a new istance of clear coat configuration.
  44280. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44281. */
  44282. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44283. /**
  44284. * Checks to see if a texture is used in the material.
  44285. * @param defines the list of "defines" to update.
  44286. */
  44287. prepareDefines(defines: IMaterialBRDFDefines): void;
  44288. /**
  44289. * Get the current class name of the texture useful for serialization or dynamic coding.
  44290. * @returns "PBRClearCoatConfiguration"
  44291. */
  44292. getClassName(): string;
  44293. /**
  44294. * Makes a duplicate of the current configuration into another one.
  44295. * @param brdfConfiguration define the config where to copy the info
  44296. */
  44297. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44298. /**
  44299. * Serializes this BRDF configuration.
  44300. * @returns - An object with the serialized config.
  44301. */
  44302. serialize(): any;
  44303. /**
  44304. * Parses a anisotropy Configuration from a serialized object.
  44305. * @param source - Serialized object.
  44306. * @param scene Defines the scene we are parsing for
  44307. * @param rootUrl Defines the rootUrl to load from
  44308. */
  44309. parse(source: any, scene: Scene, rootUrl: string): void;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * @hidden
  44315. */
  44316. export interface IMaterialSheenDefines {
  44317. SHEEN: boolean;
  44318. SHEEN_TEXTURE: boolean;
  44319. SHEEN_TEXTUREDIRECTUV: number;
  44320. SHEEN_LINKWITHALBEDO: boolean;
  44321. /** @hidden */ private _areTexturesDirty: boolean;
  44322. }
  44323. /**
  44324. * Define the code related to the Sheen parameters of the pbr material.
  44325. */
  44326. export class PBRSheenConfiguration {
  44327. private _isEnabled;
  44328. /**
  44329. * Defines if the material uses sheen.
  44330. */
  44331. isEnabled: boolean;
  44332. private _linkSheenWithAlbedo;
  44333. /**
  44334. * Defines if the sheen is linked to the sheen color.
  44335. */
  44336. linkSheenWithAlbedo: boolean;
  44337. /**
  44338. * Defines the sheen intensity.
  44339. */
  44340. intensity: number;
  44341. /**
  44342. * Defines the sheen color.
  44343. */
  44344. color: Color3;
  44345. private _texture;
  44346. /**
  44347. * Stores the sheen tint values in a texture.
  44348. * rgb is tint
  44349. * a is a intensity
  44350. */
  44351. texture: Nullable<BaseTexture>;
  44352. /** @hidden */
  44353. private _internalMarkAllSubMeshesAsTexturesDirty;
  44354. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44355. /**
  44356. * Instantiate a new istance of clear coat configuration.
  44357. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44358. */
  44359. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44360. /**
  44361. * Specifies that the submesh is ready to be used.
  44362. * @param defines the list of "defines" to update.
  44363. * @param scene defines the scene the material belongs to.
  44364. * @returns - boolean indicating that the submesh is ready or not.
  44365. */
  44366. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44367. /**
  44368. * Checks to see if a texture is used in the material.
  44369. * @param defines the list of "defines" to update.
  44370. * @param scene defines the scene the material belongs to.
  44371. */
  44372. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44373. /**
  44374. * Binds the material data.
  44375. * @param uniformBuffer defines the Uniform buffer to fill in.
  44376. * @param scene defines the scene the material belongs to.
  44377. * @param isFrozen defines wether the material is frozen or not.
  44378. */
  44379. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44380. /**
  44381. * Checks to see if a texture is used in the material.
  44382. * @param texture - Base texture to use.
  44383. * @returns - Boolean specifying if a texture is used in the material.
  44384. */
  44385. hasTexture(texture: BaseTexture): boolean;
  44386. /**
  44387. * Returns an array of the actively used textures.
  44388. * @param activeTextures Array of BaseTextures
  44389. */
  44390. getActiveTextures(activeTextures: BaseTexture[]): void;
  44391. /**
  44392. * Returns the animatable textures.
  44393. * @param animatables Array of animatable textures.
  44394. */
  44395. getAnimatables(animatables: IAnimatable[]): void;
  44396. /**
  44397. * Disposes the resources of the material.
  44398. * @param forceDisposeTextures - Forces the disposal of all textures.
  44399. */
  44400. dispose(forceDisposeTextures?: boolean): void;
  44401. /**
  44402. * Get the current class name of the texture useful for serialization or dynamic coding.
  44403. * @returns "PBRSheenConfiguration"
  44404. */
  44405. getClassName(): string;
  44406. /**
  44407. * Add fallbacks to the effect fallbacks list.
  44408. * @param defines defines the Base texture to use.
  44409. * @param fallbacks defines the current fallback list.
  44410. * @param currentRank defines the current fallback rank.
  44411. * @returns the new fallback rank.
  44412. */
  44413. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44414. /**
  44415. * Add the required uniforms to the current list.
  44416. * @param uniforms defines the current uniform list.
  44417. */
  44418. static AddUniforms(uniforms: string[]): void;
  44419. /**
  44420. * Add the required uniforms to the current buffer.
  44421. * @param uniformBuffer defines the current uniform buffer.
  44422. */
  44423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44424. /**
  44425. * Add the required samplers to the current list.
  44426. * @param samplers defines the current sampler list.
  44427. */
  44428. static AddSamplers(samplers: string[]): void;
  44429. /**
  44430. * Makes a duplicate of the current configuration into another one.
  44431. * @param sheenConfiguration define the config where to copy the info
  44432. */
  44433. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44434. /**
  44435. * Serializes this BRDF configuration.
  44436. * @returns - An object with the serialized config.
  44437. */
  44438. serialize(): any;
  44439. /**
  44440. * Parses a anisotropy Configuration from a serialized object.
  44441. * @param source - Serialized object.
  44442. * @param scene Defines the scene we are parsing for
  44443. * @param rootUrl Defines the rootUrl to load from
  44444. */
  44445. parse(source: any, scene: Scene, rootUrl: string): void;
  44446. }
  44447. }
  44448. declare module BABYLON {
  44449. /**
  44450. * @hidden
  44451. */
  44452. export interface IMaterialSubSurfaceDefines {
  44453. SUBSURFACE: boolean;
  44454. SS_REFRACTION: boolean;
  44455. SS_TRANSLUCENCY: boolean;
  44456. SS_SCATERRING: boolean;
  44457. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44458. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44459. SS_REFRACTIONMAP_3D: boolean;
  44460. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44461. SS_LODINREFRACTIONALPHA: boolean;
  44462. SS_GAMMAREFRACTION: boolean;
  44463. SS_RGBDREFRACTION: boolean;
  44464. SS_LINEARSPECULARREFRACTION: boolean;
  44465. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44466. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44467. /** @hidden */ private _areTexturesDirty: boolean;
  44468. }
  44469. /**
  44470. * Define the code related to the sub surface parameters of the pbr material.
  44471. */
  44472. export class PBRSubSurfaceConfiguration {
  44473. private _isRefractionEnabled;
  44474. /**
  44475. * Defines if the refraction is enabled in the material.
  44476. */
  44477. isRefractionEnabled: boolean;
  44478. private _isTranslucencyEnabled;
  44479. /**
  44480. * Defines if the translucency is enabled in the material.
  44481. */
  44482. isTranslucencyEnabled: boolean;
  44483. private _isScatteringEnabled;
  44484. /**
  44485. * Defines the refraction intensity of the material.
  44486. * The refraction when enabled replaces the Diffuse part of the material.
  44487. * The intensity helps transitionning between diffuse and refraction.
  44488. */
  44489. refractionIntensity: number;
  44490. /**
  44491. * Defines the translucency intensity of the material.
  44492. * When translucency has been enabled, this defines how much of the "translucency"
  44493. * is addded to the diffuse part of the material.
  44494. */
  44495. translucencyIntensity: number;
  44496. /**
  44497. * Defines the scattering intensity of the material.
  44498. * When scattering has been enabled, this defines how much of the "scattered light"
  44499. * is addded to the diffuse part of the material.
  44500. */
  44501. scatteringIntensity: number;
  44502. private _thicknessTexture;
  44503. /**
  44504. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44505. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44506. * 0 would mean minimumThickness
  44507. * 1 would mean maximumThickness
  44508. * The other channels might be use as a mask to vary the different effects intensity.
  44509. */
  44510. thicknessTexture: Nullable<BaseTexture>;
  44511. private _refractionTexture;
  44512. /**
  44513. * Defines the texture to use for refraction.
  44514. */
  44515. refractionTexture: Nullable<BaseTexture>;
  44516. private _indexOfRefraction;
  44517. /**
  44518. * Defines the index of refraction used in the material.
  44519. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44520. */
  44521. indexOfRefraction: number;
  44522. private _invertRefractionY;
  44523. /**
  44524. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44525. */
  44526. invertRefractionY: boolean;
  44527. private _linkRefractionWithTransparency;
  44528. /**
  44529. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44530. * Materials half opaque for instance using refraction could benefit from this control.
  44531. */
  44532. linkRefractionWithTransparency: boolean;
  44533. /**
  44534. * Defines the minimum thickness stored in the thickness map.
  44535. * If no thickness map is defined, this value will be used to simulate thickness.
  44536. */
  44537. minimumThickness: number;
  44538. /**
  44539. * Defines the maximum thickness stored in the thickness map.
  44540. */
  44541. maximumThickness: number;
  44542. /**
  44543. * Defines the volume tint of the material.
  44544. * This is used for both translucency and scattering.
  44545. */
  44546. tintColor: Color3;
  44547. /**
  44548. * Defines the distance at which the tint color should be found in the media.
  44549. * This is used for refraction only.
  44550. */
  44551. tintColorAtDistance: number;
  44552. /**
  44553. * Defines how far each channel transmit through the media.
  44554. * It is defined as a color to simplify it selection.
  44555. */
  44556. diffusionDistance: Color3;
  44557. private _useMaskFromThicknessTexture;
  44558. /**
  44559. * Stores the intensity of the different subsurface effects in the thickness texture.
  44560. * * the green channel is the translucency intensity.
  44561. * * the blue channel is the scattering intensity.
  44562. * * the alpha channel is the refraction intensity.
  44563. */
  44564. useMaskFromThicknessTexture: boolean;
  44565. /** @hidden */
  44566. private _internalMarkAllSubMeshesAsTexturesDirty;
  44567. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44568. /**
  44569. * Instantiate a new istance of sub surface configuration.
  44570. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44571. */
  44572. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44573. /**
  44574. * Gets wehter the submesh is ready to be used or not.
  44575. * @param defines the list of "defines" to update.
  44576. * @param scene defines the scene the material belongs to.
  44577. * @returns - boolean indicating that the submesh is ready or not.
  44578. */
  44579. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44580. /**
  44581. * Checks to see if a texture is used in the material.
  44582. * @param defines the list of "defines" to update.
  44583. * @param scene defines the scene to the material belongs to.
  44584. */
  44585. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44586. /**
  44587. * Binds the material data.
  44588. * @param uniformBuffer defines the Uniform buffer to fill in.
  44589. * @param scene defines the scene the material belongs to.
  44590. * @param engine defines the engine the material belongs to.
  44591. * @param isFrozen defines wether the material is frozen or not.
  44592. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44593. */
  44594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44595. /**
  44596. * Unbinds the material from the mesh.
  44597. * @param activeEffect defines the effect that should be unbound from.
  44598. * @returns true if unbound, otherwise false
  44599. */
  44600. unbind(activeEffect: Effect): boolean;
  44601. /**
  44602. * Returns the texture used for refraction or null if none is used.
  44603. * @param scene defines the scene the material belongs to.
  44604. * @returns - Refraction texture if present. If no refraction texture and refraction
  44605. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44606. */
  44607. private _getRefractionTexture;
  44608. /**
  44609. * Returns true if alpha blending should be disabled.
  44610. */
  44611. readonly disableAlphaBlending: boolean;
  44612. /**
  44613. * Fills the list of render target textures.
  44614. * @param renderTargets the list of render targets to update
  44615. */
  44616. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44617. /**
  44618. * Checks to see if a texture is used in the material.
  44619. * @param texture - Base texture to use.
  44620. * @returns - Boolean specifying if a texture is used in the material.
  44621. */
  44622. hasTexture(texture: BaseTexture): boolean;
  44623. /**
  44624. * Gets a boolean indicating that current material needs to register RTT
  44625. * @returns true if this uses a render target otherwise false.
  44626. */
  44627. hasRenderTargetTextures(): boolean;
  44628. /**
  44629. * Returns an array of the actively used textures.
  44630. * @param activeTextures Array of BaseTextures
  44631. */
  44632. getActiveTextures(activeTextures: BaseTexture[]): void;
  44633. /**
  44634. * Returns the animatable textures.
  44635. * @param animatables Array of animatable textures.
  44636. */
  44637. getAnimatables(animatables: IAnimatable[]): void;
  44638. /**
  44639. * Disposes the resources of the material.
  44640. * @param forceDisposeTextures - Forces the disposal of all textures.
  44641. */
  44642. dispose(forceDisposeTextures?: boolean): void;
  44643. /**
  44644. * Get the current class name of the texture useful for serialization or dynamic coding.
  44645. * @returns "PBRSubSurfaceConfiguration"
  44646. */
  44647. getClassName(): string;
  44648. /**
  44649. * Add fallbacks to the effect fallbacks list.
  44650. * @param defines defines the Base texture to use.
  44651. * @param fallbacks defines the current fallback list.
  44652. * @param currentRank defines the current fallback rank.
  44653. * @returns the new fallback rank.
  44654. */
  44655. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44656. /**
  44657. * Add the required uniforms to the current list.
  44658. * @param uniforms defines the current uniform list.
  44659. */
  44660. static AddUniforms(uniforms: string[]): void;
  44661. /**
  44662. * Add the required samplers to the current list.
  44663. * @param samplers defines the current sampler list.
  44664. */
  44665. static AddSamplers(samplers: string[]): void;
  44666. /**
  44667. * Add the required uniforms to the current buffer.
  44668. * @param uniformBuffer defines the current uniform buffer.
  44669. */
  44670. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44671. /**
  44672. * Makes a duplicate of the current configuration into another one.
  44673. * @param configuration define the config where to copy the info
  44674. */
  44675. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44676. /**
  44677. * Serializes this Sub Surface configuration.
  44678. * @returns - An object with the serialized config.
  44679. */
  44680. serialize(): any;
  44681. /**
  44682. * Parses a anisotropy Configuration from a serialized object.
  44683. * @param source - Serialized object.
  44684. * @param scene Defines the scene we are parsing for
  44685. * @param rootUrl Defines the rootUrl to load from
  44686. */
  44687. parse(source: any, scene: Scene, rootUrl: string): void;
  44688. }
  44689. }
  44690. declare module BABYLON {
  44691. /** @hidden */
  44692. export var pbrFragmentDeclaration: {
  44693. name: string;
  44694. shader: string;
  44695. };
  44696. }
  44697. declare module BABYLON {
  44698. /** @hidden */
  44699. export var pbrUboDeclaration: {
  44700. name: string;
  44701. shader: string;
  44702. };
  44703. }
  44704. declare module BABYLON {
  44705. /** @hidden */
  44706. export var pbrFragmentExtraDeclaration: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module BABYLON {
  44712. /** @hidden */
  44713. export var pbrFragmentSamplersDeclaration: {
  44714. name: string;
  44715. shader: string;
  44716. };
  44717. }
  44718. declare module BABYLON {
  44719. /** @hidden */
  44720. export var pbrHelperFunctions: {
  44721. name: string;
  44722. shader: string;
  44723. };
  44724. }
  44725. declare module BABYLON {
  44726. /** @hidden */
  44727. export var harmonicsFunctions: {
  44728. name: string;
  44729. shader: string;
  44730. };
  44731. }
  44732. declare module BABYLON {
  44733. /** @hidden */
  44734. export var pbrDirectLightingSetupFunctions: {
  44735. name: string;
  44736. shader: string;
  44737. };
  44738. }
  44739. declare module BABYLON {
  44740. /** @hidden */
  44741. export var pbrDirectLightingFalloffFunctions: {
  44742. name: string;
  44743. shader: string;
  44744. };
  44745. }
  44746. declare module BABYLON {
  44747. /** @hidden */
  44748. export var pbrBRDFFunctions: {
  44749. name: string;
  44750. shader: string;
  44751. };
  44752. }
  44753. declare module BABYLON {
  44754. /** @hidden */
  44755. export var pbrDirectLightingFunctions: {
  44756. name: string;
  44757. shader: string;
  44758. };
  44759. }
  44760. declare module BABYLON {
  44761. /** @hidden */
  44762. export var pbrIBLFunctions: {
  44763. name: string;
  44764. shader: string;
  44765. };
  44766. }
  44767. declare module BABYLON {
  44768. /** @hidden */
  44769. export var pbrDebug: {
  44770. name: string;
  44771. shader: string;
  44772. };
  44773. }
  44774. declare module BABYLON {
  44775. /** @hidden */
  44776. export var pbrPixelShader: {
  44777. name: string;
  44778. shader: string;
  44779. };
  44780. }
  44781. declare module BABYLON {
  44782. /** @hidden */
  44783. export var pbrVertexDeclaration: {
  44784. name: string;
  44785. shader: string;
  44786. };
  44787. }
  44788. declare module BABYLON {
  44789. /** @hidden */
  44790. export var pbrVertexShader: {
  44791. name: string;
  44792. shader: string;
  44793. };
  44794. }
  44795. declare module BABYLON {
  44796. /**
  44797. * Manages the defines for the PBR Material.
  44798. * @hidden
  44799. */
  44800. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44801. PBR: boolean;
  44802. MAINUV1: boolean;
  44803. MAINUV2: boolean;
  44804. UV1: boolean;
  44805. UV2: boolean;
  44806. ALBEDO: boolean;
  44807. ALBEDODIRECTUV: number;
  44808. VERTEXCOLOR: boolean;
  44809. AMBIENT: boolean;
  44810. AMBIENTDIRECTUV: number;
  44811. AMBIENTINGRAYSCALE: boolean;
  44812. OPACITY: boolean;
  44813. VERTEXALPHA: boolean;
  44814. OPACITYDIRECTUV: number;
  44815. OPACITYRGB: boolean;
  44816. ALPHATEST: boolean;
  44817. DEPTHPREPASS: boolean;
  44818. ALPHABLEND: boolean;
  44819. ALPHAFROMALBEDO: boolean;
  44820. ALPHATESTVALUE: string;
  44821. SPECULAROVERALPHA: boolean;
  44822. RADIANCEOVERALPHA: boolean;
  44823. ALPHAFRESNEL: boolean;
  44824. LINEARALPHAFRESNEL: boolean;
  44825. PREMULTIPLYALPHA: boolean;
  44826. EMISSIVE: boolean;
  44827. EMISSIVEDIRECTUV: number;
  44828. REFLECTIVITY: boolean;
  44829. REFLECTIVITYDIRECTUV: number;
  44830. SPECULARTERM: boolean;
  44831. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44832. MICROSURFACEAUTOMATIC: boolean;
  44833. LODBASEDMICROSFURACE: boolean;
  44834. MICROSURFACEMAP: boolean;
  44835. MICROSURFACEMAPDIRECTUV: number;
  44836. METALLICWORKFLOW: boolean;
  44837. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44838. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44839. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44840. AOSTOREINMETALMAPRED: boolean;
  44841. ENVIRONMENTBRDF: boolean;
  44842. ENVIRONMENTBRDF_RGBD: boolean;
  44843. NORMAL: boolean;
  44844. TANGENT: boolean;
  44845. BUMP: boolean;
  44846. BUMPDIRECTUV: number;
  44847. OBJECTSPACE_NORMALMAP: boolean;
  44848. PARALLAX: boolean;
  44849. PARALLAXOCCLUSION: boolean;
  44850. NORMALXYSCALE: boolean;
  44851. LIGHTMAP: boolean;
  44852. LIGHTMAPDIRECTUV: number;
  44853. USELIGHTMAPASSHADOWMAP: boolean;
  44854. GAMMALIGHTMAP: boolean;
  44855. REFLECTION: boolean;
  44856. REFLECTIONMAP_3D: boolean;
  44857. REFLECTIONMAP_SPHERICAL: boolean;
  44858. REFLECTIONMAP_PLANAR: boolean;
  44859. REFLECTIONMAP_CUBIC: boolean;
  44860. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44861. REFLECTIONMAP_PROJECTION: boolean;
  44862. REFLECTIONMAP_SKYBOX: boolean;
  44863. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44864. REFLECTIONMAP_EXPLICIT: boolean;
  44865. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44866. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44867. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44868. INVERTCUBICMAP: boolean;
  44869. USESPHERICALFROMREFLECTIONMAP: boolean;
  44870. USEIRRADIANCEMAP: boolean;
  44871. SPHERICAL_HARMONICS: boolean;
  44872. USESPHERICALINVERTEX: boolean;
  44873. REFLECTIONMAP_OPPOSITEZ: boolean;
  44874. LODINREFLECTIONALPHA: boolean;
  44875. GAMMAREFLECTION: boolean;
  44876. RGBDREFLECTION: boolean;
  44877. LINEARSPECULARREFLECTION: boolean;
  44878. RADIANCEOCCLUSION: boolean;
  44879. HORIZONOCCLUSION: boolean;
  44880. INSTANCES: boolean;
  44881. NUM_BONE_INFLUENCERS: number;
  44882. BonesPerMesh: number;
  44883. BONETEXTURE: boolean;
  44884. NONUNIFORMSCALING: boolean;
  44885. MORPHTARGETS: boolean;
  44886. MORPHTARGETS_NORMAL: boolean;
  44887. MORPHTARGETS_TANGENT: boolean;
  44888. MORPHTARGETS_UV: boolean;
  44889. NUM_MORPH_INFLUENCERS: number;
  44890. IMAGEPROCESSING: boolean;
  44891. VIGNETTE: boolean;
  44892. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44893. VIGNETTEBLENDMODEOPAQUE: boolean;
  44894. TONEMAPPING: boolean;
  44895. TONEMAPPING_ACES: boolean;
  44896. CONTRAST: boolean;
  44897. COLORCURVES: boolean;
  44898. COLORGRADING: boolean;
  44899. COLORGRADING3D: boolean;
  44900. SAMPLER3DGREENDEPTH: boolean;
  44901. SAMPLER3DBGRMAP: boolean;
  44902. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44903. EXPOSURE: boolean;
  44904. MULTIVIEW: boolean;
  44905. USEPHYSICALLIGHTFALLOFF: boolean;
  44906. USEGLTFLIGHTFALLOFF: boolean;
  44907. TWOSIDEDLIGHTING: boolean;
  44908. SHADOWFLOAT: boolean;
  44909. CLIPPLANE: boolean;
  44910. CLIPPLANE2: boolean;
  44911. CLIPPLANE3: boolean;
  44912. CLIPPLANE4: boolean;
  44913. POINTSIZE: boolean;
  44914. FOG: boolean;
  44915. LOGARITHMICDEPTH: boolean;
  44916. FORCENORMALFORWARD: boolean;
  44917. SPECULARAA: boolean;
  44918. CLEARCOAT: boolean;
  44919. CLEARCOAT_DEFAULTIOR: boolean;
  44920. CLEARCOAT_TEXTURE: boolean;
  44921. CLEARCOAT_TEXTUREDIRECTUV: number;
  44922. CLEARCOAT_BUMP: boolean;
  44923. CLEARCOAT_BUMPDIRECTUV: number;
  44924. CLEARCOAT_TINT: boolean;
  44925. CLEARCOAT_TINT_TEXTURE: boolean;
  44926. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44927. ANISOTROPIC: boolean;
  44928. ANISOTROPIC_TEXTURE: boolean;
  44929. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44930. BRDF_V_HEIGHT_CORRELATED: boolean;
  44931. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44932. SHEEN: boolean;
  44933. SHEEN_TEXTURE: boolean;
  44934. SHEEN_TEXTUREDIRECTUV: number;
  44935. SHEEN_LINKWITHALBEDO: boolean;
  44936. SUBSURFACE: boolean;
  44937. SS_REFRACTION: boolean;
  44938. SS_TRANSLUCENCY: boolean;
  44939. SS_SCATERRING: boolean;
  44940. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44941. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44942. SS_REFRACTIONMAP_3D: boolean;
  44943. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44944. SS_LODINREFRACTIONALPHA: boolean;
  44945. SS_GAMMAREFRACTION: boolean;
  44946. SS_RGBDREFRACTION: boolean;
  44947. SS_LINEARSPECULARREFRACTION: boolean;
  44948. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44949. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44950. UNLIT: boolean;
  44951. DEBUGMODE: number;
  44952. /**
  44953. * Initializes the PBR Material defines.
  44954. */
  44955. constructor();
  44956. /**
  44957. * Resets the PBR Material defines.
  44958. */
  44959. reset(): void;
  44960. }
  44961. /**
  44962. * The Physically based material base class of BJS.
  44963. *
  44964. * This offers the main features of a standard PBR material.
  44965. * For more information, please refer to the documentation :
  44966. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44967. */
  44968. export abstract class PBRBaseMaterial extends PushMaterial {
  44969. /**
  44970. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44971. */
  44972. static readonly PBRMATERIAL_OPAQUE: number;
  44973. /**
  44974. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44975. */
  44976. static readonly PBRMATERIAL_ALPHATEST: number;
  44977. /**
  44978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44979. */
  44980. static readonly PBRMATERIAL_ALPHABLEND: number;
  44981. /**
  44982. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44983. * They are also discarded below the alpha cutoff threshold to improve performances.
  44984. */
  44985. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44986. /**
  44987. * Defines the default value of how much AO map is occluding the analytical lights
  44988. * (point spot...).
  44989. */
  44990. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44991. /**
  44992. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44993. */
  44994. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44995. /**
  44996. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44997. * to enhance interoperability with other engines.
  44998. */
  44999. static readonly LIGHTFALLOFF_GLTF: number;
  45000. /**
  45001. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45002. * to enhance interoperability with other materials.
  45003. */
  45004. static readonly LIGHTFALLOFF_STANDARD: number;
  45005. /**
  45006. * Intensity of the direct lights e.g. the four lights available in your scene.
  45007. * This impacts both the direct diffuse and specular highlights.
  45008. */
  45009. protected _directIntensity: number;
  45010. /**
  45011. * Intensity of the emissive part of the material.
  45012. * This helps controlling the emissive effect without modifying the emissive color.
  45013. */
  45014. protected _emissiveIntensity: number;
  45015. /**
  45016. * Intensity of the environment e.g. how much the environment will light the object
  45017. * either through harmonics for rough material or through the refelction for shiny ones.
  45018. */
  45019. protected _environmentIntensity: number;
  45020. /**
  45021. * This is a special control allowing the reduction of the specular highlights coming from the
  45022. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45023. */
  45024. protected _specularIntensity: number;
  45025. /**
  45026. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45027. */
  45028. private _lightingInfos;
  45029. /**
  45030. * Debug Control allowing disabling the bump map on this material.
  45031. */
  45032. protected _disableBumpMap: boolean;
  45033. /**
  45034. * AKA Diffuse Texture in standard nomenclature.
  45035. */
  45036. protected _albedoTexture: Nullable<BaseTexture>;
  45037. /**
  45038. * AKA Occlusion Texture in other nomenclature.
  45039. */
  45040. protected _ambientTexture: Nullable<BaseTexture>;
  45041. /**
  45042. * AKA Occlusion Texture Intensity in other nomenclature.
  45043. */
  45044. protected _ambientTextureStrength: number;
  45045. /**
  45046. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45047. * 1 means it completely occludes it
  45048. * 0 mean it has no impact
  45049. */
  45050. protected _ambientTextureImpactOnAnalyticalLights: number;
  45051. /**
  45052. * Stores the alpha values in a texture.
  45053. */
  45054. protected _opacityTexture: Nullable<BaseTexture>;
  45055. /**
  45056. * Stores the reflection values in a texture.
  45057. */
  45058. protected _reflectionTexture: Nullable<BaseTexture>;
  45059. /**
  45060. * Stores the emissive values in a texture.
  45061. */
  45062. protected _emissiveTexture: Nullable<BaseTexture>;
  45063. /**
  45064. * AKA Specular texture in other nomenclature.
  45065. */
  45066. protected _reflectivityTexture: Nullable<BaseTexture>;
  45067. /**
  45068. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45069. */
  45070. protected _metallicTexture: Nullable<BaseTexture>;
  45071. /**
  45072. * Specifies the metallic scalar of the metallic/roughness workflow.
  45073. * Can also be used to scale the metalness values of the metallic texture.
  45074. */
  45075. protected _metallic: Nullable<number>;
  45076. /**
  45077. * Specifies the roughness scalar of the metallic/roughness workflow.
  45078. * Can also be used to scale the roughness values of the metallic texture.
  45079. */
  45080. protected _roughness: Nullable<number>;
  45081. /**
  45082. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45083. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45084. */
  45085. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45086. /**
  45087. * Stores surface normal data used to displace a mesh in a texture.
  45088. */
  45089. protected _bumpTexture: Nullable<BaseTexture>;
  45090. /**
  45091. * Stores the pre-calculated light information of a mesh in a texture.
  45092. */
  45093. protected _lightmapTexture: Nullable<BaseTexture>;
  45094. /**
  45095. * The color of a material in ambient lighting.
  45096. */
  45097. protected _ambientColor: Color3;
  45098. /**
  45099. * AKA Diffuse Color in other nomenclature.
  45100. */
  45101. protected _albedoColor: Color3;
  45102. /**
  45103. * AKA Specular Color in other nomenclature.
  45104. */
  45105. protected _reflectivityColor: Color3;
  45106. /**
  45107. * The color applied when light is reflected from a material.
  45108. */
  45109. protected _reflectionColor: Color3;
  45110. /**
  45111. * The color applied when light is emitted from a material.
  45112. */
  45113. protected _emissiveColor: Color3;
  45114. /**
  45115. * AKA Glossiness in other nomenclature.
  45116. */
  45117. protected _microSurface: number;
  45118. /**
  45119. * Specifies that the material will use the light map as a show map.
  45120. */
  45121. protected _useLightmapAsShadowmap: boolean;
  45122. /**
  45123. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45124. * makes the reflect vector face the model (under horizon).
  45125. */
  45126. protected _useHorizonOcclusion: boolean;
  45127. /**
  45128. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45129. * too much the area relying on ambient texture to define their ambient occlusion.
  45130. */
  45131. protected _useRadianceOcclusion: boolean;
  45132. /**
  45133. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45134. */
  45135. protected _useAlphaFromAlbedoTexture: boolean;
  45136. /**
  45137. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45138. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45139. */
  45140. protected _useSpecularOverAlpha: boolean;
  45141. /**
  45142. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45143. */
  45144. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45145. /**
  45146. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45147. */
  45148. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45149. /**
  45150. * Specifies if the metallic texture contains the roughness information in its green channel.
  45151. */
  45152. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45153. /**
  45154. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45155. */
  45156. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45157. /**
  45158. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45159. */
  45160. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45161. /**
  45162. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45163. */
  45164. protected _useAmbientInGrayScale: boolean;
  45165. /**
  45166. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45167. * The material will try to infer what glossiness each pixel should be.
  45168. */
  45169. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45170. /**
  45171. * Defines the falloff type used in this material.
  45172. * It by default is Physical.
  45173. */
  45174. protected _lightFalloff: number;
  45175. /**
  45176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45178. */
  45179. protected _useRadianceOverAlpha: boolean;
  45180. /**
  45181. * Allows using an object space normal map (instead of tangent space).
  45182. */
  45183. protected _useObjectSpaceNormalMap: boolean;
  45184. /**
  45185. * Allows using the bump map in parallax mode.
  45186. */
  45187. protected _useParallax: boolean;
  45188. /**
  45189. * Allows using the bump map in parallax occlusion mode.
  45190. */
  45191. protected _useParallaxOcclusion: boolean;
  45192. /**
  45193. * Controls the scale bias of the parallax mode.
  45194. */
  45195. protected _parallaxScaleBias: number;
  45196. /**
  45197. * If sets to true, disables all the lights affecting the material.
  45198. */
  45199. protected _disableLighting: boolean;
  45200. /**
  45201. * Number of Simultaneous lights allowed on the material.
  45202. */
  45203. protected _maxSimultaneousLights: number;
  45204. /**
  45205. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45206. */
  45207. protected _invertNormalMapX: boolean;
  45208. /**
  45209. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45210. */
  45211. protected _invertNormalMapY: boolean;
  45212. /**
  45213. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45214. */
  45215. protected _twoSidedLighting: boolean;
  45216. /**
  45217. * Defines the alpha limits in alpha test mode.
  45218. */
  45219. protected _alphaCutOff: number;
  45220. /**
  45221. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45222. */
  45223. protected _forceAlphaTest: boolean;
  45224. /**
  45225. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45226. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45227. */
  45228. protected _useAlphaFresnel: boolean;
  45229. /**
  45230. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45231. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45232. */
  45233. protected _useLinearAlphaFresnel: boolean;
  45234. /**
  45235. * The transparency mode of the material.
  45236. */
  45237. protected _transparencyMode: Nullable<number>;
  45238. /**
  45239. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45240. * from cos thetav and roughness:
  45241. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45242. */
  45243. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45244. /**
  45245. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45246. */
  45247. protected _forceIrradianceInFragment: boolean;
  45248. /**
  45249. * Force normal to face away from face.
  45250. */
  45251. protected _forceNormalForward: boolean;
  45252. /**
  45253. * Enables specular anti aliasing in the PBR shader.
  45254. * It will both interacts on the Geometry for analytical and IBL lighting.
  45255. * It also prefilter the roughness map based on the bump values.
  45256. */
  45257. protected _enableSpecularAntiAliasing: boolean;
  45258. /**
  45259. * Default configuration related to image processing available in the PBR Material.
  45260. */
  45261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45262. /**
  45263. * Keep track of the image processing observer to allow dispose and replace.
  45264. */
  45265. private _imageProcessingObserver;
  45266. /**
  45267. * Attaches a new image processing configuration to the PBR Material.
  45268. * @param configuration
  45269. */
  45270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45271. /**
  45272. * Stores the available render targets.
  45273. */
  45274. private _renderTargets;
  45275. /**
  45276. * Sets the global ambient color for the material used in lighting calculations.
  45277. */
  45278. private _globalAmbientColor;
  45279. /**
  45280. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45281. */
  45282. private _useLogarithmicDepth;
  45283. /**
  45284. * If set to true, no lighting calculations will be applied.
  45285. */
  45286. private _unlit;
  45287. private _debugMode;
  45288. /**
  45289. * @hidden
  45290. * This is reserved for the inspector.
  45291. * Defines the material debug mode.
  45292. * It helps seeing only some components of the material while troubleshooting.
  45293. */
  45294. debugMode: number;
  45295. /**
  45296. * @hidden
  45297. * This is reserved for the inspector.
  45298. * Specify from where on screen the debug mode should start.
  45299. * The value goes from -1 (full screen) to 1 (not visible)
  45300. * It helps with side by side comparison against the final render
  45301. * This defaults to -1
  45302. */
  45303. private debugLimit;
  45304. /**
  45305. * @hidden
  45306. * This is reserved for the inspector.
  45307. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45308. * You can use the factor to better multiply the final value.
  45309. */
  45310. private debugFactor;
  45311. /**
  45312. * Defines the clear coat layer parameters for the material.
  45313. */
  45314. readonly clearCoat: PBRClearCoatConfiguration;
  45315. /**
  45316. * Defines the anisotropic parameters for the material.
  45317. */
  45318. readonly anisotropy: PBRAnisotropicConfiguration;
  45319. /**
  45320. * Defines the BRDF parameters for the material.
  45321. */
  45322. readonly brdf: PBRBRDFConfiguration;
  45323. /**
  45324. * Defines the Sheen parameters for the material.
  45325. */
  45326. readonly sheen: PBRSheenConfiguration;
  45327. /**
  45328. * Defines the SubSurface parameters for the material.
  45329. */
  45330. readonly subSurface: PBRSubSurfaceConfiguration;
  45331. /**
  45332. * Custom callback helping to override the default shader used in the material.
  45333. */
  45334. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45335. /**
  45336. * Instantiates a new PBRMaterial instance.
  45337. *
  45338. * @param name The material name
  45339. * @param scene The scene the material will be use in.
  45340. */
  45341. constructor(name: string, scene: Scene);
  45342. /**
  45343. * Gets a boolean indicating that current material needs to register RTT
  45344. */
  45345. readonly hasRenderTargetTextures: boolean;
  45346. /**
  45347. * Gets the name of the material class.
  45348. */
  45349. getClassName(): string;
  45350. /**
  45351. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45352. */
  45353. /**
  45354. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45355. */
  45356. useLogarithmicDepth: boolean;
  45357. /**
  45358. * Gets the current transparency mode.
  45359. */
  45360. /**
  45361. * Sets the transparency mode of the material.
  45362. *
  45363. * | Value | Type | Description |
  45364. * | ----- | ----------------------------------- | ----------- |
  45365. * | 0 | OPAQUE | |
  45366. * | 1 | ALPHATEST | |
  45367. * | 2 | ALPHABLEND | |
  45368. * | 3 | ALPHATESTANDBLEND | |
  45369. *
  45370. */
  45371. transparencyMode: Nullable<number>;
  45372. /**
  45373. * Returns true if alpha blending should be disabled.
  45374. */
  45375. private readonly _disableAlphaBlending;
  45376. /**
  45377. * Specifies whether or not this material should be rendered in alpha blend mode.
  45378. */
  45379. needAlphaBlending(): boolean;
  45380. /**
  45381. * Specifies if the mesh will require alpha blending.
  45382. * @param mesh - BJS mesh.
  45383. */
  45384. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45385. /**
  45386. * Specifies whether or not this material should be rendered in alpha test mode.
  45387. */
  45388. needAlphaTesting(): boolean;
  45389. /**
  45390. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45391. */
  45392. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45393. /**
  45394. * Gets the texture used for the alpha test.
  45395. */
  45396. getAlphaTestTexture(): Nullable<BaseTexture>;
  45397. /**
  45398. * Specifies that the submesh is ready to be used.
  45399. * @param mesh - BJS mesh.
  45400. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45401. * @param useInstances - Specifies that instances should be used.
  45402. * @returns - boolean indicating that the submesh is ready or not.
  45403. */
  45404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45405. /**
  45406. * Specifies if the material uses metallic roughness workflow.
  45407. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45408. */
  45409. isMetallicWorkflow(): boolean;
  45410. private _prepareEffect;
  45411. private _prepareDefines;
  45412. /**
  45413. * Force shader compilation
  45414. */
  45415. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45416. clipPlane: boolean;
  45417. }>): void;
  45418. /**
  45419. * Initializes the uniform buffer layout for the shader.
  45420. */
  45421. buildUniformLayout(): void;
  45422. /**
  45423. * Unbinds the material from the mesh
  45424. */
  45425. unbind(): void;
  45426. /**
  45427. * Binds the submesh data.
  45428. * @param world - The world matrix.
  45429. * @param mesh - The BJS mesh.
  45430. * @param subMesh - A submesh of the BJS mesh.
  45431. */
  45432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45433. /**
  45434. * Returns the animatable textures.
  45435. * @returns - Array of animatable textures.
  45436. */
  45437. getAnimatables(): IAnimatable[];
  45438. /**
  45439. * Returns the texture used for reflections.
  45440. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45441. */
  45442. private _getReflectionTexture;
  45443. /**
  45444. * Returns an array of the actively used textures.
  45445. * @returns - Array of BaseTextures
  45446. */
  45447. getActiveTextures(): BaseTexture[];
  45448. /**
  45449. * Checks to see if a texture is used in the material.
  45450. * @param texture - Base texture to use.
  45451. * @returns - Boolean specifying if a texture is used in the material.
  45452. */
  45453. hasTexture(texture: BaseTexture): boolean;
  45454. /**
  45455. * Disposes the resources of the material.
  45456. * @param forceDisposeEffect - Forces the disposal of effects.
  45457. * @param forceDisposeTextures - Forces the disposal of all textures.
  45458. */
  45459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45460. }
  45461. }
  45462. declare module BABYLON {
  45463. /**
  45464. * The Physically based material of BJS.
  45465. *
  45466. * This offers the main features of a standard PBR material.
  45467. * For more information, please refer to the documentation :
  45468. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45469. */
  45470. export class PBRMaterial extends PBRBaseMaterial {
  45471. /**
  45472. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45473. */
  45474. static readonly PBRMATERIAL_OPAQUE: number;
  45475. /**
  45476. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45477. */
  45478. static readonly PBRMATERIAL_ALPHATEST: number;
  45479. /**
  45480. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45481. */
  45482. static readonly PBRMATERIAL_ALPHABLEND: number;
  45483. /**
  45484. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45485. * They are also discarded below the alpha cutoff threshold to improve performances.
  45486. */
  45487. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45488. /**
  45489. * Defines the default value of how much AO map is occluding the analytical lights
  45490. * (point spot...).
  45491. */
  45492. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45493. /**
  45494. * Intensity of the direct lights e.g. the four lights available in your scene.
  45495. * This impacts both the direct diffuse and specular highlights.
  45496. */
  45497. directIntensity: number;
  45498. /**
  45499. * Intensity of the emissive part of the material.
  45500. * This helps controlling the emissive effect without modifying the emissive color.
  45501. */
  45502. emissiveIntensity: number;
  45503. /**
  45504. * Intensity of the environment e.g. how much the environment will light the object
  45505. * either through harmonics for rough material or through the refelction for shiny ones.
  45506. */
  45507. environmentIntensity: number;
  45508. /**
  45509. * This is a special control allowing the reduction of the specular highlights coming from the
  45510. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45511. */
  45512. specularIntensity: number;
  45513. /**
  45514. * Debug Control allowing disabling the bump map on this material.
  45515. */
  45516. disableBumpMap: boolean;
  45517. /**
  45518. * AKA Diffuse Texture in standard nomenclature.
  45519. */
  45520. albedoTexture: BaseTexture;
  45521. /**
  45522. * AKA Occlusion Texture in other nomenclature.
  45523. */
  45524. ambientTexture: BaseTexture;
  45525. /**
  45526. * AKA Occlusion Texture Intensity in other nomenclature.
  45527. */
  45528. ambientTextureStrength: number;
  45529. /**
  45530. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45531. * 1 means it completely occludes it
  45532. * 0 mean it has no impact
  45533. */
  45534. ambientTextureImpactOnAnalyticalLights: number;
  45535. /**
  45536. * Stores the alpha values in a texture.
  45537. */
  45538. opacityTexture: BaseTexture;
  45539. /**
  45540. * Stores the reflection values in a texture.
  45541. */
  45542. reflectionTexture: Nullable<BaseTexture>;
  45543. /**
  45544. * Stores the emissive values in a texture.
  45545. */
  45546. emissiveTexture: BaseTexture;
  45547. /**
  45548. * AKA Specular texture in other nomenclature.
  45549. */
  45550. reflectivityTexture: BaseTexture;
  45551. /**
  45552. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45553. */
  45554. metallicTexture: BaseTexture;
  45555. /**
  45556. * Specifies the metallic scalar of the metallic/roughness workflow.
  45557. * Can also be used to scale the metalness values of the metallic texture.
  45558. */
  45559. metallic: Nullable<number>;
  45560. /**
  45561. * Specifies the roughness scalar of the metallic/roughness workflow.
  45562. * Can also be used to scale the roughness values of the metallic texture.
  45563. */
  45564. roughness: Nullable<number>;
  45565. /**
  45566. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45567. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45568. */
  45569. microSurfaceTexture: BaseTexture;
  45570. /**
  45571. * Stores surface normal data used to displace a mesh in a texture.
  45572. */
  45573. bumpTexture: BaseTexture;
  45574. /**
  45575. * Stores the pre-calculated light information of a mesh in a texture.
  45576. */
  45577. lightmapTexture: BaseTexture;
  45578. /**
  45579. * Stores the refracted light information in a texture.
  45580. */
  45581. refractionTexture: Nullable<BaseTexture>;
  45582. /**
  45583. * The color of a material in ambient lighting.
  45584. */
  45585. ambientColor: Color3;
  45586. /**
  45587. * AKA Diffuse Color in other nomenclature.
  45588. */
  45589. albedoColor: Color3;
  45590. /**
  45591. * AKA Specular Color in other nomenclature.
  45592. */
  45593. reflectivityColor: Color3;
  45594. /**
  45595. * The color reflected from the material.
  45596. */
  45597. reflectionColor: Color3;
  45598. /**
  45599. * The color emitted from the material.
  45600. */
  45601. emissiveColor: Color3;
  45602. /**
  45603. * AKA Glossiness in other nomenclature.
  45604. */
  45605. microSurface: number;
  45606. /**
  45607. * source material index of refraction (IOR)' / 'destination material IOR.
  45608. */
  45609. indexOfRefraction: number;
  45610. /**
  45611. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45612. */
  45613. invertRefractionY: boolean;
  45614. /**
  45615. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45616. * Materials half opaque for instance using refraction could benefit from this control.
  45617. */
  45618. linkRefractionWithTransparency: boolean;
  45619. /**
  45620. * If true, the light map contains occlusion information instead of lighting info.
  45621. */
  45622. useLightmapAsShadowmap: boolean;
  45623. /**
  45624. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45625. */
  45626. useAlphaFromAlbedoTexture: boolean;
  45627. /**
  45628. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45629. */
  45630. forceAlphaTest: boolean;
  45631. /**
  45632. * Defines the alpha limits in alpha test mode.
  45633. */
  45634. alphaCutOff: number;
  45635. /**
  45636. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45637. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45638. */
  45639. useSpecularOverAlpha: boolean;
  45640. /**
  45641. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45642. */
  45643. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45644. /**
  45645. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45646. */
  45647. useRoughnessFromMetallicTextureAlpha: boolean;
  45648. /**
  45649. * Specifies if the metallic texture contains the roughness information in its green channel.
  45650. */
  45651. useRoughnessFromMetallicTextureGreen: boolean;
  45652. /**
  45653. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45654. */
  45655. useMetallnessFromMetallicTextureBlue: boolean;
  45656. /**
  45657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45658. */
  45659. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45660. /**
  45661. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45662. */
  45663. useAmbientInGrayScale: boolean;
  45664. /**
  45665. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45666. * The material will try to infer what glossiness each pixel should be.
  45667. */
  45668. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45669. /**
  45670. * BJS is using an harcoded light falloff based on a manually sets up range.
  45671. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45672. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45673. */
  45674. /**
  45675. * BJS is using an harcoded light falloff based on a manually sets up range.
  45676. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45677. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45678. */
  45679. usePhysicalLightFalloff: boolean;
  45680. /**
  45681. * In order to support the falloff compatibility with gltf, a special mode has been added
  45682. * to reproduce the gltf light falloff.
  45683. */
  45684. /**
  45685. * In order to support the falloff compatibility with gltf, a special mode has been added
  45686. * to reproduce the gltf light falloff.
  45687. */
  45688. useGLTFLightFalloff: boolean;
  45689. /**
  45690. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45691. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45692. */
  45693. useRadianceOverAlpha: boolean;
  45694. /**
  45695. * Allows using an object space normal map (instead of tangent space).
  45696. */
  45697. useObjectSpaceNormalMap: boolean;
  45698. /**
  45699. * Allows using the bump map in parallax mode.
  45700. */
  45701. useParallax: boolean;
  45702. /**
  45703. * Allows using the bump map in parallax occlusion mode.
  45704. */
  45705. useParallaxOcclusion: boolean;
  45706. /**
  45707. * Controls the scale bias of the parallax mode.
  45708. */
  45709. parallaxScaleBias: number;
  45710. /**
  45711. * If sets to true, disables all the lights affecting the material.
  45712. */
  45713. disableLighting: boolean;
  45714. /**
  45715. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45716. */
  45717. forceIrradianceInFragment: boolean;
  45718. /**
  45719. * Number of Simultaneous lights allowed on the material.
  45720. */
  45721. maxSimultaneousLights: number;
  45722. /**
  45723. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45724. */
  45725. invertNormalMapX: boolean;
  45726. /**
  45727. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45728. */
  45729. invertNormalMapY: boolean;
  45730. /**
  45731. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45732. */
  45733. twoSidedLighting: boolean;
  45734. /**
  45735. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45736. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45737. */
  45738. useAlphaFresnel: boolean;
  45739. /**
  45740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45741. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45742. */
  45743. useLinearAlphaFresnel: boolean;
  45744. /**
  45745. * Let user defines the brdf lookup texture used for IBL.
  45746. * A default 8bit version is embedded but you could point at :
  45747. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  45748. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45749. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  45750. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45751. */
  45752. environmentBRDFTexture: Nullable<BaseTexture>;
  45753. /**
  45754. * Force normal to face away from face.
  45755. */
  45756. forceNormalForward: boolean;
  45757. /**
  45758. * Enables specular anti aliasing in the PBR shader.
  45759. * It will both interacts on the Geometry for analytical and IBL lighting.
  45760. * It also prefilter the roughness map based on the bump values.
  45761. */
  45762. enableSpecularAntiAliasing: boolean;
  45763. /**
  45764. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45765. * makes the reflect vector face the model (under horizon).
  45766. */
  45767. useHorizonOcclusion: boolean;
  45768. /**
  45769. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45770. * too much the area relying on ambient texture to define their ambient occlusion.
  45771. */
  45772. useRadianceOcclusion: boolean;
  45773. /**
  45774. * If set to true, no lighting calculations will be applied.
  45775. */
  45776. unlit: boolean;
  45777. /**
  45778. * Gets the image processing configuration used either in this material.
  45779. */
  45780. /**
  45781. * Sets the Default image processing configuration used either in the this material.
  45782. *
  45783. * If sets to null, the scene one is in use.
  45784. */
  45785. imageProcessingConfiguration: ImageProcessingConfiguration;
  45786. /**
  45787. * Gets wether the color curves effect is enabled.
  45788. */
  45789. /**
  45790. * Sets wether the color curves effect is enabled.
  45791. */
  45792. cameraColorCurvesEnabled: boolean;
  45793. /**
  45794. * Gets wether the color grading effect is enabled.
  45795. */
  45796. /**
  45797. * Gets wether the color grading effect is enabled.
  45798. */
  45799. cameraColorGradingEnabled: boolean;
  45800. /**
  45801. * Gets wether tonemapping is enabled or not.
  45802. */
  45803. /**
  45804. * Sets wether tonemapping is enabled or not
  45805. */
  45806. cameraToneMappingEnabled: boolean;
  45807. /**
  45808. * The camera exposure used on this material.
  45809. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45810. * This corresponds to a photographic exposure.
  45811. */
  45812. /**
  45813. * The camera exposure used on this material.
  45814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45815. * This corresponds to a photographic exposure.
  45816. */
  45817. cameraExposure: number;
  45818. /**
  45819. * Gets The camera contrast used on this material.
  45820. */
  45821. /**
  45822. * Sets The camera contrast used on this material.
  45823. */
  45824. cameraContrast: number;
  45825. /**
  45826. * Gets the Color Grading 2D Lookup Texture.
  45827. */
  45828. /**
  45829. * Sets the Color Grading 2D Lookup Texture.
  45830. */
  45831. cameraColorGradingTexture: Nullable<BaseTexture>;
  45832. /**
  45833. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45834. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45835. * 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;
  45836. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45837. */
  45838. /**
  45839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45841. * 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;
  45842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45843. */
  45844. cameraColorCurves: Nullable<ColorCurves>;
  45845. /**
  45846. * Instantiates a new PBRMaterial instance.
  45847. *
  45848. * @param name The material name
  45849. * @param scene The scene the material will be use in.
  45850. */
  45851. constructor(name: string, scene: Scene);
  45852. /**
  45853. * Returns the name of this material class.
  45854. */
  45855. getClassName(): string;
  45856. /**
  45857. * Makes a duplicate of the current material.
  45858. * @param name - name to use for the new material.
  45859. */
  45860. clone(name: string): PBRMaterial;
  45861. /**
  45862. * Serializes this PBR Material.
  45863. * @returns - An object with the serialized material.
  45864. */
  45865. serialize(): any;
  45866. /**
  45867. * Parses a PBR Material from a serialized object.
  45868. * @param source - Serialized object.
  45869. * @param scene - BJS scene instance.
  45870. * @param rootUrl - url for the scene object
  45871. * @returns - PBRMaterial
  45872. */
  45873. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45874. }
  45875. }
  45876. declare module BABYLON {
  45877. /**
  45878. * Direct draw surface info
  45879. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45880. */
  45881. export interface DDSInfo {
  45882. /**
  45883. * Width of the texture
  45884. */
  45885. width: number;
  45886. /**
  45887. * Width of the texture
  45888. */
  45889. height: number;
  45890. /**
  45891. * Number of Mipmaps for the texture
  45892. * @see https://en.wikipedia.org/wiki/Mipmap
  45893. */
  45894. mipmapCount: number;
  45895. /**
  45896. * If the textures format is a known fourCC format
  45897. * @see https://www.fourcc.org/
  45898. */
  45899. isFourCC: boolean;
  45900. /**
  45901. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45902. */
  45903. isRGB: boolean;
  45904. /**
  45905. * If the texture is a lumincance format
  45906. */
  45907. isLuminance: boolean;
  45908. /**
  45909. * If this is a cube texture
  45910. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45911. */
  45912. isCube: boolean;
  45913. /**
  45914. * If the texture is a compressed format eg. FOURCC_DXT1
  45915. */
  45916. isCompressed: boolean;
  45917. /**
  45918. * The dxgiFormat of the texture
  45919. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45920. */
  45921. dxgiFormat: number;
  45922. /**
  45923. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45924. */
  45925. textureType: number;
  45926. /**
  45927. * Sphericle polynomial created for the dds texture
  45928. */
  45929. sphericalPolynomial?: SphericalPolynomial;
  45930. }
  45931. /**
  45932. * Class used to provide DDS decompression tools
  45933. */
  45934. export class DDSTools {
  45935. /**
  45936. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45937. */
  45938. static StoreLODInAlphaChannel: boolean;
  45939. /**
  45940. * Gets DDS information from an array buffer
  45941. * @param arrayBuffer defines the array buffer to read data from
  45942. * @returns the DDS information
  45943. */
  45944. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45945. private static _FloatView;
  45946. private static _Int32View;
  45947. private static _ToHalfFloat;
  45948. private static _FromHalfFloat;
  45949. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45950. private static _GetHalfFloatRGBAArrayBuffer;
  45951. private static _GetFloatRGBAArrayBuffer;
  45952. private static _GetFloatAsUIntRGBAArrayBuffer;
  45953. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45954. private static _GetRGBAArrayBuffer;
  45955. private static _ExtractLongWordOrder;
  45956. private static _GetRGBArrayBuffer;
  45957. private static _GetLuminanceArrayBuffer;
  45958. /**
  45959. * Uploads DDS Levels to a Babylon Texture
  45960. * @hidden
  45961. */
  45962. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45963. }
  45964. interface Engine {
  45965. /**
  45966. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45967. * @param rootUrl defines the url where the file to load is located
  45968. * @param scene defines the current scene
  45969. * @param lodScale defines scale to apply to the mip map selection
  45970. * @param lodOffset defines offset to apply to the mip map selection
  45971. * @param onLoad defines an optional callback raised when the texture is loaded
  45972. * @param onError defines an optional callback raised if there is an issue to load the texture
  45973. * @param format defines the format of the data
  45974. * @param forcedExtension defines the extension to use to pick the right loader
  45975. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45976. * @returns the cube texture as an InternalTexture
  45977. */
  45978. 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;
  45979. }
  45980. }
  45981. declare module BABYLON {
  45982. /**
  45983. * Implementation of the DDS Texture Loader.
  45984. * @hidden
  45985. */
  45986. export class _DDSTextureLoader implements IInternalTextureLoader {
  45987. /**
  45988. * Defines wether the loader supports cascade loading the different faces.
  45989. */
  45990. readonly supportCascades: boolean;
  45991. /**
  45992. * This returns if the loader support the current file information.
  45993. * @param extension defines the file extension of the file being loaded
  45994. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45995. * @param fallback defines the fallback internal texture if any
  45996. * @param isBase64 defines whether the texture is encoded as a base64
  45997. * @param isBuffer defines whether the texture data are stored as a buffer
  45998. * @returns true if the loader can load the specified file
  45999. */
  46000. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46001. /**
  46002. * Transform the url before loading if required.
  46003. * @param rootUrl the url of the texture
  46004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46005. * @returns the transformed texture
  46006. */
  46007. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46008. /**
  46009. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46010. * @param rootUrl the url of the texture
  46011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46012. * @returns the fallback texture
  46013. */
  46014. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46015. /**
  46016. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46017. * @param data contains the texture data
  46018. * @param texture defines the BabylonJS internal texture
  46019. * @param createPolynomials will be true if polynomials have been requested
  46020. * @param onLoad defines the callback to trigger once the texture is ready
  46021. * @param onError defines the callback to trigger in case of error
  46022. */
  46023. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46024. /**
  46025. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46026. * @param data contains the texture data
  46027. * @param texture defines the BabylonJS internal texture
  46028. * @param callback defines the method to call once ready to upload
  46029. */
  46030. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46031. }
  46032. }
  46033. declare module BABYLON {
  46034. /** @hidden */
  46035. export var rgbdEncodePixelShader: {
  46036. name: string;
  46037. shader: string;
  46038. };
  46039. }
  46040. declare module BABYLON {
  46041. /**
  46042. * Raw texture data and descriptor sufficient for WebGL texture upload
  46043. */
  46044. export interface EnvironmentTextureInfo {
  46045. /**
  46046. * Version of the environment map
  46047. */
  46048. version: number;
  46049. /**
  46050. * Width of image
  46051. */
  46052. width: number;
  46053. /**
  46054. * Irradiance information stored in the file.
  46055. */
  46056. irradiance: any;
  46057. /**
  46058. * Specular information stored in the file.
  46059. */
  46060. specular: any;
  46061. }
  46062. /**
  46063. * Sets of helpers addressing the serialization and deserialization of environment texture
  46064. * stored in a BabylonJS env file.
  46065. * Those files are usually stored as .env files.
  46066. */
  46067. export class EnvironmentTextureTools {
  46068. /**
  46069. * Magic number identifying the env file.
  46070. */
  46071. private static _MagicBytes;
  46072. /**
  46073. * Gets the environment info from an env file.
  46074. * @param data The array buffer containing the .env bytes.
  46075. * @returns the environment file info (the json header) if successfully parsed.
  46076. */
  46077. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46078. /**
  46079. * Creates an environment texture from a loaded cube texture.
  46080. * @param texture defines the cube texture to convert in env file
  46081. * @return a promise containing the environment data if succesfull.
  46082. */
  46083. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46084. /**
  46085. * Creates a JSON representation of the spherical data.
  46086. * @param texture defines the texture containing the polynomials
  46087. * @return the JSON representation of the spherical info
  46088. */
  46089. private static _CreateEnvTextureIrradiance;
  46090. /**
  46091. * Uploads the texture info contained in the env file to the GPU.
  46092. * @param texture defines the internal texture to upload to
  46093. * @param arrayBuffer defines the buffer cotaining the data to load
  46094. * @param info defines the texture info retrieved through the GetEnvInfo method
  46095. * @returns a promise
  46096. */
  46097. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46098. /**
  46099. * Uploads the levels of image data to the GPU.
  46100. * @param texture defines the internal texture to upload to
  46101. * @param imageData defines the array buffer views of image data [mipmap][face]
  46102. * @returns a promise
  46103. */
  46104. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46105. /**
  46106. * Uploads spherical polynomials information to the texture.
  46107. * @param texture defines the texture we are trying to upload the information to
  46108. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46109. */
  46110. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46111. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46112. }
  46113. }
  46114. declare module BABYLON {
  46115. /**
  46116. * Implementation of the ENV Texture Loader.
  46117. * @hidden
  46118. */
  46119. export class _ENVTextureLoader implements IInternalTextureLoader {
  46120. /**
  46121. * Defines wether the loader supports cascade loading the different faces.
  46122. */
  46123. readonly supportCascades: boolean;
  46124. /**
  46125. * This returns if the loader support the current file information.
  46126. * @param extension defines the file extension of the file being loaded
  46127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46128. * @param fallback defines the fallback internal texture if any
  46129. * @param isBase64 defines whether the texture is encoded as a base64
  46130. * @param isBuffer defines whether the texture data are stored as a buffer
  46131. * @returns true if the loader can load the specified file
  46132. */
  46133. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46134. /**
  46135. * Transform the url before loading if required.
  46136. * @param rootUrl the url of the texture
  46137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46138. * @returns the transformed texture
  46139. */
  46140. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46141. /**
  46142. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46143. * @param rootUrl the url of the texture
  46144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46145. * @returns the fallback texture
  46146. */
  46147. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46148. /**
  46149. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46150. * @param data contains the texture data
  46151. * @param texture defines the BabylonJS internal texture
  46152. * @param createPolynomials will be true if polynomials have been requested
  46153. * @param onLoad defines the callback to trigger once the texture is ready
  46154. * @param onError defines the callback to trigger in case of error
  46155. */
  46156. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46157. /**
  46158. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46159. * @param data contains the texture data
  46160. * @param texture defines the BabylonJS internal texture
  46161. * @param callback defines the method to call once ready to upload
  46162. */
  46163. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46164. }
  46165. }
  46166. declare module BABYLON {
  46167. /**
  46168. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46169. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46170. */
  46171. export class KhronosTextureContainer {
  46172. /** contents of the KTX container file */
  46173. arrayBuffer: any;
  46174. private static HEADER_LEN;
  46175. private static COMPRESSED_2D;
  46176. private static COMPRESSED_3D;
  46177. private static TEX_2D;
  46178. private static TEX_3D;
  46179. /**
  46180. * Gets the openGL type
  46181. */
  46182. glType: number;
  46183. /**
  46184. * Gets the openGL type size
  46185. */
  46186. glTypeSize: number;
  46187. /**
  46188. * Gets the openGL format
  46189. */
  46190. glFormat: number;
  46191. /**
  46192. * Gets the openGL internal format
  46193. */
  46194. glInternalFormat: number;
  46195. /**
  46196. * Gets the base internal format
  46197. */
  46198. glBaseInternalFormat: number;
  46199. /**
  46200. * Gets image width in pixel
  46201. */
  46202. pixelWidth: number;
  46203. /**
  46204. * Gets image height in pixel
  46205. */
  46206. pixelHeight: number;
  46207. /**
  46208. * Gets image depth in pixels
  46209. */
  46210. pixelDepth: number;
  46211. /**
  46212. * Gets the number of array elements
  46213. */
  46214. numberOfArrayElements: number;
  46215. /**
  46216. * Gets the number of faces
  46217. */
  46218. numberOfFaces: number;
  46219. /**
  46220. * Gets the number of mipmap levels
  46221. */
  46222. numberOfMipmapLevels: number;
  46223. /**
  46224. * Gets the bytes of key value data
  46225. */
  46226. bytesOfKeyValueData: number;
  46227. /**
  46228. * Gets the load type
  46229. */
  46230. loadType: number;
  46231. /**
  46232. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46233. */
  46234. isInvalid: boolean;
  46235. /**
  46236. * Creates a new KhronosTextureContainer
  46237. * @param arrayBuffer contents of the KTX container file
  46238. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46239. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46240. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46241. */
  46242. constructor(
  46243. /** contents of the KTX container file */
  46244. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46245. /**
  46246. * Uploads KTX content to a Babylon Texture.
  46247. * It is assumed that the texture has already been created & is currently bound
  46248. * @hidden
  46249. */
  46250. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46251. private _upload2DCompressedLevels;
  46252. }
  46253. }
  46254. declare module BABYLON {
  46255. /**
  46256. * Implementation of the KTX Texture Loader.
  46257. * @hidden
  46258. */
  46259. export class _KTXTextureLoader implements IInternalTextureLoader {
  46260. /**
  46261. * Defines wether the loader supports cascade loading the different faces.
  46262. */
  46263. readonly supportCascades: boolean;
  46264. /**
  46265. * This returns if the loader support the current file information.
  46266. * @param extension defines the file extension of the file being loaded
  46267. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46268. * @param fallback defines the fallback internal texture if any
  46269. * @param isBase64 defines whether the texture is encoded as a base64
  46270. * @param isBuffer defines whether the texture data are stored as a buffer
  46271. * @returns true if the loader can load the specified file
  46272. */
  46273. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46274. /**
  46275. * Transform the url before loading if required.
  46276. * @param rootUrl the url of the texture
  46277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46278. * @returns the transformed texture
  46279. */
  46280. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46281. /**
  46282. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46283. * @param rootUrl the url of the texture
  46284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46285. * @returns the fallback texture
  46286. */
  46287. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46288. /**
  46289. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46290. * @param data contains the texture data
  46291. * @param texture defines the BabylonJS internal texture
  46292. * @param createPolynomials will be true if polynomials have been requested
  46293. * @param onLoad defines the callback to trigger once the texture is ready
  46294. * @param onError defines the callback to trigger in case of error
  46295. */
  46296. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46297. /**
  46298. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46299. * @param data contains the texture data
  46300. * @param texture defines the BabylonJS internal texture
  46301. * @param callback defines the method to call once ready to upload
  46302. */
  46303. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46304. }
  46305. }
  46306. declare module BABYLON {
  46307. /** @hidden */
  46308. export var _forceSceneHelpersToBundle: boolean;
  46309. interface Scene {
  46310. /**
  46311. * Creates a default light for the scene.
  46312. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46313. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46314. */
  46315. createDefaultLight(replace?: boolean): void;
  46316. /**
  46317. * Creates a default camera for the scene.
  46318. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46319. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46320. * @param replace has default false, when true replaces the active camera in the scene
  46321. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46322. */
  46323. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46324. /**
  46325. * Creates a default camera and a default light.
  46326. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46327. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46328. * @param replace has the default false, when true replaces the active camera/light in the scene
  46329. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46330. */
  46331. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46332. /**
  46333. * Creates a new sky box
  46334. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46335. * @param environmentTexture defines the texture to use as environment texture
  46336. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46337. * @param scale defines the overall scale of the skybox
  46338. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46339. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46340. * @returns a new mesh holding the sky box
  46341. */
  46342. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46343. /**
  46344. * Creates a new environment
  46345. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46346. * @param options defines the options you can use to configure the environment
  46347. * @returns the new EnvironmentHelper
  46348. */
  46349. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46350. /**
  46351. * Creates a new VREXperienceHelper
  46352. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46353. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46354. * @returns a new VREXperienceHelper
  46355. */
  46356. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46357. /**
  46358. * Creates a new XREXperienceHelper
  46359. * @see http://doc.babylonjs.com/how_to/webxr
  46360. * @returns a promise for a new XREXperienceHelper
  46361. */
  46362. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46363. }
  46364. }
  46365. declare module BABYLON {
  46366. /**
  46367. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46368. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46369. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46370. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46371. */
  46372. export class VideoDome extends TransformNode {
  46373. /**
  46374. * Define the video source as a Monoscopic panoramic 360 video.
  46375. */
  46376. static readonly MODE_MONOSCOPIC: number;
  46377. /**
  46378. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46379. */
  46380. static readonly MODE_TOPBOTTOM: number;
  46381. /**
  46382. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46383. */
  46384. static readonly MODE_SIDEBYSIDE: number;
  46385. private _useDirectMapping;
  46386. /**
  46387. * The video texture being displayed on the sphere
  46388. */
  46389. protected _videoTexture: VideoTexture;
  46390. /**
  46391. * Gets the video texture being displayed on the sphere
  46392. */
  46393. readonly videoTexture: VideoTexture;
  46394. /**
  46395. * The skybox material
  46396. */
  46397. protected _material: BackgroundMaterial;
  46398. /**
  46399. * The surface used for the skybox
  46400. */
  46401. protected _mesh: Mesh;
  46402. /**
  46403. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46404. * Also see the options.resolution property.
  46405. */
  46406. fovMultiplier: number;
  46407. private _videoMode;
  46408. /**
  46409. * Gets or set the current video mode for the video. It can be:
  46410. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46411. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46412. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46413. */
  46414. videoMode: number;
  46415. /**
  46416. * Oberserver used in Stereoscopic VR Mode.
  46417. */
  46418. private _onBeforeCameraRenderObserver;
  46419. /**
  46420. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46421. * @param name Element's name, child elements will append suffixes for their own names.
  46422. * @param urlsOrVideo defines the url(s) or the video element to use
  46423. * @param options An object containing optional or exposed sub element properties
  46424. */
  46425. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46426. resolution?: number;
  46427. clickToPlay?: boolean;
  46428. autoPlay?: boolean;
  46429. loop?: boolean;
  46430. size?: number;
  46431. poster?: string;
  46432. faceForward?: boolean;
  46433. useDirectMapping?: boolean;
  46434. }, scene: Scene);
  46435. private _changeVideoMode;
  46436. /**
  46437. * Releases resources associated with this node.
  46438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46440. */
  46441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46442. }
  46443. }
  46444. declare module BABYLON {
  46445. /**
  46446. * This class can be used to get instrumentation data from a Babylon engine
  46447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46448. */
  46449. export class EngineInstrumentation implements IDisposable {
  46450. /**
  46451. * Define the instrumented engine.
  46452. */
  46453. engine: Engine;
  46454. private _captureGPUFrameTime;
  46455. private _gpuFrameTimeToken;
  46456. private _gpuFrameTime;
  46457. private _captureShaderCompilationTime;
  46458. private _shaderCompilationTime;
  46459. private _onBeginFrameObserver;
  46460. private _onEndFrameObserver;
  46461. private _onBeforeShaderCompilationObserver;
  46462. private _onAfterShaderCompilationObserver;
  46463. /**
  46464. * Gets the perf counter used for GPU frame time
  46465. */
  46466. readonly gpuFrameTimeCounter: PerfCounter;
  46467. /**
  46468. * Gets the GPU frame time capture status
  46469. */
  46470. /**
  46471. * Enable or disable the GPU frame time capture
  46472. */
  46473. captureGPUFrameTime: boolean;
  46474. /**
  46475. * Gets the perf counter used for shader compilation time
  46476. */
  46477. readonly shaderCompilationTimeCounter: PerfCounter;
  46478. /**
  46479. * Gets the shader compilation time capture status
  46480. */
  46481. /**
  46482. * Enable or disable the shader compilation time capture
  46483. */
  46484. captureShaderCompilationTime: boolean;
  46485. /**
  46486. * Instantiates a new engine instrumentation.
  46487. * This class can be used to get instrumentation data from a Babylon engine
  46488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46489. * @param engine Defines the engine to instrument
  46490. */
  46491. constructor(
  46492. /**
  46493. * Define the instrumented engine.
  46494. */
  46495. engine: Engine);
  46496. /**
  46497. * Dispose and release associated resources.
  46498. */
  46499. dispose(): void;
  46500. }
  46501. }
  46502. declare module BABYLON {
  46503. /**
  46504. * This class can be used to get instrumentation data from a Babylon engine
  46505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46506. */
  46507. export class SceneInstrumentation implements IDisposable {
  46508. /**
  46509. * Defines the scene to instrument
  46510. */
  46511. scene: Scene;
  46512. private _captureActiveMeshesEvaluationTime;
  46513. private _activeMeshesEvaluationTime;
  46514. private _captureRenderTargetsRenderTime;
  46515. private _renderTargetsRenderTime;
  46516. private _captureFrameTime;
  46517. private _frameTime;
  46518. private _captureRenderTime;
  46519. private _renderTime;
  46520. private _captureInterFrameTime;
  46521. private _interFrameTime;
  46522. private _captureParticlesRenderTime;
  46523. private _particlesRenderTime;
  46524. private _captureSpritesRenderTime;
  46525. private _spritesRenderTime;
  46526. private _capturePhysicsTime;
  46527. private _physicsTime;
  46528. private _captureAnimationsTime;
  46529. private _animationsTime;
  46530. private _captureCameraRenderTime;
  46531. private _cameraRenderTime;
  46532. private _onBeforeActiveMeshesEvaluationObserver;
  46533. private _onAfterActiveMeshesEvaluationObserver;
  46534. private _onBeforeRenderTargetsRenderObserver;
  46535. private _onAfterRenderTargetsRenderObserver;
  46536. private _onAfterRenderObserver;
  46537. private _onBeforeDrawPhaseObserver;
  46538. private _onAfterDrawPhaseObserver;
  46539. private _onBeforeAnimationsObserver;
  46540. private _onBeforeParticlesRenderingObserver;
  46541. private _onAfterParticlesRenderingObserver;
  46542. private _onBeforeSpritesRenderingObserver;
  46543. private _onAfterSpritesRenderingObserver;
  46544. private _onBeforePhysicsObserver;
  46545. private _onAfterPhysicsObserver;
  46546. private _onAfterAnimationsObserver;
  46547. private _onBeforeCameraRenderObserver;
  46548. private _onAfterCameraRenderObserver;
  46549. /**
  46550. * Gets the perf counter used for active meshes evaluation time
  46551. */
  46552. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46553. /**
  46554. * Gets the active meshes evaluation time capture status
  46555. */
  46556. /**
  46557. * Enable or disable the active meshes evaluation time capture
  46558. */
  46559. captureActiveMeshesEvaluationTime: boolean;
  46560. /**
  46561. * Gets the perf counter used for render targets render time
  46562. */
  46563. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46564. /**
  46565. * Gets the render targets render time capture status
  46566. */
  46567. /**
  46568. * Enable or disable the render targets render time capture
  46569. */
  46570. captureRenderTargetsRenderTime: boolean;
  46571. /**
  46572. * Gets the perf counter used for particles render time
  46573. */
  46574. readonly particlesRenderTimeCounter: PerfCounter;
  46575. /**
  46576. * Gets the particles render time capture status
  46577. */
  46578. /**
  46579. * Enable or disable the particles render time capture
  46580. */
  46581. captureParticlesRenderTime: boolean;
  46582. /**
  46583. * Gets the perf counter used for sprites render time
  46584. */
  46585. readonly spritesRenderTimeCounter: PerfCounter;
  46586. /**
  46587. * Gets the sprites render time capture status
  46588. */
  46589. /**
  46590. * Enable or disable the sprites render time capture
  46591. */
  46592. captureSpritesRenderTime: boolean;
  46593. /**
  46594. * Gets the perf counter used for physics time
  46595. */
  46596. readonly physicsTimeCounter: PerfCounter;
  46597. /**
  46598. * Gets the physics time capture status
  46599. */
  46600. /**
  46601. * Enable or disable the physics time capture
  46602. */
  46603. capturePhysicsTime: boolean;
  46604. /**
  46605. * Gets the perf counter used for animations time
  46606. */
  46607. readonly animationsTimeCounter: PerfCounter;
  46608. /**
  46609. * Gets the animations time capture status
  46610. */
  46611. /**
  46612. * Enable or disable the animations time capture
  46613. */
  46614. captureAnimationsTime: boolean;
  46615. /**
  46616. * Gets the perf counter used for frame time capture
  46617. */
  46618. readonly frameTimeCounter: PerfCounter;
  46619. /**
  46620. * Gets the frame time capture status
  46621. */
  46622. /**
  46623. * Enable or disable the frame time capture
  46624. */
  46625. captureFrameTime: boolean;
  46626. /**
  46627. * Gets the perf counter used for inter-frames time capture
  46628. */
  46629. readonly interFrameTimeCounter: PerfCounter;
  46630. /**
  46631. * Gets the inter-frames time capture status
  46632. */
  46633. /**
  46634. * Enable or disable the inter-frames time capture
  46635. */
  46636. captureInterFrameTime: boolean;
  46637. /**
  46638. * Gets the perf counter used for render time capture
  46639. */
  46640. readonly renderTimeCounter: PerfCounter;
  46641. /**
  46642. * Gets the render time capture status
  46643. */
  46644. /**
  46645. * Enable or disable the render time capture
  46646. */
  46647. captureRenderTime: boolean;
  46648. /**
  46649. * Gets the perf counter used for camera render time capture
  46650. */
  46651. readonly cameraRenderTimeCounter: PerfCounter;
  46652. /**
  46653. * Gets the camera render time capture status
  46654. */
  46655. /**
  46656. * Enable or disable the camera render time capture
  46657. */
  46658. captureCameraRenderTime: boolean;
  46659. /**
  46660. * Gets the perf counter used for draw calls
  46661. */
  46662. readonly drawCallsCounter: PerfCounter;
  46663. /**
  46664. * Instantiates a new scene instrumentation.
  46665. * This class can be used to get instrumentation data from a Babylon engine
  46666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46667. * @param scene Defines the scene to instrument
  46668. */
  46669. constructor(
  46670. /**
  46671. * Defines the scene to instrument
  46672. */
  46673. scene: Scene);
  46674. /**
  46675. * Dispose and release associated resources.
  46676. */
  46677. dispose(): void;
  46678. }
  46679. }
  46680. declare module BABYLON {
  46681. /** @hidden */
  46682. export var glowMapGenerationPixelShader: {
  46683. name: string;
  46684. shader: string;
  46685. };
  46686. }
  46687. declare module BABYLON {
  46688. /** @hidden */
  46689. export var glowMapGenerationVertexShader: {
  46690. name: string;
  46691. shader: string;
  46692. };
  46693. }
  46694. declare module BABYLON {
  46695. /**
  46696. * Effect layer options. This helps customizing the behaviour
  46697. * of the effect layer.
  46698. */
  46699. export interface IEffectLayerOptions {
  46700. /**
  46701. * Multiplication factor apply to the canvas size to compute the render target size
  46702. * used to generated the objects (the smaller the faster).
  46703. */
  46704. mainTextureRatio: number;
  46705. /**
  46706. * Enforces a fixed size texture to ensure effect stability across devices.
  46707. */
  46708. mainTextureFixedSize?: number;
  46709. /**
  46710. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46711. */
  46712. alphaBlendingMode: number;
  46713. /**
  46714. * The camera attached to the layer.
  46715. */
  46716. camera: Nullable<Camera>;
  46717. /**
  46718. * The rendering group to draw the layer in.
  46719. */
  46720. renderingGroupId: number;
  46721. }
  46722. /**
  46723. * The effect layer Helps adding post process effect blended with the main pass.
  46724. *
  46725. * This can be for instance use to generate glow or higlight effects on the scene.
  46726. *
  46727. * The effect layer class can not be used directly and is intented to inherited from to be
  46728. * customized per effects.
  46729. */
  46730. export abstract class EffectLayer {
  46731. private _vertexBuffers;
  46732. private _indexBuffer;
  46733. private _cachedDefines;
  46734. private _effectLayerMapGenerationEffect;
  46735. private _effectLayerOptions;
  46736. private _mergeEffect;
  46737. protected _scene: Scene;
  46738. protected _engine: Engine;
  46739. protected _maxSize: number;
  46740. protected _mainTextureDesiredSize: ISize;
  46741. protected _mainTexture: RenderTargetTexture;
  46742. protected _shouldRender: boolean;
  46743. protected _postProcesses: PostProcess[];
  46744. protected _textures: BaseTexture[];
  46745. protected _emissiveTextureAndColor: {
  46746. texture: Nullable<BaseTexture>;
  46747. color: Color4;
  46748. };
  46749. /**
  46750. * The name of the layer
  46751. */
  46752. name: string;
  46753. /**
  46754. * The clear color of the texture used to generate the glow map.
  46755. */
  46756. neutralColor: Color4;
  46757. /**
  46758. * Specifies wether the highlight layer is enabled or not.
  46759. */
  46760. isEnabled: boolean;
  46761. /**
  46762. * Gets the camera attached to the layer.
  46763. */
  46764. readonly camera: Nullable<Camera>;
  46765. /**
  46766. * Gets the rendering group id the layer should render in.
  46767. */
  46768. renderingGroupId: number;
  46769. /**
  46770. * An event triggered when the effect layer has been disposed.
  46771. */
  46772. onDisposeObservable: Observable<EffectLayer>;
  46773. /**
  46774. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46775. */
  46776. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46777. /**
  46778. * An event triggered when the generated texture is being merged in the scene.
  46779. */
  46780. onBeforeComposeObservable: Observable<EffectLayer>;
  46781. /**
  46782. * An event triggered when the generated texture has been merged in the scene.
  46783. */
  46784. onAfterComposeObservable: Observable<EffectLayer>;
  46785. /**
  46786. * An event triggered when the efffect layer changes its size.
  46787. */
  46788. onSizeChangedObservable: Observable<EffectLayer>;
  46789. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46790. /**
  46791. * Instantiates a new effect Layer and references it in the scene.
  46792. * @param name The name of the layer
  46793. * @param scene The scene to use the layer in
  46794. */
  46795. constructor(
  46796. /** The Friendly of the effect in the scene */
  46797. name: string, scene: Scene);
  46798. /**
  46799. * Get the effect name of the layer.
  46800. * @return The effect name
  46801. */
  46802. abstract getEffectName(): string;
  46803. /**
  46804. * Checks for the readiness of the element composing the layer.
  46805. * @param subMesh the mesh to check for
  46806. * @param useInstances specify wether or not to use instances to render the mesh
  46807. * @return true if ready otherwise, false
  46808. */
  46809. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46810. /**
  46811. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46812. * @returns true if the effect requires stencil during the main canvas render pass.
  46813. */
  46814. abstract needStencil(): boolean;
  46815. /**
  46816. * Create the merge effect. This is the shader use to blit the information back
  46817. * to the main canvas at the end of the scene rendering.
  46818. * @returns The effect containing the shader used to merge the effect on the main canvas
  46819. */
  46820. protected abstract _createMergeEffect(): Effect;
  46821. /**
  46822. * Creates the render target textures and post processes used in the effect layer.
  46823. */
  46824. protected abstract _createTextureAndPostProcesses(): void;
  46825. /**
  46826. * Implementation specific of rendering the generating effect on the main canvas.
  46827. * @param effect The effect used to render through
  46828. */
  46829. protected abstract _internalRender(effect: Effect): void;
  46830. /**
  46831. * Sets the required values for both the emissive texture and and the main color.
  46832. */
  46833. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46834. /**
  46835. * Free any resources and references associated to a mesh.
  46836. * Internal use
  46837. * @param mesh The mesh to free.
  46838. */
  46839. abstract _disposeMesh(mesh: Mesh): void;
  46840. /**
  46841. * Serializes this layer (Glow or Highlight for example)
  46842. * @returns a serialized layer object
  46843. */
  46844. abstract serialize?(): any;
  46845. /**
  46846. * Initializes the effect layer with the required options.
  46847. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46848. */
  46849. protected _init(options: Partial<IEffectLayerOptions>): void;
  46850. /**
  46851. * Generates the index buffer of the full screen quad blending to the main canvas.
  46852. */
  46853. private _generateIndexBuffer;
  46854. /**
  46855. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46856. */
  46857. private _generateVertexBuffer;
  46858. /**
  46859. * Sets the main texture desired size which is the closest power of two
  46860. * of the engine canvas size.
  46861. */
  46862. private _setMainTextureSize;
  46863. /**
  46864. * Creates the main texture for the effect layer.
  46865. */
  46866. protected _createMainTexture(): void;
  46867. /**
  46868. * Adds specific effects defines.
  46869. * @param defines The defines to add specifics to.
  46870. */
  46871. protected _addCustomEffectDefines(defines: string[]): void;
  46872. /**
  46873. * Checks for the readiness of the element composing the layer.
  46874. * @param subMesh the mesh to check for
  46875. * @param useInstances specify wether or not to use instances to render the mesh
  46876. * @param emissiveTexture the associated emissive texture used to generate the glow
  46877. * @return true if ready otherwise, false
  46878. */
  46879. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46880. /**
  46881. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46882. */
  46883. render(): void;
  46884. /**
  46885. * Determine if a given mesh will be used in the current effect.
  46886. * @param mesh mesh to test
  46887. * @returns true if the mesh will be used
  46888. */
  46889. hasMesh(mesh: AbstractMesh): boolean;
  46890. /**
  46891. * Returns true if the layer contains information to display, otherwise false.
  46892. * @returns true if the glow layer should be rendered
  46893. */
  46894. shouldRender(): boolean;
  46895. /**
  46896. * Returns true if the mesh should render, otherwise false.
  46897. * @param mesh The mesh to render
  46898. * @returns true if it should render otherwise false
  46899. */
  46900. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46901. /**
  46902. * Returns true if the mesh can be rendered, otherwise false.
  46903. * @param mesh The mesh to render
  46904. * @param material The material used on the mesh
  46905. * @returns true if it can be rendered otherwise false
  46906. */
  46907. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46908. /**
  46909. * Returns true if the mesh should render, otherwise false.
  46910. * @param mesh The mesh to render
  46911. * @returns true if it should render otherwise false
  46912. */
  46913. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46914. /**
  46915. * Renders the submesh passed in parameter to the generation map.
  46916. */
  46917. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46918. /**
  46919. * Rebuild the required buffers.
  46920. * @hidden Internal use only.
  46921. */ private _rebuild(): void;
  46922. /**
  46923. * Dispose only the render target textures and post process.
  46924. */
  46925. private _disposeTextureAndPostProcesses;
  46926. /**
  46927. * Dispose the highlight layer and free resources.
  46928. */
  46929. dispose(): void;
  46930. /**
  46931. * Gets the class name of the effect layer
  46932. * @returns the string with the class name of the effect layer
  46933. */
  46934. getClassName(): string;
  46935. /**
  46936. * Creates an effect layer from parsed effect layer data
  46937. * @param parsedEffectLayer defines effect layer data
  46938. * @param scene defines the current scene
  46939. * @param rootUrl defines the root URL containing the effect layer information
  46940. * @returns a parsed effect Layer
  46941. */
  46942. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46943. }
  46944. }
  46945. declare module BABYLON {
  46946. interface AbstractScene {
  46947. /**
  46948. * The list of effect layers (highlights/glow) added to the scene
  46949. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46950. * @see http://doc.babylonjs.com/how_to/glow_layer
  46951. */
  46952. effectLayers: Array<EffectLayer>;
  46953. /**
  46954. * Removes the given effect layer from this scene.
  46955. * @param toRemove defines the effect layer to remove
  46956. * @returns the index of the removed effect layer
  46957. */
  46958. removeEffectLayer(toRemove: EffectLayer): number;
  46959. /**
  46960. * Adds the given effect layer to this scene
  46961. * @param newEffectLayer defines the effect layer to add
  46962. */
  46963. addEffectLayer(newEffectLayer: EffectLayer): void;
  46964. }
  46965. /**
  46966. * Defines the layer scene component responsible to manage any effect layers
  46967. * in a given scene.
  46968. */
  46969. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46970. /**
  46971. * The component name helpfull to identify the component in the list of scene components.
  46972. */
  46973. readonly name: string;
  46974. /**
  46975. * The scene the component belongs to.
  46976. */
  46977. scene: Scene;
  46978. private _engine;
  46979. private _renderEffects;
  46980. private _needStencil;
  46981. private _previousStencilState;
  46982. /**
  46983. * Creates a new instance of the component for the given scene
  46984. * @param scene Defines the scene to register the component in
  46985. */
  46986. constructor(scene: Scene);
  46987. /**
  46988. * Registers the component in a given scene
  46989. */
  46990. register(): void;
  46991. /**
  46992. * Rebuilds the elements related to this component in case of
  46993. * context lost for instance.
  46994. */
  46995. rebuild(): void;
  46996. /**
  46997. * Serializes the component data to the specified json object
  46998. * @param serializationObject The object to serialize to
  46999. */
  47000. serialize(serializationObject: any): void;
  47001. /**
  47002. * Adds all the elements from the container to the scene
  47003. * @param container the container holding the elements
  47004. */
  47005. addFromContainer(container: AbstractScene): void;
  47006. /**
  47007. * Removes all the elements in the container from the scene
  47008. * @param container contains the elements to remove
  47009. * @param dispose if the removed element should be disposed (default: false)
  47010. */
  47011. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47012. /**
  47013. * Disposes the component and the associated ressources.
  47014. */
  47015. dispose(): void;
  47016. private _isReadyForMesh;
  47017. private _renderMainTexture;
  47018. private _setStencil;
  47019. private _setStencilBack;
  47020. private _draw;
  47021. private _drawCamera;
  47022. private _drawRenderingGroup;
  47023. }
  47024. }
  47025. declare module BABYLON {
  47026. /** @hidden */
  47027. export var glowMapMergePixelShader: {
  47028. name: string;
  47029. shader: string;
  47030. };
  47031. }
  47032. declare module BABYLON {
  47033. /** @hidden */
  47034. export var glowMapMergeVertexShader: {
  47035. name: string;
  47036. shader: string;
  47037. };
  47038. }
  47039. declare module BABYLON {
  47040. interface AbstractScene {
  47041. /**
  47042. * Return a the first highlight layer of the scene with a given name.
  47043. * @param name The name of the highlight layer to look for.
  47044. * @return The highlight layer if found otherwise null.
  47045. */
  47046. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47047. }
  47048. /**
  47049. * Glow layer options. This helps customizing the behaviour
  47050. * of the glow layer.
  47051. */
  47052. export interface IGlowLayerOptions {
  47053. /**
  47054. * Multiplication factor apply to the canvas size to compute the render target size
  47055. * used to generated the glowing objects (the smaller the faster).
  47056. */
  47057. mainTextureRatio: number;
  47058. /**
  47059. * Enforces a fixed size texture to ensure resize independant blur.
  47060. */
  47061. mainTextureFixedSize?: number;
  47062. /**
  47063. * How big is the kernel of the blur texture.
  47064. */
  47065. blurKernelSize: number;
  47066. /**
  47067. * The camera attached to the layer.
  47068. */
  47069. camera: Nullable<Camera>;
  47070. /**
  47071. * Enable MSAA by chosing the number of samples.
  47072. */
  47073. mainTextureSamples?: number;
  47074. /**
  47075. * The rendering group to draw the layer in.
  47076. */
  47077. renderingGroupId: number;
  47078. }
  47079. /**
  47080. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47081. *
  47082. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47083. * glowy meshes to your scene.
  47084. *
  47085. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47086. */
  47087. export class GlowLayer extends EffectLayer {
  47088. /**
  47089. * Effect Name of the layer.
  47090. */
  47091. static readonly EffectName: string;
  47092. /**
  47093. * The default blur kernel size used for the glow.
  47094. */
  47095. static DefaultBlurKernelSize: number;
  47096. /**
  47097. * The default texture size ratio used for the glow.
  47098. */
  47099. static DefaultTextureRatio: number;
  47100. /**
  47101. * Sets the kernel size of the blur.
  47102. */
  47103. /**
  47104. * Gets the kernel size of the blur.
  47105. */
  47106. blurKernelSize: number;
  47107. /**
  47108. * Sets the glow intensity.
  47109. */
  47110. /**
  47111. * Gets the glow intensity.
  47112. */
  47113. intensity: number;
  47114. private _options;
  47115. private _intensity;
  47116. private _horizontalBlurPostprocess1;
  47117. private _verticalBlurPostprocess1;
  47118. private _horizontalBlurPostprocess2;
  47119. private _verticalBlurPostprocess2;
  47120. private _blurTexture1;
  47121. private _blurTexture2;
  47122. private _postProcesses1;
  47123. private _postProcesses2;
  47124. private _includedOnlyMeshes;
  47125. private _excludedMeshes;
  47126. /**
  47127. * Callback used to let the user override the color selection on a per mesh basis
  47128. */
  47129. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47130. /**
  47131. * Callback used to let the user override the texture selection on a per mesh basis
  47132. */
  47133. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47134. /**
  47135. * Instantiates a new glow Layer and references it to the scene.
  47136. * @param name The name of the layer
  47137. * @param scene The scene to use the layer in
  47138. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47139. */
  47140. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47141. /**
  47142. * Get the effect name of the layer.
  47143. * @return The effect name
  47144. */
  47145. getEffectName(): string;
  47146. /**
  47147. * Create the merge effect. This is the shader use to blit the information back
  47148. * to the main canvas at the end of the scene rendering.
  47149. */
  47150. protected _createMergeEffect(): Effect;
  47151. /**
  47152. * Creates the render target textures and post processes used in the glow layer.
  47153. */
  47154. protected _createTextureAndPostProcesses(): void;
  47155. /**
  47156. * Checks for the readiness of the element composing the layer.
  47157. * @param subMesh the mesh to check for
  47158. * @param useInstances specify wether or not to use instances to render the mesh
  47159. * @param emissiveTexture the associated emissive texture used to generate the glow
  47160. * @return true if ready otherwise, false
  47161. */
  47162. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47163. /**
  47164. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47165. */
  47166. needStencil(): boolean;
  47167. /**
  47168. * Returns true if the mesh can be rendered, otherwise false.
  47169. * @param mesh The mesh to render
  47170. * @param material The material used on the mesh
  47171. * @returns true if it can be rendered otherwise false
  47172. */
  47173. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47174. /**
  47175. * Implementation specific of rendering the generating effect on the main canvas.
  47176. * @param effect The effect used to render through
  47177. */
  47178. protected _internalRender(effect: Effect): void;
  47179. /**
  47180. * Sets the required values for both the emissive texture and and the main color.
  47181. */
  47182. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47183. /**
  47184. * Returns true if the mesh should render, otherwise false.
  47185. * @param mesh The mesh to render
  47186. * @returns true if it should render otherwise false
  47187. */
  47188. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47189. /**
  47190. * Adds specific effects defines.
  47191. * @param defines The defines to add specifics to.
  47192. */
  47193. protected _addCustomEffectDefines(defines: string[]): void;
  47194. /**
  47195. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47196. * @param mesh The mesh to exclude from the glow layer
  47197. */
  47198. addExcludedMesh(mesh: Mesh): void;
  47199. /**
  47200. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47201. * @param mesh The mesh to remove
  47202. */
  47203. removeExcludedMesh(mesh: Mesh): void;
  47204. /**
  47205. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47206. * @param mesh The mesh to include in the glow layer
  47207. */
  47208. addIncludedOnlyMesh(mesh: Mesh): void;
  47209. /**
  47210. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47211. * @param mesh The mesh to remove
  47212. */
  47213. removeIncludedOnlyMesh(mesh: Mesh): void;
  47214. /**
  47215. * Determine if a given mesh will be used in the glow layer
  47216. * @param mesh The mesh to test
  47217. * @returns true if the mesh will be highlighted by the current glow layer
  47218. */
  47219. hasMesh(mesh: AbstractMesh): boolean;
  47220. /**
  47221. * Free any resources and references associated to a mesh.
  47222. * Internal use
  47223. * @param mesh The mesh to free.
  47224. * @hidden
  47225. */ private _disposeMesh(mesh: Mesh): void;
  47226. /**
  47227. * Gets the class name of the effect layer
  47228. * @returns the string with the class name of the effect layer
  47229. */
  47230. getClassName(): string;
  47231. /**
  47232. * Serializes this glow layer
  47233. * @returns a serialized glow layer object
  47234. */
  47235. serialize(): any;
  47236. /**
  47237. * Creates a Glow Layer from parsed glow layer data
  47238. * @param parsedGlowLayer defines glow layer data
  47239. * @param scene defines the current scene
  47240. * @param rootUrl defines the root URL containing the glow layer information
  47241. * @returns a parsed Glow Layer
  47242. */
  47243. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47244. }
  47245. }
  47246. declare module BABYLON {
  47247. /** @hidden */
  47248. export var glowBlurPostProcessPixelShader: {
  47249. name: string;
  47250. shader: string;
  47251. };
  47252. }
  47253. declare module BABYLON {
  47254. interface AbstractScene {
  47255. /**
  47256. * Return a the first highlight layer of the scene with a given name.
  47257. * @param name The name of the highlight layer to look for.
  47258. * @return The highlight layer if found otherwise null.
  47259. */
  47260. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47261. }
  47262. /**
  47263. * Highlight layer options. This helps customizing the behaviour
  47264. * of the highlight layer.
  47265. */
  47266. export interface IHighlightLayerOptions {
  47267. /**
  47268. * Multiplication factor apply to the canvas size to compute the render target size
  47269. * used to generated the glowing objects (the smaller the faster).
  47270. */
  47271. mainTextureRatio: number;
  47272. /**
  47273. * Enforces a fixed size texture to ensure resize independant blur.
  47274. */
  47275. mainTextureFixedSize?: number;
  47276. /**
  47277. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47278. * of the picture to blur (the smaller the faster).
  47279. */
  47280. blurTextureSizeRatio: number;
  47281. /**
  47282. * How big in texel of the blur texture is the vertical blur.
  47283. */
  47284. blurVerticalSize: number;
  47285. /**
  47286. * How big in texel of the blur texture is the horizontal blur.
  47287. */
  47288. blurHorizontalSize: number;
  47289. /**
  47290. * Alpha blending mode used to apply the blur. Default is combine.
  47291. */
  47292. alphaBlendingMode: number;
  47293. /**
  47294. * The camera attached to the layer.
  47295. */
  47296. camera: Nullable<Camera>;
  47297. /**
  47298. * Should we display highlight as a solid stroke?
  47299. */
  47300. isStroke?: boolean;
  47301. /**
  47302. * The rendering group to draw the layer in.
  47303. */
  47304. renderingGroupId: number;
  47305. }
  47306. /**
  47307. * The highlight layer Helps adding a glow effect around a mesh.
  47308. *
  47309. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47310. * glowy meshes to your scene.
  47311. *
  47312. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47313. */
  47314. export class HighlightLayer extends EffectLayer {
  47315. name: string;
  47316. /**
  47317. * Effect Name of the highlight layer.
  47318. */
  47319. static readonly EffectName: string;
  47320. /**
  47321. * The neutral color used during the preparation of the glow effect.
  47322. * This is black by default as the blend operation is a blend operation.
  47323. */
  47324. static NeutralColor: Color4;
  47325. /**
  47326. * Stencil value used for glowing meshes.
  47327. */
  47328. static GlowingMeshStencilReference: number;
  47329. /**
  47330. * Stencil value used for the other meshes in the scene.
  47331. */
  47332. static NormalMeshStencilReference: number;
  47333. /**
  47334. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47335. */
  47336. innerGlow: boolean;
  47337. /**
  47338. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47339. */
  47340. outerGlow: boolean;
  47341. /**
  47342. * Specifies the horizontal size of the blur.
  47343. */
  47344. /**
  47345. * Gets the horizontal size of the blur.
  47346. */
  47347. blurHorizontalSize: number;
  47348. /**
  47349. * Specifies the vertical size of the blur.
  47350. */
  47351. /**
  47352. * Gets the vertical size of the blur.
  47353. */
  47354. blurVerticalSize: number;
  47355. /**
  47356. * An event triggered when the highlight layer is being blurred.
  47357. */
  47358. onBeforeBlurObservable: Observable<HighlightLayer>;
  47359. /**
  47360. * An event triggered when the highlight layer has been blurred.
  47361. */
  47362. onAfterBlurObservable: Observable<HighlightLayer>;
  47363. private _instanceGlowingMeshStencilReference;
  47364. private _options;
  47365. private _downSamplePostprocess;
  47366. private _horizontalBlurPostprocess;
  47367. private _verticalBlurPostprocess;
  47368. private _blurTexture;
  47369. private _meshes;
  47370. private _excludedMeshes;
  47371. /**
  47372. * Instantiates a new highlight Layer and references it to the scene..
  47373. * @param name The name of the layer
  47374. * @param scene The scene to use the layer in
  47375. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47376. */
  47377. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47378. /**
  47379. * Get the effect name of the layer.
  47380. * @return The effect name
  47381. */
  47382. getEffectName(): string;
  47383. /**
  47384. * Create the merge effect. This is the shader use to blit the information back
  47385. * to the main canvas at the end of the scene rendering.
  47386. */
  47387. protected _createMergeEffect(): Effect;
  47388. /**
  47389. * Creates the render target textures and post processes used in the highlight layer.
  47390. */
  47391. protected _createTextureAndPostProcesses(): void;
  47392. /**
  47393. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47394. */
  47395. needStencil(): boolean;
  47396. /**
  47397. * Checks for the readiness of the element composing the layer.
  47398. * @param subMesh the mesh to check for
  47399. * @param useInstances specify wether or not to use instances to render the mesh
  47400. * @param emissiveTexture the associated emissive texture used to generate the glow
  47401. * @return true if ready otherwise, false
  47402. */
  47403. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47404. /**
  47405. * Implementation specific of rendering the generating effect on the main canvas.
  47406. * @param effect The effect used to render through
  47407. */
  47408. protected _internalRender(effect: Effect): void;
  47409. /**
  47410. * Returns true if the layer contains information to display, otherwise false.
  47411. */
  47412. shouldRender(): boolean;
  47413. /**
  47414. * Returns true if the mesh should render, otherwise false.
  47415. * @param mesh The mesh to render
  47416. * @returns true if it should render otherwise false
  47417. */
  47418. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47419. /**
  47420. * Sets the required values for both the emissive texture and and the main color.
  47421. */
  47422. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47423. /**
  47424. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47425. * @param mesh The mesh to exclude from the highlight layer
  47426. */
  47427. addExcludedMesh(mesh: Mesh): void;
  47428. /**
  47429. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47430. * @param mesh The mesh to highlight
  47431. */
  47432. removeExcludedMesh(mesh: Mesh): void;
  47433. /**
  47434. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47435. * @param mesh mesh to test
  47436. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47437. */
  47438. hasMesh(mesh: AbstractMesh): boolean;
  47439. /**
  47440. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47441. * @param mesh The mesh to highlight
  47442. * @param color The color of the highlight
  47443. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47444. */
  47445. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47446. /**
  47447. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47448. * @param mesh The mesh to highlight
  47449. */
  47450. removeMesh(mesh: Mesh): void;
  47451. /**
  47452. * Force the stencil to the normal expected value for none glowing parts
  47453. */
  47454. private _defaultStencilReference;
  47455. /**
  47456. * Free any resources and references associated to a mesh.
  47457. * Internal use
  47458. * @param mesh The mesh to free.
  47459. * @hidden
  47460. */ private _disposeMesh(mesh: Mesh): void;
  47461. /**
  47462. * Dispose the highlight layer and free resources.
  47463. */
  47464. dispose(): void;
  47465. /**
  47466. * Gets the class name of the effect layer
  47467. * @returns the string with the class name of the effect layer
  47468. */
  47469. getClassName(): string;
  47470. /**
  47471. * Serializes this Highlight layer
  47472. * @returns a serialized Highlight layer object
  47473. */
  47474. serialize(): any;
  47475. /**
  47476. * Creates a Highlight layer from parsed Highlight layer data
  47477. * @param parsedHightlightLayer defines the Highlight layer data
  47478. * @param scene defines the current scene
  47479. * @param rootUrl defines the root URL containing the Highlight layer information
  47480. * @returns a parsed Highlight layer
  47481. */
  47482. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47483. }
  47484. }
  47485. declare module BABYLON {
  47486. interface AbstractScene {
  47487. /**
  47488. * The list of layers (background and foreground) of the scene
  47489. */
  47490. layers: Array<Layer>;
  47491. }
  47492. /**
  47493. * Defines the layer scene component responsible to manage any layers
  47494. * in a given scene.
  47495. */
  47496. export class LayerSceneComponent implements ISceneComponent {
  47497. /**
  47498. * The component name helpfull to identify the component in the list of scene components.
  47499. */
  47500. readonly name: string;
  47501. /**
  47502. * The scene the component belongs to.
  47503. */
  47504. scene: Scene;
  47505. private _engine;
  47506. /**
  47507. * Creates a new instance of the component for the given scene
  47508. * @param scene Defines the scene to register the component in
  47509. */
  47510. constructor(scene: Scene);
  47511. /**
  47512. * Registers the component in a given scene
  47513. */
  47514. register(): void;
  47515. /**
  47516. * Rebuilds the elements related to this component in case of
  47517. * context lost for instance.
  47518. */
  47519. rebuild(): void;
  47520. /**
  47521. * Disposes the component and the associated ressources.
  47522. */
  47523. dispose(): void;
  47524. private _draw;
  47525. private _drawCameraPredicate;
  47526. private _drawCameraBackground;
  47527. private _drawCameraForeground;
  47528. private _drawRenderTargetPredicate;
  47529. private _drawRenderTargetBackground;
  47530. private _drawRenderTargetForeground;
  47531. /**
  47532. * Adds all the elements from the container to the scene
  47533. * @param container the container holding the elements
  47534. */
  47535. addFromContainer(container: AbstractScene): void;
  47536. /**
  47537. * Removes all the elements in the container from the scene
  47538. * @param container contains the elements to remove
  47539. * @param dispose if the removed element should be disposed (default: false)
  47540. */
  47541. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47542. }
  47543. }
  47544. declare module BABYLON {
  47545. /** @hidden */
  47546. export var layerPixelShader: {
  47547. name: string;
  47548. shader: string;
  47549. };
  47550. }
  47551. declare module BABYLON {
  47552. /** @hidden */
  47553. export var layerVertexShader: {
  47554. name: string;
  47555. shader: string;
  47556. };
  47557. }
  47558. declare module BABYLON {
  47559. /**
  47560. * This represents a full screen 2d layer.
  47561. * This can be useful to display a picture in the background of your scene for instance.
  47562. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47563. */
  47564. export class Layer {
  47565. /**
  47566. * Define the name of the layer.
  47567. */
  47568. name: string;
  47569. /**
  47570. * Define the texture the layer should display.
  47571. */
  47572. texture: Nullable<Texture>;
  47573. /**
  47574. * Is the layer in background or foreground.
  47575. */
  47576. isBackground: boolean;
  47577. /**
  47578. * Define the color of the layer (instead of texture).
  47579. */
  47580. color: Color4;
  47581. /**
  47582. * Define the scale of the layer in order to zoom in out of the texture.
  47583. */
  47584. scale: Vector2;
  47585. /**
  47586. * Define an offset for the layer in order to shift the texture.
  47587. */
  47588. offset: Vector2;
  47589. /**
  47590. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47591. */
  47592. alphaBlendingMode: number;
  47593. /**
  47594. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47595. * Alpha test will not mix with the background color in case of transparency.
  47596. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47597. */
  47598. alphaTest: boolean;
  47599. /**
  47600. * Define a mask to restrict the layer to only some of the scene cameras.
  47601. */
  47602. layerMask: number;
  47603. /**
  47604. * Define the list of render target the layer is visible into.
  47605. */
  47606. renderTargetTextures: RenderTargetTexture[];
  47607. /**
  47608. * Define if the layer is only used in renderTarget or if it also
  47609. * renders in the main frame buffer of the canvas.
  47610. */
  47611. renderOnlyInRenderTargetTextures: boolean;
  47612. private _scene;
  47613. private _vertexBuffers;
  47614. private _indexBuffer;
  47615. private _effect;
  47616. private _alphaTestEffect;
  47617. /**
  47618. * An event triggered when the layer is disposed.
  47619. */
  47620. onDisposeObservable: Observable<Layer>;
  47621. private _onDisposeObserver;
  47622. /**
  47623. * Back compatibility with callback before the onDisposeObservable existed.
  47624. * The set callback will be triggered when the layer has been disposed.
  47625. */
  47626. onDispose: () => void;
  47627. /**
  47628. * An event triggered before rendering the scene
  47629. */
  47630. onBeforeRenderObservable: Observable<Layer>;
  47631. private _onBeforeRenderObserver;
  47632. /**
  47633. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47634. * The set callback will be triggered just before rendering the layer.
  47635. */
  47636. onBeforeRender: () => void;
  47637. /**
  47638. * An event triggered after rendering the scene
  47639. */
  47640. onAfterRenderObservable: Observable<Layer>;
  47641. private _onAfterRenderObserver;
  47642. /**
  47643. * Back compatibility with callback before the onAfterRenderObservable existed.
  47644. * The set callback will be triggered just after rendering the layer.
  47645. */
  47646. onAfterRender: () => void;
  47647. /**
  47648. * Instantiates a new layer.
  47649. * This represents a full screen 2d layer.
  47650. * This can be useful to display a picture in the background of your scene for instance.
  47651. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47652. * @param name Define the name of the layer in the scene
  47653. * @param imgUrl Define the url of the texture to display in the layer
  47654. * @param scene Define the scene the layer belongs to
  47655. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47656. * @param color Defines a color for the layer
  47657. */
  47658. constructor(
  47659. /**
  47660. * Define the name of the layer.
  47661. */
  47662. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47663. private _createIndexBuffer;
  47664. /** @hidden */ private _rebuild(): void;
  47665. /**
  47666. * Renders the layer in the scene.
  47667. */
  47668. render(): void;
  47669. /**
  47670. * Disposes and releases the associated ressources.
  47671. */
  47672. dispose(): void;
  47673. }
  47674. }
  47675. declare module BABYLON {
  47676. /** @hidden */
  47677. export var lensFlarePixelShader: {
  47678. name: string;
  47679. shader: string;
  47680. };
  47681. }
  47682. declare module BABYLON {
  47683. /** @hidden */
  47684. export var lensFlareVertexShader: {
  47685. name: string;
  47686. shader: string;
  47687. };
  47688. }
  47689. declare module BABYLON {
  47690. /**
  47691. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47692. * It is usually composed of several `lensFlare`.
  47693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47694. */
  47695. export class LensFlareSystem {
  47696. /**
  47697. * Define the name of the lens flare system
  47698. */
  47699. name: string;
  47700. /**
  47701. * List of lens flares used in this system.
  47702. */
  47703. lensFlares: LensFlare[];
  47704. /**
  47705. * Define a limit from the border the lens flare can be visible.
  47706. */
  47707. borderLimit: number;
  47708. /**
  47709. * Define a viewport border we do not want to see the lens flare in.
  47710. */
  47711. viewportBorder: number;
  47712. /**
  47713. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47714. */
  47715. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47716. /**
  47717. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47718. */
  47719. layerMask: number;
  47720. /**
  47721. * Define the id of the lens flare system in the scene.
  47722. * (equal to name by default)
  47723. */
  47724. id: string;
  47725. private _scene;
  47726. private _emitter;
  47727. private _vertexBuffers;
  47728. private _indexBuffer;
  47729. private _effect;
  47730. private _positionX;
  47731. private _positionY;
  47732. private _isEnabled;
  47733. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47734. /**
  47735. * Instantiates a lens flare system.
  47736. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47737. * It is usually composed of several `lensFlare`.
  47738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47739. * @param name Define the name of the lens flare system in the scene
  47740. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47741. * @param scene Define the scene the lens flare system belongs to
  47742. */
  47743. constructor(
  47744. /**
  47745. * Define the name of the lens flare system
  47746. */
  47747. name: string, emitter: any, scene: Scene);
  47748. /**
  47749. * Define if the lens flare system is enabled.
  47750. */
  47751. isEnabled: boolean;
  47752. /**
  47753. * Get the scene the effects belongs to.
  47754. * @returns the scene holding the lens flare system
  47755. */
  47756. getScene(): Scene;
  47757. /**
  47758. * Get the emitter of the lens flare system.
  47759. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47760. * @returns the emitter of the lens flare system
  47761. */
  47762. getEmitter(): any;
  47763. /**
  47764. * Set the emitter of the lens flare system.
  47765. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47766. * @param newEmitter Define the new emitter of the system
  47767. */
  47768. setEmitter(newEmitter: any): void;
  47769. /**
  47770. * Get the lens flare system emitter position.
  47771. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47772. * @returns the position
  47773. */
  47774. getEmitterPosition(): Vector3;
  47775. /**
  47776. * @hidden
  47777. */
  47778. computeEffectivePosition(globalViewport: Viewport): boolean;
  47779. /** @hidden */ private _isVisible(): boolean;
  47780. /**
  47781. * @hidden
  47782. */
  47783. render(): boolean;
  47784. /**
  47785. * Dispose and release the lens flare with its associated resources.
  47786. */
  47787. dispose(): void;
  47788. /**
  47789. * Parse a lens flare system from a JSON repressentation
  47790. * @param parsedLensFlareSystem Define the JSON to parse
  47791. * @param scene Define the scene the parsed system should be instantiated in
  47792. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47793. * @returns the parsed system
  47794. */
  47795. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47796. /**
  47797. * Serialize the current Lens Flare System into a JSON representation.
  47798. * @returns the serialized JSON
  47799. */
  47800. serialize(): any;
  47801. }
  47802. }
  47803. declare module BABYLON {
  47804. /**
  47805. * This represents one of the lens effect in a `lensFlareSystem`.
  47806. * It controls one of the indiviual texture used in the effect.
  47807. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47808. */
  47809. export class LensFlare {
  47810. /**
  47811. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47812. */
  47813. size: number;
  47814. /**
  47815. * 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.
  47816. */
  47817. position: number;
  47818. /**
  47819. * Define the lens color.
  47820. */
  47821. color: Color3;
  47822. /**
  47823. * Define the lens texture.
  47824. */
  47825. texture: Nullable<Texture>;
  47826. /**
  47827. * Define the alpha mode to render this particular lens.
  47828. */
  47829. alphaMode: number;
  47830. private _system;
  47831. /**
  47832. * Creates a new Lens Flare.
  47833. * This represents one of the lens effect in a `lensFlareSystem`.
  47834. * It controls one of the indiviual texture used in the effect.
  47835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47836. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47837. * @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.
  47838. * @param color Define the lens color
  47839. * @param imgUrl Define the lens texture url
  47840. * @param system Define the `lensFlareSystem` this flare is part of
  47841. * @returns The newly created Lens Flare
  47842. */
  47843. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47844. /**
  47845. * Instantiates a new Lens Flare.
  47846. * This represents one of the lens effect in a `lensFlareSystem`.
  47847. * It controls one of the indiviual texture used in the effect.
  47848. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47849. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47850. * @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.
  47851. * @param color Define the lens color
  47852. * @param imgUrl Define the lens texture url
  47853. * @param system Define the `lensFlareSystem` this flare is part of
  47854. */
  47855. constructor(
  47856. /**
  47857. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47858. */
  47859. size: number,
  47860. /**
  47861. * 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.
  47862. */
  47863. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47864. /**
  47865. * Dispose and release the lens flare with its associated resources.
  47866. */
  47867. dispose(): void;
  47868. }
  47869. }
  47870. declare module BABYLON {
  47871. interface AbstractScene {
  47872. /**
  47873. * The list of lens flare system added to the scene
  47874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47875. */
  47876. lensFlareSystems: Array<LensFlareSystem>;
  47877. /**
  47878. * Removes the given lens flare system from this scene.
  47879. * @param toRemove The lens flare system to remove
  47880. * @returns The index of the removed lens flare system
  47881. */
  47882. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47883. /**
  47884. * Adds the given lens flare system to this scene
  47885. * @param newLensFlareSystem The lens flare system to add
  47886. */
  47887. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47888. /**
  47889. * Gets a lens flare system using its name
  47890. * @param name defines the name to look for
  47891. * @returns the lens flare system or null if not found
  47892. */
  47893. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47894. /**
  47895. * Gets a lens flare system using its id
  47896. * @param id defines the id to look for
  47897. * @returns the lens flare system or null if not found
  47898. */
  47899. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47900. }
  47901. /**
  47902. * Defines the lens flare scene component responsible to manage any lens flares
  47903. * in a given scene.
  47904. */
  47905. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47906. /**
  47907. * The component name helpfull to identify the component in the list of scene components.
  47908. */
  47909. readonly name: string;
  47910. /**
  47911. * The scene the component belongs to.
  47912. */
  47913. scene: Scene;
  47914. /**
  47915. * Creates a new instance of the component for the given scene
  47916. * @param scene Defines the scene to register the component in
  47917. */
  47918. constructor(scene: Scene);
  47919. /**
  47920. * Registers the component in a given scene
  47921. */
  47922. register(): void;
  47923. /**
  47924. * Rebuilds the elements related to this component in case of
  47925. * context lost for instance.
  47926. */
  47927. rebuild(): void;
  47928. /**
  47929. * Adds all the elements from the container to the scene
  47930. * @param container the container holding the elements
  47931. */
  47932. addFromContainer(container: AbstractScene): void;
  47933. /**
  47934. * Removes all the elements in the container from the scene
  47935. * @param container contains the elements to remove
  47936. * @param dispose if the removed element should be disposed (default: false)
  47937. */
  47938. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47939. /**
  47940. * Serializes the component data to the specified json object
  47941. * @param serializationObject The object to serialize to
  47942. */
  47943. serialize(serializationObject: any): void;
  47944. /**
  47945. * Disposes the component and the associated ressources.
  47946. */
  47947. dispose(): void;
  47948. private _draw;
  47949. }
  47950. }
  47951. declare module BABYLON {
  47952. /**
  47953. * Defines the shadow generator component responsible to manage any shadow generators
  47954. * in a given scene.
  47955. */
  47956. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47957. /**
  47958. * The component name helpfull to identify the component in the list of scene components.
  47959. */
  47960. readonly name: string;
  47961. /**
  47962. * The scene the component belongs to.
  47963. */
  47964. scene: Scene;
  47965. /**
  47966. * Creates a new instance of the component for the given scene
  47967. * @param scene Defines the scene to register the component in
  47968. */
  47969. constructor(scene: Scene);
  47970. /**
  47971. * Registers the component in a given scene
  47972. */
  47973. register(): void;
  47974. /**
  47975. * Rebuilds the elements related to this component in case of
  47976. * context lost for instance.
  47977. */
  47978. rebuild(): void;
  47979. /**
  47980. * Serializes the component data to the specified json object
  47981. * @param serializationObject The object to serialize to
  47982. */
  47983. serialize(serializationObject: any): void;
  47984. /**
  47985. * Adds all the elements from the container to the scene
  47986. * @param container the container holding the elements
  47987. */
  47988. addFromContainer(container: AbstractScene): void;
  47989. /**
  47990. * Removes all the elements in the container from the scene
  47991. * @param container contains the elements to remove
  47992. * @param dispose if the removed element should be disposed (default: false)
  47993. */
  47994. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47995. /**
  47996. * Rebuilds the elements related to this component in case of
  47997. * context lost for instance.
  47998. */
  47999. dispose(): void;
  48000. private _gatherRenderTargets;
  48001. }
  48002. }
  48003. declare module BABYLON {
  48004. /**
  48005. * A point light is a light defined by an unique point in world space.
  48006. * The light is emitted in every direction from this point.
  48007. * A good example of a point light is a standard light bulb.
  48008. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48009. */
  48010. export class PointLight extends ShadowLight {
  48011. private _shadowAngle;
  48012. /**
  48013. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48014. * This specifies what angle the shadow will use to be created.
  48015. *
  48016. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48017. */
  48018. /**
  48019. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48020. * This specifies what angle the shadow will use to be created.
  48021. *
  48022. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48023. */
  48024. shadowAngle: number;
  48025. /**
  48026. * Gets the direction if it has been set.
  48027. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48028. */
  48029. /**
  48030. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48031. */
  48032. direction: Vector3;
  48033. /**
  48034. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48035. * A PointLight emits the light in every direction.
  48036. * It can cast shadows.
  48037. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48038. * ```javascript
  48039. * var pointLight = new PointLight("pl", camera.position, scene);
  48040. * ```
  48041. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48042. * @param name The light friendly name
  48043. * @param position The position of the point light in the scene
  48044. * @param scene The scene the lights belongs to
  48045. */
  48046. constructor(name: string, position: Vector3, scene: Scene);
  48047. /**
  48048. * Returns the string "PointLight"
  48049. * @returns the class name
  48050. */
  48051. getClassName(): string;
  48052. /**
  48053. * Returns the integer 0.
  48054. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48055. */
  48056. getTypeID(): number;
  48057. /**
  48058. * Specifies wether or not the shadowmap should be a cube texture.
  48059. * @returns true if the shadowmap needs to be a cube texture.
  48060. */
  48061. needCube(): boolean;
  48062. /**
  48063. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48064. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48065. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48066. */
  48067. getShadowDirection(faceIndex?: number): Vector3;
  48068. /**
  48069. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48070. * - fov = PI / 2
  48071. * - aspect ratio : 1.0
  48072. * - z-near and far equal to the active camera minZ and maxZ.
  48073. * Returns the PointLight.
  48074. */
  48075. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48076. protected _buildUniformLayout(): void;
  48077. /**
  48078. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48079. * @param effect The effect to update
  48080. * @param lightIndex The index of the light in the effect to update
  48081. * @returns The point light
  48082. */
  48083. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48084. /**
  48085. * Prepares the list of defines specific to the light type.
  48086. * @param defines the list of defines
  48087. * @param lightIndex defines the index of the light for the effect
  48088. */
  48089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * Header information of HDR texture files.
  48095. */
  48096. export interface HDRInfo {
  48097. /**
  48098. * The height of the texture in pixels.
  48099. */
  48100. height: number;
  48101. /**
  48102. * The width of the texture in pixels.
  48103. */
  48104. width: number;
  48105. /**
  48106. * The index of the beginning of the data in the binary file.
  48107. */
  48108. dataPosition: number;
  48109. }
  48110. /**
  48111. * This groups tools to convert HDR texture to native colors array.
  48112. */
  48113. export class HDRTools {
  48114. private static Ldexp;
  48115. private static Rgbe2float;
  48116. private static readStringLine;
  48117. /**
  48118. * Reads header information from an RGBE texture stored in a native array.
  48119. * More information on this format are available here:
  48120. * https://en.wikipedia.org/wiki/RGBE_image_format
  48121. *
  48122. * @param uint8array The binary file stored in native array.
  48123. * @return The header information.
  48124. */
  48125. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48126. /**
  48127. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48128. * This RGBE texture needs to store the information as a panorama.
  48129. *
  48130. * More information on this format are available here:
  48131. * https://en.wikipedia.org/wiki/RGBE_image_format
  48132. *
  48133. * @param buffer The binary file stored in an array buffer.
  48134. * @param size The expected size of the extracted cubemap.
  48135. * @return The Cube Map information.
  48136. */
  48137. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48138. /**
  48139. * Returns the pixels data extracted from an RGBE texture.
  48140. * This pixels will be stored left to right up to down in the R G B order in one array.
  48141. *
  48142. * More information on this format are available here:
  48143. * https://en.wikipedia.org/wiki/RGBE_image_format
  48144. *
  48145. * @param uint8array The binary file stored in an array buffer.
  48146. * @param hdrInfo The header information of the file.
  48147. * @return The pixels data in RGB right to left up to down order.
  48148. */
  48149. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48150. private static RGBE_ReadPixels_RLE;
  48151. }
  48152. }
  48153. declare module BABYLON {
  48154. /**
  48155. * This represents a texture coming from an HDR input.
  48156. *
  48157. * The only supported format is currently panorama picture stored in RGBE format.
  48158. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48159. */
  48160. export class HDRCubeTexture extends BaseTexture {
  48161. private static _facesMapping;
  48162. private _generateHarmonics;
  48163. private _noMipmap;
  48164. private _textureMatrix;
  48165. private _size;
  48166. private _onLoad;
  48167. private _onError;
  48168. /**
  48169. * The texture URL.
  48170. */
  48171. url: string;
  48172. /**
  48173. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48174. */
  48175. coordinatesMode: number;
  48176. protected _isBlocking: boolean;
  48177. /**
  48178. * Sets wether or not the texture is blocking during loading.
  48179. */
  48180. /**
  48181. * Gets wether or not the texture is blocking during loading.
  48182. */
  48183. isBlocking: boolean;
  48184. protected _rotationY: number;
  48185. /**
  48186. * Sets texture matrix rotation angle around Y axis in radians.
  48187. */
  48188. /**
  48189. * Gets texture matrix rotation angle around Y axis radians.
  48190. */
  48191. rotationY: number;
  48192. /**
  48193. * Gets or sets the center of the bounding box associated with the cube texture
  48194. * It must define where the camera used to render the texture was set
  48195. */
  48196. boundingBoxPosition: Vector3;
  48197. private _boundingBoxSize;
  48198. /**
  48199. * Gets or sets the size of the bounding box associated with the cube texture
  48200. * When defined, the cubemap will switch to local mode
  48201. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48202. * @example https://www.babylonjs-playground.com/#RNASML
  48203. */
  48204. boundingBoxSize: Vector3;
  48205. /**
  48206. * Instantiates an HDRTexture from the following parameters.
  48207. *
  48208. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48209. * @param scene The scene the texture will be used in
  48210. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48211. * @param noMipmap Forces to not generate the mipmap if true
  48212. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48213. * @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)
  48214. * @param reserved Reserved flag for internal use.
  48215. */
  48216. 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>);
  48217. /**
  48218. * Get the current class name of the texture useful for serialization or dynamic coding.
  48219. * @returns "HDRCubeTexture"
  48220. */
  48221. getClassName(): string;
  48222. /**
  48223. * Occurs when the file is raw .hdr file.
  48224. */
  48225. private loadTexture;
  48226. clone(): HDRCubeTexture;
  48227. delayLoad(): void;
  48228. /**
  48229. * Get the texture reflection matrix used to rotate/transform the reflection.
  48230. * @returns the reflection matrix
  48231. */
  48232. getReflectionTextureMatrix(): Matrix;
  48233. /**
  48234. * Set the texture reflection matrix used to rotate/transform the reflection.
  48235. * @param value Define the reflection matrix to set
  48236. */
  48237. setReflectionTextureMatrix(value: Matrix): void;
  48238. /**
  48239. * Parses a JSON representation of an HDR Texture in order to create the texture
  48240. * @param parsedTexture Define the JSON representation
  48241. * @param scene Define the scene the texture should be created in
  48242. * @param rootUrl Define the root url in case we need to load relative dependencies
  48243. * @returns the newly created texture after parsing
  48244. */
  48245. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48246. serialize(): any;
  48247. }
  48248. }
  48249. declare module BABYLON {
  48250. /**
  48251. * Class used to control physics engine
  48252. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48253. */
  48254. export class PhysicsEngine implements IPhysicsEngine {
  48255. private _physicsPlugin;
  48256. /**
  48257. * Global value used to control the smallest number supported by the simulation
  48258. */
  48259. static Epsilon: number;
  48260. private _impostors;
  48261. private _joints;
  48262. /**
  48263. * Gets the gravity vector used by the simulation
  48264. */
  48265. gravity: Vector3;
  48266. /**
  48267. * Factory used to create the default physics plugin.
  48268. * @returns The default physics plugin
  48269. */
  48270. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48271. /**
  48272. * Creates a new Physics Engine
  48273. * @param gravity defines the gravity vector used by the simulation
  48274. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48275. */
  48276. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48277. /**
  48278. * Sets the gravity vector used by the simulation
  48279. * @param gravity defines the gravity vector to use
  48280. */
  48281. setGravity(gravity: Vector3): void;
  48282. /**
  48283. * Set the time step of the physics engine.
  48284. * Default is 1/60.
  48285. * To slow it down, enter 1/600 for example.
  48286. * To speed it up, 1/30
  48287. * @param newTimeStep defines the new timestep to apply to this world.
  48288. */
  48289. setTimeStep(newTimeStep?: number): void;
  48290. /**
  48291. * Get the time step of the physics engine.
  48292. * @returns the current time step
  48293. */
  48294. getTimeStep(): number;
  48295. /**
  48296. * Release all resources
  48297. */
  48298. dispose(): void;
  48299. /**
  48300. * Gets the name of the current physics plugin
  48301. * @returns the name of the plugin
  48302. */
  48303. getPhysicsPluginName(): string;
  48304. /**
  48305. * Adding a new impostor for the impostor tracking.
  48306. * This will be done by the impostor itself.
  48307. * @param impostor the impostor to add
  48308. */
  48309. addImpostor(impostor: PhysicsImpostor): void;
  48310. /**
  48311. * Remove an impostor from the engine.
  48312. * This impostor and its mesh will not longer be updated by the physics engine.
  48313. * @param impostor the impostor to remove
  48314. */
  48315. removeImpostor(impostor: PhysicsImpostor): void;
  48316. /**
  48317. * Add a joint to the physics engine
  48318. * @param mainImpostor defines the main impostor to which the joint is added.
  48319. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48320. * @param joint defines the joint that will connect both impostors.
  48321. */
  48322. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48323. /**
  48324. * Removes a joint from the simulation
  48325. * @param mainImpostor defines the impostor used with the joint
  48326. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48327. * @param joint defines the joint to remove
  48328. */
  48329. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48330. /**
  48331. * Called by the scene. No need to call it.
  48332. * @param delta defines the timespam between frames
  48333. */ private _step(delta: number): void;
  48334. /**
  48335. * Gets the current plugin used to run the simulation
  48336. * @returns current plugin
  48337. */
  48338. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48339. /**
  48340. * Gets the list of physic impostors
  48341. * @returns an array of PhysicsImpostor
  48342. */
  48343. getImpostors(): Array<PhysicsImpostor>;
  48344. /**
  48345. * Gets the impostor for a physics enabled object
  48346. * @param object defines the object impersonated by the impostor
  48347. * @returns the PhysicsImpostor or null if not found
  48348. */
  48349. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48350. /**
  48351. * Gets the impostor for a physics body object
  48352. * @param body defines physics body used by the impostor
  48353. * @returns the PhysicsImpostor or null if not found
  48354. */
  48355. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48356. /**
  48357. * Does a raycast in the physics world
  48358. * @param from when should the ray start?
  48359. * @param to when should the ray end?
  48360. * @returns PhysicsRaycastResult
  48361. */
  48362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48363. }
  48364. }
  48365. declare module BABYLON {
  48366. /** @hidden */
  48367. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48368. private _useDeltaForWorldStep;
  48369. world: any;
  48370. name: string;
  48371. private _physicsMaterials;
  48372. private _fixedTimeStep;
  48373. private _cannonRaycastResult;
  48374. private _raycastResult;
  48375. private _physicsBodysToRemoveAfterStep;
  48376. BJSCANNON: any;
  48377. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48378. setGravity(gravity: Vector3): void;
  48379. setTimeStep(timeStep: number): void;
  48380. getTimeStep(): number;
  48381. executeStep(delta: number): void;
  48382. private _removeMarkedPhysicsBodiesFromWorld;
  48383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48386. private _processChildMeshes;
  48387. removePhysicsBody(impostor: PhysicsImpostor): void;
  48388. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48390. private _addMaterial;
  48391. private _checkWithEpsilon;
  48392. private _createShape;
  48393. private _createHeightmap;
  48394. private _minus90X;
  48395. private _plus90X;
  48396. private _tmpPosition;
  48397. private _tmpDeltaPosition;
  48398. private _tmpUnityRotation;
  48399. private _updatePhysicsBodyTransformation;
  48400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48402. isSupported(): boolean;
  48403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48408. getBodyMass(impostor: PhysicsImpostor): number;
  48409. getBodyFriction(impostor: PhysicsImpostor): number;
  48410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48411. getBodyRestitution(impostor: PhysicsImpostor): number;
  48412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48413. sleepBody(impostor: PhysicsImpostor): void;
  48414. wakeUpBody(impostor: PhysicsImpostor): void;
  48415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48416. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48419. getRadius(impostor: PhysicsImpostor): number;
  48420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48421. dispose(): void;
  48422. private _extendNamespace;
  48423. /**
  48424. * Does a raycast in the physics world
  48425. * @param from when should the ray start?
  48426. * @param to when should the ray end?
  48427. * @returns PhysicsRaycastResult
  48428. */
  48429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48430. }
  48431. }
  48432. declare module BABYLON {
  48433. /** @hidden */
  48434. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48435. world: any;
  48436. name: string;
  48437. BJSOIMO: any;
  48438. private _raycastResult;
  48439. constructor(iterations?: number, oimoInjection?: any);
  48440. setGravity(gravity: Vector3): void;
  48441. setTimeStep(timeStep: number): void;
  48442. getTimeStep(): number;
  48443. private _tmpImpostorsArray;
  48444. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48445. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48447. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48448. private _tmpPositionVector;
  48449. removePhysicsBody(impostor: PhysicsImpostor): void;
  48450. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48451. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48452. isSupported(): boolean;
  48453. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48454. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48455. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48457. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48459. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48460. getBodyMass(impostor: PhysicsImpostor): number;
  48461. getBodyFriction(impostor: PhysicsImpostor): number;
  48462. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48463. getBodyRestitution(impostor: PhysicsImpostor): number;
  48464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48465. sleepBody(impostor: PhysicsImpostor): void;
  48466. wakeUpBody(impostor: PhysicsImpostor): void;
  48467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48468. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48471. getRadius(impostor: PhysicsImpostor): number;
  48472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48473. dispose(): void;
  48474. /**
  48475. * Does a raycast in the physics world
  48476. * @param from when should the ray start?
  48477. * @param to when should the ray end?
  48478. * @returns PhysicsRaycastResult
  48479. */
  48480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48481. }
  48482. }
  48483. declare module BABYLON {
  48484. /**
  48485. * Class containing static functions to help procedurally build meshes
  48486. */
  48487. export class RibbonBuilder {
  48488. /**
  48489. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48490. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48491. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48492. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48493. * * 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
  48494. * * 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
  48495. * * 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
  48496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48497. * * 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
  48498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48499. * * 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
  48500. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48501. * * 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
  48502. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48504. * @param name defines the name of the mesh
  48505. * @param options defines the options used to create the mesh
  48506. * @param scene defines the hosting scene
  48507. * @returns the ribbon mesh
  48508. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48510. */
  48511. static CreateRibbon(name: string, options: {
  48512. pathArray: Vector3[][];
  48513. closeArray?: boolean;
  48514. closePath?: boolean;
  48515. offset?: number;
  48516. updatable?: boolean;
  48517. sideOrientation?: number;
  48518. frontUVs?: Vector4;
  48519. backUVs?: Vector4;
  48520. instance?: Mesh;
  48521. invertUV?: boolean;
  48522. uvs?: Vector2[];
  48523. colors?: Color4[];
  48524. }, scene?: Nullable<Scene>): Mesh;
  48525. }
  48526. }
  48527. declare module BABYLON {
  48528. /**
  48529. * Class containing static functions to help procedurally build meshes
  48530. */
  48531. export class ShapeBuilder {
  48532. /**
  48533. * 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.
  48534. * * 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.
  48535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48536. * * 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.
  48537. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48538. * * 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
  48539. * * 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
  48540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48542. * * 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
  48543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48545. * @param name defines the name of the mesh
  48546. * @param options defines the options used to create the mesh
  48547. * @param scene defines the hosting scene
  48548. * @returns the extruded shape mesh
  48549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48551. */
  48552. static ExtrudeShape(name: string, options: {
  48553. shape: Vector3[];
  48554. path: Vector3[];
  48555. scale?: number;
  48556. rotation?: number;
  48557. cap?: number;
  48558. updatable?: boolean;
  48559. sideOrientation?: number;
  48560. frontUVs?: Vector4;
  48561. backUVs?: Vector4;
  48562. instance?: Mesh;
  48563. invertUV?: boolean;
  48564. }, scene?: Nullable<Scene>): Mesh;
  48565. /**
  48566. * Creates an custom extruded shape mesh.
  48567. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48568. * * 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.
  48569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48570. * * 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
  48571. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48572. * * 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
  48573. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48574. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48575. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48576. * * 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
  48577. * * 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
  48578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48580. * * 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
  48581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48583. * @param name defines the name of the mesh
  48584. * @param options defines the options used to create the mesh
  48585. * @param scene defines the hosting scene
  48586. * @returns the custom extruded shape mesh
  48587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48590. */
  48591. static ExtrudeShapeCustom(name: string, options: {
  48592. shape: Vector3[];
  48593. path: Vector3[];
  48594. scaleFunction?: any;
  48595. rotationFunction?: any;
  48596. ribbonCloseArray?: boolean;
  48597. ribbonClosePath?: boolean;
  48598. cap?: number;
  48599. updatable?: boolean;
  48600. sideOrientation?: number;
  48601. frontUVs?: Vector4;
  48602. backUVs?: Vector4;
  48603. instance?: Mesh;
  48604. invertUV?: boolean;
  48605. }, scene?: Nullable<Scene>): Mesh;
  48606. private static _ExtrudeShapeGeneric;
  48607. }
  48608. }
  48609. declare module BABYLON {
  48610. /**
  48611. * AmmoJS Physics plugin
  48612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48613. * @see https://github.com/kripken/ammo.js/
  48614. */
  48615. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48616. private _useDeltaForWorldStep;
  48617. /**
  48618. * Reference to the Ammo library
  48619. */
  48620. bjsAMMO: any;
  48621. /**
  48622. * Created ammoJS world which physics bodies are added to
  48623. */
  48624. world: any;
  48625. /**
  48626. * Name of the plugin
  48627. */
  48628. name: string;
  48629. private _timeStep;
  48630. private _fixedTimeStep;
  48631. private _maxSteps;
  48632. private _tmpQuaternion;
  48633. private _tmpAmmoTransform;
  48634. private _tmpAmmoQuaternion;
  48635. private _tmpAmmoConcreteContactResultCallback;
  48636. private _collisionConfiguration;
  48637. private _dispatcher;
  48638. private _overlappingPairCache;
  48639. private _solver;
  48640. private _softBodySolver;
  48641. private _tmpAmmoVectorA;
  48642. private _tmpAmmoVectorB;
  48643. private _tmpAmmoVectorC;
  48644. private _tmpAmmoVectorD;
  48645. private _tmpContactCallbackResult;
  48646. private _tmpAmmoVectorRCA;
  48647. private _tmpAmmoVectorRCB;
  48648. private _raycastResult;
  48649. private static readonly DISABLE_COLLISION_FLAG;
  48650. private static readonly KINEMATIC_FLAG;
  48651. private static readonly DISABLE_DEACTIVATION_FLAG;
  48652. /**
  48653. * Initializes the ammoJS plugin
  48654. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48655. * @param ammoInjection can be used to inject your own ammo reference
  48656. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  48657. */
  48658. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  48659. /**
  48660. * Sets the gravity of the physics world (m/(s^2))
  48661. * @param gravity Gravity to set
  48662. */
  48663. setGravity(gravity: Vector3): void;
  48664. /**
  48665. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48666. * @param timeStep timestep to use in seconds
  48667. */
  48668. setTimeStep(timeStep: number): void;
  48669. /**
  48670. * 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)
  48671. * @param fixedTimeStep fixedTimeStep to use in seconds
  48672. */
  48673. setFixedTimeStep(fixedTimeStep: number): void;
  48674. /**
  48675. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48676. * @param maxSteps the maximum number of steps by the physics engine per frame
  48677. */
  48678. setMaxSteps(maxSteps: number): void;
  48679. /**
  48680. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48681. * @returns the current timestep in seconds
  48682. */
  48683. getTimeStep(): number;
  48684. private _isImpostorInContact;
  48685. private _isImpostorPairInContact;
  48686. private _stepSimulation;
  48687. /**
  48688. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48689. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48690. * After the step the babylon meshes are set to the position of the physics imposters
  48691. * @param delta amount of time to step forward
  48692. * @param impostors array of imposters to update before/after the step
  48693. */
  48694. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48695. /**
  48696. * Update babylon mesh to match physics world object
  48697. * @param impostor imposter to match
  48698. */
  48699. private _afterSoftStep;
  48700. /**
  48701. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48702. * @param impostor imposter to match
  48703. */
  48704. private _ropeStep;
  48705. /**
  48706. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48707. * @param impostor imposter to match
  48708. */
  48709. private _softbodyOrClothStep;
  48710. private _tmpVector;
  48711. private _tmpMatrix;
  48712. /**
  48713. * Applies an impulse on the imposter
  48714. * @param impostor imposter to apply impulse to
  48715. * @param force amount of force to be applied to the imposter
  48716. * @param contactPoint the location to apply the impulse on the imposter
  48717. */
  48718. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48719. /**
  48720. * Applies a force on the imposter
  48721. * @param impostor imposter to apply force
  48722. * @param force amount of force to be applied to the imposter
  48723. * @param contactPoint the location to apply the force on the imposter
  48724. */
  48725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48726. /**
  48727. * Creates a physics body using the plugin
  48728. * @param impostor the imposter to create the physics body on
  48729. */
  48730. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48731. /**
  48732. * Removes the physics body from the imposter and disposes of the body's memory
  48733. * @param impostor imposter to remove the physics body from
  48734. */
  48735. removePhysicsBody(impostor: PhysicsImpostor): void;
  48736. /**
  48737. * Generates a joint
  48738. * @param impostorJoint the imposter joint to create the joint with
  48739. */
  48740. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48741. /**
  48742. * Removes a joint
  48743. * @param impostorJoint the imposter joint to remove the joint from
  48744. */
  48745. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48746. private _addMeshVerts;
  48747. /**
  48748. * Initialise the soft body vertices to match its object's (mesh) vertices
  48749. * Softbody vertices (nodes) are in world space and to match this
  48750. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48751. * @param impostor to create the softbody for
  48752. */
  48753. private _softVertexData;
  48754. /**
  48755. * Create an impostor's soft body
  48756. * @param impostor to create the softbody for
  48757. */
  48758. private _createSoftbody;
  48759. /**
  48760. * Create cloth for an impostor
  48761. * @param impostor to create the softbody for
  48762. */
  48763. private _createCloth;
  48764. /**
  48765. * Create rope for an impostor
  48766. * @param impostor to create the softbody for
  48767. */
  48768. private _createRope;
  48769. private _addHullVerts;
  48770. private _createShape;
  48771. /**
  48772. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48773. * @param impostor imposter containing the physics body and babylon object
  48774. */
  48775. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48776. /**
  48777. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48778. * @param impostor imposter containing the physics body and babylon object
  48779. * @param newPosition new position
  48780. * @param newRotation new rotation
  48781. */
  48782. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48783. /**
  48784. * If this plugin is supported
  48785. * @returns true if its supported
  48786. */
  48787. isSupported(): boolean;
  48788. /**
  48789. * Sets the linear velocity of the physics body
  48790. * @param impostor imposter to set the velocity on
  48791. * @param velocity velocity to set
  48792. */
  48793. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48794. /**
  48795. * Sets the angular velocity of the physics body
  48796. * @param impostor imposter to set the velocity on
  48797. * @param velocity velocity to set
  48798. */
  48799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48800. /**
  48801. * gets the linear velocity
  48802. * @param impostor imposter to get linear velocity from
  48803. * @returns linear velocity
  48804. */
  48805. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48806. /**
  48807. * gets the angular velocity
  48808. * @param impostor imposter to get angular velocity from
  48809. * @returns angular velocity
  48810. */
  48811. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48812. /**
  48813. * Sets the mass of physics body
  48814. * @param impostor imposter to set the mass on
  48815. * @param mass mass to set
  48816. */
  48817. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48818. /**
  48819. * Gets the mass of the physics body
  48820. * @param impostor imposter to get the mass from
  48821. * @returns mass
  48822. */
  48823. getBodyMass(impostor: PhysicsImpostor): number;
  48824. /**
  48825. * Gets friction of the impostor
  48826. * @param impostor impostor to get friction from
  48827. * @returns friction value
  48828. */
  48829. getBodyFriction(impostor: PhysicsImpostor): number;
  48830. /**
  48831. * Sets friction of the impostor
  48832. * @param impostor impostor to set friction on
  48833. * @param friction friction value
  48834. */
  48835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48836. /**
  48837. * Gets restitution of the impostor
  48838. * @param impostor impostor to get restitution from
  48839. * @returns restitution value
  48840. */
  48841. getBodyRestitution(impostor: PhysicsImpostor): number;
  48842. /**
  48843. * Sets resitution of the impostor
  48844. * @param impostor impostor to set resitution on
  48845. * @param restitution resitution value
  48846. */
  48847. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48848. /**
  48849. * Gets pressure inside the impostor
  48850. * @param impostor impostor to get pressure from
  48851. * @returns pressure value
  48852. */
  48853. getBodyPressure(impostor: PhysicsImpostor): number;
  48854. /**
  48855. * Sets pressure inside a soft body impostor
  48856. * Cloth and rope must remain 0 pressure
  48857. * @param impostor impostor to set pressure on
  48858. * @param pressure pressure value
  48859. */
  48860. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48861. /**
  48862. * Gets stiffness of the impostor
  48863. * @param impostor impostor to get stiffness from
  48864. * @returns pressure value
  48865. */
  48866. getBodyStiffness(impostor: PhysicsImpostor): number;
  48867. /**
  48868. * Sets stiffness of the impostor
  48869. * @param impostor impostor to set stiffness on
  48870. * @param stiffness stiffness value from 0 to 1
  48871. */
  48872. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48873. /**
  48874. * Gets velocityIterations of the impostor
  48875. * @param impostor impostor to get velocity iterations from
  48876. * @returns velocityIterations value
  48877. */
  48878. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48879. /**
  48880. * Sets velocityIterations of the impostor
  48881. * @param impostor impostor to set velocity iterations on
  48882. * @param velocityIterations velocityIterations value
  48883. */
  48884. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48885. /**
  48886. * Gets positionIterations of the impostor
  48887. * @param impostor impostor to get position iterations from
  48888. * @returns positionIterations value
  48889. */
  48890. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48891. /**
  48892. * Sets positionIterations of the impostor
  48893. * @param impostor impostor to set position on
  48894. * @param positionIterations positionIterations value
  48895. */
  48896. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48897. /**
  48898. * Append an anchor to a cloth object
  48899. * @param impostor is the cloth impostor to add anchor to
  48900. * @param otherImpostor is the rigid impostor to anchor to
  48901. * @param width ratio across width from 0 to 1
  48902. * @param height ratio up height from 0 to 1
  48903. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48904. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48905. */
  48906. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48907. /**
  48908. * Append an hook to a rope object
  48909. * @param impostor is the rope impostor to add hook to
  48910. * @param otherImpostor is the rigid impostor to hook to
  48911. * @param length ratio along the rope from 0 to 1
  48912. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48914. */
  48915. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48916. /**
  48917. * Sleeps the physics body and stops it from being active
  48918. * @param impostor impostor to sleep
  48919. */
  48920. sleepBody(impostor: PhysicsImpostor): void;
  48921. /**
  48922. * Activates the physics body
  48923. * @param impostor impostor to activate
  48924. */
  48925. wakeUpBody(impostor: PhysicsImpostor): void;
  48926. /**
  48927. * Updates the distance parameters of the joint
  48928. * @param joint joint to update
  48929. * @param maxDistance maximum distance of the joint
  48930. * @param minDistance minimum distance of the joint
  48931. */
  48932. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48933. /**
  48934. * Sets a motor on the joint
  48935. * @param joint joint to set motor on
  48936. * @param speed speed of the motor
  48937. * @param maxForce maximum force of the motor
  48938. * @param motorIndex index of the motor
  48939. */
  48940. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48941. /**
  48942. * Sets the motors limit
  48943. * @param joint joint to set limit on
  48944. * @param upperLimit upper limit
  48945. * @param lowerLimit lower limit
  48946. */
  48947. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48948. /**
  48949. * Syncs the position and rotation of a mesh with the impostor
  48950. * @param mesh mesh to sync
  48951. * @param impostor impostor to update the mesh with
  48952. */
  48953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48954. /**
  48955. * Gets the radius of the impostor
  48956. * @param impostor impostor to get radius from
  48957. * @returns the radius
  48958. */
  48959. getRadius(impostor: PhysicsImpostor): number;
  48960. /**
  48961. * Gets the box size of the impostor
  48962. * @param impostor impostor to get box size from
  48963. * @param result the resulting box size
  48964. */
  48965. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48966. /**
  48967. * Disposes of the impostor
  48968. */
  48969. dispose(): void;
  48970. /**
  48971. * Does a raycast in the physics world
  48972. * @param from when should the ray start?
  48973. * @param to when should the ray end?
  48974. * @returns PhysicsRaycastResult
  48975. */
  48976. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48977. }
  48978. }
  48979. declare module BABYLON {
  48980. interface AbstractScene {
  48981. /**
  48982. * The list of reflection probes added to the scene
  48983. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48984. */
  48985. reflectionProbes: Array<ReflectionProbe>;
  48986. /**
  48987. * Removes the given reflection probe from this scene.
  48988. * @param toRemove The reflection probe to remove
  48989. * @returns The index of the removed reflection probe
  48990. */
  48991. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48992. /**
  48993. * Adds the given reflection probe to this scene.
  48994. * @param newReflectionProbe The reflection probe to add
  48995. */
  48996. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48997. }
  48998. /**
  48999. * Class used to generate realtime reflection / refraction cube textures
  49000. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49001. */
  49002. export class ReflectionProbe {
  49003. /** defines the name of the probe */
  49004. name: string;
  49005. private _scene;
  49006. private _renderTargetTexture;
  49007. private _projectionMatrix;
  49008. private _viewMatrix;
  49009. private _target;
  49010. private _add;
  49011. private _attachedMesh;
  49012. private _invertYAxis;
  49013. /** Gets or sets probe position (center of the cube map) */
  49014. position: Vector3;
  49015. /**
  49016. * Creates a new reflection probe
  49017. * @param name defines the name of the probe
  49018. * @param size defines the texture resolution (for each face)
  49019. * @param scene defines the hosting scene
  49020. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49021. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49022. */
  49023. constructor(
  49024. /** defines the name of the probe */
  49025. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49026. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49027. samples: number;
  49028. /** Gets or sets the refresh rate to use (on every frame by default) */
  49029. refreshRate: number;
  49030. /**
  49031. * Gets the hosting scene
  49032. * @returns a Scene
  49033. */
  49034. getScene(): Scene;
  49035. /** Gets the internal CubeTexture used to render to */
  49036. readonly cubeTexture: RenderTargetTexture;
  49037. /** Gets the list of meshes to render */
  49038. readonly renderList: Nullable<AbstractMesh[]>;
  49039. /**
  49040. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49041. * @param mesh defines the mesh to attach to
  49042. */
  49043. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49044. /**
  49045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49046. * @param renderingGroupId The rendering group id corresponding to its index
  49047. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49048. */
  49049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49050. /**
  49051. * Clean all associated resources
  49052. */
  49053. dispose(): void;
  49054. /**
  49055. * Converts the reflection probe information to a readable string for debug purpose.
  49056. * @param fullDetails Supports for multiple levels of logging within scene loading
  49057. * @returns the human readable reflection probe info
  49058. */
  49059. toString(fullDetails?: boolean): string;
  49060. /**
  49061. * Get the class name of the relfection probe.
  49062. * @returns "ReflectionProbe"
  49063. */
  49064. getClassName(): string;
  49065. /**
  49066. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49067. * @returns The JSON representation of the texture
  49068. */
  49069. serialize(): any;
  49070. /**
  49071. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49072. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49073. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49075. * @returns The parsed reflection probe if successful
  49076. */
  49077. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49078. }
  49079. }
  49080. declare module BABYLON {
  49081. /** @hidden */
  49082. export var _BabylonLoaderRegistered: boolean;
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * The Physically based simple base material of BJS.
  49087. *
  49088. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49089. * It is used as the base class for both the specGloss and metalRough conventions.
  49090. */
  49091. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49092. /**
  49093. * Number of Simultaneous lights allowed on the material.
  49094. */
  49095. maxSimultaneousLights: number;
  49096. /**
  49097. * If sets to true, disables all the lights affecting the material.
  49098. */
  49099. disableLighting: boolean;
  49100. /**
  49101. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49102. */
  49103. environmentTexture: BaseTexture;
  49104. /**
  49105. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49106. */
  49107. invertNormalMapX: boolean;
  49108. /**
  49109. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49110. */
  49111. invertNormalMapY: boolean;
  49112. /**
  49113. * Normal map used in the model.
  49114. */
  49115. normalTexture: BaseTexture;
  49116. /**
  49117. * Emissivie color used to self-illuminate the model.
  49118. */
  49119. emissiveColor: Color3;
  49120. /**
  49121. * Emissivie texture used to self-illuminate the model.
  49122. */
  49123. emissiveTexture: BaseTexture;
  49124. /**
  49125. * Occlusion Channel Strenght.
  49126. */
  49127. occlusionStrength: number;
  49128. /**
  49129. * Occlusion Texture of the material (adding extra occlusion effects).
  49130. */
  49131. occlusionTexture: BaseTexture;
  49132. /**
  49133. * Defines the alpha limits in alpha test mode.
  49134. */
  49135. alphaCutOff: number;
  49136. /**
  49137. * Gets the current double sided mode.
  49138. */
  49139. /**
  49140. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49141. */
  49142. doubleSided: boolean;
  49143. /**
  49144. * Stores the pre-calculated light information of a mesh in a texture.
  49145. */
  49146. lightmapTexture: BaseTexture;
  49147. /**
  49148. * If true, the light map contains occlusion information instead of lighting info.
  49149. */
  49150. useLightmapAsShadowmap: boolean;
  49151. /**
  49152. * Instantiates a new PBRMaterial instance.
  49153. *
  49154. * @param name The material name
  49155. * @param scene The scene the material will be use in.
  49156. */
  49157. constructor(name: string, scene: Scene);
  49158. getClassName(): string;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. /**
  49163. * The PBR material of BJS following the metal roughness convention.
  49164. *
  49165. * This fits to the PBR convention in the GLTF definition:
  49166. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49167. */
  49168. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49169. /**
  49170. * The base color has two different interpretations depending on the value of metalness.
  49171. * When the material is a metal, the base color is the specific measured reflectance value
  49172. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49173. * of the material.
  49174. */
  49175. baseColor: Color3;
  49176. /**
  49177. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49178. * well as opacity information in the alpha channel.
  49179. */
  49180. baseTexture: BaseTexture;
  49181. /**
  49182. * Specifies the metallic scalar value of the material.
  49183. * Can also be used to scale the metalness values of the metallic texture.
  49184. */
  49185. metallic: number;
  49186. /**
  49187. * Specifies the roughness scalar value of the material.
  49188. * Can also be used to scale the roughness values of the metallic texture.
  49189. */
  49190. roughness: number;
  49191. /**
  49192. * Texture containing both the metallic value in the B channel and the
  49193. * roughness value in the G channel to keep better precision.
  49194. */
  49195. metallicRoughnessTexture: BaseTexture;
  49196. /**
  49197. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49198. *
  49199. * @param name The material name
  49200. * @param scene The scene the material will be use in.
  49201. */
  49202. constructor(name: string, scene: Scene);
  49203. /**
  49204. * Return the currrent class name of the material.
  49205. */
  49206. getClassName(): string;
  49207. /**
  49208. * Makes a duplicate of the current material.
  49209. * @param name - name to use for the new material.
  49210. */
  49211. clone(name: string): PBRMetallicRoughnessMaterial;
  49212. /**
  49213. * Serialize the material to a parsable JSON object.
  49214. */
  49215. serialize(): any;
  49216. /**
  49217. * Parses a JSON object correponding to the serialize function.
  49218. */
  49219. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49220. }
  49221. }
  49222. declare module BABYLON {
  49223. /**
  49224. * The PBR material of BJS following the specular glossiness convention.
  49225. *
  49226. * This fits to the PBR convention in the GLTF definition:
  49227. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49228. */
  49229. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49230. /**
  49231. * Specifies the diffuse color of the material.
  49232. */
  49233. diffuseColor: Color3;
  49234. /**
  49235. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49236. * channel.
  49237. */
  49238. diffuseTexture: BaseTexture;
  49239. /**
  49240. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49241. */
  49242. specularColor: Color3;
  49243. /**
  49244. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49245. */
  49246. glossiness: number;
  49247. /**
  49248. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49249. */
  49250. specularGlossinessTexture: BaseTexture;
  49251. /**
  49252. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49253. *
  49254. * @param name The material name
  49255. * @param scene The scene the material will be use in.
  49256. */
  49257. constructor(name: string, scene: Scene);
  49258. /**
  49259. * Return the currrent class name of the material.
  49260. */
  49261. getClassName(): string;
  49262. /**
  49263. * Makes a duplicate of the current material.
  49264. * @param name - name to use for the new material.
  49265. */
  49266. clone(name: string): PBRSpecularGlossinessMaterial;
  49267. /**
  49268. * Serialize the material to a parsable JSON object.
  49269. */
  49270. serialize(): any;
  49271. /**
  49272. * Parses a JSON object correponding to the serialize function.
  49273. */
  49274. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49275. }
  49276. }
  49277. declare module BABYLON {
  49278. /**
  49279. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49280. * It can help converting any input color in a desired output one. This can then be used to create effects
  49281. * from sepia, black and white to sixties or futuristic rendering...
  49282. *
  49283. * The only supported format is currently 3dl.
  49284. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49285. */
  49286. export class ColorGradingTexture extends BaseTexture {
  49287. /**
  49288. * The current texture matrix. (will always be identity in color grading texture)
  49289. */
  49290. private _textureMatrix;
  49291. /**
  49292. * The texture URL.
  49293. */
  49294. url: string;
  49295. /**
  49296. * Empty line regex stored for GC.
  49297. */
  49298. private static _noneEmptyLineRegex;
  49299. private _engine;
  49300. /**
  49301. * Instantiates a ColorGradingTexture from the following parameters.
  49302. *
  49303. * @param url The location of the color gradind data (currently only supporting 3dl)
  49304. * @param scene The scene the texture will be used in
  49305. */
  49306. constructor(url: string, scene: Scene);
  49307. /**
  49308. * Returns the texture matrix used in most of the material.
  49309. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49310. */
  49311. getTextureMatrix(): Matrix;
  49312. /**
  49313. * Occurs when the file being loaded is a .3dl LUT file.
  49314. */
  49315. private load3dlTexture;
  49316. /**
  49317. * Starts the loading process of the texture.
  49318. */
  49319. private loadTexture;
  49320. /**
  49321. * Clones the color gradind texture.
  49322. */
  49323. clone(): ColorGradingTexture;
  49324. /**
  49325. * Called during delayed load for textures.
  49326. */
  49327. delayLoad(): void;
  49328. /**
  49329. * Parses a color grading texture serialized by Babylon.
  49330. * @param parsedTexture The texture information being parsedTexture
  49331. * @param scene The scene to load the texture in
  49332. * @param rootUrl The root url of the data assets to load
  49333. * @return A color gradind texture
  49334. */
  49335. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49336. /**
  49337. * Serializes the LUT texture to json format.
  49338. */
  49339. serialize(): any;
  49340. }
  49341. }
  49342. declare module BABYLON {
  49343. /**
  49344. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49345. */
  49346. export class EquiRectangularCubeTexture extends BaseTexture {
  49347. /** The six faces of the cube. */
  49348. private static _FacesMapping;
  49349. private _noMipmap;
  49350. private _onLoad;
  49351. private _onError;
  49352. /** The size of the cubemap. */
  49353. private _size;
  49354. /** The buffer of the image. */
  49355. private _buffer;
  49356. /** The width of the input image. */
  49357. private _width;
  49358. /** The height of the input image. */
  49359. private _height;
  49360. /** The URL to the image. */
  49361. url: string;
  49362. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49363. coordinatesMode: number;
  49364. /**
  49365. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49366. * @param url The location of the image
  49367. * @param scene The scene the texture will be used in
  49368. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49369. * @param noMipmap Forces to not generate the mipmap if true
  49370. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49371. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49372. * @param onLoad — defines a callback called when texture is loaded
  49373. * @param onError — defines a callback called if there is an error
  49374. */
  49375. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49376. /**
  49377. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49378. */
  49379. private loadImage;
  49380. /**
  49381. * Convert the image buffer into a cubemap and create a CubeTexture.
  49382. */
  49383. private loadTexture;
  49384. /**
  49385. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49386. * @param buffer The ArrayBuffer that should be converted.
  49387. * @returns The buffer as Float32Array.
  49388. */
  49389. private getFloat32ArrayFromArrayBuffer;
  49390. /**
  49391. * Get the current class name of the texture useful for serialization or dynamic coding.
  49392. * @returns "EquiRectangularCubeTexture"
  49393. */
  49394. getClassName(): string;
  49395. /**
  49396. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49397. * @returns A clone of the current EquiRectangularCubeTexture.
  49398. */
  49399. clone(): EquiRectangularCubeTexture;
  49400. }
  49401. }
  49402. declare module BABYLON {
  49403. /**
  49404. * Based on jsTGALoader - Javascript loader for TGA file
  49405. * By Vincent Thibault
  49406. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49407. */
  49408. export class TGATools {
  49409. private static _TYPE_INDEXED;
  49410. private static _TYPE_RGB;
  49411. private static _TYPE_GREY;
  49412. private static _TYPE_RLE_INDEXED;
  49413. private static _TYPE_RLE_RGB;
  49414. private static _TYPE_RLE_GREY;
  49415. private static _ORIGIN_MASK;
  49416. private static _ORIGIN_SHIFT;
  49417. private static _ORIGIN_BL;
  49418. private static _ORIGIN_BR;
  49419. private static _ORIGIN_UL;
  49420. private static _ORIGIN_UR;
  49421. /**
  49422. * Gets the header of a TGA file
  49423. * @param data defines the TGA data
  49424. * @returns the header
  49425. */
  49426. static GetTGAHeader(data: Uint8Array): any;
  49427. /**
  49428. * Uploads TGA content to a Babylon Texture
  49429. * @hidden
  49430. */
  49431. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49432. /** @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;
  49433. /** @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;
  49434. /** @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;
  49435. /** @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;
  49436. /** @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;
  49437. /** @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;
  49438. }
  49439. }
  49440. declare module BABYLON {
  49441. /**
  49442. * Implementation of the TGA Texture Loader.
  49443. * @hidden
  49444. */
  49445. export class _TGATextureLoader implements IInternalTextureLoader {
  49446. /**
  49447. * Defines wether the loader supports cascade loading the different faces.
  49448. */
  49449. readonly supportCascades: boolean;
  49450. /**
  49451. * This returns if the loader support the current file information.
  49452. * @param extension defines the file extension of the file being loaded
  49453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49454. * @param fallback defines the fallback internal texture if any
  49455. * @param isBase64 defines whether the texture is encoded as a base64
  49456. * @param isBuffer defines whether the texture data are stored as a buffer
  49457. * @returns true if the loader can load the specified file
  49458. */
  49459. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49460. /**
  49461. * Transform the url before loading if required.
  49462. * @param rootUrl the url of the texture
  49463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49464. * @returns the transformed texture
  49465. */
  49466. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49467. /**
  49468. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49469. * @param rootUrl the url of the texture
  49470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49471. * @returns the fallback texture
  49472. */
  49473. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49474. /**
  49475. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49476. * @param data contains the texture data
  49477. * @param texture defines the BabylonJS internal texture
  49478. * @param createPolynomials will be true if polynomials have been requested
  49479. * @param onLoad defines the callback to trigger once the texture is ready
  49480. * @param onError defines the callback to trigger in case of error
  49481. */
  49482. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49483. /**
  49484. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49485. * @param data contains the texture data
  49486. * @param texture defines the BabylonJS internal texture
  49487. * @param callback defines the method to call once ready to upload
  49488. */
  49489. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49490. }
  49491. }
  49492. declare module BABYLON {
  49493. /**
  49494. * Info about the .basis files
  49495. */
  49496. class BasisFileInfo {
  49497. /**
  49498. * If the file has alpha
  49499. */
  49500. hasAlpha: boolean;
  49501. /**
  49502. * Info about each image of the basis file
  49503. */
  49504. images: Array<{
  49505. levels: Array<{
  49506. width: number;
  49507. height: number;
  49508. transcodedPixels: ArrayBufferView;
  49509. }>;
  49510. }>;
  49511. }
  49512. /**
  49513. * Result of transcoding a basis file
  49514. */
  49515. class TranscodeResult {
  49516. /**
  49517. * Info about the .basis file
  49518. */
  49519. fileInfo: BasisFileInfo;
  49520. /**
  49521. * Format to use when loading the file
  49522. */
  49523. format: number;
  49524. }
  49525. /**
  49526. * Configuration options for the Basis transcoder
  49527. */
  49528. export class BasisTranscodeConfiguration {
  49529. /**
  49530. * Supported compression formats used to determine the supported output format of the transcoder
  49531. */
  49532. supportedCompressionFormats?: {
  49533. /**
  49534. * etc1 compression format
  49535. */
  49536. etc1?: boolean;
  49537. /**
  49538. * s3tc compression format
  49539. */
  49540. s3tc?: boolean;
  49541. /**
  49542. * pvrtc compression format
  49543. */
  49544. pvrtc?: boolean;
  49545. /**
  49546. * etc2 compression format
  49547. */
  49548. etc2?: boolean;
  49549. };
  49550. /**
  49551. * If mipmap levels should be loaded for transcoded images (Default: true)
  49552. */
  49553. loadMipmapLevels?: boolean;
  49554. /**
  49555. * Index of a single image to load (Default: all images)
  49556. */
  49557. loadSingleImage?: number;
  49558. }
  49559. /**
  49560. * Used to load .Basis files
  49561. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  49562. */
  49563. export class BasisTools {
  49564. private static _IgnoreSupportedFormats;
  49565. /**
  49566. * URL to use when loading the basis transcoder
  49567. */
  49568. static JSModuleURL: string;
  49569. /**
  49570. * URL to use when loading the wasm module for the transcoder
  49571. */
  49572. static WasmModuleURL: string;
  49573. /**
  49574. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  49575. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  49576. * @returns internal format corresponding to the Basis format
  49577. */
  49578. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  49579. private static _WorkerPromise;
  49580. private static _Worker;
  49581. private static _actionId;
  49582. private static _CreateWorkerAsync;
  49583. /**
  49584. * Transcodes a loaded image file to compressed pixel data
  49585. * @param imageData image data to transcode
  49586. * @param config configuration options for the transcoding
  49587. * @returns a promise resulting in the transcoded image
  49588. */
  49589. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  49590. /**
  49591. * Loads a texture from the transcode result
  49592. * @param texture texture load to
  49593. * @param transcodeResult the result of transcoding the basis file to load from
  49594. */
  49595. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  49596. }
  49597. }
  49598. declare module BABYLON {
  49599. /**
  49600. * Loader for .basis file format
  49601. */
  49602. export class _BasisTextureLoader implements IInternalTextureLoader {
  49603. /**
  49604. * Defines whether the loader supports cascade loading the different faces.
  49605. */
  49606. readonly supportCascades: boolean;
  49607. /**
  49608. * This returns if the loader support the current file information.
  49609. * @param extension defines the file extension of the file being loaded
  49610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49611. * @param fallback defines the fallback internal texture if any
  49612. * @param isBase64 defines whether the texture is encoded as a base64
  49613. * @param isBuffer defines whether the texture data are stored as a buffer
  49614. * @returns true if the loader can load the specified file
  49615. */
  49616. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49617. /**
  49618. * Transform the url before loading if required.
  49619. * @param rootUrl the url of the texture
  49620. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49621. * @returns the transformed texture
  49622. */
  49623. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49624. /**
  49625. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49626. * @param rootUrl the url of the texture
  49627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49628. * @returns the fallback texture
  49629. */
  49630. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49631. /**
  49632. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  49633. * @param data contains the texture data
  49634. * @param texture defines the BabylonJS internal texture
  49635. * @param createPolynomials will be true if polynomials have been requested
  49636. * @param onLoad defines the callback to trigger once the texture is ready
  49637. * @param onError defines the callback to trigger in case of error
  49638. */
  49639. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49640. /**
  49641. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49642. * @param data contains the texture data
  49643. * @param texture defines the BabylonJS internal texture
  49644. * @param callback defines the method to call once ready to upload
  49645. */
  49646. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49647. }
  49648. }
  49649. declare module BABYLON {
  49650. /**
  49651. * 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.
  49652. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49653. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49654. */
  49655. export class CustomProceduralTexture extends ProceduralTexture {
  49656. private _animate;
  49657. private _time;
  49658. private _config;
  49659. private _texturePath;
  49660. /**
  49661. * Instantiates a new Custom Procedural Texture.
  49662. * 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.
  49663. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49664. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49665. * @param name Define the name of the texture
  49666. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49667. * @param size Define the size of the texture to create
  49668. * @param scene Define the scene the texture belongs to
  49669. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49670. * @param generateMipMaps Define if the texture should creates mip maps or not
  49671. */
  49672. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49673. private _loadJson;
  49674. /**
  49675. * Is the texture ready to be used ? (rendered at least once)
  49676. * @returns true if ready, otherwise, false.
  49677. */
  49678. isReady(): boolean;
  49679. /**
  49680. * Render the texture to its associated render target.
  49681. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49682. */
  49683. render(useCameraPostProcess?: boolean): void;
  49684. /**
  49685. * Update the list of dependant textures samplers in the shader.
  49686. */
  49687. updateTextures(): void;
  49688. /**
  49689. * Update the uniform values of the procedural texture in the shader.
  49690. */
  49691. updateShaderUniforms(): void;
  49692. /**
  49693. * Define if the texture animates or not.
  49694. */
  49695. animate: boolean;
  49696. }
  49697. }
  49698. declare module BABYLON {
  49699. /** @hidden */
  49700. export var noisePixelShader: {
  49701. name: string;
  49702. shader: string;
  49703. };
  49704. }
  49705. declare module BABYLON {
  49706. /**
  49707. * Class used to generate noise procedural textures
  49708. */
  49709. export class NoiseProceduralTexture extends ProceduralTexture {
  49710. private _time;
  49711. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49712. brightness: number;
  49713. /** Defines the number of octaves to process */
  49714. octaves: number;
  49715. /** Defines the level of persistence (0.8 by default) */
  49716. persistence: number;
  49717. /** Gets or sets animation speed factor (default is 1) */
  49718. animationSpeedFactor: number;
  49719. /**
  49720. * Creates a new NoiseProceduralTexture
  49721. * @param name defines the name fo the texture
  49722. * @param size defines the size of the texture (default is 256)
  49723. * @param scene defines the hosting scene
  49724. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49725. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49726. */
  49727. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49728. private _updateShaderUniforms;
  49729. protected _getDefines(): string;
  49730. /** Generate the current state of the procedural texture */
  49731. render(useCameraPostProcess?: boolean): void;
  49732. /**
  49733. * Serializes this noise procedural texture
  49734. * @returns a serialized noise procedural texture object
  49735. */
  49736. serialize(): any;
  49737. /**
  49738. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49739. * @param parsedTexture defines parsed texture data
  49740. * @param scene defines the current scene
  49741. * @param rootUrl defines the root URL containing noise procedural texture information
  49742. * @returns a parsed NoiseProceduralTexture
  49743. */
  49744. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49745. }
  49746. }
  49747. declare module BABYLON {
  49748. /**
  49749. * Raw cube texture where the raw buffers are passed in
  49750. */
  49751. export class RawCubeTexture extends CubeTexture {
  49752. /**
  49753. * Creates a cube texture where the raw buffers are passed in.
  49754. * @param scene defines the scene the texture is attached to
  49755. * @param data defines the array of data to use to create each face
  49756. * @param size defines the size of the textures
  49757. * @param format defines the format of the data
  49758. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49759. * @param generateMipMaps defines if the engine should generate the mip levels
  49760. * @param invertY defines if data must be stored with Y axis inverted
  49761. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49762. * @param compression defines the compression used (null by default)
  49763. */
  49764. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49765. /**
  49766. * Updates the raw cube texture.
  49767. * @param data defines the data to store
  49768. * @param format defines the data format
  49769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49770. * @param invertY defines if data must be stored with Y axis inverted
  49771. * @param compression defines the compression used (null by default)
  49772. * @param level defines which level of the texture to update
  49773. */
  49774. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49775. /**
  49776. * Updates a raw cube texture with RGBD encoded data.
  49777. * @param data defines the array of data [mipmap][face] to use to create each face
  49778. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49779. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49780. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49781. * @returns a promsie that resolves when the operation is complete
  49782. */
  49783. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49784. /**
  49785. * Clones the raw cube texture.
  49786. * @return a new cube texture
  49787. */
  49788. clone(): CubeTexture;
  49789. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49790. }
  49791. }
  49792. declare module BABYLON {
  49793. /**
  49794. * Class used to store 3D textures containing user data
  49795. */
  49796. export class RawTexture3D extends Texture {
  49797. /** Gets or sets the texture format to use */
  49798. format: number;
  49799. private _engine;
  49800. /**
  49801. * Create a new RawTexture3D
  49802. * @param data defines the data of the texture
  49803. * @param width defines the width of the texture
  49804. * @param height defines the height of the texture
  49805. * @param depth defines the depth of the texture
  49806. * @param format defines the texture format to use
  49807. * @param scene defines the hosting scene
  49808. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49809. * @param invertY defines if texture must be stored with Y axis inverted
  49810. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49811. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49812. */
  49813. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49814. /** Gets or sets the texture format to use */
  49815. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49816. /**
  49817. * Update the texture with new data
  49818. * @param data defines the data to store in the texture
  49819. */
  49820. update(data: ArrayBufferView): void;
  49821. }
  49822. }
  49823. declare module BABYLON {
  49824. /**
  49825. * Creates a refraction texture used by refraction channel of the standard material.
  49826. * It is like a mirror but to see through a material.
  49827. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49828. */
  49829. export class RefractionTexture extends RenderTargetTexture {
  49830. /**
  49831. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49832. * 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.
  49833. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49834. */
  49835. refractionPlane: Plane;
  49836. /**
  49837. * Define how deep under the surface we should see.
  49838. */
  49839. depth: number;
  49840. /**
  49841. * Creates a refraction texture used by refraction channel of the standard material.
  49842. * It is like a mirror but to see through a material.
  49843. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49844. * @param name Define the texture name
  49845. * @param size Define the size of the underlying texture
  49846. * @param scene Define the scene the refraction belongs to
  49847. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49848. */
  49849. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49850. /**
  49851. * Clone the refraction texture.
  49852. * @returns the cloned texture
  49853. */
  49854. clone(): RefractionTexture;
  49855. /**
  49856. * Serialize the texture to a JSON representation you could use in Parse later on
  49857. * @returns the serialized JSON representation
  49858. */
  49859. serialize(): any;
  49860. }
  49861. }
  49862. declare module BABYLON {
  49863. /**
  49864. * Defines the options related to the creation of an HtmlElementTexture
  49865. */
  49866. export interface IHtmlElementTextureOptions {
  49867. /**
  49868. * Defines wether mip maps should be created or not.
  49869. */
  49870. generateMipMaps?: boolean;
  49871. /**
  49872. * Defines the sampling mode of the texture.
  49873. */
  49874. samplingMode?: number;
  49875. /**
  49876. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49877. */
  49878. engine: Nullable<Engine>;
  49879. /**
  49880. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49881. */
  49882. scene: Nullable<Scene>;
  49883. }
  49884. /**
  49885. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49886. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49887. * is automatically managed.
  49888. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49889. * in your application.
  49890. *
  49891. * As the update is not automatic, you need to call them manually.
  49892. */
  49893. export class HtmlElementTexture extends BaseTexture {
  49894. /**
  49895. * The texture URL.
  49896. */
  49897. element: HTMLVideoElement | HTMLCanvasElement;
  49898. private static readonly DefaultOptions;
  49899. private _textureMatrix;
  49900. private _engine;
  49901. private _isVideo;
  49902. private _generateMipMaps;
  49903. private _samplingMode;
  49904. /**
  49905. * Instantiates a HtmlElementTexture from the following parameters.
  49906. *
  49907. * @param name Defines the name of the texture
  49908. * @param element Defines the video or canvas the texture is filled with
  49909. * @param options Defines the other none mandatory texture creation options
  49910. */
  49911. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49912. private _createInternalTexture;
  49913. /**
  49914. * Returns the texture matrix used in most of the material.
  49915. */
  49916. getTextureMatrix(): Matrix;
  49917. /**
  49918. * Updates the content of the texture.
  49919. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49920. */
  49921. update(invertY?: Nullable<boolean>): void;
  49922. }
  49923. }
  49924. declare module BABYLON {
  49925. /**
  49926. * Enum used to define the target of a block
  49927. */
  49928. export enum NodeMaterialBlockTargets {
  49929. /** Vertex shader */
  49930. Vertex = 1,
  49931. /** Fragment shader */
  49932. Fragment = 2,
  49933. /** Vertex and Fragment */
  49934. VertexAndFragment = 3
  49935. }
  49936. }
  49937. declare module BABYLON {
  49938. /**
  49939. * Defines the kind of connection point for node based material
  49940. */
  49941. export enum NodeMaterialBlockConnectionPointTypes {
  49942. /** Float */
  49943. Float = 1,
  49944. /** Int */
  49945. Int = 2,
  49946. /** Vector2 */
  49947. Vector2 = 4,
  49948. /** Vector3 */
  49949. Vector3 = 8,
  49950. /** Vector4 */
  49951. Vector4 = 16,
  49952. /** Color3 */
  49953. Color3 = 32,
  49954. /** Color4 */
  49955. Color4 = 64,
  49956. /** Matrix */
  49957. Matrix = 128,
  49958. /** Texture */
  49959. Texture = 256,
  49960. /** Texture3D */
  49961. Texture3D = 512,
  49962. /** Vector3 or Color3 */
  49963. Vector3OrColor3 = 40,
  49964. /** Vector3 or Vector4 */
  49965. Vector3OrVector4 = 24,
  49966. /** Vector4 or Color4 */
  49967. Vector4OrColor4 = 80,
  49968. /** Color3 or Color4 */
  49969. Color3OrColor4 = 96,
  49970. /** Vector3 or Color3 */
  49971. Vector3OrColor3OrVector4OrColor4 = 120,
  49972. /** Detect type based on connection */
  49973. AutoDetect = 1024,
  49974. /** Output type that will be defined by input type */
  49975. BasedOnInput = 2048,
  49976. /** Light */
  49977. Light = 4096
  49978. }
  49979. }
  49980. declare module BABYLON {
  49981. /**
  49982. * Enum used to define well known values e.g. values automatically provided by the system
  49983. */
  49984. export enum NodeMaterialWellKnownValues {
  49985. /** World */
  49986. World = 1,
  49987. /** View */
  49988. View = 2,
  49989. /** Projection */
  49990. Projection = 3,
  49991. /** ViewProjection */
  49992. ViewProjection = 4,
  49993. /** WorldView */
  49994. WorldView = 5,
  49995. /** WorldViewProjection */
  49996. WorldViewProjection = 6,
  49997. /** CameraPosition */
  49998. CameraPosition = 7,
  49999. /** Will be filled by the block itself */
  50000. Automatic = 8
  50001. }
  50002. }
  50003. declare module BABYLON {
  50004. /**
  50005. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50006. */
  50007. export enum NodeMaterialBlockConnectionPointMode {
  50008. /** Value is an uniform */
  50009. Uniform = 0,
  50010. /** Value is a mesh attribute */
  50011. Attribute = 1,
  50012. /** Value is a varying between vertex and fragment shaders */
  50013. Varying = 2,
  50014. /** Mode is undefined */
  50015. Undefined = 3
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. /**
  50020. * Class used to store shared data between 2 NodeMaterialBuildState
  50021. */
  50022. export class NodeMaterialBuildStateSharedData {
  50023. /**
  50024. * Gets the list of emitted varyings
  50025. */
  50026. varyings: string[];
  50027. /**
  50028. * Gets the varying declaration string
  50029. */
  50030. varyingDeclaration: string;
  50031. /**
  50032. * Uniform connection points
  50033. */
  50034. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50035. /**
  50036. * Bindable blocks (Blocks that need to set data to the effect)
  50037. */
  50038. bindableBlocks: NodeMaterialBlock[];
  50039. /**
  50040. * List of blocks that can provide a compilation fallback
  50041. */
  50042. blocksWithFallbacks: NodeMaterialBlock[];
  50043. /**
  50044. * List of blocks that can provide a define update
  50045. */
  50046. blocksWithDefines: NodeMaterialBlock[];
  50047. /**
  50048. * List of blocks that can provide a repeatable content
  50049. */
  50050. repeatableContentBlocks: NodeMaterialBlock[];
  50051. /**
  50052. * List of blocks that can provide a dynamic list of uniforms
  50053. */
  50054. dynamicUniformBlocks: NodeMaterialBlock[];
  50055. /**
  50056. * List of blocks that can block the isReady function for the material
  50057. */
  50058. blockingBlocks: NodeMaterialBlock[];
  50059. /**
  50060. * Build Id used to avoid multiple recompilations
  50061. */
  50062. buildId: number;
  50063. /** List of emitted variables */
  50064. variableNames: {
  50065. [key: string]: number;
  50066. };
  50067. /** List of emitted defines */
  50068. defineNames: {
  50069. [key: string]: number;
  50070. };
  50071. /** Should emit comments? */
  50072. emitComments: boolean;
  50073. /** Emit build activity */
  50074. verbose: boolean;
  50075. /**
  50076. * Gets the compilation hints emitted at compilation time
  50077. */
  50078. hints: {
  50079. needWorldViewMatrix: boolean;
  50080. needWorldViewProjectionMatrix: boolean;
  50081. needAlphaBlending: boolean;
  50082. needAlphaTesting: boolean;
  50083. };
  50084. /**
  50085. * List of compilation checks
  50086. */
  50087. checks: {
  50088. emitVertex: boolean;
  50089. emitFragment: boolean;
  50090. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50091. };
  50092. /** Creates a new shared data */
  50093. constructor();
  50094. /**
  50095. * Emits console errors and exceptions if there is a failing check
  50096. */
  50097. emitErrors(): void;
  50098. }
  50099. }
  50100. declare module BABYLON {
  50101. /**
  50102. * Class used to store node based material build state
  50103. */
  50104. export class NodeMaterialBuildState {
  50105. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50106. supportUniformBuffers: boolean;
  50107. /**
  50108. * Gets the list of emitted attributes
  50109. */
  50110. attributes: string[];
  50111. /**
  50112. * Gets the list of emitted uniforms
  50113. */
  50114. uniforms: string[];
  50115. /**
  50116. * Gets the list of emitted uniform buffers
  50117. */
  50118. uniformBuffers: string[];
  50119. /**
  50120. * Gets the list of emitted samplers
  50121. */
  50122. samplers: string[];
  50123. /**
  50124. * Gets the list of emitted functions
  50125. */
  50126. functions: {
  50127. [key: string]: string;
  50128. };
  50129. /**
  50130. * Gets the target of the compilation state
  50131. */
  50132. target: NodeMaterialBlockTargets;
  50133. /**
  50134. * Gets the list of emitted counters
  50135. */
  50136. counters: {
  50137. [key: string]: number;
  50138. };
  50139. /**
  50140. * Shared data between multiple NodeMaterialBuildState instances
  50141. */
  50142. sharedData: NodeMaterialBuildStateSharedData;
  50143. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  50144. private _attributeDeclaration;
  50145. private _uniformDeclaration;
  50146. private _samplerDeclaration;
  50147. private _varyingTransfer;
  50148. private _repeatableContentAnchorIndex;
  50149. /** @hidden */ private _builtCompilationString: string;
  50150. /**
  50151. * Gets the emitted compilation strings
  50152. */
  50153. compilationString: string;
  50154. /**
  50155. * Finalize the compilation strings
  50156. * @param state defines the current compilation state
  50157. */
  50158. finalize(state: NodeMaterialBuildState): void;
  50159. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  50160. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  50161. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  50162. /** @hidden */ private _excludeVariableName(name: string): void;
  50163. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50164. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  50165. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50166. replaceStrings?: {
  50167. search: RegExp;
  50168. replace: string;
  50169. }[];
  50170. repeatKey?: string;
  50171. }): string;
  50172. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50173. repeatKey?: string;
  50174. removeAttributes?: boolean;
  50175. removeUniforms?: boolean;
  50176. removeVaryings?: boolean;
  50177. removeIfDef?: boolean;
  50178. replaceStrings?: {
  50179. search: RegExp;
  50180. replace: string;
  50181. }[];
  50182. }, storeKey?: string): void;
  50183. /** @hidden */ private _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50184. private _emitDefine;
  50185. /** @hidden */ private _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /**
  50190. * Root class for all node material optimizers
  50191. */
  50192. export class NodeMaterialOptimizer {
  50193. /**
  50194. * Function used to optimize a NodeMaterial graph
  50195. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50196. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50197. */
  50198. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50199. }
  50200. }
  50201. declare module BABYLON {
  50202. /**
  50203. * Block used to transform a vector4 with a matrix
  50204. */
  50205. export class Vector4TransformBlock extends NodeMaterialBlock {
  50206. /**
  50207. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50208. */
  50209. complementW: number;
  50210. /**
  50211. * Creates a new Vector4TransformBlock
  50212. * @param name defines the block name
  50213. */
  50214. constructor(name: string);
  50215. /**
  50216. * Gets the current class name
  50217. * @returns the class name
  50218. */
  50219. getClassName(): string;
  50220. /**
  50221. * Gets the vector input
  50222. */
  50223. readonly vector: NodeMaterialConnectionPoint;
  50224. /**
  50225. * Gets the output component
  50226. */
  50227. readonly output: NodeMaterialConnectionPoint;
  50228. /**
  50229. * Gets the matrix transform input
  50230. */
  50231. readonly transform: NodeMaterialConnectionPoint;
  50232. protected _buildBlock(state: NodeMaterialBuildState): this;
  50233. }
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * Block used to output the vertex position
  50238. */
  50239. export class VertexOutputBlock extends NodeMaterialBlock {
  50240. /**
  50241. * Creates a new VertexOutputBlock
  50242. * @param name defines the block name
  50243. */
  50244. constructor(name: string);
  50245. /**
  50246. * Gets the current class name
  50247. * @returns the class name
  50248. */
  50249. getClassName(): string;
  50250. /**
  50251. * Gets the vector input component
  50252. */
  50253. readonly vector: NodeMaterialConnectionPoint;
  50254. protected _buildBlock(state: NodeMaterialBuildState): this;
  50255. }
  50256. }
  50257. declare module BABYLON {
  50258. /**
  50259. * Block used to output the final color
  50260. */
  50261. export class FragmentOutputBlock extends NodeMaterialBlock {
  50262. /**
  50263. * Gets or sets a boolean indicating if this block will output an alpha value
  50264. */
  50265. alphaBlendingEnabled: boolean;
  50266. /**
  50267. * Create a new FragmentOutputBlock
  50268. * @param name defines the block name
  50269. */
  50270. constructor(name: string);
  50271. /**
  50272. * Gets the current class name
  50273. * @returns the class name
  50274. */
  50275. getClassName(): string;
  50276. /**
  50277. * Gets the color input component
  50278. */
  50279. readonly color: NodeMaterialConnectionPoint;
  50280. protected _buildBlock(state: NodeMaterialBuildState): this;
  50281. }
  50282. }
  50283. declare module BABYLON {
  50284. /**
  50285. * Interface used to configure the node material editor
  50286. */
  50287. export interface INodeMaterialEditorOptions {
  50288. /** Define the URl to load node editor script */
  50289. editorURL?: string;
  50290. }
  50291. /** @hidden */
  50292. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50293. /** BONES */
  50294. NUM_BONE_INFLUENCERS: number;
  50295. BonesPerMesh: number;
  50296. BONETEXTURE: boolean;
  50297. /** MORPH TARGETS */
  50298. MORPHTARGETS: boolean;
  50299. MORPHTARGETS_NORMAL: boolean;
  50300. MORPHTARGETS_TANGENT: boolean;
  50301. MORPHTARGETS_UV: boolean;
  50302. NUM_MORPH_INFLUENCERS: number;
  50303. /** IMAGE PROCESSING */
  50304. IMAGEPROCESSING: boolean;
  50305. VIGNETTE: boolean;
  50306. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50307. VIGNETTEBLENDMODEOPAQUE: boolean;
  50308. TONEMAPPING: boolean;
  50309. TONEMAPPING_ACES: boolean;
  50310. CONTRAST: boolean;
  50311. EXPOSURE: boolean;
  50312. COLORCURVES: boolean;
  50313. COLORGRADING: boolean;
  50314. COLORGRADING3D: boolean;
  50315. SAMPLER3DGREENDEPTH: boolean;
  50316. SAMPLER3DBGRMAP: boolean;
  50317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50318. constructor();
  50319. setValue(name: string, value: boolean): void;
  50320. }
  50321. /**
  50322. * Class used to configure NodeMaterial
  50323. */
  50324. export interface INodeMaterialOptions {
  50325. /**
  50326. * Defines if blocks should emit comments
  50327. */
  50328. emitComments: boolean;
  50329. }
  50330. /**
  50331. * Class used to create a node based material built by assembling shader blocks
  50332. */
  50333. export class NodeMaterial extends PushMaterial {
  50334. private _options;
  50335. private _vertexCompilationState;
  50336. private _fragmentCompilationState;
  50337. private _sharedData;
  50338. private _buildId;
  50339. private _buildWasSuccessful;
  50340. private _cachedWorldViewMatrix;
  50341. private _cachedWorldViewProjectionMatrix;
  50342. private _textureConnectionPoints;
  50343. private _optimizers;
  50344. /** Define the URl to load node editor script */
  50345. static EditorURL: string;
  50346. private BJSNODEMATERIALEDITOR;
  50347. /** Get the inspector from bundle or global */
  50348. private _getGlobalNodeMaterialEditor;
  50349. /**
  50350. * Defines the maximum number of lights that can be used in the material
  50351. */
  50352. maxSimultaneousLights: number;
  50353. /**
  50354. * Observable raised when the material is built
  50355. */
  50356. onBuildObservable: Observable<NodeMaterial>;
  50357. /**
  50358. * Gets or sets the root nodes of the material vertex shader
  50359. */ private _vertexOutputNodes: NodeMaterialBlock[];
  50360. /**
  50361. * Gets or sets the root nodes of the material fragment (pixel) shader
  50362. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  50363. /** Gets or sets options to control the node material overall behavior */
  50364. options: INodeMaterialOptions;
  50365. /**
  50366. * Default configuration related to image processing available in the standard Material.
  50367. */
  50368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50369. /**
  50370. * Gets the image processing configuration used either in this material.
  50371. */
  50372. /**
  50373. * Sets the Default image processing configuration used either in the this material.
  50374. *
  50375. * If sets to null, the scene one is in use.
  50376. */
  50377. imageProcessingConfiguration: ImageProcessingConfiguration;
  50378. /**
  50379. * Create a new node based material
  50380. * @param name defines the material name
  50381. * @param scene defines the hosting scene
  50382. * @param options defines creation option
  50383. */
  50384. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50385. /**
  50386. * Gets the current class name of the material e.g. "NodeMaterial"
  50387. * @returns the class name
  50388. */
  50389. getClassName(): string;
  50390. /**
  50391. * Keep track of the image processing observer to allow dispose and replace.
  50392. */
  50393. private _imageProcessingObserver;
  50394. /**
  50395. * Attaches a new image processing configuration to the Standard Material.
  50396. * @param configuration
  50397. */
  50398. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50399. /**
  50400. * Adds a new optimizer to the list of optimizers
  50401. * @param optimizer defines the optimizers to add
  50402. * @returns the current material
  50403. */
  50404. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50405. /**
  50406. * Remove an optimizer from the list of optimizers
  50407. * @param optimizer defines the optimizers to remove
  50408. * @returns the current material
  50409. */
  50410. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50411. /**
  50412. * Add a new block to the list of output nodes
  50413. * @param node defines the node to add
  50414. * @returns the current material
  50415. */
  50416. addOutputNode(node: NodeMaterialBlock): this;
  50417. /**
  50418. * Remove a block from the list of root nodes
  50419. * @param node defines the node to remove
  50420. * @returns the current material
  50421. */
  50422. removeOutputNode(node: NodeMaterialBlock): this;
  50423. private _addVertexOutputNode;
  50424. private _removeVertexOutputNode;
  50425. private _addFragmentOutputNode;
  50426. private _removeFragmentOutputNode;
  50427. /**
  50428. * Specifies if the material will require alpha blending
  50429. * @returns a boolean specifying if alpha blending is needed
  50430. */
  50431. needAlphaBlending(): boolean;
  50432. /**
  50433. * Specifies if this material should be rendered in alpha test mode
  50434. * @returns a boolean specifying if an alpha test is needed.
  50435. */
  50436. needAlphaTesting(): boolean;
  50437. private _initializeBlock;
  50438. private _resetDualBlocks;
  50439. /**
  50440. * Build the material and generates the inner effect
  50441. * @param verbose defines if the build should log activity
  50442. */
  50443. build(verbose?: boolean): void;
  50444. /**
  50445. * Runs an otpimization phase to try to improve the shader code
  50446. */
  50447. optimize(): void;
  50448. private _prepareDefinesForAttributes;
  50449. /**
  50450. * Get if the submesh is ready to be used and all its information available.
  50451. * Child classes can use it to update shaders
  50452. * @param mesh defines the mesh to check
  50453. * @param subMesh defines which submesh to check
  50454. * @param useInstances specifies that instances should be used
  50455. * @returns a boolean indicating that the submesh is ready or not
  50456. */
  50457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50458. /**
  50459. * Binds the world matrix to the material
  50460. * @param world defines the world transformation matrix
  50461. */
  50462. bindOnlyWorldMatrix(world: Matrix): void;
  50463. /**
  50464. * Binds the submesh to this material by preparing the effect and shader to draw
  50465. * @param world defines the world transformation matrix
  50466. * @param mesh defines the mesh containing the submesh
  50467. * @param subMesh defines the submesh to bind the material to
  50468. */
  50469. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50470. /**
  50471. * Gets the active textures from the material
  50472. * @returns an array of textures
  50473. */
  50474. getActiveTextures(): BaseTexture[];
  50475. /**
  50476. * Specifies if the material uses a texture
  50477. * @param texture defines the texture to check against the material
  50478. * @returns a boolean specifying if the material uses the texture
  50479. */
  50480. hasTexture(texture: BaseTexture): boolean;
  50481. /**
  50482. * Disposes the material
  50483. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50484. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50485. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50486. */
  50487. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50488. /** Creates the node editor window. */
  50489. private _createNodeEditor;
  50490. /**
  50491. * Launch the node material editor
  50492. * @param config Define the configuration of the editor
  50493. * @return a promise fulfilled when the node editor is visible
  50494. */
  50495. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50496. /**
  50497. * Clear the current material
  50498. */
  50499. clear(): void;
  50500. /**
  50501. * Clear the current material and set it to a default state
  50502. */
  50503. setToDefault(): void;
  50504. }
  50505. }
  50506. declare module BABYLON {
  50507. /**
  50508. * Defines a block that can be used inside a node based material
  50509. */
  50510. export class NodeMaterialBlock {
  50511. private _buildId;
  50512. private _target;
  50513. private _isFinalMerger;
  50514. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  50515. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  50516. /**
  50517. * Gets or sets the name of the block
  50518. */
  50519. name: string;
  50520. /**
  50521. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50522. */
  50523. readonly isFinalMerger: boolean;
  50524. /**
  50525. * Gets or sets the build Id
  50526. */
  50527. buildId: number;
  50528. /**
  50529. * Gets or sets the target of the block
  50530. */
  50531. target: NodeMaterialBlockTargets;
  50532. /**
  50533. * Gets the list of input points
  50534. */
  50535. readonly inputs: NodeMaterialConnectionPoint[];
  50536. /** Gets the list of output points */
  50537. readonly outputs: NodeMaterialConnectionPoint[];
  50538. /**
  50539. * Find an input by its name
  50540. * @param name defines the name of the input to look for
  50541. * @returns the input or null if not found
  50542. */
  50543. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50544. /**
  50545. * Find an output by its name
  50546. * @param name defines the name of the outputto look for
  50547. * @returns the output or null if not found
  50548. */
  50549. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50550. /**
  50551. * Creates a new NodeMaterialBlock
  50552. * @param name defines the block name
  50553. * @param target defines the target of that block (Vertex by default)
  50554. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50555. */
  50556. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50557. /**
  50558. * Initialize the block and prepare the context for build
  50559. * @param state defines the state that will be used for the build
  50560. */
  50561. initialize(state: NodeMaterialBuildState): void;
  50562. /**
  50563. * Bind data to effect. Will only be called for blocks with isBindable === true
  50564. * @param effect defines the effect to bind data to
  50565. * @param nodeMaterial defines the hosting NodeMaterial
  50566. * @param mesh defines the mesh that will be rendered
  50567. */
  50568. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50569. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50570. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50571. protected _writeFloat(value: number): string;
  50572. /**
  50573. * Gets the current class name e.g. "NodeMaterialBlock"
  50574. * @returns the class name
  50575. */
  50576. getClassName(): string;
  50577. /**
  50578. * Register a new input. Must be called inside a block constructor
  50579. * @param name defines the connection point name
  50580. * @param type defines the connection point type
  50581. * @param isOptional defines a boolean indicating that this input can be omitted
  50582. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50583. * @returns the current block
  50584. */
  50585. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50586. /**
  50587. * Register a new output. Must be called inside a block constructor
  50588. * @param name defines the connection point name
  50589. * @param type defines the connection point type
  50590. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50591. * @returns the current block
  50592. */
  50593. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50594. /**
  50595. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50596. * @param forOutput defines an optional connection point to check compatibility with
  50597. * @returns the first available input or null
  50598. */
  50599. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50600. /**
  50601. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50602. * @param forBlock defines an optional block to check compatibility with
  50603. * @returns the first available input or null
  50604. */
  50605. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50606. /**
  50607. * Connect current block with another block
  50608. * @param other defines the block to connect with
  50609. * @param options define the various options to help pick the right connections
  50610. * @returns the current block
  50611. */
  50612. connectTo(other: NodeMaterialBlock, options?: {
  50613. input?: string;
  50614. output?: string;
  50615. outputSwizzle?: string;
  50616. }): this | undefined;
  50617. protected _buildBlock(state: NodeMaterialBuildState): void;
  50618. /**
  50619. * Add uniforms, samplers and uniform buffers at compilation time
  50620. * @param state defines the state to update
  50621. * @param nodeMaterial defines the node material requesting the update
  50622. * @param defines defines the material defines to update
  50623. */
  50624. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50625. /**
  50626. * Add potential fallbacks if shader compilation fails
  50627. * @param mesh defines the mesh to be rendered
  50628. * @param fallbacks defines the current prioritized list of fallbacks
  50629. */
  50630. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50631. /**
  50632. * Update defines for shader compilation
  50633. * @param mesh defines the mesh to be rendered
  50634. * @param nodeMaterial defines the node material requesting the update
  50635. * @param defines defines the material defines to update
  50636. * @param useInstances specifies that instances should be used
  50637. */
  50638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50639. /**
  50640. * Lets the block try to connect some inputs automatically
  50641. */
  50642. autoConfigure(): void;
  50643. /**
  50644. * Function called when a block is declared as repeatable content generator
  50645. * @param vertexShaderState defines the current compilation state for the vertex shader
  50646. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50647. * @param mesh defines the mesh to be rendered
  50648. * @param defines defines the material defines to update
  50649. */
  50650. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50651. /**
  50652. * Checks if the block is ready
  50653. * @param mesh defines the mesh to be rendered
  50654. * @param nodeMaterial defines the node material requesting the update
  50655. * @param defines defines the material defines to update
  50656. * @param useInstances specifies that instances should be used
  50657. * @returns true if the block is ready
  50658. */
  50659. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50660. /**
  50661. * Compile the current node and generate the shader code
  50662. * @param state defines the current compilation state (uniforms, samplers, current string)
  50663. * @returns the current block
  50664. */
  50665. build(state: NodeMaterialBuildState): this | undefined;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /**
  50670. * Defines a connection point for a block
  50671. */
  50672. export class NodeMaterialConnectionPoint {
  50673. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  50674. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50675. private _associatedVariableName;
  50676. private _endpoints;
  50677. private _storedValue;
  50678. private _valueCallback;
  50679. private _mode;
  50680. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50681. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  50682. /** @hidden */ private _needToEmitVarying: boolean;
  50683. /** @hidden */ private _forceUniformInVertexShaderOnly: boolean;
  50684. private _type;
  50685. /**
  50686. * Gets or sets the connection point type (default is float)
  50687. */
  50688. type: NodeMaterialBlockConnectionPointTypes;
  50689. /**
  50690. * Gets or sets the connection point name
  50691. */
  50692. name: string;
  50693. /**
  50694. * Gets or sets the swizzle to apply to this connection point when reading or writing
  50695. */
  50696. swizzle: string;
  50697. /**
  50698. * Gets or sets a boolean indicating that this connection point can be omitted
  50699. */
  50700. isOptional: boolean;
  50701. /**
  50702. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  50703. */
  50704. define: string;
  50705. /** Gets or sets the target of that connection point */
  50706. target: NodeMaterialBlockTargets;
  50707. /**
  50708. * Gets or sets the value of that point.
  50709. * Please note that this value will be ignored if valueCallback is defined
  50710. */
  50711. value: any;
  50712. /**
  50713. * Gets or sets a callback used to get the value of that point.
  50714. * Please note that setting this value will force the connection point to ignore the value property
  50715. */
  50716. valueCallback: () => any;
  50717. /**
  50718. * Gets or sets the associated variable name in the shader
  50719. */
  50720. associatedVariableName: string;
  50721. /**
  50722. * Gets a boolean indicating that this connection point not defined yet
  50723. */
  50724. readonly isUndefined: boolean;
  50725. /**
  50726. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  50727. * In this case the connection point name must be the name of the uniform to use.
  50728. * Can only be set on inputs
  50729. */
  50730. isUniform: boolean;
  50731. /**
  50732. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  50733. * In this case the connection point name must be the name of the attribute to use
  50734. * Can only be set on inputs
  50735. */
  50736. isAttribute: boolean;
  50737. /**
  50738. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  50739. * Can only be set on exit points
  50740. */
  50741. isVarying: boolean;
  50742. /** Get the other side of the connection (if any) */
  50743. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50744. /** Get the block that owns this connection point */
  50745. readonly ownerBlock: NodeMaterialBlock;
  50746. /** Get the block connected on the other side of this connection (if any) */
  50747. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  50748. /** Get the block connected on the endpoints of this connection (if any) */
  50749. readonly connectedBlocks: Array<NodeMaterialBlock>;
  50750. /**
  50751. * Creates a new connection point
  50752. * @param name defines the connection point name
  50753. * @param ownerBlock defines the block hosting this connection point
  50754. */
  50755. constructor(name: string, ownerBlock: NodeMaterialBlock);
  50756. /**
  50757. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  50758. * @returns the class name
  50759. */
  50760. getClassName(): string;
  50761. /**
  50762. * Set the source of this connection point to a vertex attribute
  50763. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  50764. * @returns the current connection point
  50765. */
  50766. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  50767. /**
  50768. * Set the source of this connection point to a well known value
  50769. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  50770. * @returns the current connection point
  50771. */
  50772. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  50773. /**
  50774. * Gets a boolean indicating that the current connection point is a well known value
  50775. */
  50776. readonly isWellKnownValue: boolean;
  50777. /**
  50778. * Gets or sets the current well known value or null if not defined as well know value
  50779. */
  50780. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50781. private _getTypeLength;
  50782. /**
  50783. * Gets an boolean indicating if the current point can be connected to another point
  50784. * @param connectionPoint defines the other connection point
  50785. * @returns true if the connection is possible
  50786. */
  50787. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  50788. /**
  50789. * Connect this point to another connection point
  50790. * @param connectionPoint defines the other connection point
  50791. * @returns the current connection point
  50792. */
  50793. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50794. /**
  50795. * Disconnect this point from one of his endpoint
  50796. * @param endpoint defines the other connection point
  50797. * @returns the current connection point
  50798. */
  50799. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50800. /**
  50801. * When connection point is an uniform, this function will send its value to the effect
  50802. * @param effect defines the effect to transmit value to
  50803. * @param world defines the world matrix
  50804. * @param worldView defines the worldxview matrix
  50805. * @param worldViewProjection defines the worldxviewxprojection matrix
  50806. */
  50807. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  50808. /**
  50809. * When connection point is an uniform, this function will send its value to the effect
  50810. * @param effect defines the effect to transmit value to
  50811. * @param scene defines the hosting scene
  50812. */
  50813. transmit(effect: Effect, scene: Scene): void;
  50814. }
  50815. }
  50816. declare module BABYLON {
  50817. /**
  50818. * Block used to add support for vertex skinning (bones)
  50819. */
  50820. export class BonesBlock extends NodeMaterialBlock {
  50821. /**
  50822. * Creates a new BonesBlock
  50823. * @param name defines the block name
  50824. */
  50825. constructor(name: string);
  50826. /**
  50827. * Initialize the block and prepare the context for build
  50828. * @param state defines the state that will be used for the build
  50829. */
  50830. initialize(state: NodeMaterialBuildState): void;
  50831. /**
  50832. * Gets the current class name
  50833. * @returns the class name
  50834. */
  50835. getClassName(): string;
  50836. /**
  50837. * Gets the matrix indices input component
  50838. */
  50839. readonly matricesIndices: NodeMaterialConnectionPoint;
  50840. /**
  50841. * Gets the matrix weights input component
  50842. */
  50843. readonly matricesWeights: NodeMaterialConnectionPoint;
  50844. /**
  50845. * Gets the extra matrix indices input component
  50846. */
  50847. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  50848. /**
  50849. * Gets the extra matrix weights input component
  50850. */
  50851. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  50852. /**
  50853. * Gets the world input component
  50854. */
  50855. readonly world: NodeMaterialConnectionPoint;
  50856. /**
  50857. * Gets the output component
  50858. */
  50859. readonly output: NodeMaterialConnectionPoint;
  50860. autoConfigure(): void;
  50861. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50862. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50864. protected _buildBlock(state: NodeMaterialBuildState): this;
  50865. }
  50866. }
  50867. declare module BABYLON {
  50868. /**
  50869. * Block used to add support for instances
  50870. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  50871. */
  50872. export class InstancesBlock extends NodeMaterialBlock {
  50873. /**
  50874. * Creates a new InstancesBlock
  50875. * @param name defines the block name
  50876. */
  50877. constructor(name: string);
  50878. /**
  50879. * Gets the current class name
  50880. * @returns the class name
  50881. */
  50882. getClassName(): string;
  50883. /**
  50884. * Gets the first world row input component
  50885. */
  50886. readonly world0: NodeMaterialConnectionPoint;
  50887. /**
  50888. * Gets the second world row input component
  50889. */
  50890. readonly world1: NodeMaterialConnectionPoint;
  50891. /**
  50892. * Gets the third world row input component
  50893. */
  50894. readonly world2: NodeMaterialConnectionPoint;
  50895. /**
  50896. * Gets the forth world row input component
  50897. */
  50898. readonly world3: NodeMaterialConnectionPoint;
  50899. /**
  50900. * Gets the world input component
  50901. */
  50902. readonly world: NodeMaterialConnectionPoint;
  50903. /**
  50904. * Gets the output component
  50905. */
  50906. readonly output: NodeMaterialConnectionPoint;
  50907. autoConfigure(): void;
  50908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50909. protected _buildBlock(state: NodeMaterialBuildState): this;
  50910. }
  50911. }
  50912. declare module BABYLON {
  50913. /**
  50914. * Block used to add morph targets support to vertex shader
  50915. */
  50916. export class MorphTargetsBlock extends NodeMaterialBlock {
  50917. private _repeatableContentAnchor;
  50918. private _repeatebleContentGenerated;
  50919. /**
  50920. * Create a new MorphTargetsBlock
  50921. * @param name defines the block name
  50922. */
  50923. constructor(name: string);
  50924. /**
  50925. * Gets the current class name
  50926. * @returns the class name
  50927. */
  50928. getClassName(): string;
  50929. /**
  50930. * Gets the position input component
  50931. */
  50932. readonly position: NodeMaterialConnectionPoint;
  50933. /**
  50934. * Gets the normal input component
  50935. */
  50936. readonly normal: NodeMaterialConnectionPoint;
  50937. /**
  50938. * Gets the tangent input component
  50939. */
  50940. readonly tangent: NodeMaterialConnectionPoint;
  50941. /**
  50942. * Gets the tangent input component
  50943. */
  50944. readonly uv: NodeMaterialConnectionPoint;
  50945. /**
  50946. * Gets the position output component
  50947. */
  50948. readonly positionOutput: NodeMaterialConnectionPoint;
  50949. /**
  50950. * Gets the normal output component
  50951. */
  50952. readonly normalOutput: NodeMaterialConnectionPoint;
  50953. /**
  50954. * Gets the tangent output component
  50955. */
  50956. readonly tangentOutput: NodeMaterialConnectionPoint;
  50957. /**
  50958. * Gets the tangent output component
  50959. */
  50960. readonly uvOutput: NodeMaterialConnectionPoint;
  50961. initialize(state: NodeMaterialBuildState): void;
  50962. autoConfigure(): void;
  50963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50965. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50966. protected _buildBlock(state: NodeMaterialBuildState): this;
  50967. }
  50968. }
  50969. declare module BABYLON {
  50970. /**
  50971. * Block used to add an alpha test in the fragment shader
  50972. */
  50973. export class AlphaTestBlock extends NodeMaterialBlock {
  50974. /**
  50975. * Gets or sets the alpha value where alpha testing happens
  50976. */
  50977. alphaCutOff: number;
  50978. /**
  50979. * Create a new AlphaTestBlock
  50980. * @param name defines the block name
  50981. */
  50982. constructor(name: string);
  50983. /**
  50984. * Gets the current class name
  50985. * @returns the class name
  50986. */
  50987. getClassName(): string;
  50988. /**
  50989. * Gets the color input component
  50990. */
  50991. readonly color: NodeMaterialConnectionPoint;
  50992. protected _buildBlock(state: NodeMaterialBuildState): this;
  50993. }
  50994. }
  50995. declare module BABYLON {
  50996. /**
  50997. * Block used to create a Color4 out of 4 inputs (one for each component)
  50998. */
  50999. export class RGBAMergerBlock extends NodeMaterialBlock {
  51000. /**
  51001. * Create a new RGBAMergerBlock
  51002. * @param name defines the block name
  51003. */
  51004. constructor(name: string);
  51005. /**
  51006. * Gets the current class name
  51007. * @returns the class name
  51008. */
  51009. getClassName(): string;
  51010. /**
  51011. * Gets the R input component
  51012. */
  51013. readonly r: NodeMaterialConnectionPoint;
  51014. /**
  51015. * Gets the G input component
  51016. */
  51017. readonly g: NodeMaterialConnectionPoint;
  51018. /**
  51019. * Gets the B input component
  51020. */
  51021. readonly b: NodeMaterialConnectionPoint;
  51022. /**
  51023. * Gets the RGB input component
  51024. */
  51025. readonly rgb: NodeMaterialConnectionPoint;
  51026. /**
  51027. * Gets the R input component
  51028. */
  51029. readonly a: NodeMaterialConnectionPoint;
  51030. /**
  51031. * Gets the output component
  51032. */
  51033. readonly output: NodeMaterialConnectionPoint;
  51034. protected _buildBlock(state: NodeMaterialBuildState): this;
  51035. }
  51036. }
  51037. declare module BABYLON {
  51038. /**
  51039. * Block used to create a Color3 out of 3 inputs (one for each component)
  51040. */
  51041. export class RGBMergerBlock extends NodeMaterialBlock {
  51042. /**
  51043. * Create a new RGBMergerBlock
  51044. * @param name defines the block name
  51045. */
  51046. constructor(name: string);
  51047. /**
  51048. * Gets the current class name
  51049. * @returns the class name
  51050. */
  51051. getClassName(): string;
  51052. /**
  51053. * Gets the R component input
  51054. */
  51055. readonly r: NodeMaterialConnectionPoint;
  51056. /**
  51057. * Gets the G component input
  51058. */
  51059. readonly g: NodeMaterialConnectionPoint;
  51060. /**
  51061. * Gets the B component input
  51062. */
  51063. readonly b: NodeMaterialConnectionPoint;
  51064. /**
  51065. * Gets the output component
  51066. */
  51067. readonly output: NodeMaterialConnectionPoint;
  51068. protected _buildBlock(state: NodeMaterialBuildState): this;
  51069. }
  51070. }
  51071. declare module BABYLON {
  51072. /**
  51073. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51074. */
  51075. export class RGBASplitterBlock extends NodeMaterialBlock {
  51076. /**
  51077. * Create a new RGBASplitterBlock
  51078. * @param name defines the block name
  51079. */
  51080. constructor(name: string);
  51081. /**
  51082. * Gets the current class name
  51083. * @returns the class name
  51084. */
  51085. getClassName(): string;
  51086. /**
  51087. * Gets the input component
  51088. */
  51089. readonly input: NodeMaterialConnectionPoint;
  51090. protected _buildBlock(state: NodeMaterialBuildState): this;
  51091. }
  51092. }
  51093. declare module BABYLON {
  51094. /**
  51095. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51096. */
  51097. export class RGBSplitterBlock extends NodeMaterialBlock {
  51098. /**
  51099. * Create a new RGBSplitterBlock
  51100. * @param name defines the block name
  51101. */
  51102. constructor(name: string);
  51103. /**
  51104. * Gets the current class name
  51105. * @returns the class name
  51106. */
  51107. getClassName(): string;
  51108. /**
  51109. * Gets the input component
  51110. */
  51111. readonly input: NodeMaterialConnectionPoint;
  51112. protected _buildBlock(state: NodeMaterialBuildState): this;
  51113. }
  51114. }
  51115. declare module BABYLON {
  51116. /**
  51117. * Block used to read a texture from a sampler
  51118. */
  51119. export class TextureBlock extends NodeMaterialBlock {
  51120. private _defineName;
  51121. /**
  51122. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51123. */
  51124. autoConnectTextureMatrix: boolean;
  51125. /**
  51126. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51127. */
  51128. autoSelectUV: boolean;
  51129. /**
  51130. * Create a new TextureBlock
  51131. * @param name defines the block name
  51132. */
  51133. constructor(name: string);
  51134. /**
  51135. * Gets the current class name
  51136. * @returns the class name
  51137. */
  51138. getClassName(): string;
  51139. /**
  51140. * Gets the uv input component
  51141. */
  51142. readonly uv: NodeMaterialConnectionPoint;
  51143. /**
  51144. * Gets the texture information input component
  51145. */
  51146. readonly textureInfo: NodeMaterialConnectionPoint;
  51147. /**
  51148. * Gets the transformed uv input component
  51149. */
  51150. readonly transformedUV: NodeMaterialConnectionPoint;
  51151. /**
  51152. * Gets the texture input component
  51153. */
  51154. readonly texture: NodeMaterialConnectionPoint;
  51155. /**
  51156. * Gets the texture transform input component
  51157. */
  51158. readonly textureTransform: NodeMaterialConnectionPoint;
  51159. /**
  51160. * Gets the output component
  51161. */
  51162. readonly output: NodeMaterialConnectionPoint;
  51163. autoConfigure(): void;
  51164. initialize(state: NodeMaterialBuildState): void;
  51165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51166. isReady(): boolean;
  51167. private _injectVertexCode;
  51168. protected _buildBlock(state: NodeMaterialBuildState): this;
  51169. }
  51170. }
  51171. declare module BABYLON {
  51172. /**
  51173. * Block used to add image processing support to fragment shader
  51174. */
  51175. export class ImageProcessingBlock extends NodeMaterialBlock {
  51176. /**
  51177. * Create a new ImageProcessingBlock
  51178. * @param name defines the block name
  51179. */
  51180. constructor(name: string);
  51181. /**
  51182. * Gets the current class name
  51183. * @returns the class name
  51184. */
  51185. getClassName(): string;
  51186. /**
  51187. * Gets the color input component
  51188. */
  51189. readonly color: NodeMaterialConnectionPoint;
  51190. /**
  51191. * Gets the output component
  51192. */
  51193. readonly output: NodeMaterialConnectionPoint;
  51194. /**
  51195. * Initialize the block and prepare the context for build
  51196. * @param state defines the state that will be used for the build
  51197. */
  51198. initialize(state: NodeMaterialBuildState): void;
  51199. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51200. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51201. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51202. protected _buildBlock(state: NodeMaterialBuildState): this;
  51203. }
  51204. }
  51205. declare module BABYLON {
  51206. /**
  51207. * Block used to add support for scene fog
  51208. */
  51209. export class FogBlock extends NodeMaterialBlock {
  51210. /**
  51211. * Create a new FogBlock
  51212. * @param name defines the block name
  51213. */
  51214. constructor(name: string);
  51215. /**
  51216. * Gets the current class name
  51217. * @returns the class name
  51218. */
  51219. getClassName(): string;
  51220. /**
  51221. * Gets the world position input component
  51222. */
  51223. readonly worldPosition: NodeMaterialConnectionPoint;
  51224. /**
  51225. * Gets the view input component
  51226. */
  51227. readonly view: NodeMaterialConnectionPoint;
  51228. /**
  51229. * Gets the color input component
  51230. */
  51231. readonly color: NodeMaterialConnectionPoint;
  51232. /**
  51233. * Gets the fog color input component
  51234. */
  51235. readonly fogColor: NodeMaterialConnectionPoint;
  51236. /**
  51237. * Gets the for parameter input component
  51238. */
  51239. readonly fogParameters: NodeMaterialConnectionPoint;
  51240. /**
  51241. * Gets the output component
  51242. */
  51243. readonly output: NodeMaterialConnectionPoint;
  51244. autoConfigure(): void;
  51245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51247. protected _buildBlock(state: NodeMaterialBuildState): this;
  51248. }
  51249. }
  51250. declare module BABYLON {
  51251. /**
  51252. * Block used to add light in the fragment shader
  51253. */
  51254. export class LightBlock extends NodeMaterialBlock {
  51255. private _lightId;
  51256. /**
  51257. * Create a new LightBlock
  51258. * @param name defines the block name
  51259. */
  51260. constructor(name: string);
  51261. /**
  51262. * Gets the current class name
  51263. * @returns the class name
  51264. */
  51265. getClassName(): string;
  51266. /**
  51267. * Gets the world position input component
  51268. */
  51269. readonly worldPosition: NodeMaterialConnectionPoint;
  51270. /**
  51271. * Gets the world normal input component
  51272. */
  51273. readonly worldNormal: NodeMaterialConnectionPoint;
  51274. /**
  51275. * Gets the light input component.
  51276. * If not defined, all lights will be considered
  51277. */
  51278. readonly light: NodeMaterialConnectionPoint;
  51279. /**
  51280. * Gets the camera (or eye) position component
  51281. */
  51282. readonly cameraPosition: NodeMaterialConnectionPoint;
  51283. /**
  51284. * Gets the diffuse output component
  51285. */
  51286. readonly diffuseOutput: NodeMaterialConnectionPoint;
  51287. /**
  51288. * Gets the specular output component
  51289. */
  51290. readonly specularOutput: NodeMaterialConnectionPoint;
  51291. autoConfigure(): void;
  51292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51293. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51295. private _injectVertexCode;
  51296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51297. }
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * Block used to multiply 2 vector4
  51302. */
  51303. export class MultiplyBlock extends NodeMaterialBlock {
  51304. /**
  51305. * Creates a new MultiplyBlock
  51306. * @param name defines the block name
  51307. */
  51308. constructor(name: string);
  51309. /**
  51310. * Gets the current class name
  51311. * @returns the class name
  51312. */
  51313. getClassName(): string;
  51314. /**
  51315. * Gets the left operand input component
  51316. */
  51317. readonly left: NodeMaterialConnectionPoint;
  51318. /**
  51319. * Gets the right operand input component
  51320. */
  51321. readonly right: NodeMaterialConnectionPoint;
  51322. /**
  51323. * Gets the output component
  51324. */
  51325. readonly output: NodeMaterialConnectionPoint;
  51326. protected _buildBlock(state: NodeMaterialBuildState): this;
  51327. }
  51328. }
  51329. declare module BABYLON {
  51330. /**
  51331. * Block used to add 2 vector4
  51332. */
  51333. export class AddBlock extends NodeMaterialBlock {
  51334. /**
  51335. * Creates a new AddBlock
  51336. * @param name defines the block name
  51337. */
  51338. constructor(name: string);
  51339. /**
  51340. * Gets the current class name
  51341. * @returns the class name
  51342. */
  51343. getClassName(): string;
  51344. /**
  51345. * Gets the left operand input component
  51346. */
  51347. readonly left: NodeMaterialConnectionPoint;
  51348. /**
  51349. * Gets the right operand input component
  51350. */
  51351. readonly right: NodeMaterialConnectionPoint;
  51352. /**
  51353. * Gets the output component
  51354. */
  51355. readonly output: NodeMaterialConnectionPoint;
  51356. protected _buildBlock(state: NodeMaterialBuildState): this;
  51357. }
  51358. }
  51359. declare module BABYLON {
  51360. /**
  51361. * Block used to clamp a float
  51362. */
  51363. export class ClampBlock extends NodeMaterialBlock {
  51364. /** Gets or sets the minimum range */
  51365. minimum: number;
  51366. /** Gets or sets the maximum range */
  51367. maximum: number;
  51368. /**
  51369. * Creates a new ClampBlock
  51370. * @param name defines the block name
  51371. */
  51372. constructor(name: string);
  51373. /**
  51374. * Gets the current class name
  51375. * @returns the class name
  51376. */
  51377. getClassName(): string;
  51378. /**
  51379. * Gets the value input component
  51380. */
  51381. readonly value: NodeMaterialConnectionPoint;
  51382. /**
  51383. * Gets the output component
  51384. */
  51385. readonly output: NodeMaterialConnectionPoint;
  51386. protected _buildBlock(state: NodeMaterialBuildState): this;
  51387. }
  51388. }
  51389. declare module BABYLON {
  51390. /**
  51391. * Block used to scale a value
  51392. */
  51393. export class ScaleBlock extends NodeMaterialBlock {
  51394. /**
  51395. * Creates a new ScaleBlock
  51396. * @param name defines the block name
  51397. */
  51398. constructor(name: string);
  51399. /**
  51400. * Gets the current class name
  51401. * @returns the class name
  51402. */
  51403. getClassName(): string;
  51404. /**
  51405. * Gets the value operand input component
  51406. */
  51407. readonly value: NodeMaterialConnectionPoint;
  51408. /**
  51409. * Gets the scale operand input component
  51410. */
  51411. readonly scale: NodeMaterialConnectionPoint;
  51412. /**
  51413. * Gets the output component
  51414. */
  51415. readonly output: NodeMaterialConnectionPoint;
  51416. protected _buildBlock(state: NodeMaterialBuildState): this;
  51417. }
  51418. }
  51419. declare module BABYLON {
  51420. /**
  51421. * Block used to transform a vector2 with a matrix
  51422. */
  51423. export class Vector2TransformBlock extends NodeMaterialBlock {
  51424. /**
  51425. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51426. */
  51427. complementZ: number;
  51428. /**
  51429. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51430. */
  51431. complementW: number;
  51432. /**
  51433. * Creates a new Vector2TransformBlock
  51434. * @param name defines the block name
  51435. */
  51436. constructor(name: string);
  51437. /**
  51438. * Gets the vector input
  51439. */
  51440. readonly vector: NodeMaterialConnectionPoint;
  51441. /**
  51442. * Gets the matrix transform input
  51443. */
  51444. readonly transform: NodeMaterialConnectionPoint;
  51445. /**
  51446. * Gets the output component
  51447. */
  51448. readonly output: NodeMaterialConnectionPoint;
  51449. /**
  51450. * Gets the current class name
  51451. * @returns the class name
  51452. */
  51453. getClassName(): string;
  51454. protected _buildBlock(state: NodeMaterialBuildState): this;
  51455. }
  51456. }
  51457. declare module BABYLON {
  51458. /**
  51459. * Block used to transform a vector3 with a matrix
  51460. */
  51461. export class Vector3TransformBlock extends NodeMaterialBlock {
  51462. /**
  51463. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51464. */
  51465. complement: number;
  51466. /**
  51467. * Creates a new Vector3TransformBlock
  51468. * @param name defines the block name
  51469. */
  51470. constructor(name: string);
  51471. /**
  51472. * Gets the vector input
  51473. */
  51474. readonly vector: NodeMaterialConnectionPoint;
  51475. /**
  51476. * Gets the matrix transform input
  51477. */
  51478. readonly transform: NodeMaterialConnectionPoint;
  51479. /**
  51480. * Gets the output component
  51481. */
  51482. readonly output: NodeMaterialConnectionPoint;
  51483. /**
  51484. * Gets the current class name
  51485. * @returns the class name
  51486. */
  51487. getClassName(): string;
  51488. protected _buildBlock(state: NodeMaterialBuildState): this;
  51489. }
  51490. }
  51491. declare module BABYLON {
  51492. /**
  51493. * Block used to multiply two matrices
  51494. */
  51495. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51496. /**
  51497. * Creates a new MatrixMultiplicationBlock
  51498. * @param name defines the block name
  51499. */
  51500. constructor(name: string);
  51501. /**
  51502. * Gets the left operand
  51503. */
  51504. readonly left: NodeMaterialConnectionPoint;
  51505. /**
  51506. * Gets the right operand
  51507. */
  51508. readonly right: NodeMaterialConnectionPoint;
  51509. /**
  51510. * Gets the output component
  51511. */
  51512. readonly output: NodeMaterialConnectionPoint;
  51513. /**
  51514. * Gets the current class name
  51515. * @returns the class name
  51516. */
  51517. getClassName(): string;
  51518. protected _buildBlock(state: NodeMaterialBuildState): this;
  51519. }
  51520. }
  51521. declare module BABYLON {
  51522. /**
  51523. * Helper class to push actions to a pool of workers.
  51524. */
  51525. export class WorkerPool implements IDisposable {
  51526. private _workerInfos;
  51527. private _pendingActions;
  51528. /**
  51529. * Constructor
  51530. * @param workers Array of workers to use for actions
  51531. */
  51532. constructor(workers: Array<Worker>);
  51533. /**
  51534. * Terminates all workers and clears any pending actions.
  51535. */
  51536. dispose(): void;
  51537. /**
  51538. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51539. * pended until a worker has completed its action.
  51540. * @param action The action to perform. Call onComplete when the action is complete.
  51541. */
  51542. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51543. private _execute;
  51544. }
  51545. }
  51546. declare module BABYLON {
  51547. /**
  51548. * Configuration for Draco compression
  51549. */
  51550. export interface IDracoCompressionConfiguration {
  51551. /**
  51552. * Configuration for the decoder.
  51553. */
  51554. decoder: {
  51555. /**
  51556. * The url to the WebAssembly module.
  51557. */
  51558. wasmUrl?: string;
  51559. /**
  51560. * The url to the WebAssembly binary.
  51561. */
  51562. wasmBinaryUrl?: string;
  51563. /**
  51564. * The url to the fallback JavaScript module.
  51565. */
  51566. fallbackUrl?: string;
  51567. };
  51568. }
  51569. /**
  51570. * Draco compression (https://google.github.io/draco/)
  51571. *
  51572. * This class wraps the Draco module.
  51573. *
  51574. * **Encoder**
  51575. *
  51576. * The encoder is not currently implemented.
  51577. *
  51578. * **Decoder**
  51579. *
  51580. * 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.
  51581. *
  51582. * To update the configuration, use the following code:
  51583. * ```javascript
  51584. * DracoCompression.Configuration = {
  51585. * decoder: {
  51586. * wasmUrl: "<url to the WebAssembly library>",
  51587. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51588. * fallbackUrl: "<url to the fallback JavaScript library>",
  51589. * }
  51590. * };
  51591. * ```
  51592. *
  51593. * 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.
  51594. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51595. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51596. *
  51597. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51598. * ```javascript
  51599. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51600. * ```
  51601. *
  51602. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51603. */
  51604. export class DracoCompression implements IDisposable {
  51605. private _workerPoolPromise?;
  51606. private _decoderModulePromise?;
  51607. /**
  51608. * The configuration. Defaults to the following urls:
  51609. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51610. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51611. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51612. */
  51613. static Configuration: IDracoCompressionConfiguration;
  51614. /**
  51615. * Returns true if the decoder configuration is available.
  51616. */
  51617. static readonly DecoderAvailable: boolean;
  51618. /**
  51619. * Default number of workers to create when creating the draco compression object.
  51620. */
  51621. static DefaultNumWorkers: number;
  51622. private static GetDefaultNumWorkers;
  51623. private static _Default;
  51624. /**
  51625. * Default instance for the draco compression object.
  51626. */
  51627. static readonly Default: DracoCompression;
  51628. /**
  51629. * Constructor
  51630. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51631. */
  51632. constructor(numWorkers?: number);
  51633. /**
  51634. * Stop all async operations and release resources.
  51635. */
  51636. dispose(): void;
  51637. /**
  51638. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51639. * @returns a promise that resolves when ready
  51640. */
  51641. whenReadyAsync(): Promise<void>;
  51642. /**
  51643. * Decode Draco compressed mesh data to vertex data.
  51644. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51645. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51646. * @returns A promise that resolves with the decoded vertex data
  51647. */
  51648. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51649. [kind: string]: number;
  51650. }): Promise<VertexData>;
  51651. }
  51652. }
  51653. declare module BABYLON {
  51654. /**
  51655. * Class for building Constructive Solid Geometry
  51656. */
  51657. export class CSG {
  51658. private polygons;
  51659. /**
  51660. * The world matrix
  51661. */
  51662. matrix: Matrix;
  51663. /**
  51664. * Stores the position
  51665. */
  51666. position: Vector3;
  51667. /**
  51668. * Stores the rotation
  51669. */
  51670. rotation: Vector3;
  51671. /**
  51672. * Stores the rotation quaternion
  51673. */
  51674. rotationQuaternion: Nullable<Quaternion>;
  51675. /**
  51676. * Stores the scaling vector
  51677. */
  51678. scaling: Vector3;
  51679. /**
  51680. * Convert the Mesh to CSG
  51681. * @param mesh The Mesh to convert to CSG
  51682. * @returns A new CSG from the Mesh
  51683. */
  51684. static FromMesh(mesh: Mesh): CSG;
  51685. /**
  51686. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51687. * @param polygons Polygons used to construct a CSG solid
  51688. */
  51689. private static FromPolygons;
  51690. /**
  51691. * Clones, or makes a deep copy, of the CSG
  51692. * @returns A new CSG
  51693. */
  51694. clone(): CSG;
  51695. /**
  51696. * Unions this CSG with another CSG
  51697. * @param csg The CSG to union against this CSG
  51698. * @returns The unioned CSG
  51699. */
  51700. union(csg: CSG): CSG;
  51701. /**
  51702. * Unions this CSG with another CSG in place
  51703. * @param csg The CSG to union against this CSG
  51704. */
  51705. unionInPlace(csg: CSG): void;
  51706. /**
  51707. * Subtracts this CSG with another CSG
  51708. * @param csg The CSG to subtract against this CSG
  51709. * @returns A new CSG
  51710. */
  51711. subtract(csg: CSG): CSG;
  51712. /**
  51713. * Subtracts this CSG with another CSG in place
  51714. * @param csg The CSG to subtact against this CSG
  51715. */
  51716. subtractInPlace(csg: CSG): void;
  51717. /**
  51718. * Intersect this CSG with another CSG
  51719. * @param csg The CSG to intersect against this CSG
  51720. * @returns A new CSG
  51721. */
  51722. intersect(csg: CSG): CSG;
  51723. /**
  51724. * Intersects this CSG with another CSG in place
  51725. * @param csg The CSG to intersect against this CSG
  51726. */
  51727. intersectInPlace(csg: CSG): void;
  51728. /**
  51729. * Return a new CSG solid with solid and empty space switched. This solid is
  51730. * not modified.
  51731. * @returns A new CSG solid with solid and empty space switched
  51732. */
  51733. inverse(): CSG;
  51734. /**
  51735. * Inverses the CSG in place
  51736. */
  51737. inverseInPlace(): void;
  51738. /**
  51739. * This is used to keep meshes transformations so they can be restored
  51740. * when we build back a Babylon Mesh
  51741. * NB : All CSG operations are performed in world coordinates
  51742. * @param csg The CSG to copy the transform attributes from
  51743. * @returns This CSG
  51744. */
  51745. copyTransformAttributes(csg: CSG): CSG;
  51746. /**
  51747. * Build Raw mesh from CSG
  51748. * Coordinates here are in world space
  51749. * @param name The name of the mesh geometry
  51750. * @param scene The Scene
  51751. * @param keepSubMeshes Specifies if the submeshes should be kept
  51752. * @returns A new Mesh
  51753. */
  51754. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51755. /**
  51756. * Build Mesh from CSG taking material and transforms into account
  51757. * @param name The name of the Mesh
  51758. * @param material The material of the Mesh
  51759. * @param scene The Scene
  51760. * @param keepSubMeshes Specifies if submeshes should be kept
  51761. * @returns The new Mesh
  51762. */
  51763. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51764. }
  51765. }
  51766. declare module BABYLON {
  51767. /**
  51768. * Class used to create a trail following a mesh
  51769. */
  51770. export class TrailMesh extends Mesh {
  51771. private _generator;
  51772. private _autoStart;
  51773. private _running;
  51774. private _diameter;
  51775. private _length;
  51776. private _sectionPolygonPointsCount;
  51777. private _sectionVectors;
  51778. private _sectionNormalVectors;
  51779. private _beforeRenderObserver;
  51780. /**
  51781. * @constructor
  51782. * @param name The value used by scene.getMeshByName() to do a lookup.
  51783. * @param generator The mesh to generate a trail.
  51784. * @param scene The scene to add this mesh to.
  51785. * @param diameter Diameter of trailing mesh. Default is 1.
  51786. * @param length Length of trailing mesh. Default is 60.
  51787. * @param autoStart Automatically start trailing mesh. Default true.
  51788. */
  51789. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51790. /**
  51791. * "TrailMesh"
  51792. * @returns "TrailMesh"
  51793. */
  51794. getClassName(): string;
  51795. private _createMesh;
  51796. /**
  51797. * Start trailing mesh.
  51798. */
  51799. start(): void;
  51800. /**
  51801. * Stop trailing mesh.
  51802. */
  51803. stop(): void;
  51804. /**
  51805. * Update trailing mesh geometry.
  51806. */
  51807. update(): void;
  51808. /**
  51809. * Returns a new TrailMesh object.
  51810. * @param name is a string, the name given to the new mesh
  51811. * @param newGenerator use new generator object for cloned trail mesh
  51812. * @returns a new mesh
  51813. */
  51814. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51815. /**
  51816. * Serializes this trail mesh
  51817. * @param serializationObject object to write serialization to
  51818. */
  51819. serialize(serializationObject: any): void;
  51820. /**
  51821. * Parses a serialized trail mesh
  51822. * @param parsedMesh the serialized mesh
  51823. * @param scene the scene to create the trail mesh in
  51824. * @returns the created trail mesh
  51825. */
  51826. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51827. }
  51828. }
  51829. declare module BABYLON {
  51830. /**
  51831. * Class containing static functions to help procedurally build meshes
  51832. */
  51833. export class TiledBoxBuilder {
  51834. /**
  51835. * Creates a box mesh
  51836. * 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)
  51837. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51839. * * 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
  51840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51841. * @param name defines the name of the mesh
  51842. * @param options defines the options used to create the mesh
  51843. * @param scene defines the hosting scene
  51844. * @returns the box mesh
  51845. */
  51846. static CreateTiledBox(name: string, options: {
  51847. pattern?: number;
  51848. width?: number;
  51849. height?: number;
  51850. depth?: number;
  51851. tileSize?: number;
  51852. tileWidth?: number;
  51853. tileHeight?: number;
  51854. alignHorizontal?: number;
  51855. alignVertical?: number;
  51856. faceUV?: Vector4[];
  51857. faceColors?: Color4[];
  51858. sideOrientation?: number;
  51859. updatable?: boolean;
  51860. }, scene?: Nullable<Scene>): Mesh;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * Class containing static functions to help procedurally build meshes
  51866. */
  51867. export class TorusKnotBuilder {
  51868. /**
  51869. * Creates a torus knot mesh
  51870. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51871. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51872. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51873. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51875. * * 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
  51876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51877. * @param name defines the name of the mesh
  51878. * @param options defines the options used to create the mesh
  51879. * @param scene defines the hosting scene
  51880. * @returns the torus knot mesh
  51881. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51882. */
  51883. static CreateTorusKnot(name: string, options: {
  51884. radius?: number;
  51885. tube?: number;
  51886. radialSegments?: number;
  51887. tubularSegments?: number;
  51888. p?: number;
  51889. q?: number;
  51890. updatable?: boolean;
  51891. sideOrientation?: number;
  51892. frontUVs?: Vector4;
  51893. backUVs?: Vector4;
  51894. }, scene: any): Mesh;
  51895. }
  51896. }
  51897. declare module BABYLON {
  51898. /**
  51899. * Polygon
  51900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51901. */
  51902. export class Polygon {
  51903. /**
  51904. * Creates a rectangle
  51905. * @param xmin bottom X coord
  51906. * @param ymin bottom Y coord
  51907. * @param xmax top X coord
  51908. * @param ymax top Y coord
  51909. * @returns points that make the resulting rectation
  51910. */
  51911. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51912. /**
  51913. * Creates a circle
  51914. * @param radius radius of circle
  51915. * @param cx scale in x
  51916. * @param cy scale in y
  51917. * @param numberOfSides number of sides that make up the circle
  51918. * @returns points that make the resulting circle
  51919. */
  51920. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51921. /**
  51922. * Creates a polygon from input string
  51923. * @param input Input polygon data
  51924. * @returns the parsed points
  51925. */
  51926. static Parse(input: string): Vector2[];
  51927. /**
  51928. * Starts building a polygon from x and y coordinates
  51929. * @param x x coordinate
  51930. * @param y y coordinate
  51931. * @returns the started path2
  51932. */
  51933. static StartingAt(x: number, y: number): Path2;
  51934. }
  51935. /**
  51936. * Builds a polygon
  51937. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51938. */
  51939. export class PolygonMeshBuilder {
  51940. private _points;
  51941. private _outlinepoints;
  51942. private _holes;
  51943. private _name;
  51944. private _scene;
  51945. private _epoints;
  51946. private _eholes;
  51947. private _addToepoint;
  51948. /**
  51949. * Babylon reference to the earcut plugin.
  51950. */
  51951. bjsEarcut: any;
  51952. /**
  51953. * Creates a PolygonMeshBuilder
  51954. * @param name name of the builder
  51955. * @param contours Path of the polygon
  51956. * @param scene scene to add to when creating the mesh
  51957. * @param earcutInjection can be used to inject your own earcut reference
  51958. */
  51959. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51960. /**
  51961. * Adds a whole within the polygon
  51962. * @param hole Array of points defining the hole
  51963. * @returns this
  51964. */
  51965. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51966. /**
  51967. * Creates the polygon
  51968. * @param updatable If the mesh should be updatable
  51969. * @param depth The depth of the mesh created
  51970. * @returns the created mesh
  51971. */
  51972. build(updatable?: boolean, depth?: number): Mesh;
  51973. /**
  51974. * Creates the polygon
  51975. * @param depth The depth of the mesh created
  51976. * @returns the created VertexData
  51977. */
  51978. buildVertexData(depth?: number): VertexData;
  51979. /**
  51980. * Adds a side to the polygon
  51981. * @param positions points that make the polygon
  51982. * @param normals normals of the polygon
  51983. * @param uvs uvs of the polygon
  51984. * @param indices indices of the polygon
  51985. * @param bounds bounds of the polygon
  51986. * @param points points of the polygon
  51987. * @param depth depth of the polygon
  51988. * @param flip flip of the polygon
  51989. */
  51990. private addSide;
  51991. }
  51992. }
  51993. declare module BABYLON {
  51994. /**
  51995. * Class containing static functions to help procedurally build meshes
  51996. */
  51997. export class PolygonBuilder {
  51998. /**
  51999. * Creates a polygon mesh
  52000. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52001. * * 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
  52002. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52004. * * 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)
  52005. * * Remember you can only change the shape positions, not their number when updating a polygon
  52006. * @param name defines the name of the mesh
  52007. * @param options defines the options used to create the mesh
  52008. * @param scene defines the hosting scene
  52009. * @param earcutInjection can be used to inject your own earcut reference
  52010. * @returns the polygon mesh
  52011. */
  52012. static CreatePolygon(name: string, options: {
  52013. shape: Vector3[];
  52014. holes?: Vector3[][];
  52015. depth?: number;
  52016. faceUV?: Vector4[];
  52017. faceColors?: Color4[];
  52018. updatable?: boolean;
  52019. sideOrientation?: number;
  52020. frontUVs?: Vector4;
  52021. backUVs?: Vector4;
  52022. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52023. /**
  52024. * Creates an extruded polygon mesh, with depth in the Y direction.
  52025. * * 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)
  52026. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52027. * @param name defines the name of the mesh
  52028. * @param options defines the options used to create the mesh
  52029. * @param scene defines the hosting scene
  52030. * @param earcutInjection can be used to inject your own earcut reference
  52031. * @returns the polygon mesh
  52032. */
  52033. static ExtrudePolygon(name: string, options: {
  52034. shape: Vector3[];
  52035. holes?: Vector3[][];
  52036. depth?: number;
  52037. faceUV?: Vector4[];
  52038. faceColors?: Color4[];
  52039. updatable?: boolean;
  52040. sideOrientation?: number;
  52041. frontUVs?: Vector4;
  52042. backUVs?: Vector4;
  52043. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52044. }
  52045. }
  52046. declare module BABYLON {
  52047. /**
  52048. * Class containing static functions to help procedurally build meshes
  52049. */
  52050. export class LatheBuilder {
  52051. /**
  52052. * Creates lathe mesh.
  52053. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52054. * * 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
  52055. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52056. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52057. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52058. * * 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
  52059. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52060. * * 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
  52061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52062. * * 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
  52063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52065. * @param name defines the name of the mesh
  52066. * @param options defines the options used to create the mesh
  52067. * @param scene defines the hosting scene
  52068. * @returns the lathe mesh
  52069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52070. */
  52071. static CreateLathe(name: string, options: {
  52072. shape: Vector3[];
  52073. radius?: number;
  52074. tessellation?: number;
  52075. clip?: number;
  52076. arc?: number;
  52077. closed?: boolean;
  52078. updatable?: boolean;
  52079. sideOrientation?: number;
  52080. frontUVs?: Vector4;
  52081. backUVs?: Vector4;
  52082. cap?: number;
  52083. invertUV?: boolean;
  52084. }, scene?: Nullable<Scene>): Mesh;
  52085. }
  52086. }
  52087. declare module BABYLON {
  52088. /**
  52089. * Class containing static functions to help procedurally build meshes
  52090. */
  52091. export class TiledPlaneBuilder {
  52092. /**
  52093. * Creates a tiled plane mesh
  52094. * * The parameter `pattern` will, depending on value, do nothing or
  52095. * * * flip (reflect about central vertical) alternate tiles across and up
  52096. * * * flip every tile on alternate rows
  52097. * * * rotate (180 degs) alternate tiles across and up
  52098. * * * rotate every tile on alternate rows
  52099. * * * flip and rotate alternate tiles across and up
  52100. * * * flip and rotate every tile on alternate rows
  52101. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52102. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52103. * * 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
  52104. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52105. * * 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)
  52106. * * 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)
  52107. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52108. * @param name defines the name of the mesh
  52109. * @param options defines the options used to create the mesh
  52110. * @param scene defines the hosting scene
  52111. * @returns the box mesh
  52112. */
  52113. static CreateTiledPlane(name: string, options: {
  52114. pattern?: number;
  52115. tileSize?: number;
  52116. tileWidth?: number;
  52117. tileHeight?: number;
  52118. size?: number;
  52119. width?: number;
  52120. height?: number;
  52121. alignHorizontal?: number;
  52122. alignVertical?: number;
  52123. sideOrientation?: number;
  52124. frontUVs?: Vector4;
  52125. backUVs?: Vector4;
  52126. updatable?: boolean;
  52127. }, scene?: Nullable<Scene>): Mesh;
  52128. }
  52129. }
  52130. declare module BABYLON {
  52131. /**
  52132. * Class containing static functions to help procedurally build meshes
  52133. */
  52134. export class TubeBuilder {
  52135. /**
  52136. * Creates a tube mesh.
  52137. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52138. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52139. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52140. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52141. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52142. * * 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)
  52143. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52144. * * 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
  52145. * * 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
  52146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52147. * * 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
  52148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52150. * @param name defines the name of the mesh
  52151. * @param options defines the options used to create the mesh
  52152. * @param scene defines the hosting scene
  52153. * @returns the tube mesh
  52154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52155. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52156. */
  52157. static CreateTube(name: string, options: {
  52158. path: Vector3[];
  52159. radius?: number;
  52160. tessellation?: number;
  52161. radiusFunction?: {
  52162. (i: number, distance: number): number;
  52163. };
  52164. cap?: number;
  52165. arc?: number;
  52166. updatable?: boolean;
  52167. sideOrientation?: number;
  52168. frontUVs?: Vector4;
  52169. backUVs?: Vector4;
  52170. instance?: Mesh;
  52171. invertUV?: boolean;
  52172. }, scene?: Nullable<Scene>): Mesh;
  52173. }
  52174. }
  52175. declare module BABYLON {
  52176. /**
  52177. * Class containing static functions to help procedurally build meshes
  52178. */
  52179. export class IcoSphereBuilder {
  52180. /**
  52181. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52182. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52183. * * 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`)
  52184. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52185. * * 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
  52186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52187. * * 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
  52188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52189. * @param name defines the name of the mesh
  52190. * @param options defines the options used to create the mesh
  52191. * @param scene defines the hosting scene
  52192. * @returns the icosahedron mesh
  52193. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52194. */
  52195. static CreateIcoSphere(name: string, options: {
  52196. radius?: number;
  52197. radiusX?: number;
  52198. radiusY?: number;
  52199. radiusZ?: number;
  52200. flat?: boolean;
  52201. subdivisions?: number;
  52202. sideOrientation?: number;
  52203. frontUVs?: Vector4;
  52204. backUVs?: Vector4;
  52205. updatable?: boolean;
  52206. }, scene?: Nullable<Scene>): Mesh;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /**
  52211. * Class containing static functions to help procedurally build meshes
  52212. */
  52213. export class DecalBuilder {
  52214. /**
  52215. * Creates a decal mesh.
  52216. * 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
  52217. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52218. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52219. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52220. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52221. * @param name defines the name of the mesh
  52222. * @param sourceMesh defines the mesh where the decal must be applied
  52223. * @param options defines the options used to create the mesh
  52224. * @param scene defines the hosting scene
  52225. * @returns the decal mesh
  52226. * @see https://doc.babylonjs.com/how_to/decals
  52227. */
  52228. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52229. position?: Vector3;
  52230. normal?: Vector3;
  52231. size?: Vector3;
  52232. angle?: number;
  52233. }): Mesh;
  52234. }
  52235. }
  52236. declare module BABYLON {
  52237. /**
  52238. * Class containing static functions to help procedurally build meshes
  52239. */
  52240. export class MeshBuilder {
  52241. /**
  52242. * Creates a box mesh
  52243. * * The parameter `size` sets the size (float) of each box side (default 1)
  52244. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52245. * * 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)
  52246. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52248. * * 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
  52249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52250. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52251. * @param name defines the name of the mesh
  52252. * @param options defines the options used to create the mesh
  52253. * @param scene defines the hosting scene
  52254. * @returns the box mesh
  52255. */
  52256. static CreateBox(name: string, options: {
  52257. size?: number;
  52258. width?: number;
  52259. height?: number;
  52260. depth?: number;
  52261. faceUV?: Vector4[];
  52262. faceColors?: Color4[];
  52263. sideOrientation?: number;
  52264. frontUVs?: Vector4;
  52265. backUVs?: Vector4;
  52266. updatable?: boolean;
  52267. }, scene?: Nullable<Scene>): Mesh;
  52268. /**
  52269. * Creates a tiled box mesh
  52270. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52272. * @param name defines the name of the mesh
  52273. * @param options defines the options used to create the mesh
  52274. * @param scene defines the hosting scene
  52275. * @returns the tiled box mesh
  52276. */
  52277. static CreateTiledBox(name: string, options: {
  52278. pattern?: number;
  52279. size?: number;
  52280. width?: number;
  52281. height?: number;
  52282. depth: number;
  52283. tileSize?: number;
  52284. tileWidth?: number;
  52285. tileHeight?: number;
  52286. faceUV?: Vector4[];
  52287. faceColors?: Color4[];
  52288. alignHorizontal?: number;
  52289. alignVertical?: number;
  52290. sideOrientation?: number;
  52291. updatable?: boolean;
  52292. }, scene?: Nullable<Scene>): Mesh;
  52293. /**
  52294. * Creates a sphere mesh
  52295. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52296. * * 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`)
  52297. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52298. * * 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
  52299. * * 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)
  52300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52301. * * 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
  52302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52303. * @param name defines the name of the mesh
  52304. * @param options defines the options used to create the mesh
  52305. * @param scene defines the hosting scene
  52306. * @returns the sphere mesh
  52307. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52308. */
  52309. static CreateSphere(name: string, options: {
  52310. segments?: number;
  52311. diameter?: number;
  52312. diameterX?: number;
  52313. diameterY?: number;
  52314. diameterZ?: number;
  52315. arc?: number;
  52316. slice?: number;
  52317. sideOrientation?: number;
  52318. frontUVs?: Vector4;
  52319. backUVs?: Vector4;
  52320. updatable?: boolean;
  52321. }, scene?: Nullable<Scene>): Mesh;
  52322. /**
  52323. * Creates a plane polygonal mesh. By default, this is a disc
  52324. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52325. * * 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
  52326. * * 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
  52327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52328. * * 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
  52329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52330. * @param name defines the name of the mesh
  52331. * @param options defines the options used to create the mesh
  52332. * @param scene defines the hosting scene
  52333. * @returns the plane polygonal mesh
  52334. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52335. */
  52336. static CreateDisc(name: string, options: {
  52337. radius?: number;
  52338. tessellation?: number;
  52339. arc?: number;
  52340. updatable?: boolean;
  52341. sideOrientation?: number;
  52342. frontUVs?: Vector4;
  52343. backUVs?: Vector4;
  52344. }, scene?: Nullable<Scene>): Mesh;
  52345. /**
  52346. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52347. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52348. * * 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`)
  52349. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52350. * * 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
  52351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52352. * * 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
  52353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52354. * @param name defines the name of the mesh
  52355. * @param options defines the options used to create the mesh
  52356. * @param scene defines the hosting scene
  52357. * @returns the icosahedron mesh
  52358. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52359. */
  52360. static CreateIcoSphere(name: string, options: {
  52361. radius?: number;
  52362. radiusX?: number;
  52363. radiusY?: number;
  52364. radiusZ?: number;
  52365. flat?: boolean;
  52366. subdivisions?: number;
  52367. sideOrientation?: number;
  52368. frontUVs?: Vector4;
  52369. backUVs?: Vector4;
  52370. updatable?: boolean;
  52371. }, scene?: Nullable<Scene>): Mesh;
  52372. /**
  52373. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52374. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52375. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52376. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52377. * * 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
  52378. * * 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
  52379. * * 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
  52380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52381. * * 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
  52382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52383. * * 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
  52384. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52385. * * 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
  52386. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52388. * @param name defines the name of the mesh
  52389. * @param options defines the options used to create the mesh
  52390. * @param scene defines the hosting scene
  52391. * @returns the ribbon mesh
  52392. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52393. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52394. */
  52395. static CreateRibbon(name: string, options: {
  52396. pathArray: Vector3[][];
  52397. closeArray?: boolean;
  52398. closePath?: boolean;
  52399. offset?: number;
  52400. updatable?: boolean;
  52401. sideOrientation?: number;
  52402. frontUVs?: Vector4;
  52403. backUVs?: Vector4;
  52404. instance?: Mesh;
  52405. invertUV?: boolean;
  52406. uvs?: Vector2[];
  52407. colors?: Color4[];
  52408. }, scene?: Nullable<Scene>): Mesh;
  52409. /**
  52410. * Creates a cylinder or a cone mesh
  52411. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52412. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52413. * * 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.
  52414. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52415. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52416. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52417. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52418. * * 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).
  52419. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52420. * * 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).
  52421. * * 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
  52422. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52423. * * 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
  52424. * * 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.
  52425. * * If `enclose` is false, a ring surface is one element.
  52426. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52427. * * 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
  52428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52429. * * 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
  52430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52431. * @param name defines the name of the mesh
  52432. * @param options defines the options used to create the mesh
  52433. * @param scene defines the hosting scene
  52434. * @returns the cylinder mesh
  52435. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52436. */
  52437. static CreateCylinder(name: string, options: {
  52438. height?: number;
  52439. diameterTop?: number;
  52440. diameterBottom?: number;
  52441. diameter?: number;
  52442. tessellation?: number;
  52443. subdivisions?: number;
  52444. arc?: number;
  52445. faceColors?: Color4[];
  52446. faceUV?: Vector4[];
  52447. updatable?: boolean;
  52448. hasRings?: boolean;
  52449. enclose?: boolean;
  52450. cap?: number;
  52451. sideOrientation?: number;
  52452. frontUVs?: Vector4;
  52453. backUVs?: Vector4;
  52454. }, scene?: Nullable<Scene>): Mesh;
  52455. /**
  52456. * Creates a torus mesh
  52457. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52458. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52459. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52461. * * 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
  52462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52463. * @param name defines the name of the mesh
  52464. * @param options defines the options used to create the mesh
  52465. * @param scene defines the hosting scene
  52466. * @returns the torus mesh
  52467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52468. */
  52469. static CreateTorus(name: string, options: {
  52470. diameter?: number;
  52471. thickness?: number;
  52472. tessellation?: number;
  52473. updatable?: boolean;
  52474. sideOrientation?: number;
  52475. frontUVs?: Vector4;
  52476. backUVs?: Vector4;
  52477. }, scene?: Nullable<Scene>): Mesh;
  52478. /**
  52479. * Creates a torus knot mesh
  52480. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52481. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52482. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52483. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52485. * * 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
  52486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52487. * @param name defines the name of the mesh
  52488. * @param options defines the options used to create the mesh
  52489. * @param scene defines the hosting scene
  52490. * @returns the torus knot mesh
  52491. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52492. */
  52493. static CreateTorusKnot(name: string, options: {
  52494. radius?: number;
  52495. tube?: number;
  52496. radialSegments?: number;
  52497. tubularSegments?: number;
  52498. p?: number;
  52499. q?: number;
  52500. updatable?: boolean;
  52501. sideOrientation?: number;
  52502. frontUVs?: Vector4;
  52503. backUVs?: Vector4;
  52504. }, scene?: Nullable<Scene>): Mesh;
  52505. /**
  52506. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52507. * * 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
  52508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52509. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52510. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52511. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52513. * * 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
  52514. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52517. * @param name defines the name of the new line system
  52518. * @param options defines the options used to create the line system
  52519. * @param scene defines the hosting scene
  52520. * @returns a new line system mesh
  52521. */
  52522. static CreateLineSystem(name: string, options: {
  52523. lines: Vector3[][];
  52524. updatable?: boolean;
  52525. instance?: Nullable<LinesMesh>;
  52526. colors?: Nullable<Color4[][]>;
  52527. useVertexAlpha?: boolean;
  52528. }, scene: Nullable<Scene>): LinesMesh;
  52529. /**
  52530. * Creates a line mesh
  52531. * 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
  52532. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52533. * * The parameter `points` is an array successive Vector3
  52534. * * 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
  52535. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52536. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52537. * * When updating an instance, remember that only point positions can change, not the number of points
  52538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52540. * @param name defines the name of the new line system
  52541. * @param options defines the options used to create the line system
  52542. * @param scene defines the hosting scene
  52543. * @returns a new line mesh
  52544. */
  52545. static CreateLines(name: string, options: {
  52546. points: Vector3[];
  52547. updatable?: boolean;
  52548. instance?: Nullable<LinesMesh>;
  52549. colors?: Color4[];
  52550. useVertexAlpha?: boolean;
  52551. }, scene?: Nullable<Scene>): LinesMesh;
  52552. /**
  52553. * Creates a dashed line mesh
  52554. * * 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
  52555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52556. * * The parameter `points` is an array successive Vector3
  52557. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52558. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52559. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52560. * * 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
  52561. * * When updating an instance, remember that only point positions can change, not the number of points
  52562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52563. * @param name defines the name of the mesh
  52564. * @param options defines the options used to create the mesh
  52565. * @param scene defines the hosting scene
  52566. * @returns the dashed line mesh
  52567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52568. */
  52569. static CreateDashedLines(name: string, options: {
  52570. points: Vector3[];
  52571. dashSize?: number;
  52572. gapSize?: number;
  52573. dashNb?: number;
  52574. updatable?: boolean;
  52575. instance?: LinesMesh;
  52576. }, scene?: Nullable<Scene>): LinesMesh;
  52577. /**
  52578. * 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.
  52579. * * 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.
  52580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52581. * * 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.
  52582. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52583. * * 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
  52584. * * 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
  52585. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52587. * * 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
  52588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52590. * @param name defines the name of the mesh
  52591. * @param options defines the options used to create the mesh
  52592. * @param scene defines the hosting scene
  52593. * @returns the extruded shape mesh
  52594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52596. */
  52597. static ExtrudeShape(name: string, options: {
  52598. shape: Vector3[];
  52599. path: Vector3[];
  52600. scale?: number;
  52601. rotation?: number;
  52602. cap?: number;
  52603. updatable?: boolean;
  52604. sideOrientation?: number;
  52605. frontUVs?: Vector4;
  52606. backUVs?: Vector4;
  52607. instance?: Mesh;
  52608. invertUV?: boolean;
  52609. }, scene?: Nullable<Scene>): Mesh;
  52610. /**
  52611. * Creates an custom extruded shape mesh.
  52612. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52613. * * 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.
  52614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52615. * * 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
  52616. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52617. * * 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
  52618. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52619. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52620. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52621. * * 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
  52622. * * 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
  52623. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52625. * * 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
  52626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52628. * @param name defines the name of the mesh
  52629. * @param options defines the options used to create the mesh
  52630. * @param scene defines the hosting scene
  52631. * @returns the custom extruded shape mesh
  52632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52633. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52635. */
  52636. static ExtrudeShapeCustom(name: string, options: {
  52637. shape: Vector3[];
  52638. path: Vector3[];
  52639. scaleFunction?: any;
  52640. rotationFunction?: any;
  52641. ribbonCloseArray?: boolean;
  52642. ribbonClosePath?: boolean;
  52643. cap?: number;
  52644. updatable?: boolean;
  52645. sideOrientation?: number;
  52646. frontUVs?: Vector4;
  52647. backUVs?: Vector4;
  52648. instance?: Mesh;
  52649. invertUV?: boolean;
  52650. }, scene?: Nullable<Scene>): Mesh;
  52651. /**
  52652. * Creates lathe mesh.
  52653. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52654. * * 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
  52655. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52656. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52657. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52658. * * 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
  52659. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52660. * * 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
  52661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52662. * * 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
  52663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52665. * @param name defines the name of the mesh
  52666. * @param options defines the options used to create the mesh
  52667. * @param scene defines the hosting scene
  52668. * @returns the lathe mesh
  52669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52670. */
  52671. static CreateLathe(name: string, options: {
  52672. shape: Vector3[];
  52673. radius?: number;
  52674. tessellation?: number;
  52675. clip?: number;
  52676. arc?: number;
  52677. closed?: boolean;
  52678. updatable?: boolean;
  52679. sideOrientation?: number;
  52680. frontUVs?: Vector4;
  52681. backUVs?: Vector4;
  52682. cap?: number;
  52683. invertUV?: boolean;
  52684. }, scene?: Nullable<Scene>): Mesh;
  52685. /**
  52686. * Creates a tiled plane mesh
  52687. * * You can set a limited pattern arrangement with the tiles
  52688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52689. * * 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
  52690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52691. * @param name defines the name of the mesh
  52692. * @param options defines the options used to create the mesh
  52693. * @param scene defines the hosting scene
  52694. * @returns the plane mesh
  52695. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52696. */
  52697. static CreateTiledPlane(name: string, options: {
  52698. pattern?: number;
  52699. tileSize?: number;
  52700. tileWidth?: number;
  52701. tileHeight?: number;
  52702. size?: number;
  52703. width?: number;
  52704. height?: number;
  52705. alignHorizontal?: number;
  52706. alignVertical?: number;
  52707. sideOrientation?: number;
  52708. frontUVs?: Vector4;
  52709. backUVs?: Vector4;
  52710. updatable?: boolean;
  52711. }, scene?: Nullable<Scene>): Mesh;
  52712. /**
  52713. * Creates a plane mesh
  52714. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52715. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52716. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52718. * * 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
  52719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52720. * @param name defines the name of the mesh
  52721. * @param options defines the options used to create the mesh
  52722. * @param scene defines the hosting scene
  52723. * @returns the plane mesh
  52724. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52725. */
  52726. static CreatePlane(name: string, options: {
  52727. size?: number;
  52728. width?: number;
  52729. height?: number;
  52730. sideOrientation?: number;
  52731. frontUVs?: Vector4;
  52732. backUVs?: Vector4;
  52733. updatable?: boolean;
  52734. sourcePlane?: Plane;
  52735. }, scene?: Nullable<Scene>): Mesh;
  52736. /**
  52737. * Creates a ground mesh
  52738. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52739. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52741. * @param name defines the name of the mesh
  52742. * @param options defines the options used to create the mesh
  52743. * @param scene defines the hosting scene
  52744. * @returns the ground mesh
  52745. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52746. */
  52747. static CreateGround(name: string, options: {
  52748. width?: number;
  52749. height?: number;
  52750. subdivisions?: number;
  52751. subdivisionsX?: number;
  52752. subdivisionsY?: number;
  52753. updatable?: boolean;
  52754. }, scene?: Nullable<Scene>): Mesh;
  52755. /**
  52756. * Creates a tiled ground mesh
  52757. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52758. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52759. * * 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
  52760. * * 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
  52761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52762. * @param name defines the name of the mesh
  52763. * @param options defines the options used to create the mesh
  52764. * @param scene defines the hosting scene
  52765. * @returns the tiled ground mesh
  52766. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52767. */
  52768. static CreateTiledGround(name: string, options: {
  52769. xmin: number;
  52770. zmin: number;
  52771. xmax: number;
  52772. zmax: number;
  52773. subdivisions?: {
  52774. w: number;
  52775. h: number;
  52776. };
  52777. precision?: {
  52778. w: number;
  52779. h: number;
  52780. };
  52781. updatable?: boolean;
  52782. }, scene?: Nullable<Scene>): Mesh;
  52783. /**
  52784. * Creates a ground mesh from a height map
  52785. * * The parameter `url` sets the URL of the height map image resource.
  52786. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52787. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52788. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52789. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52790. * * 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.
  52791. * * 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).
  52792. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52794. * @param name defines the name of the mesh
  52795. * @param url defines the url to the height map
  52796. * @param options defines the options used to create the mesh
  52797. * @param scene defines the hosting scene
  52798. * @returns the ground mesh
  52799. * @see https://doc.babylonjs.com/babylon101/height_map
  52800. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52801. */
  52802. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52803. width?: number;
  52804. height?: number;
  52805. subdivisions?: number;
  52806. minHeight?: number;
  52807. maxHeight?: number;
  52808. colorFilter?: Color3;
  52809. alphaFilter?: number;
  52810. updatable?: boolean;
  52811. onReady?: (mesh: GroundMesh) => void;
  52812. }, scene?: Nullable<Scene>): GroundMesh;
  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. * Creates a tube mesh.
  52861. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52862. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52863. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52864. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52865. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52866. * * 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)
  52867. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52868. * * 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
  52869. * * 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
  52870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52871. * * 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
  52872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52874. * @param name defines the name of the mesh
  52875. * @param options defines the options used to create the mesh
  52876. * @param scene defines the hosting scene
  52877. * @returns the tube mesh
  52878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52879. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52880. */
  52881. static CreateTube(name: string, options: {
  52882. path: Vector3[];
  52883. radius?: number;
  52884. tessellation?: number;
  52885. radiusFunction?: {
  52886. (i: number, distance: number): number;
  52887. };
  52888. cap?: number;
  52889. arc?: number;
  52890. updatable?: boolean;
  52891. sideOrientation?: number;
  52892. frontUVs?: Vector4;
  52893. backUVs?: Vector4;
  52894. instance?: Mesh;
  52895. invertUV?: boolean;
  52896. }, scene?: Nullable<Scene>): Mesh;
  52897. /**
  52898. * Creates a polyhedron mesh
  52899. * * 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
  52900. * * The parameter `size` (positive float, default 1) sets the polygon size
  52901. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52902. * * 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`
  52903. * * 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
  52904. * * 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)`)
  52905. * * 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
  52906. * * 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
  52907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52908. * * 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
  52909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52910. * @param name defines the name of the mesh
  52911. * @param options defines the options used to create the mesh
  52912. * @param scene defines the hosting scene
  52913. * @returns the polyhedron mesh
  52914. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52915. */
  52916. static CreatePolyhedron(name: string, options: {
  52917. type?: number;
  52918. size?: number;
  52919. sizeX?: number;
  52920. sizeY?: number;
  52921. sizeZ?: number;
  52922. custom?: any;
  52923. faceUV?: Vector4[];
  52924. faceColors?: Color4[];
  52925. flat?: boolean;
  52926. updatable?: boolean;
  52927. sideOrientation?: number;
  52928. frontUVs?: Vector4;
  52929. backUVs?: Vector4;
  52930. }, scene?: Nullable<Scene>): Mesh;
  52931. /**
  52932. * Creates a decal mesh.
  52933. * 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
  52934. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52935. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52936. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52937. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52938. * @param name defines the name of the mesh
  52939. * @param sourceMesh defines the mesh where the decal must be applied
  52940. * @param options defines the options used to create the mesh
  52941. * @param scene defines the hosting scene
  52942. * @returns the decal mesh
  52943. * @see https://doc.babylonjs.com/how_to/decals
  52944. */
  52945. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52946. position?: Vector3;
  52947. normal?: Vector3;
  52948. size?: Vector3;
  52949. angle?: number;
  52950. }): Mesh;
  52951. }
  52952. }
  52953. declare module BABYLON {
  52954. /**
  52955. * A simplifier interface for future simplification implementations
  52956. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52957. */
  52958. export interface ISimplifier {
  52959. /**
  52960. * Simplification of a given mesh according to the given settings.
  52961. * Since this requires computation, it is assumed that the function runs async.
  52962. * @param settings The settings of the simplification, including quality and distance
  52963. * @param successCallback A callback that will be called after the mesh was simplified.
  52964. * @param errorCallback in case of an error, this callback will be called. optional.
  52965. */
  52966. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52967. }
  52968. /**
  52969. * Expected simplification settings.
  52970. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52972. */
  52973. export interface ISimplificationSettings {
  52974. /**
  52975. * Gets or sets the expected quality
  52976. */
  52977. quality: number;
  52978. /**
  52979. * Gets or sets the distance when this optimized version should be used
  52980. */
  52981. distance: number;
  52982. /**
  52983. * Gets an already optimized mesh
  52984. */
  52985. optimizeMesh?: boolean;
  52986. }
  52987. /**
  52988. * Class used to specify simplification options
  52989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52990. */
  52991. export class SimplificationSettings implements ISimplificationSettings {
  52992. /** expected quality */
  52993. quality: number;
  52994. /** distance when this optimized version should be used */
  52995. distance: number;
  52996. /** already optimized mesh */
  52997. optimizeMesh?: boolean | undefined;
  52998. /**
  52999. * Creates a SimplificationSettings
  53000. * @param quality expected quality
  53001. * @param distance distance when this optimized version should be used
  53002. * @param optimizeMesh already optimized mesh
  53003. */
  53004. constructor(
  53005. /** expected quality */
  53006. quality: number,
  53007. /** distance when this optimized version should be used */
  53008. distance: number,
  53009. /** already optimized mesh */
  53010. optimizeMesh?: boolean | undefined);
  53011. }
  53012. /**
  53013. * Interface used to define a simplification task
  53014. */
  53015. export interface ISimplificationTask {
  53016. /**
  53017. * Array of settings
  53018. */
  53019. settings: Array<ISimplificationSettings>;
  53020. /**
  53021. * Simplification type
  53022. */
  53023. simplificationType: SimplificationType;
  53024. /**
  53025. * Mesh to simplify
  53026. */
  53027. mesh: Mesh;
  53028. /**
  53029. * Callback called on success
  53030. */
  53031. successCallback?: () => void;
  53032. /**
  53033. * Defines if parallel processing can be used
  53034. */
  53035. parallelProcessing: boolean;
  53036. }
  53037. /**
  53038. * Queue used to order the simplification tasks
  53039. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53040. */
  53041. export class SimplificationQueue {
  53042. private _simplificationArray;
  53043. /**
  53044. * Gets a boolean indicating that the process is still running
  53045. */
  53046. running: boolean;
  53047. /**
  53048. * Creates a new queue
  53049. */
  53050. constructor();
  53051. /**
  53052. * Adds a new simplification task
  53053. * @param task defines a task to add
  53054. */
  53055. addTask(task: ISimplificationTask): void;
  53056. /**
  53057. * Execute next task
  53058. */
  53059. executeNext(): void;
  53060. /**
  53061. * Execute a simplification task
  53062. * @param task defines the task to run
  53063. */
  53064. runSimplification(task: ISimplificationTask): void;
  53065. private getSimplifier;
  53066. }
  53067. /**
  53068. * The implemented types of simplification
  53069. * At the moment only Quadratic Error Decimation is implemented
  53070. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53071. */
  53072. export enum SimplificationType {
  53073. /** Quadratic error decimation */
  53074. QUADRATIC = 0
  53075. }
  53076. }
  53077. declare module BABYLON {
  53078. interface Scene {
  53079. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  53080. /**
  53081. * Gets or sets the simplification queue attached to the scene
  53082. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53083. */
  53084. simplificationQueue: SimplificationQueue;
  53085. }
  53086. interface Mesh {
  53087. /**
  53088. * Simplify the mesh according to the given array of settings.
  53089. * Function will return immediately and will simplify async
  53090. * @param settings a collection of simplification settings
  53091. * @param parallelProcessing should all levels calculate parallel or one after the other
  53092. * @param simplificationType the type of simplification to run
  53093. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53094. * @returns the current mesh
  53095. */
  53096. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53097. }
  53098. /**
  53099. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53100. * created in a scene
  53101. */
  53102. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53103. /**
  53104. * The component name helpfull to identify the component in the list of scene components.
  53105. */
  53106. readonly name: string;
  53107. /**
  53108. * The scene the component belongs to.
  53109. */
  53110. scene: Scene;
  53111. /**
  53112. * Creates a new instance of the component for the given scene
  53113. * @param scene Defines the scene to register the component in
  53114. */
  53115. constructor(scene: Scene);
  53116. /**
  53117. * Registers the component in a given scene
  53118. */
  53119. register(): void;
  53120. /**
  53121. * Rebuilds the elements related to this component in case of
  53122. * context lost for instance.
  53123. */
  53124. rebuild(): void;
  53125. /**
  53126. * Disposes the component and the associated ressources
  53127. */
  53128. dispose(): void;
  53129. private _beforeCameraUpdate;
  53130. }
  53131. }
  53132. declare module BABYLON {
  53133. /**
  53134. * Class used to enable access to IndexedDB
  53135. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53136. */
  53137. export class Database implements IOfflineProvider {
  53138. private _callbackManifestChecked;
  53139. private _currentSceneUrl;
  53140. private _db;
  53141. private _enableSceneOffline;
  53142. private _enableTexturesOffline;
  53143. private _manifestVersionFound;
  53144. private _mustUpdateRessources;
  53145. private _hasReachedQuota;
  53146. private _isSupported;
  53147. private _idbFactory;
  53148. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53149. private static IsUASupportingBlobStorage;
  53150. /**
  53151. * Gets a boolean indicating if Database storate is enabled (off by default)
  53152. */
  53153. static IDBStorageEnabled: boolean;
  53154. /**
  53155. * Gets a boolean indicating if scene must be saved in the database
  53156. */
  53157. readonly enableSceneOffline: boolean;
  53158. /**
  53159. * Gets a boolean indicating if textures must be saved in the database
  53160. */
  53161. readonly enableTexturesOffline: boolean;
  53162. /**
  53163. * Creates a new Database
  53164. * @param urlToScene defines the url to load the scene
  53165. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53166. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53167. */
  53168. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53169. private static _ParseURL;
  53170. private static _ReturnFullUrlLocation;
  53171. private _checkManifestFile;
  53172. /**
  53173. * Open the database and make it available
  53174. * @param successCallback defines the callback to call on success
  53175. * @param errorCallback defines the callback to call on error
  53176. */
  53177. open(successCallback: () => void, errorCallback: () => void): void;
  53178. /**
  53179. * Loads an image from the database
  53180. * @param url defines the url to load from
  53181. * @param image defines the target DOM image
  53182. */
  53183. loadImage(url: string, image: HTMLImageElement): void;
  53184. private _loadImageFromDBAsync;
  53185. private _saveImageIntoDBAsync;
  53186. private _checkVersionFromDB;
  53187. private _loadVersionFromDBAsync;
  53188. private _saveVersionIntoDBAsync;
  53189. /**
  53190. * Loads a file from database
  53191. * @param url defines the URL to load from
  53192. * @param sceneLoaded defines a callback to call on success
  53193. * @param progressCallBack defines a callback to call when progress changed
  53194. * @param errorCallback defines a callback to call on error
  53195. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53196. */
  53197. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53198. private _loadFileAsync;
  53199. private _saveFileAsync;
  53200. /**
  53201. * Validates if xhr data is correct
  53202. * @param xhr defines the request to validate
  53203. * @param dataType defines the expected data type
  53204. * @returns true if data is correct
  53205. */
  53206. private static _ValidateXHRData;
  53207. }
  53208. }
  53209. declare module BABYLON {
  53210. /** @hidden */
  53211. export var gpuUpdateParticlesPixelShader: {
  53212. name: string;
  53213. shader: string;
  53214. };
  53215. }
  53216. declare module BABYLON {
  53217. /** @hidden */
  53218. export var gpuUpdateParticlesVertexShader: {
  53219. name: string;
  53220. shader: string;
  53221. };
  53222. }
  53223. declare module BABYLON {
  53224. /** @hidden */
  53225. export var clipPlaneFragmentDeclaration2: {
  53226. name: string;
  53227. shader: string;
  53228. };
  53229. }
  53230. declare module BABYLON {
  53231. /** @hidden */
  53232. export var gpuRenderParticlesPixelShader: {
  53233. name: string;
  53234. shader: string;
  53235. };
  53236. }
  53237. declare module BABYLON {
  53238. /** @hidden */
  53239. export var clipPlaneVertexDeclaration2: {
  53240. name: string;
  53241. shader: string;
  53242. };
  53243. }
  53244. declare module BABYLON {
  53245. /** @hidden */
  53246. export var gpuRenderParticlesVertexShader: {
  53247. name: string;
  53248. shader: string;
  53249. };
  53250. }
  53251. declare module BABYLON {
  53252. /**
  53253. * This represents a GPU particle system in Babylon
  53254. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53255. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53256. */
  53257. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53258. /**
  53259. * The layer mask we are rendering the particles through.
  53260. */
  53261. layerMask: number;
  53262. private _capacity;
  53263. private _activeCount;
  53264. private _currentActiveCount;
  53265. private _accumulatedCount;
  53266. private _renderEffect;
  53267. private _updateEffect;
  53268. private _buffer0;
  53269. private _buffer1;
  53270. private _spriteBuffer;
  53271. private _updateVAO;
  53272. private _renderVAO;
  53273. private _targetIndex;
  53274. private _sourceBuffer;
  53275. private _targetBuffer;
  53276. private _engine;
  53277. private _currentRenderId;
  53278. private _started;
  53279. private _stopped;
  53280. private _timeDelta;
  53281. private _randomTexture;
  53282. private _randomTexture2;
  53283. private _attributesStrideSize;
  53284. private _updateEffectOptions;
  53285. private _randomTextureSize;
  53286. private _actualFrame;
  53287. private readonly _rawTextureWidth;
  53288. /**
  53289. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53290. */
  53291. static readonly IsSupported: boolean;
  53292. /**
  53293. * An event triggered when the system is disposed.
  53294. */
  53295. onDisposeObservable: Observable<GPUParticleSystem>;
  53296. /**
  53297. * Gets the maximum number of particles active at the same time.
  53298. * @returns The max number of active particles.
  53299. */
  53300. getCapacity(): number;
  53301. /**
  53302. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53303. * to override the particles.
  53304. */
  53305. forceDepthWrite: boolean;
  53306. /**
  53307. * Gets or set the number of active particles
  53308. */
  53309. activeParticleCount: number;
  53310. private _preWarmDone;
  53311. /**
  53312. * Is this system ready to be used/rendered
  53313. * @return true if the system is ready
  53314. */
  53315. isReady(): boolean;
  53316. /**
  53317. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53318. * @returns True if it has been started, otherwise false.
  53319. */
  53320. isStarted(): boolean;
  53321. /**
  53322. * Starts the particle system and begins to emit
  53323. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53324. */
  53325. start(delay?: number): void;
  53326. /**
  53327. * Stops the particle system.
  53328. */
  53329. stop(): void;
  53330. /**
  53331. * Remove all active particles
  53332. */
  53333. reset(): void;
  53334. /**
  53335. * Returns the string "GPUParticleSystem"
  53336. * @returns a string containing the class name
  53337. */
  53338. getClassName(): string;
  53339. private _colorGradientsTexture;
  53340. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53341. /**
  53342. * Adds a new color gradient
  53343. * @param gradient defines the gradient to use (between 0 and 1)
  53344. * @param color1 defines the color to affect to the specified gradient
  53345. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53346. * @returns the current particle system
  53347. */
  53348. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53349. /**
  53350. * Remove a specific color gradient
  53351. * @param gradient defines the gradient to remove
  53352. * @returns the current particle system
  53353. */
  53354. removeColorGradient(gradient: number): GPUParticleSystem;
  53355. private _angularSpeedGradientsTexture;
  53356. private _sizeGradientsTexture;
  53357. private _velocityGradientsTexture;
  53358. private _limitVelocityGradientsTexture;
  53359. private _dragGradientsTexture;
  53360. private _addFactorGradient;
  53361. /**
  53362. * Adds a new size gradient
  53363. * @param gradient defines the gradient to use (between 0 and 1)
  53364. * @param factor defines the size factor to affect to the specified gradient
  53365. * @returns the current particle system
  53366. */
  53367. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53368. /**
  53369. * Remove a specific size gradient
  53370. * @param gradient defines the gradient to remove
  53371. * @returns the current particle system
  53372. */
  53373. removeSizeGradient(gradient: number): GPUParticleSystem;
  53374. /**
  53375. * Adds a new angular speed gradient
  53376. * @param gradient defines the gradient to use (between 0 and 1)
  53377. * @param factor defines the angular speed to affect to the specified gradient
  53378. * @returns the current particle system
  53379. */
  53380. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53381. /**
  53382. * Remove a specific angular speed gradient
  53383. * @param gradient defines the gradient to remove
  53384. * @returns the current particle system
  53385. */
  53386. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53387. /**
  53388. * Adds a new velocity gradient
  53389. * @param gradient defines the gradient to use (between 0 and 1)
  53390. * @param factor defines the velocity to affect to the specified gradient
  53391. * @returns the current particle system
  53392. */
  53393. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53394. /**
  53395. * Remove a specific velocity gradient
  53396. * @param gradient defines the gradient to remove
  53397. * @returns the current particle system
  53398. */
  53399. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53400. /**
  53401. * Adds a new limit velocity gradient
  53402. * @param gradient defines the gradient to use (between 0 and 1)
  53403. * @param factor defines the limit velocity value to affect to the specified gradient
  53404. * @returns the current particle system
  53405. */
  53406. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53407. /**
  53408. * Remove a specific limit velocity gradient
  53409. * @param gradient defines the gradient to remove
  53410. * @returns the current particle system
  53411. */
  53412. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53413. /**
  53414. * Adds a new drag gradient
  53415. * @param gradient defines the gradient to use (between 0 and 1)
  53416. * @param factor defines the drag value to affect to the specified gradient
  53417. * @returns the current particle system
  53418. */
  53419. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53420. /**
  53421. * Remove a specific drag gradient
  53422. * @param gradient defines the gradient to remove
  53423. * @returns the current particle system
  53424. */
  53425. removeDragGradient(gradient: number): GPUParticleSystem;
  53426. /**
  53427. * Not supported by GPUParticleSystem
  53428. * @param gradient defines the gradient to use (between 0 and 1)
  53429. * @param factor defines the emit rate value to affect to the specified gradient
  53430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53431. * @returns the current particle system
  53432. */
  53433. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53434. /**
  53435. * Not supported by GPUParticleSystem
  53436. * @param gradient defines the gradient to remove
  53437. * @returns the current particle system
  53438. */
  53439. removeEmitRateGradient(gradient: number): IParticleSystem;
  53440. /**
  53441. * Not supported by GPUParticleSystem
  53442. * @param gradient defines the gradient to use (between 0 and 1)
  53443. * @param factor defines the start size value to affect to the specified gradient
  53444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53445. * @returns the current particle system
  53446. */
  53447. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53448. /**
  53449. * Not supported by GPUParticleSystem
  53450. * @param gradient defines the gradient to remove
  53451. * @returns the current particle system
  53452. */
  53453. removeStartSizeGradient(gradient: number): IParticleSystem;
  53454. /**
  53455. * Not supported by GPUParticleSystem
  53456. * @param gradient defines the gradient to use (between 0 and 1)
  53457. * @param min defines the color remap minimal range
  53458. * @param max defines the color remap maximal range
  53459. * @returns the current particle system
  53460. */
  53461. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53462. /**
  53463. * Not supported by GPUParticleSystem
  53464. * @param gradient defines the gradient to remove
  53465. * @returns the current particle system
  53466. */
  53467. removeColorRemapGradient(): IParticleSystem;
  53468. /**
  53469. * Not supported by GPUParticleSystem
  53470. * @param gradient defines the gradient to use (between 0 and 1)
  53471. * @param min defines the alpha remap minimal range
  53472. * @param max defines the alpha remap maximal range
  53473. * @returns the current particle system
  53474. */
  53475. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53476. /**
  53477. * Not supported by GPUParticleSystem
  53478. * @param gradient defines the gradient to remove
  53479. * @returns the current particle system
  53480. */
  53481. removeAlphaRemapGradient(): IParticleSystem;
  53482. /**
  53483. * Not supported by GPUParticleSystem
  53484. * @param gradient defines the gradient to use (between 0 and 1)
  53485. * @param color defines the color to affect to the specified gradient
  53486. * @returns the current particle system
  53487. */
  53488. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53489. /**
  53490. * Not supported by GPUParticleSystem
  53491. * @param gradient defines the gradient to remove
  53492. * @returns the current particle system
  53493. */
  53494. removeRampGradient(): IParticleSystem;
  53495. /**
  53496. * Not supported by GPUParticleSystem
  53497. * @returns the list of ramp gradients
  53498. */
  53499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53500. /**
  53501. * Not supported by GPUParticleSystem
  53502. * Gets or sets a boolean indicating that ramp gradients must be used
  53503. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53504. */
  53505. useRampGradients: boolean;
  53506. /**
  53507. * Not supported by GPUParticleSystem
  53508. * @param gradient defines the gradient to use (between 0 and 1)
  53509. * @param factor defines the life time factor to affect to the specified gradient
  53510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53511. * @returns the current particle system
  53512. */
  53513. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53514. /**
  53515. * Not supported by GPUParticleSystem
  53516. * @param gradient defines the gradient to remove
  53517. * @returns the current particle system
  53518. */
  53519. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53520. /**
  53521. * Instantiates a GPU particle system.
  53522. * 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.
  53523. * @param name The name of the particle system
  53524. * @param options The options used to create the system
  53525. * @param scene The scene the particle system belongs to
  53526. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53527. */
  53528. constructor(name: string, options: Partial<{
  53529. capacity: number;
  53530. randomTextureSize: number;
  53531. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53532. protected _reset(): void;
  53533. private _createUpdateVAO;
  53534. private _createRenderVAO;
  53535. private _initialize;
  53536. /** @hidden */ private _recreateUpdateEffect(): void;
  53537. /** @hidden */ private _recreateRenderEffect(): void;
  53538. /**
  53539. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53540. * @param preWarm defines if we are in the pre-warmimg phase
  53541. */
  53542. animate(preWarm?: boolean): void;
  53543. private _createFactorGradientTexture;
  53544. private _createSizeGradientTexture;
  53545. private _createAngularSpeedGradientTexture;
  53546. private _createVelocityGradientTexture;
  53547. private _createLimitVelocityGradientTexture;
  53548. private _createDragGradientTexture;
  53549. private _createColorGradientTexture;
  53550. /**
  53551. * Renders the particle system in its current state
  53552. * @param preWarm defines if the system should only update the particles but not render them
  53553. * @returns the current number of particles
  53554. */
  53555. render(preWarm?: boolean): number;
  53556. /**
  53557. * Rebuilds the particle system
  53558. */
  53559. rebuild(): void;
  53560. private _releaseBuffers;
  53561. private _releaseVAOs;
  53562. /**
  53563. * Disposes the particle system and free the associated resources
  53564. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53565. */
  53566. dispose(disposeTexture?: boolean): void;
  53567. /**
  53568. * Clones the particle system.
  53569. * @param name The name of the cloned object
  53570. * @param newEmitter The new emitter to use
  53571. * @returns the cloned particle system
  53572. */
  53573. clone(name: string, newEmitter: any): GPUParticleSystem;
  53574. /**
  53575. * Serializes the particle system to a JSON object.
  53576. * @returns the JSON object
  53577. */
  53578. serialize(): any;
  53579. /**
  53580. * Parses a JSON object to create a GPU particle system.
  53581. * @param parsedParticleSystem The JSON object to parse
  53582. * @param scene The scene to create the particle system in
  53583. * @param rootUrl The root url to use to load external dependencies like texture
  53584. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53585. * @returns the parsed GPU particle system
  53586. */
  53587. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53588. }
  53589. }
  53590. declare module BABYLON {
  53591. /**
  53592. * Represents a set of particle systems working together to create a specific effect
  53593. */
  53594. export class ParticleSystemSet implements IDisposable {
  53595. private _emitterCreationOptions;
  53596. private _emitterNode;
  53597. /**
  53598. * Gets the particle system list
  53599. */
  53600. systems: IParticleSystem[];
  53601. /**
  53602. * Gets the emitter node used with this set
  53603. */
  53604. readonly emitterNode: Nullable<TransformNode>;
  53605. /**
  53606. * Creates a new emitter mesh as a sphere
  53607. * @param options defines the options used to create the sphere
  53608. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53609. * @param scene defines the hosting scene
  53610. */
  53611. setEmitterAsSphere(options: {
  53612. diameter: number;
  53613. segments: number;
  53614. color: Color3;
  53615. }, renderingGroupId: number, scene: Scene): void;
  53616. /**
  53617. * Starts all particle systems of the set
  53618. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53619. */
  53620. start(emitter?: AbstractMesh): void;
  53621. /**
  53622. * Release all associated resources
  53623. */
  53624. dispose(): void;
  53625. /**
  53626. * Serialize the set into a JSON compatible object
  53627. * @returns a JSON compatible representation of the set
  53628. */
  53629. serialize(): any;
  53630. /**
  53631. * Parse a new ParticleSystemSet from a serialized source
  53632. * @param data defines a JSON compatible representation of the set
  53633. * @param scene defines the hosting scene
  53634. * @param gpu defines if we want GPU particles or CPU particles
  53635. * @returns a new ParticleSystemSet
  53636. */
  53637. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53638. }
  53639. }
  53640. declare module BABYLON {
  53641. /**
  53642. * This class is made for on one-liner static method to help creating particle system set.
  53643. */
  53644. export class ParticleHelper {
  53645. /**
  53646. * Gets or sets base Assets URL
  53647. */
  53648. static BaseAssetsUrl: string;
  53649. /**
  53650. * Create a default particle system that you can tweak
  53651. * @param emitter defines the emitter to use
  53652. * @param capacity defines the system capacity (default is 500 particles)
  53653. * @param scene defines the hosting scene
  53654. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53655. * @returns the new Particle system
  53656. */
  53657. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53658. /**
  53659. * This is the main static method (one-liner) of this helper to create different particle systems
  53660. * @param type This string represents the type to the particle system to create
  53661. * @param scene The scene where the particle system should live
  53662. * @param gpu If the system will use gpu
  53663. * @returns the ParticleSystemSet created
  53664. */
  53665. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53666. /**
  53667. * Static function used to export a particle system to a ParticleSystemSet variable.
  53668. * Please note that the emitter shape is not exported
  53669. * @param systems defines the particle systems to export
  53670. * @returns the created particle system set
  53671. */
  53672. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53673. }
  53674. }
  53675. declare module BABYLON {
  53676. interface Engine {
  53677. /**
  53678. * Create an effect to use with particle systems.
  53679. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53680. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53681. * @param uniformsNames defines a list of attribute names
  53682. * @param samplers defines an array of string used to represent textures
  53683. * @param defines defines the string containing the defines to use to compile the shaders
  53684. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53685. * @param onCompiled defines a function to call when the effect creation is successful
  53686. * @param onError defines a function to call when the effect creation has failed
  53687. * @returns the new Effect
  53688. */
  53689. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53690. }
  53691. interface Mesh {
  53692. /**
  53693. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53694. * @returns an array of IParticleSystem
  53695. */
  53696. getEmittedParticleSystems(): IParticleSystem[];
  53697. /**
  53698. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53699. * @returns an array of IParticleSystem
  53700. */
  53701. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53702. }
  53703. /**
  53704. * @hidden
  53705. */
  53706. export var _IDoNeedToBeInTheBuild: number;
  53707. }
  53708. declare module BABYLON {
  53709. interface Scene {
  53710. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  53711. /**
  53712. * Gets the current physics engine
  53713. * @returns a IPhysicsEngine or null if none attached
  53714. */
  53715. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53716. /**
  53717. * Enables physics to the current scene
  53718. * @param gravity defines the scene's gravity for the physics engine
  53719. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53720. * @return a boolean indicating if the physics engine was initialized
  53721. */
  53722. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53723. /**
  53724. * Disables and disposes the physics engine associated with the scene
  53725. */
  53726. disablePhysicsEngine(): void;
  53727. /**
  53728. * Gets a boolean indicating if there is an active physics engine
  53729. * @returns a boolean indicating if there is an active physics engine
  53730. */
  53731. isPhysicsEnabled(): boolean;
  53732. /**
  53733. * Deletes a physics compound impostor
  53734. * @param compound defines the compound to delete
  53735. */
  53736. deleteCompoundImpostor(compound: any): void;
  53737. /**
  53738. * An event triggered when physic simulation is about to be run
  53739. */
  53740. onBeforePhysicsObservable: Observable<Scene>;
  53741. /**
  53742. * An event triggered when physic simulation has been done
  53743. */
  53744. onAfterPhysicsObservable: Observable<Scene>;
  53745. }
  53746. interface AbstractMesh {
  53747. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  53748. /**
  53749. * Gets or sets impostor used for physic simulation
  53750. * @see http://doc.babylonjs.com/features/physics_engine
  53751. */
  53752. physicsImpostor: Nullable<PhysicsImpostor>;
  53753. /**
  53754. * Gets the current physics impostor
  53755. * @see http://doc.babylonjs.com/features/physics_engine
  53756. * @returns a physics impostor or null
  53757. */
  53758. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53759. /** Apply a physic impulse to the mesh
  53760. * @param force defines the force to apply
  53761. * @param contactPoint defines where to apply the force
  53762. * @returns the current mesh
  53763. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53764. */
  53765. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53766. /**
  53767. * Creates a physic joint between two meshes
  53768. * @param otherMesh defines the other mesh to use
  53769. * @param pivot1 defines the pivot to use on this mesh
  53770. * @param pivot2 defines the pivot to use on the other mesh
  53771. * @param options defines additional options (can be plugin dependent)
  53772. * @returns the current mesh
  53773. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53774. */
  53775. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53776. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  53777. }
  53778. /**
  53779. * Defines the physics engine scene component responsible to manage a physics engine
  53780. */
  53781. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53782. /**
  53783. * The component name helpful to identify the component in the list of scene components.
  53784. */
  53785. readonly name: string;
  53786. /**
  53787. * The scene the component belongs to.
  53788. */
  53789. scene: Scene;
  53790. /**
  53791. * Creates a new instance of the component for the given scene
  53792. * @param scene Defines the scene to register the component in
  53793. */
  53794. constructor(scene: Scene);
  53795. /**
  53796. * Registers the component in a given scene
  53797. */
  53798. register(): void;
  53799. /**
  53800. * Rebuilds the elements related to this component in case of
  53801. * context lost for instance.
  53802. */
  53803. rebuild(): void;
  53804. /**
  53805. * Disposes the component and the associated ressources
  53806. */
  53807. dispose(): void;
  53808. }
  53809. }
  53810. declare module BABYLON {
  53811. /**
  53812. * A helper for physics simulations
  53813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53814. */
  53815. export class PhysicsHelper {
  53816. private _scene;
  53817. private _physicsEngine;
  53818. /**
  53819. * Initializes the Physics helper
  53820. * @param scene Babylon.js scene
  53821. */
  53822. constructor(scene: Scene);
  53823. /**
  53824. * Applies a radial explosion impulse
  53825. * @param origin the origin of the explosion
  53826. * @param radiusOrEventOptions the radius or the options of radial explosion
  53827. * @param strength the explosion strength
  53828. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53829. * @returns A physics radial explosion event, or null
  53830. */
  53831. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53832. /**
  53833. * Applies a radial explosion force
  53834. * @param origin the origin of the explosion
  53835. * @param radiusOrEventOptions the radius or the options of radial explosion
  53836. * @param strength the explosion strength
  53837. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53838. * @returns A physics radial explosion event, or null
  53839. */
  53840. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53841. /**
  53842. * Creates a gravitational field
  53843. * @param origin the origin of the explosion
  53844. * @param radiusOrEventOptions the radius or the options of radial explosion
  53845. * @param strength the explosion strength
  53846. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53847. * @returns A physics gravitational field event, or null
  53848. */
  53849. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53850. /**
  53851. * Creates a physics updraft event
  53852. * @param origin the origin of the updraft
  53853. * @param radiusOrEventOptions the radius or the options of the updraft
  53854. * @param strength the strength of the updraft
  53855. * @param height the height of the updraft
  53856. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53857. * @returns A physics updraft event, or null
  53858. */
  53859. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53860. /**
  53861. * Creates a physics vortex event
  53862. * @param origin the of the vortex
  53863. * @param radiusOrEventOptions the radius or the options of the vortex
  53864. * @param strength the strength of the vortex
  53865. * @param height the height of the vortex
  53866. * @returns a Physics vortex event, or null
  53867. * A physics vortex event or null
  53868. */
  53869. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53870. }
  53871. /**
  53872. * Represents a physics radial explosion event
  53873. */
  53874. class PhysicsRadialExplosionEvent {
  53875. private _scene;
  53876. private _options;
  53877. private _sphere;
  53878. private _dataFetched;
  53879. /**
  53880. * Initializes a radial explosioin event
  53881. * @param _scene BabylonJS scene
  53882. * @param _options The options for the vortex event
  53883. */
  53884. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53885. /**
  53886. * Returns the data related to the radial explosion event (sphere).
  53887. * @returns The radial explosion event data
  53888. */
  53889. getData(): PhysicsRadialExplosionEventData;
  53890. /**
  53891. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53892. * @param impostor A physics imposter
  53893. * @param origin the origin of the explosion
  53894. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53895. */
  53896. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53897. /**
  53898. * Triggers affecterd impostors callbacks
  53899. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53900. */
  53901. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53902. /**
  53903. * Disposes the sphere.
  53904. * @param force Specifies if the sphere should be disposed by force
  53905. */
  53906. dispose(force?: boolean): void;
  53907. /*** Helpers ***/
  53908. private _prepareSphere;
  53909. private _intersectsWithSphere;
  53910. }
  53911. /**
  53912. * Represents a gravitational field event
  53913. */
  53914. class PhysicsGravitationalFieldEvent {
  53915. private _physicsHelper;
  53916. private _scene;
  53917. private _origin;
  53918. private _options;
  53919. private _tickCallback;
  53920. private _sphere;
  53921. private _dataFetched;
  53922. /**
  53923. * Initializes the physics gravitational field event
  53924. * @param _physicsHelper A physics helper
  53925. * @param _scene BabylonJS scene
  53926. * @param _origin The origin position of the gravitational field event
  53927. * @param _options The options for the vortex event
  53928. */
  53929. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53930. /**
  53931. * Returns the data related to the gravitational field event (sphere).
  53932. * @returns A gravitational field event
  53933. */
  53934. getData(): PhysicsGravitationalFieldEventData;
  53935. /**
  53936. * Enables the gravitational field.
  53937. */
  53938. enable(): void;
  53939. /**
  53940. * Disables the gravitational field.
  53941. */
  53942. disable(): void;
  53943. /**
  53944. * Disposes the sphere.
  53945. * @param force The force to dispose from the gravitational field event
  53946. */
  53947. dispose(force?: boolean): void;
  53948. private _tick;
  53949. }
  53950. /**
  53951. * Represents a physics updraft event
  53952. */
  53953. class PhysicsUpdraftEvent {
  53954. private _scene;
  53955. private _origin;
  53956. private _options;
  53957. private _physicsEngine;
  53958. private _originTop;
  53959. private _originDirection;
  53960. private _tickCallback;
  53961. private _cylinder;
  53962. private _cylinderPosition;
  53963. private _dataFetched;
  53964. /**
  53965. * Initializes the physics updraft event
  53966. * @param _scene BabylonJS scene
  53967. * @param _origin The origin position of the updraft
  53968. * @param _options The options for the updraft event
  53969. */
  53970. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53971. /**
  53972. * Returns the data related to the updraft event (cylinder).
  53973. * @returns A physics updraft event
  53974. */
  53975. getData(): PhysicsUpdraftEventData;
  53976. /**
  53977. * Enables the updraft.
  53978. */
  53979. enable(): void;
  53980. /**
  53981. * Disables the updraft.
  53982. */
  53983. disable(): void;
  53984. /**
  53985. * Disposes the cylinder.
  53986. * @param force Specifies if the updraft should be disposed by force
  53987. */
  53988. dispose(force?: boolean): void;
  53989. private getImpostorHitData;
  53990. private _tick;
  53991. /*** Helpers ***/
  53992. private _prepareCylinder;
  53993. private _intersectsWithCylinder;
  53994. }
  53995. /**
  53996. * Represents a physics vortex event
  53997. */
  53998. class PhysicsVortexEvent {
  53999. private _scene;
  54000. private _origin;
  54001. private _options;
  54002. private _physicsEngine;
  54003. private _originTop;
  54004. private _tickCallback;
  54005. private _cylinder;
  54006. private _cylinderPosition;
  54007. private _dataFetched;
  54008. /**
  54009. * Initializes the physics vortex event
  54010. * @param _scene The BabylonJS scene
  54011. * @param _origin The origin position of the vortex
  54012. * @param _options The options for the vortex event
  54013. */
  54014. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54015. /**
  54016. * Returns the data related to the vortex event (cylinder).
  54017. * @returns The physics vortex event data
  54018. */
  54019. getData(): PhysicsVortexEventData;
  54020. /**
  54021. * Enables the vortex.
  54022. */
  54023. enable(): void;
  54024. /**
  54025. * Disables the cortex.
  54026. */
  54027. disable(): void;
  54028. /**
  54029. * Disposes the sphere.
  54030. * @param force
  54031. */
  54032. dispose(force?: boolean): void;
  54033. private getImpostorHitData;
  54034. private _tick;
  54035. /*** Helpers ***/
  54036. private _prepareCylinder;
  54037. private _intersectsWithCylinder;
  54038. }
  54039. /**
  54040. * Options fot the radial explosion event
  54041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54042. */
  54043. export class PhysicsRadialExplosionEventOptions {
  54044. /**
  54045. * The radius of the sphere for the radial explosion.
  54046. */
  54047. radius: number;
  54048. /**
  54049. * The strenth of the explosion.
  54050. */
  54051. strength: number;
  54052. /**
  54053. * The strenght of the force in correspondence to the distance of the affected object
  54054. */
  54055. falloff: PhysicsRadialImpulseFalloff;
  54056. /**
  54057. * Sphere options for the radial explosion.
  54058. */
  54059. sphere: {
  54060. segments: number;
  54061. diameter: number;
  54062. };
  54063. /**
  54064. * Sphere options for the radial explosion.
  54065. */
  54066. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54067. }
  54068. /**
  54069. * Options fot the updraft event
  54070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54071. */
  54072. export class PhysicsUpdraftEventOptions {
  54073. /**
  54074. * The radius of the cylinder for the vortex
  54075. */
  54076. radius: number;
  54077. /**
  54078. * The strenth of the updraft.
  54079. */
  54080. strength: number;
  54081. /**
  54082. * The height of the cylinder for the updraft.
  54083. */
  54084. height: number;
  54085. /**
  54086. * The mode for the the updraft.
  54087. */
  54088. updraftMode: PhysicsUpdraftMode;
  54089. }
  54090. /**
  54091. * Options fot the vortex event
  54092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54093. */
  54094. export class PhysicsVortexEventOptions {
  54095. /**
  54096. * The radius of the cylinder for the vortex
  54097. */
  54098. radius: number;
  54099. /**
  54100. * The strenth of the vortex.
  54101. */
  54102. strength: number;
  54103. /**
  54104. * The height of the cylinder for the vortex.
  54105. */
  54106. height: number;
  54107. /**
  54108. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54109. */
  54110. centripetalForceThreshold: number;
  54111. /**
  54112. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54113. */
  54114. centripetalForceMultiplier: number;
  54115. /**
  54116. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54117. */
  54118. centrifugalForceMultiplier: number;
  54119. /**
  54120. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54121. */
  54122. updraftForceMultiplier: number;
  54123. }
  54124. /**
  54125. * The strenght of the force in correspondence to the distance of the affected object
  54126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54127. */
  54128. export enum PhysicsRadialImpulseFalloff {
  54129. /** Defines that impulse is constant in strength across it's whole radius */
  54130. Constant = 0,
  54131. /** Defines that impulse gets weaker if it's further from the origin */
  54132. Linear = 1
  54133. }
  54134. /**
  54135. * The strength of the force in correspondence to the distance of the affected object
  54136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54137. */
  54138. export enum PhysicsUpdraftMode {
  54139. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54140. Center = 0,
  54141. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54142. Perpendicular = 1
  54143. }
  54144. /**
  54145. * Interface for a physics hit data
  54146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54147. */
  54148. export interface PhysicsHitData {
  54149. /**
  54150. * The force applied at the contact point
  54151. */
  54152. force: Vector3;
  54153. /**
  54154. * The contact point
  54155. */
  54156. contactPoint: Vector3;
  54157. /**
  54158. * The distance from the origin to the contact point
  54159. */
  54160. distanceFromOrigin: number;
  54161. }
  54162. /**
  54163. * Interface for radial explosion event data
  54164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54165. */
  54166. export interface PhysicsRadialExplosionEventData {
  54167. /**
  54168. * A sphere used for the radial explosion event
  54169. */
  54170. sphere: Mesh;
  54171. }
  54172. /**
  54173. * Interface for gravitational field event data
  54174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54175. */
  54176. export interface PhysicsGravitationalFieldEventData {
  54177. /**
  54178. * A sphere mesh used for the gravitational field event
  54179. */
  54180. sphere: Mesh;
  54181. }
  54182. /**
  54183. * Interface for updraft event data
  54184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54185. */
  54186. export interface PhysicsUpdraftEventData {
  54187. /**
  54188. * A cylinder used for the updraft event
  54189. */
  54190. cylinder: Mesh;
  54191. }
  54192. /**
  54193. * Interface for vortex event data
  54194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54195. */
  54196. export interface PhysicsVortexEventData {
  54197. /**
  54198. * A cylinder used for the vortex event
  54199. */
  54200. cylinder: Mesh;
  54201. }
  54202. /**
  54203. * Interface for an affected physics impostor
  54204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54205. */
  54206. export interface PhysicsAffectedImpostorWithData {
  54207. /**
  54208. * The impostor affected by the effect
  54209. */
  54210. impostor: PhysicsImpostor;
  54211. /**
  54212. * The data about the hit/horce from the explosion
  54213. */
  54214. hitData: PhysicsHitData;
  54215. }
  54216. }
  54217. declare module BABYLON {
  54218. /** @hidden */
  54219. export var blackAndWhitePixelShader: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module BABYLON {
  54225. /**
  54226. * Post process used to render in black and white
  54227. */
  54228. export class BlackAndWhitePostProcess extends PostProcess {
  54229. /**
  54230. * Linear about to convert he result to black and white (default: 1)
  54231. */
  54232. degree: number;
  54233. /**
  54234. * Creates a black and white post process
  54235. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54236. * @param name The name of the effect.
  54237. * @param options The required width/height ratio to downsize to before computing the render pass.
  54238. * @param camera The camera to apply the render pass to.
  54239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54240. * @param engine The engine which the post process will be applied. (default: current engine)
  54241. * @param reusable If the post process can be reused on the same frame. (default: false)
  54242. */
  54243. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54244. }
  54245. }
  54246. declare module BABYLON {
  54247. /**
  54248. * This represents a set of one or more post processes in Babylon.
  54249. * A post process can be used to apply a shader to a texture after it is rendered.
  54250. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54251. */
  54252. export class PostProcessRenderEffect {
  54253. private _postProcesses;
  54254. private _getPostProcesses;
  54255. private _singleInstance;
  54256. private _cameras;
  54257. private _indicesForCamera;
  54258. /**
  54259. * Name of the effect
  54260. * @hidden
  54261. */ private _name: string;
  54262. /**
  54263. * Instantiates a post process render effect.
  54264. * A post process can be used to apply a shader to a texture after it is rendered.
  54265. * @param engine The engine the effect is tied to
  54266. * @param name The name of the effect
  54267. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54268. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54269. */
  54270. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54271. /**
  54272. * Checks if all the post processes in the effect are supported.
  54273. */
  54274. readonly isSupported: boolean;
  54275. /**
  54276. * Updates the current state of the effect
  54277. * @hidden
  54278. */ private _update(): void;
  54279. /**
  54280. * Attaches the effect on cameras
  54281. * @param cameras The camera to attach to.
  54282. * @hidden
  54283. */ private _attachCameras(cameras: Camera): void;
  54284. /**
  54285. * Attaches the effect on cameras
  54286. * @param cameras The camera to attach to.
  54287. * @hidden
  54288. */ private _attachCameras(cameras: Camera[]): void;
  54289. /**
  54290. * Detaches the effect on cameras
  54291. * @param cameras The camera to detatch from.
  54292. * @hidden
  54293. */ private _detachCameras(cameras: Camera): void;
  54294. /**
  54295. * Detatches the effect on cameras
  54296. * @param cameras The camera to detatch from.
  54297. * @hidden
  54298. */ private _detachCameras(cameras: Camera[]): void;
  54299. /**
  54300. * Enables the effect on given cameras
  54301. * @param cameras The camera to enable.
  54302. * @hidden
  54303. */ private _enable(cameras: Camera): void;
  54304. /**
  54305. * Enables the effect on given cameras
  54306. * @param cameras The camera to enable.
  54307. * @hidden
  54308. */ private _enable(cameras: Nullable<Camera[]>): void;
  54309. /**
  54310. * Disables the effect on the given cameras
  54311. * @param cameras The camera to disable.
  54312. * @hidden
  54313. */ private _disable(cameras: Camera): void;
  54314. /**
  54315. * Disables the effect on the given cameras
  54316. * @param cameras The camera to disable.
  54317. * @hidden
  54318. */ private _disable(cameras: Nullable<Camera[]>): void;
  54319. /**
  54320. * Gets a list of the post processes contained in the effect.
  54321. * @param camera The camera to get the post processes on.
  54322. * @returns The list of the post processes in the effect.
  54323. */
  54324. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54325. }
  54326. }
  54327. declare module BABYLON {
  54328. /** @hidden */
  54329. export var extractHighlightsPixelShader: {
  54330. name: string;
  54331. shader: string;
  54332. };
  54333. }
  54334. declare module BABYLON {
  54335. /**
  54336. * 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.
  54337. */
  54338. export class ExtractHighlightsPostProcess extends PostProcess {
  54339. /**
  54340. * The luminance threshold, pixels below this value will be set to black.
  54341. */
  54342. threshold: number;
  54343. /** @hidden */ private _exposure: number;
  54344. /**
  54345. * Post process which has the input texture to be used when performing highlight extraction
  54346. * @hidden
  54347. */ private _inputPostProcess: Nullable<PostProcess>;
  54348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54349. }
  54350. }
  54351. declare module BABYLON {
  54352. /** @hidden */
  54353. export var bloomMergePixelShader: {
  54354. name: string;
  54355. shader: string;
  54356. };
  54357. }
  54358. declare module BABYLON {
  54359. /**
  54360. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54361. */
  54362. export class BloomMergePostProcess extends PostProcess {
  54363. /** Weight of the bloom to be added to the original input. */
  54364. weight: number;
  54365. /**
  54366. * Creates a new instance of @see BloomMergePostProcess
  54367. * @param name The name of the effect.
  54368. * @param originalFromInput Post process which's input will be used for the merge.
  54369. * @param blurred Blurred highlights post process which's output will be used.
  54370. * @param weight Weight of the bloom to be added to the original input.
  54371. * @param options The required width/height ratio to downsize to before computing the render pass.
  54372. * @param camera The camera to apply the render pass to.
  54373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54374. * @param engine The engine which the post process will be applied. (default: current engine)
  54375. * @param reusable If the post process can be reused on the same frame. (default: false)
  54376. * @param textureType Type of textures used when performing the post process. (default: 0)
  54377. * @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)
  54378. */
  54379. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54380. /** Weight of the bloom to be added to the original input. */
  54381. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54382. }
  54383. }
  54384. declare module BABYLON {
  54385. /**
  54386. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54387. */
  54388. export class BloomEffect extends PostProcessRenderEffect {
  54389. private bloomScale;
  54390. /**
  54391. * @hidden Internal
  54392. */ private _effects: Array<PostProcess>;
  54393. /**
  54394. * @hidden Internal
  54395. */ private _downscale: ExtractHighlightsPostProcess;
  54396. private _blurX;
  54397. private _blurY;
  54398. private _merge;
  54399. /**
  54400. * The luminance threshold to find bright areas of the image to bloom.
  54401. */
  54402. threshold: number;
  54403. /**
  54404. * The strength of the bloom.
  54405. */
  54406. weight: number;
  54407. /**
  54408. * Specifies the size of the bloom blur kernel, relative to the final output size
  54409. */
  54410. kernel: number;
  54411. /**
  54412. * Creates a new instance of @see BloomEffect
  54413. * @param scene The scene the effect belongs to.
  54414. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54415. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54416. * @param bloomWeight The the strength of bloom.
  54417. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54418. * @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)
  54419. */
  54420. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54421. /**
  54422. * Disposes each of the internal effects for a given camera.
  54423. * @param camera The camera to dispose the effect on.
  54424. */
  54425. disposeEffects(camera: Camera): void;
  54426. /**
  54427. * @hidden Internal
  54428. */ private _updateEffects(): void;
  54429. /**
  54430. * Internal
  54431. * @returns if all the contained post processes are ready.
  54432. * @hidden
  54433. */ private _isReady(): boolean;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /** @hidden */
  54438. export var chromaticAberrationPixelShader: {
  54439. name: string;
  54440. shader: string;
  54441. };
  54442. }
  54443. declare module BABYLON {
  54444. /**
  54445. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54446. */
  54447. export class ChromaticAberrationPostProcess extends PostProcess {
  54448. /**
  54449. * The amount of seperation of rgb channels (default: 30)
  54450. */
  54451. aberrationAmount: number;
  54452. /**
  54453. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54454. */
  54455. radialIntensity: number;
  54456. /**
  54457. * 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))
  54458. */
  54459. direction: Vector2;
  54460. /**
  54461. * 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))
  54462. */
  54463. centerPosition: Vector2;
  54464. /**
  54465. * Creates a new instance ChromaticAberrationPostProcess
  54466. * @param name The name of the effect.
  54467. * @param screenWidth The width of the screen to apply the effect on.
  54468. * @param screenHeight The height of the screen to apply the effect on.
  54469. * @param options The required width/height ratio to downsize to before computing the render pass.
  54470. * @param camera The camera to apply the render pass to.
  54471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54472. * @param engine The engine which the post process will be applied. (default: current engine)
  54473. * @param reusable If the post process can be reused on the same frame. (default: false)
  54474. * @param textureType Type of textures used when performing the post process. (default: 0)
  54475. * @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)
  54476. */
  54477. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54478. }
  54479. }
  54480. declare module BABYLON {
  54481. /** @hidden */
  54482. export var circleOfConfusionPixelShader: {
  54483. name: string;
  54484. shader: string;
  54485. };
  54486. }
  54487. declare module BABYLON {
  54488. /**
  54489. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54490. */
  54491. export class CircleOfConfusionPostProcess extends PostProcess {
  54492. /**
  54493. * 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.
  54494. */
  54495. lensSize: number;
  54496. /**
  54497. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54498. */
  54499. fStop: number;
  54500. /**
  54501. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54502. */
  54503. focusDistance: number;
  54504. /**
  54505. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54506. */
  54507. focalLength: number;
  54508. private _depthTexture;
  54509. /**
  54510. * Creates a new instance CircleOfConfusionPostProcess
  54511. * @param name The name of the effect.
  54512. * @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.
  54513. * @param options The required width/height ratio to downsize to before computing the render pass.
  54514. * @param camera The camera to apply the render pass to.
  54515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54516. * @param engine The engine which the post process will be applied. (default: current engine)
  54517. * @param reusable If the post process can be reused on the same frame. (default: false)
  54518. * @param textureType Type of textures used when performing the post process. (default: 0)
  54519. * @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)
  54520. */
  54521. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54522. /**
  54523. * 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.
  54524. */
  54525. depthTexture: RenderTargetTexture;
  54526. }
  54527. }
  54528. declare module BABYLON {
  54529. /** @hidden */
  54530. export var colorCorrectionPixelShader: {
  54531. name: string;
  54532. shader: string;
  54533. };
  54534. }
  54535. declare module BABYLON {
  54536. /**
  54537. *
  54538. * This post-process allows the modification of rendered colors by using
  54539. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54540. *
  54541. * The object needs to be provided an url to a texture containing the color
  54542. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54543. * Use an image editing software to tweak the LUT to match your needs.
  54544. *
  54545. * For an example of a color LUT, see here:
  54546. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54547. * For explanations on color grading, see here:
  54548. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54549. *
  54550. */
  54551. export class ColorCorrectionPostProcess extends PostProcess {
  54552. private _colorTableTexture;
  54553. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54554. }
  54555. }
  54556. declare module BABYLON {
  54557. /** @hidden */
  54558. export var convolutionPixelShader: {
  54559. name: string;
  54560. shader: string;
  54561. };
  54562. }
  54563. declare module BABYLON {
  54564. /**
  54565. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54566. * input texture to perform effects such as edge detection or sharpening
  54567. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54568. */
  54569. export class ConvolutionPostProcess extends PostProcess {
  54570. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54571. kernel: number[];
  54572. /**
  54573. * Creates a new instance ConvolutionPostProcess
  54574. * @param name The name of the effect.
  54575. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  54576. * @param options The required width/height ratio to downsize to before computing the render pass.
  54577. * @param camera The camera to apply the render pass to.
  54578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54579. * @param engine The engine which the post process will be applied. (default: current engine)
  54580. * @param reusable If the post process can be reused on the same frame. (default: false)
  54581. * @param textureType Type of textures used when performing the post process. (default: 0)
  54582. */
  54583. constructor(name: string,
  54584. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54585. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54586. /**
  54587. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54588. */
  54589. static EdgeDetect0Kernel: number[];
  54590. /**
  54591. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54592. */
  54593. static EdgeDetect1Kernel: number[];
  54594. /**
  54595. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54596. */
  54597. static EdgeDetect2Kernel: number[];
  54598. /**
  54599. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54600. */
  54601. static SharpenKernel: number[];
  54602. /**
  54603. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54604. */
  54605. static EmbossKernel: number[];
  54606. /**
  54607. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54608. */
  54609. static GaussianKernel: number[];
  54610. }
  54611. }
  54612. declare module BABYLON {
  54613. /**
  54614. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54615. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54616. * based on samples that have a large difference in distance than the center pixel.
  54617. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54618. */
  54619. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54620. direction: Vector2;
  54621. /**
  54622. * Creates a new instance CircleOfConfusionPostProcess
  54623. * @param name The name of the effect.
  54624. * @param scene The scene the effect belongs to.
  54625. * @param direction The direction the blur should be applied.
  54626. * @param kernel The size of the kernel used to blur.
  54627. * @param options The required width/height ratio to downsize to before computing the render pass.
  54628. * @param camera The camera to apply the render pass to.
  54629. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54630. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54632. * @param engine The engine which the post process will be applied. (default: current engine)
  54633. * @param reusable If the post process can be reused on the same frame. (default: false)
  54634. * @param textureType Type of textures used when performing the post process. (default: 0)
  54635. * @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)
  54636. */
  54637. 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);
  54638. }
  54639. }
  54640. declare module BABYLON {
  54641. /** @hidden */
  54642. export var depthOfFieldMergePixelShader: {
  54643. name: string;
  54644. shader: string;
  54645. };
  54646. }
  54647. declare module BABYLON {
  54648. /**
  54649. * Options to be set when merging outputs from the default pipeline.
  54650. */
  54651. export class DepthOfFieldMergePostProcessOptions {
  54652. /**
  54653. * The original image to merge on top of
  54654. */
  54655. originalFromInput: PostProcess;
  54656. /**
  54657. * Parameters to perform the merge of the depth of field effect
  54658. */
  54659. depthOfField?: {
  54660. circleOfConfusion: PostProcess;
  54661. blurSteps: Array<PostProcess>;
  54662. };
  54663. /**
  54664. * Parameters to perform the merge of bloom effect
  54665. */
  54666. bloom?: {
  54667. blurred: PostProcess;
  54668. weight: number;
  54669. };
  54670. }
  54671. /**
  54672. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54673. */
  54674. export class DepthOfFieldMergePostProcess extends PostProcess {
  54675. private blurSteps;
  54676. /**
  54677. * Creates a new instance of DepthOfFieldMergePostProcess
  54678. * @param name The name of the effect.
  54679. * @param originalFromInput Post process which's input will be used for the merge.
  54680. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54681. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54682. * @param options The required width/height ratio to downsize to before computing the render pass.
  54683. * @param camera The camera to apply the render pass to.
  54684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54685. * @param engine The engine which the post process will be applied. (default: current engine)
  54686. * @param reusable If the post process can be reused on the same frame. (default: false)
  54687. * @param textureType Type of textures used when performing the post process. (default: 0)
  54688. * @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)
  54689. */
  54690. 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);
  54691. /**
  54692. * Updates the effect with the current post process compile time values and recompiles the shader.
  54693. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54694. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54695. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54696. * @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
  54697. * @param onCompiled Called when the shader has been compiled.
  54698. * @param onError Called if there is an error when compiling a shader.
  54699. */
  54700. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54701. }
  54702. }
  54703. declare module BABYLON {
  54704. /**
  54705. * Specifies the level of max blur that should be applied when using the depth of field effect
  54706. */
  54707. export enum DepthOfFieldEffectBlurLevel {
  54708. /**
  54709. * Subtle blur
  54710. */
  54711. Low = 0,
  54712. /**
  54713. * Medium blur
  54714. */
  54715. Medium = 1,
  54716. /**
  54717. * Large blur
  54718. */
  54719. High = 2
  54720. }
  54721. /**
  54722. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54723. */
  54724. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54725. private _circleOfConfusion;
  54726. /**
  54727. * @hidden Internal, blurs from high to low
  54728. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54729. private _depthOfFieldBlurY;
  54730. private _dofMerge;
  54731. /**
  54732. * @hidden Internal post processes in depth of field effect
  54733. */ private _effects: Array<PostProcess>;
  54734. /**
  54735. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54736. */
  54737. focalLength: number;
  54738. /**
  54739. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54740. */
  54741. fStop: number;
  54742. /**
  54743. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54744. */
  54745. focusDistance: number;
  54746. /**
  54747. * 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.
  54748. */
  54749. lensSize: number;
  54750. /**
  54751. * Creates a new instance DepthOfFieldEffect
  54752. * @param scene The scene the effect belongs to.
  54753. * @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.
  54754. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54755. * @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)
  54756. */
  54757. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54758. /**
  54759. * Get the current class name of the current effet
  54760. * @returns "DepthOfFieldEffect"
  54761. */
  54762. getClassName(): string;
  54763. /**
  54764. * 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.
  54765. */
  54766. depthTexture: RenderTargetTexture;
  54767. /**
  54768. * Disposes each of the internal effects for a given camera.
  54769. * @param camera The camera to dispose the effect on.
  54770. */
  54771. disposeEffects(camera: Camera): void;
  54772. /**
  54773. * @hidden Internal
  54774. */ private _updateEffects(): void;
  54775. /**
  54776. * Internal
  54777. * @returns if all the contained post processes are ready.
  54778. * @hidden
  54779. */ private _isReady(): boolean;
  54780. }
  54781. }
  54782. declare module BABYLON {
  54783. /** @hidden */
  54784. export var displayPassPixelShader: {
  54785. name: string;
  54786. shader: string;
  54787. };
  54788. }
  54789. declare module BABYLON {
  54790. /**
  54791. * DisplayPassPostProcess which produces an output the same as it's input
  54792. */
  54793. export class DisplayPassPostProcess extends PostProcess {
  54794. /**
  54795. * Creates the DisplayPassPostProcess
  54796. * @param name The name of the effect.
  54797. * @param options The required width/height ratio to downsize to before computing the render pass.
  54798. * @param camera The camera to apply the render pass to.
  54799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54800. * @param engine The engine which the post process will be applied. (default: current engine)
  54801. * @param reusable If the post process can be reused on the same frame. (default: false)
  54802. */
  54803. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54804. }
  54805. }
  54806. declare module BABYLON {
  54807. /** @hidden */
  54808. export var filterPixelShader: {
  54809. name: string;
  54810. shader: string;
  54811. };
  54812. }
  54813. declare module BABYLON {
  54814. /**
  54815. * Applies a kernel filter to the image
  54816. */
  54817. export class FilterPostProcess extends PostProcess {
  54818. /** The matrix to be applied to the image */
  54819. kernelMatrix: Matrix;
  54820. /**
  54821. *
  54822. * @param name The name of the effect.
  54823. * @param kernelMatrix The matrix to be applied to the image
  54824. * @param options The required width/height ratio to downsize to before computing the render pass.
  54825. * @param camera The camera to apply the render pass to.
  54826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54827. * @param engine The engine which the post process will be applied. (default: current engine)
  54828. * @param reusable If the post process can be reused on the same frame. (default: false)
  54829. */
  54830. constructor(name: string,
  54831. /** The matrix to be applied to the image */
  54832. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54833. }
  54834. }
  54835. declare module BABYLON {
  54836. /** @hidden */
  54837. export var fxaaPixelShader: {
  54838. name: string;
  54839. shader: string;
  54840. };
  54841. }
  54842. declare module BABYLON {
  54843. /** @hidden */
  54844. export var fxaaVertexShader: {
  54845. name: string;
  54846. shader: string;
  54847. };
  54848. }
  54849. declare module BABYLON {
  54850. /**
  54851. * Fxaa post process
  54852. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54853. */
  54854. export class FxaaPostProcess extends PostProcess {
  54855. /** @hidden */
  54856. texelWidth: number;
  54857. /** @hidden */
  54858. texelHeight: number;
  54859. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54860. private _getDefines;
  54861. }
  54862. }
  54863. declare module BABYLON {
  54864. /** @hidden */
  54865. export var grainPixelShader: {
  54866. name: string;
  54867. shader: string;
  54868. };
  54869. }
  54870. declare module BABYLON {
  54871. /**
  54872. * The GrainPostProcess adds noise to the image at mid luminance levels
  54873. */
  54874. export class GrainPostProcess extends PostProcess {
  54875. /**
  54876. * The intensity of the grain added (default: 30)
  54877. */
  54878. intensity: number;
  54879. /**
  54880. * If the grain should be randomized on every frame
  54881. */
  54882. animated: boolean;
  54883. /**
  54884. * Creates a new instance of @see GrainPostProcess
  54885. * @param name The name of the effect.
  54886. * @param options The required width/height ratio to downsize to before computing the render pass.
  54887. * @param camera The camera to apply the render pass to.
  54888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54889. * @param engine The engine which the post process will be applied. (default: current engine)
  54890. * @param reusable If the post process can be reused on the same frame. (default: false)
  54891. * @param textureType Type of textures used when performing the post process. (default: 0)
  54892. * @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)
  54893. */
  54894. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54895. }
  54896. }
  54897. declare module BABYLON {
  54898. /** @hidden */
  54899. export var highlightsPixelShader: {
  54900. name: string;
  54901. shader: string;
  54902. };
  54903. }
  54904. declare module BABYLON {
  54905. /**
  54906. * Extracts highlights from the image
  54907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54908. */
  54909. export class HighlightsPostProcess extends PostProcess {
  54910. /**
  54911. * Extracts highlights from the image
  54912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54913. * @param name The name of the effect.
  54914. * @param options The required width/height ratio to downsize to before computing the render pass.
  54915. * @param camera The camera to apply the render pass to.
  54916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54917. * @param engine The engine which the post process will be applied. (default: current engine)
  54918. * @param reusable If the post process can be reused on the same frame. (default: false)
  54919. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54920. */
  54921. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54922. }
  54923. }
  54924. declare module BABYLON {
  54925. /** @hidden */
  54926. export var mrtFragmentDeclaration: {
  54927. name: string;
  54928. shader: string;
  54929. };
  54930. }
  54931. declare module BABYLON {
  54932. /** @hidden */
  54933. export var geometryPixelShader: {
  54934. name: string;
  54935. shader: string;
  54936. };
  54937. }
  54938. declare module BABYLON {
  54939. /** @hidden */
  54940. export var geometryVertexShader: {
  54941. name: string;
  54942. shader: string;
  54943. };
  54944. }
  54945. declare module BABYLON {
  54946. /** @hidden */
  54947. interface ISavedTransformationMatrix {
  54948. world: Matrix;
  54949. viewProjection: Matrix;
  54950. }
  54951. /**
  54952. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54953. */
  54954. export class GeometryBufferRenderer {
  54955. /**
  54956. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54957. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54958. */
  54959. static readonly POSITION_TEXTURE_TYPE: number;
  54960. /**
  54961. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54962. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54963. */
  54964. static readonly VELOCITY_TEXTURE_TYPE: number;
  54965. /**
  54966. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54967. * in order to compute objects velocities when enableVelocity is set to "true"
  54968. * @hidden
  54969. */ private _previousTransformationMatrices: {
  54970. [index: number]: ISavedTransformationMatrix;
  54971. };
  54972. /**
  54973. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  54974. * in order to compute objects velocities when enableVelocity is set to "true"
  54975. * @hidden
  54976. */ private _previousBonesTransformationMatrices: {
  54977. [index: number]: Float32Array;
  54978. };
  54979. /**
  54980. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  54981. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  54982. */
  54983. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  54984. private _scene;
  54985. private _multiRenderTarget;
  54986. private _ratio;
  54987. private _enablePosition;
  54988. private _enableVelocity;
  54989. private _positionIndex;
  54990. private _velocityIndex;
  54991. protected _effect: Effect;
  54992. protected _cachedDefines: string;
  54993. /**
  54994. * Set the render list (meshes to be rendered) used in the G buffer.
  54995. */
  54996. renderList: Mesh[];
  54997. /**
  54998. * Gets wether or not G buffer are supported by the running hardware.
  54999. * This requires draw buffer supports
  55000. */
  55001. readonly isSupported: boolean;
  55002. /**
  55003. * Returns the index of the given texture type in the G-Buffer textures array
  55004. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55005. * @returns the index of the given texture type in the G-Buffer textures array
  55006. */
  55007. getTextureIndex(textureType: number): number;
  55008. /**
  55009. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55010. */
  55011. /**
  55012. * Sets whether or not objects positions are enabled for the G buffer.
  55013. */
  55014. enablePosition: boolean;
  55015. /**
  55016. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55017. */
  55018. /**
  55019. * Sets wether or not objects velocities are enabled for the G buffer.
  55020. */
  55021. enableVelocity: boolean;
  55022. /**
  55023. * Gets the scene associated with the buffer.
  55024. */
  55025. readonly scene: Scene;
  55026. /**
  55027. * Gets the ratio used by the buffer during its creation.
  55028. * How big is the buffer related to the main canvas.
  55029. */
  55030. readonly ratio: number;
  55031. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  55032. /**
  55033. * Creates a new G Buffer for the scene
  55034. * @param scene The scene the buffer belongs to
  55035. * @param ratio How big is the buffer related to the main canvas.
  55036. */
  55037. constructor(scene: Scene, ratio?: number);
  55038. /**
  55039. * Checks wether everything is ready to render a submesh to the G buffer.
  55040. * @param subMesh the submesh to check readiness for
  55041. * @param useInstances is the mesh drawn using instance or not
  55042. * @returns true if ready otherwise false
  55043. */
  55044. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55045. /**
  55046. * Gets the current underlying G Buffer.
  55047. * @returns the buffer
  55048. */
  55049. getGBuffer(): MultiRenderTarget;
  55050. /**
  55051. * Gets the number of samples used to render the buffer (anti aliasing).
  55052. */
  55053. /**
  55054. * Sets the number of samples used to render the buffer (anti aliasing).
  55055. */
  55056. samples: number;
  55057. /**
  55058. * Disposes the renderer and frees up associated resources.
  55059. */
  55060. dispose(): void;
  55061. protected _createRenderTargets(): void;
  55062. private _copyBonesTransformationMatrices;
  55063. }
  55064. }
  55065. declare module BABYLON {
  55066. interface Scene {
  55067. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55068. /**
  55069. * Gets or Sets the current geometry buffer associated to the scene.
  55070. */
  55071. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55072. /**
  55073. * Enables a GeometryBufferRender and associates it with the scene
  55074. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55075. * @returns the GeometryBufferRenderer
  55076. */
  55077. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55078. /**
  55079. * Disables the GeometryBufferRender associated with the scene
  55080. */
  55081. disableGeometryBufferRenderer(): void;
  55082. }
  55083. /**
  55084. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55085. * in several rendering techniques.
  55086. */
  55087. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55088. /**
  55089. * The component name helpful to identify the component in the list of scene components.
  55090. */
  55091. readonly name: string;
  55092. /**
  55093. * The scene the component belongs to.
  55094. */
  55095. scene: Scene;
  55096. /**
  55097. * Creates a new instance of the component for the given scene
  55098. * @param scene Defines the scene to register the component in
  55099. */
  55100. constructor(scene: Scene);
  55101. /**
  55102. * Registers the component in a given scene
  55103. */
  55104. register(): void;
  55105. /**
  55106. * Rebuilds the elements related to this component in case of
  55107. * context lost for instance.
  55108. */
  55109. rebuild(): void;
  55110. /**
  55111. * Disposes the component and the associated ressources
  55112. */
  55113. dispose(): void;
  55114. private _gatherRenderTargets;
  55115. }
  55116. }
  55117. declare module BABYLON {
  55118. /** @hidden */
  55119. export var motionBlurPixelShader: {
  55120. name: string;
  55121. shader: string;
  55122. };
  55123. }
  55124. declare module BABYLON {
  55125. /**
  55126. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55127. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55128. * As an example, all you have to do is to create the post-process:
  55129. * var mb = new BABYLON.MotionBlurPostProcess(
  55130. * 'mb', // The name of the effect.
  55131. * scene, // The scene containing the objects to blur according to their velocity.
  55132. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55133. * camera // The camera to apply the render pass to.
  55134. * );
  55135. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55136. */
  55137. export class MotionBlurPostProcess extends PostProcess {
  55138. /**
  55139. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55140. */
  55141. motionStrength: number;
  55142. /**
  55143. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55144. */
  55145. /**
  55146. * Sets the number of iterations to be used for motion blur quality
  55147. */
  55148. motionBlurSamples: number;
  55149. private _motionBlurSamples;
  55150. private _geometryBufferRenderer;
  55151. /**
  55152. * Creates a new instance MotionBlurPostProcess
  55153. * @param name The name of the effect.
  55154. * @param scene The scene containing the objects to blur according to their velocity.
  55155. * @param options The required width/height ratio to downsize to before computing the render pass.
  55156. * @param camera The camera to apply the render pass to.
  55157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55158. * @param engine The engine which the post process will be applied. (default: current engine)
  55159. * @param reusable If the post process can be reused on the same frame. (default: false)
  55160. * @param textureType Type of textures used when performing the post process. (default: 0)
  55161. * @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)
  55162. */
  55163. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55164. /**
  55165. * Excludes the given skinned mesh from computing bones velocities.
  55166. * 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.
  55167. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55168. */
  55169. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55170. /**
  55171. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55172. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55173. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55174. */
  55175. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55176. /**
  55177. * Disposes the post process.
  55178. * @param camera The camera to dispose the post process on.
  55179. */
  55180. dispose(camera?: Camera): void;
  55181. }
  55182. }
  55183. declare module BABYLON {
  55184. /** @hidden */
  55185. export var refractionPixelShader: {
  55186. name: string;
  55187. shader: string;
  55188. };
  55189. }
  55190. declare module BABYLON {
  55191. /**
  55192. * Post process which applies a refractin texture
  55193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55194. */
  55195. export class RefractionPostProcess extends PostProcess {
  55196. /** the base color of the refraction (used to taint the rendering) */
  55197. color: Color3;
  55198. /** simulated refraction depth */
  55199. depth: number;
  55200. /** the coefficient of the base color (0 to remove base color tainting) */
  55201. colorLevel: number;
  55202. private _refTexture;
  55203. private _ownRefractionTexture;
  55204. /**
  55205. * Gets or sets the refraction texture
  55206. * Please note that you are responsible for disposing the texture if you set it manually
  55207. */
  55208. refractionTexture: Texture;
  55209. /**
  55210. * Initializes the RefractionPostProcess
  55211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55212. * @param name The name of the effect.
  55213. * @param refractionTextureUrl Url of the refraction texture to use
  55214. * @param color the base color of the refraction (used to taint the rendering)
  55215. * @param depth simulated refraction depth
  55216. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55217. * @param camera The camera to apply the render pass to.
  55218. * @param options The required width/height ratio to downsize to before computing the render pass.
  55219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55220. * @param engine The engine which the post process will be applied. (default: current engine)
  55221. * @param reusable If the post process can be reused on the same frame. (default: false)
  55222. */
  55223. constructor(name: string, refractionTextureUrl: string,
  55224. /** the base color of the refraction (used to taint the rendering) */
  55225. color: Color3,
  55226. /** simulated refraction depth */
  55227. depth: number,
  55228. /** the coefficient of the base color (0 to remove base color tainting) */
  55229. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55230. /**
  55231. * Disposes of the post process
  55232. * @param camera Camera to dispose post process on
  55233. */
  55234. dispose(camera: Camera): void;
  55235. }
  55236. }
  55237. declare module BABYLON {
  55238. /** @hidden */
  55239. export var sharpenPixelShader: {
  55240. name: string;
  55241. shader: string;
  55242. };
  55243. }
  55244. declare module BABYLON {
  55245. /**
  55246. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55247. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55248. */
  55249. export class SharpenPostProcess extends PostProcess {
  55250. /**
  55251. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55252. */
  55253. colorAmount: number;
  55254. /**
  55255. * How much sharpness should be applied (default: 0.3)
  55256. */
  55257. edgeAmount: number;
  55258. /**
  55259. * Creates a new instance ConvolutionPostProcess
  55260. * @param name The name of the effect.
  55261. * @param options The required width/height ratio to downsize to before computing the render pass.
  55262. * @param camera The camera to apply the render pass to.
  55263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55264. * @param engine The engine which the post process will be applied. (default: current engine)
  55265. * @param reusable If the post process can be reused on the same frame. (default: false)
  55266. * @param textureType Type of textures used when performing the post process. (default: 0)
  55267. * @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)
  55268. */
  55269. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55270. }
  55271. }
  55272. declare module BABYLON {
  55273. /**
  55274. * PostProcessRenderPipeline
  55275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55276. */
  55277. export class PostProcessRenderPipeline {
  55278. private engine;
  55279. private _renderEffects;
  55280. private _renderEffectsForIsolatedPass;
  55281. /**
  55282. * List of inspectable custom properties (used by the Inspector)
  55283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55284. */
  55285. inspectableCustomProperties: IInspectable[];
  55286. /**
  55287. * @hidden
  55288. */
  55289. protected _cameras: Camera[];
  55290. /** @hidden */ private _name: string;
  55291. /**
  55292. * Gets pipeline name
  55293. */
  55294. readonly name: string;
  55295. /**
  55296. * Initializes a PostProcessRenderPipeline
  55297. * @param engine engine to add the pipeline to
  55298. * @param name name of the pipeline
  55299. */
  55300. constructor(engine: Engine, name: string);
  55301. /**
  55302. * Gets the class name
  55303. * @returns "PostProcessRenderPipeline"
  55304. */
  55305. getClassName(): string;
  55306. /**
  55307. * If all the render effects in the pipeline are supported
  55308. */
  55309. readonly isSupported: boolean;
  55310. /**
  55311. * Adds an effect to the pipeline
  55312. * @param renderEffect the effect to add
  55313. */
  55314. addEffect(renderEffect: PostProcessRenderEffect): void;
  55315. /** @hidden */ private _rebuild(): void;
  55316. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  55317. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55318. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55319. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55320. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  55321. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  55322. /** @hidden */ private _detachCameras(cameras: Camera): void;
  55323. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  55324. /** @hidden */ private _update(): void;
  55325. /** @hidden */ private _reset(): void;
  55326. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55327. /**
  55328. * Disposes of the pipeline
  55329. */
  55330. dispose(): void;
  55331. }
  55332. }
  55333. declare module BABYLON {
  55334. /**
  55335. * PostProcessRenderPipelineManager class
  55336. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55337. */
  55338. export class PostProcessRenderPipelineManager {
  55339. private _renderPipelines;
  55340. /**
  55341. * Initializes a PostProcessRenderPipelineManager
  55342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55343. */
  55344. constructor();
  55345. /**
  55346. * Gets the list of supported render pipelines
  55347. */
  55348. readonly supportedPipelines: PostProcessRenderPipeline[];
  55349. /**
  55350. * Adds a pipeline to the manager
  55351. * @param renderPipeline The pipeline to add
  55352. */
  55353. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55354. /**
  55355. * Attaches a camera to the pipeline
  55356. * @param renderPipelineName The name of the pipeline to attach to
  55357. * @param cameras the camera to attach
  55358. * @param unique if the camera can be attached multiple times to the pipeline
  55359. */
  55360. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55361. /**
  55362. * Detaches a camera from the pipeline
  55363. * @param renderPipelineName The name of the pipeline to detach from
  55364. * @param cameras the camera to detach
  55365. */
  55366. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55367. /**
  55368. * Enables an effect by name on a pipeline
  55369. * @param renderPipelineName the name of the pipeline to enable the effect in
  55370. * @param renderEffectName the name of the effect to enable
  55371. * @param cameras the cameras that the effect should be enabled on
  55372. */
  55373. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55374. /**
  55375. * Disables an effect by name on a pipeline
  55376. * @param renderPipelineName the name of the pipeline to disable the effect in
  55377. * @param renderEffectName the name of the effect to disable
  55378. * @param cameras the cameras that the effect should be disabled on
  55379. */
  55380. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55381. /**
  55382. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55383. */
  55384. update(): void;
  55385. /** @hidden */ private _rebuild(): void;
  55386. /**
  55387. * Disposes of the manager and pipelines
  55388. */
  55389. dispose(): void;
  55390. }
  55391. }
  55392. declare module BABYLON {
  55393. interface Scene {
  55394. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55395. /**
  55396. * Gets the postprocess render pipeline manager
  55397. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55398. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55399. */
  55400. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55401. }
  55402. /**
  55403. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55404. */
  55405. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55406. /**
  55407. * The component name helpfull to identify the component in the list of scene components.
  55408. */
  55409. readonly name: string;
  55410. /**
  55411. * The scene the component belongs to.
  55412. */
  55413. scene: Scene;
  55414. /**
  55415. * Creates a new instance of the component for the given scene
  55416. * @param scene Defines the scene to register the component in
  55417. */
  55418. constructor(scene: Scene);
  55419. /**
  55420. * Registers the component in a given scene
  55421. */
  55422. register(): void;
  55423. /**
  55424. * Rebuilds the elements related to this component in case of
  55425. * context lost for instance.
  55426. */
  55427. rebuild(): void;
  55428. /**
  55429. * Disposes the component and the associated ressources
  55430. */
  55431. dispose(): void;
  55432. private _gatherRenderTargets;
  55433. }
  55434. }
  55435. declare module BABYLON {
  55436. /**
  55437. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55438. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55439. */
  55440. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55441. private _scene;
  55442. private _camerasToBeAttached;
  55443. /**
  55444. * ID of the sharpen post process,
  55445. */
  55446. private readonly SharpenPostProcessId;
  55447. /**
  55448. * @ignore
  55449. * ID of the image processing post process;
  55450. */
  55451. readonly ImageProcessingPostProcessId: string;
  55452. /**
  55453. * @ignore
  55454. * ID of the Fast Approximate Anti-Aliasing post process;
  55455. */
  55456. readonly FxaaPostProcessId: string;
  55457. /**
  55458. * ID of the chromatic aberration post process,
  55459. */
  55460. private readonly ChromaticAberrationPostProcessId;
  55461. /**
  55462. * ID of the grain post process
  55463. */
  55464. private readonly GrainPostProcessId;
  55465. /**
  55466. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55467. */
  55468. sharpen: SharpenPostProcess;
  55469. private _sharpenEffect;
  55470. private bloom;
  55471. /**
  55472. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55473. */
  55474. depthOfField: DepthOfFieldEffect;
  55475. /**
  55476. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55477. */
  55478. fxaa: FxaaPostProcess;
  55479. /**
  55480. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55481. */
  55482. imageProcessing: ImageProcessingPostProcess;
  55483. /**
  55484. * Chromatic aberration post process which will shift rgb colors in the image
  55485. */
  55486. chromaticAberration: ChromaticAberrationPostProcess;
  55487. private _chromaticAberrationEffect;
  55488. /**
  55489. * Grain post process which add noise to the image
  55490. */
  55491. grain: GrainPostProcess;
  55492. private _grainEffect;
  55493. /**
  55494. * Glow post process which adds a glow to emissive areas of the image
  55495. */
  55496. private _glowLayer;
  55497. /**
  55498. * Animations which can be used to tweak settings over a period of time
  55499. */
  55500. animations: Animation[];
  55501. private _imageProcessingConfigurationObserver;
  55502. private _sharpenEnabled;
  55503. private _bloomEnabled;
  55504. private _depthOfFieldEnabled;
  55505. private _depthOfFieldBlurLevel;
  55506. private _fxaaEnabled;
  55507. private _imageProcessingEnabled;
  55508. private _defaultPipelineTextureType;
  55509. private _bloomScale;
  55510. private _chromaticAberrationEnabled;
  55511. private _grainEnabled;
  55512. private _buildAllowed;
  55513. /**
  55514. * Gets active scene
  55515. */
  55516. readonly scene: Scene;
  55517. /**
  55518. * Enable or disable the sharpen process from the pipeline
  55519. */
  55520. sharpenEnabled: boolean;
  55521. private _resizeObserver;
  55522. private _hardwareScaleLevel;
  55523. private _bloomKernel;
  55524. /**
  55525. * Specifies the size of the bloom blur kernel, relative to the final output size
  55526. */
  55527. bloomKernel: number;
  55528. /**
  55529. * Specifies the weight of the bloom in the final rendering
  55530. */
  55531. private _bloomWeight;
  55532. /**
  55533. * Specifies the luma threshold for the area that will be blurred by the bloom
  55534. */
  55535. private _bloomThreshold;
  55536. private _hdr;
  55537. /**
  55538. * The strength of the bloom.
  55539. */
  55540. bloomWeight: number;
  55541. /**
  55542. * The strength of the bloom.
  55543. */
  55544. bloomThreshold: number;
  55545. /**
  55546. * The scale of the bloom, lower value will provide better performance.
  55547. */
  55548. bloomScale: number;
  55549. /**
  55550. * Enable or disable the bloom from the pipeline
  55551. */
  55552. bloomEnabled: boolean;
  55553. private _rebuildBloom;
  55554. /**
  55555. * If the depth of field is enabled.
  55556. */
  55557. depthOfFieldEnabled: boolean;
  55558. /**
  55559. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55560. */
  55561. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55562. /**
  55563. * If the anti aliasing is enabled.
  55564. */
  55565. fxaaEnabled: boolean;
  55566. private _samples;
  55567. /**
  55568. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55569. */
  55570. samples: number;
  55571. /**
  55572. * If image processing is enabled.
  55573. */
  55574. imageProcessingEnabled: boolean;
  55575. /**
  55576. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55577. */
  55578. glowLayerEnabled: boolean;
  55579. /**
  55580. * Gets the glow layer (or null if not defined)
  55581. */
  55582. readonly glowLayer: Nullable<GlowLayer>;
  55583. /**
  55584. * Enable or disable the chromaticAberration process from the pipeline
  55585. */
  55586. chromaticAberrationEnabled: boolean;
  55587. /**
  55588. * Enable or disable the grain process from the pipeline
  55589. */
  55590. grainEnabled: boolean;
  55591. /**
  55592. * @constructor
  55593. * @param name - The rendering pipeline name (default: "")
  55594. * @param hdr - If high dynamic range textures should be used (default: true)
  55595. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55596. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55597. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55598. */
  55599. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55600. /**
  55601. * Get the class name
  55602. * @returns "DefaultRenderingPipeline"
  55603. */
  55604. getClassName(): string;
  55605. /**
  55606. * Force the compilation of the entire pipeline.
  55607. */
  55608. prepare(): void;
  55609. private _hasCleared;
  55610. private _prevPostProcess;
  55611. private _prevPrevPostProcess;
  55612. private _setAutoClearAndTextureSharing;
  55613. private _depthOfFieldSceneObserver;
  55614. private _buildPipeline;
  55615. private _disposePostProcesses;
  55616. /**
  55617. * Adds a camera to the pipeline
  55618. * @param camera the camera to be added
  55619. */
  55620. addCamera(camera: Camera): void;
  55621. /**
  55622. * Removes a camera from the pipeline
  55623. * @param camera the camera to remove
  55624. */
  55625. removeCamera(camera: Camera): void;
  55626. /**
  55627. * Dispose of the pipeline and stop all post processes
  55628. */
  55629. dispose(): void;
  55630. /**
  55631. * Serialize the rendering pipeline (Used when exporting)
  55632. * @returns the serialized object
  55633. */
  55634. serialize(): any;
  55635. /**
  55636. * Parse the serialized pipeline
  55637. * @param source Source pipeline.
  55638. * @param scene The scene to load the pipeline to.
  55639. * @param rootUrl The URL of the serialized pipeline.
  55640. * @returns An instantiated pipeline from the serialized object.
  55641. */
  55642. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55643. }
  55644. }
  55645. declare module BABYLON {
  55646. /** @hidden */
  55647. export var lensHighlightsPixelShader: {
  55648. name: string;
  55649. shader: string;
  55650. };
  55651. }
  55652. declare module BABYLON {
  55653. /** @hidden */
  55654. export var depthOfFieldPixelShader: {
  55655. name: string;
  55656. shader: string;
  55657. };
  55658. }
  55659. declare module BABYLON {
  55660. /**
  55661. * BABYLON.JS Chromatic Aberration GLSL Shader
  55662. * Author: Olivier Guyot
  55663. * Separates very slightly R, G and B colors on the edges of the screen
  55664. * Inspired by Francois Tarlier & Martins Upitis
  55665. */
  55666. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55667. /**
  55668. * @ignore
  55669. * The chromatic aberration PostProcess id in the pipeline
  55670. */
  55671. LensChromaticAberrationEffect: string;
  55672. /**
  55673. * @ignore
  55674. * The highlights enhancing PostProcess id in the pipeline
  55675. */
  55676. HighlightsEnhancingEffect: string;
  55677. /**
  55678. * @ignore
  55679. * The depth-of-field PostProcess id in the pipeline
  55680. */
  55681. LensDepthOfFieldEffect: string;
  55682. private _scene;
  55683. private _depthTexture;
  55684. private _grainTexture;
  55685. private _chromaticAberrationPostProcess;
  55686. private _highlightsPostProcess;
  55687. private _depthOfFieldPostProcess;
  55688. private _edgeBlur;
  55689. private _grainAmount;
  55690. private _chromaticAberration;
  55691. private _distortion;
  55692. private _highlightsGain;
  55693. private _highlightsThreshold;
  55694. private _dofDistance;
  55695. private _dofAperture;
  55696. private _dofDarken;
  55697. private _dofPentagon;
  55698. private _blurNoise;
  55699. /**
  55700. * @constructor
  55701. *
  55702. * Effect parameters are as follow:
  55703. * {
  55704. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55705. * edge_blur: number; // from 0 to x (1 for realism)
  55706. * distortion: number; // from 0 to x (1 for realism)
  55707. * grain_amount: number; // from 0 to 1
  55708. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55709. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55710. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55711. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55712. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55713. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55714. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55715. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55716. * }
  55717. * Note: if an effect parameter is unset, effect is disabled
  55718. *
  55719. * @param name The rendering pipeline name
  55720. * @param parameters - An object containing all parameters (see above)
  55721. * @param scene The scene linked to this pipeline
  55722. * @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)
  55723. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55724. */
  55725. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55726. /**
  55727. * Get the class name
  55728. * @returns "LensRenderingPipeline"
  55729. */
  55730. getClassName(): string;
  55731. /**
  55732. * Gets associated scene
  55733. */
  55734. readonly scene: Scene;
  55735. /**
  55736. * Gets or sets the edge blur
  55737. */
  55738. edgeBlur: number;
  55739. /**
  55740. * Gets or sets the grain amount
  55741. */
  55742. grainAmount: number;
  55743. /**
  55744. * Gets or sets the chromatic aberration amount
  55745. */
  55746. chromaticAberration: number;
  55747. /**
  55748. * Gets or sets the depth of field aperture
  55749. */
  55750. dofAperture: number;
  55751. /**
  55752. * Gets or sets the edge distortion
  55753. */
  55754. edgeDistortion: number;
  55755. /**
  55756. * Gets or sets the depth of field distortion
  55757. */
  55758. dofDistortion: number;
  55759. /**
  55760. * Gets or sets the darken out of focus amount
  55761. */
  55762. darkenOutOfFocus: number;
  55763. /**
  55764. * Gets or sets a boolean indicating if blur noise is enabled
  55765. */
  55766. blurNoise: boolean;
  55767. /**
  55768. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55769. */
  55770. pentagonBokeh: boolean;
  55771. /**
  55772. * Gets or sets the highlight grain amount
  55773. */
  55774. highlightsGain: number;
  55775. /**
  55776. * Gets or sets the highlight threshold
  55777. */
  55778. highlightsThreshold: number;
  55779. /**
  55780. * Sets the amount of blur at the edges
  55781. * @param amount blur amount
  55782. */
  55783. setEdgeBlur(amount: number): void;
  55784. /**
  55785. * Sets edge blur to 0
  55786. */
  55787. disableEdgeBlur(): void;
  55788. /**
  55789. * Sets the amout of grain
  55790. * @param amount Amount of grain
  55791. */
  55792. setGrainAmount(amount: number): void;
  55793. /**
  55794. * Set grain amount to 0
  55795. */
  55796. disableGrain(): void;
  55797. /**
  55798. * Sets the chromatic aberration amount
  55799. * @param amount amount of chromatic aberration
  55800. */
  55801. setChromaticAberration(amount: number): void;
  55802. /**
  55803. * Sets chromatic aberration amount to 0
  55804. */
  55805. disableChromaticAberration(): void;
  55806. /**
  55807. * Sets the EdgeDistortion amount
  55808. * @param amount amount of EdgeDistortion
  55809. */
  55810. setEdgeDistortion(amount: number): void;
  55811. /**
  55812. * Sets edge distortion to 0
  55813. */
  55814. disableEdgeDistortion(): void;
  55815. /**
  55816. * Sets the FocusDistance amount
  55817. * @param amount amount of FocusDistance
  55818. */
  55819. setFocusDistance(amount: number): void;
  55820. /**
  55821. * Disables depth of field
  55822. */
  55823. disableDepthOfField(): void;
  55824. /**
  55825. * Sets the Aperture amount
  55826. * @param amount amount of Aperture
  55827. */
  55828. setAperture(amount: number): void;
  55829. /**
  55830. * Sets the DarkenOutOfFocus amount
  55831. * @param amount amount of DarkenOutOfFocus
  55832. */
  55833. setDarkenOutOfFocus(amount: number): void;
  55834. private _pentagonBokehIsEnabled;
  55835. /**
  55836. * Creates a pentagon bokeh effect
  55837. */
  55838. enablePentagonBokeh(): void;
  55839. /**
  55840. * Disables the pentagon bokeh effect
  55841. */
  55842. disablePentagonBokeh(): void;
  55843. /**
  55844. * Enables noise blur
  55845. */
  55846. enableNoiseBlur(): void;
  55847. /**
  55848. * Disables noise blur
  55849. */
  55850. disableNoiseBlur(): void;
  55851. /**
  55852. * Sets the HighlightsGain amount
  55853. * @param amount amount of HighlightsGain
  55854. */
  55855. setHighlightsGain(amount: number): void;
  55856. /**
  55857. * Sets the HighlightsThreshold amount
  55858. * @param amount amount of HighlightsThreshold
  55859. */
  55860. setHighlightsThreshold(amount: number): void;
  55861. /**
  55862. * Disables highlights
  55863. */
  55864. disableHighlights(): void;
  55865. /**
  55866. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55867. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55868. */
  55869. dispose(disableDepthRender?: boolean): void;
  55870. private _createChromaticAberrationPostProcess;
  55871. private _createHighlightsPostProcess;
  55872. private _createDepthOfFieldPostProcess;
  55873. private _createGrainTexture;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /** @hidden */
  55878. export var ssao2PixelShader: {
  55879. name: string;
  55880. shader: string;
  55881. };
  55882. }
  55883. declare module BABYLON {
  55884. /** @hidden */
  55885. export var ssaoCombinePixelShader: {
  55886. name: string;
  55887. shader: string;
  55888. };
  55889. }
  55890. declare module BABYLON {
  55891. /**
  55892. * Render pipeline to produce ssao effect
  55893. */
  55894. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55895. /**
  55896. * @ignore
  55897. * The PassPostProcess id in the pipeline that contains the original scene color
  55898. */
  55899. SSAOOriginalSceneColorEffect: string;
  55900. /**
  55901. * @ignore
  55902. * The SSAO PostProcess id in the pipeline
  55903. */
  55904. SSAORenderEffect: string;
  55905. /**
  55906. * @ignore
  55907. * The horizontal blur PostProcess id in the pipeline
  55908. */
  55909. SSAOBlurHRenderEffect: string;
  55910. /**
  55911. * @ignore
  55912. * The vertical blur PostProcess id in the pipeline
  55913. */
  55914. SSAOBlurVRenderEffect: string;
  55915. /**
  55916. * @ignore
  55917. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55918. */
  55919. SSAOCombineRenderEffect: string;
  55920. /**
  55921. * The output strength of the SSAO post-process. Default value is 1.0.
  55922. */
  55923. totalStrength: number;
  55924. /**
  55925. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55926. */
  55927. maxZ: number;
  55928. /**
  55929. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55930. */
  55931. minZAspect: number;
  55932. private _samples;
  55933. /**
  55934. * Number of samples used for the SSAO calculations. Default value is 8
  55935. */
  55936. samples: number;
  55937. private _textureSamples;
  55938. /**
  55939. * Number of samples to use for antialiasing
  55940. */
  55941. textureSamples: number;
  55942. /**
  55943. * Ratio object used for SSAO ratio and blur ratio
  55944. */
  55945. private _ratio;
  55946. /**
  55947. * Dynamically generated sphere sampler.
  55948. */
  55949. private _sampleSphere;
  55950. /**
  55951. * Blur filter offsets
  55952. */
  55953. private _samplerOffsets;
  55954. private _expensiveBlur;
  55955. /**
  55956. * If bilateral blur should be used
  55957. */
  55958. expensiveBlur: boolean;
  55959. /**
  55960. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55961. */
  55962. radius: number;
  55963. /**
  55964. * The base color of the SSAO post-process
  55965. * The final result is "base + ssao" between [0, 1]
  55966. */
  55967. base: number;
  55968. /**
  55969. * Support test.
  55970. */
  55971. static readonly IsSupported: boolean;
  55972. private _scene;
  55973. private _depthTexture;
  55974. private _normalTexture;
  55975. private _randomTexture;
  55976. private _originalColorPostProcess;
  55977. private _ssaoPostProcess;
  55978. private _blurHPostProcess;
  55979. private _blurVPostProcess;
  55980. private _ssaoCombinePostProcess;
  55981. private _firstUpdate;
  55982. /**
  55983. * Gets active scene
  55984. */
  55985. readonly scene: Scene;
  55986. /**
  55987. * @constructor
  55988. * @param name The rendering pipeline name
  55989. * @param scene The scene linked to this pipeline
  55990. * @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 }
  55991. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55992. */
  55993. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55994. /**
  55995. * Get the class name
  55996. * @returns "SSAO2RenderingPipeline"
  55997. */
  55998. getClassName(): string;
  55999. /**
  56000. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56001. */
  56002. dispose(disableGeometryBufferRenderer?: boolean): void;
  56003. private _createBlurPostProcess;
  56004. /** @hidden */ private _rebuild(): void;
  56005. private _bits;
  56006. private _radicalInverse_VdC;
  56007. private _hammersley;
  56008. private _hemisphereSample_uniform;
  56009. private _generateHemisphere;
  56010. private _createSSAOPostProcess;
  56011. private _createSSAOCombinePostProcess;
  56012. private _createRandomTexture;
  56013. /**
  56014. * Serialize the rendering pipeline (Used when exporting)
  56015. * @returns the serialized object
  56016. */
  56017. serialize(): any;
  56018. /**
  56019. * Parse the serialized pipeline
  56020. * @param source Source pipeline.
  56021. * @param scene The scene to load the pipeline to.
  56022. * @param rootUrl The URL of the serialized pipeline.
  56023. * @returns An instantiated pipeline from the serialized object.
  56024. */
  56025. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56026. }
  56027. }
  56028. declare module BABYLON {
  56029. /** @hidden */
  56030. export var ssaoPixelShader: {
  56031. name: string;
  56032. shader: string;
  56033. };
  56034. }
  56035. declare module BABYLON {
  56036. /**
  56037. * Render pipeline to produce ssao effect
  56038. */
  56039. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56040. /**
  56041. * @ignore
  56042. * The PassPostProcess id in the pipeline that contains the original scene color
  56043. */
  56044. SSAOOriginalSceneColorEffect: string;
  56045. /**
  56046. * @ignore
  56047. * The SSAO PostProcess id in the pipeline
  56048. */
  56049. SSAORenderEffect: string;
  56050. /**
  56051. * @ignore
  56052. * The horizontal blur PostProcess id in the pipeline
  56053. */
  56054. SSAOBlurHRenderEffect: string;
  56055. /**
  56056. * @ignore
  56057. * The vertical blur PostProcess id in the pipeline
  56058. */
  56059. SSAOBlurVRenderEffect: string;
  56060. /**
  56061. * @ignore
  56062. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56063. */
  56064. SSAOCombineRenderEffect: string;
  56065. /**
  56066. * The output strength of the SSAO post-process. Default value is 1.0.
  56067. */
  56068. totalStrength: number;
  56069. /**
  56070. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56071. */
  56072. radius: number;
  56073. /**
  56074. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56075. * Must not be equal to fallOff and superior to fallOff.
  56076. * Default value is 0.0075
  56077. */
  56078. area: number;
  56079. /**
  56080. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56081. * Must not be equal to area and inferior to area.
  56082. * Default value is 0.000001
  56083. */
  56084. fallOff: number;
  56085. /**
  56086. * The base color of the SSAO post-process
  56087. * The final result is "base + ssao" between [0, 1]
  56088. */
  56089. base: number;
  56090. private _scene;
  56091. private _depthTexture;
  56092. private _randomTexture;
  56093. private _originalColorPostProcess;
  56094. private _ssaoPostProcess;
  56095. private _blurHPostProcess;
  56096. private _blurVPostProcess;
  56097. private _ssaoCombinePostProcess;
  56098. private _firstUpdate;
  56099. /**
  56100. * Gets active scene
  56101. */
  56102. readonly scene: Scene;
  56103. /**
  56104. * @constructor
  56105. * @param name - The rendering pipeline name
  56106. * @param scene - The scene linked to this pipeline
  56107. * @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 }
  56108. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56109. */
  56110. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56111. /**
  56112. * Get the class name
  56113. * @returns "SSAORenderingPipeline"
  56114. */
  56115. getClassName(): string;
  56116. /**
  56117. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56118. */
  56119. dispose(disableDepthRender?: boolean): void;
  56120. private _createBlurPostProcess;
  56121. /** @hidden */ private _rebuild(): void;
  56122. private _createSSAOPostProcess;
  56123. private _createSSAOCombinePostProcess;
  56124. private _createRandomTexture;
  56125. }
  56126. }
  56127. declare module BABYLON {
  56128. /** @hidden */
  56129. export var standardPixelShader: {
  56130. name: string;
  56131. shader: string;
  56132. };
  56133. }
  56134. declare module BABYLON {
  56135. /**
  56136. * Standard rendering pipeline
  56137. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56138. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56139. */
  56140. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56141. /**
  56142. * Public members
  56143. */
  56144. /**
  56145. * Post-process which contains the original scene color before the pipeline applies all the effects
  56146. */
  56147. originalPostProcess: Nullable<PostProcess>;
  56148. /**
  56149. * Post-process used to down scale an image x4
  56150. */
  56151. downSampleX4PostProcess: Nullable<PostProcess>;
  56152. /**
  56153. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56154. */
  56155. brightPassPostProcess: Nullable<PostProcess>;
  56156. /**
  56157. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56158. */
  56159. blurHPostProcesses: PostProcess[];
  56160. /**
  56161. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56162. */
  56163. blurVPostProcesses: PostProcess[];
  56164. /**
  56165. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56166. */
  56167. textureAdderPostProcess: Nullable<PostProcess>;
  56168. /**
  56169. * Post-process used to create volumetric lighting effect
  56170. */
  56171. volumetricLightPostProcess: Nullable<PostProcess>;
  56172. /**
  56173. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56174. */
  56175. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56176. /**
  56177. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56178. */
  56179. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56180. /**
  56181. * Post-process used to merge the volumetric light effect and the real scene color
  56182. */
  56183. volumetricLightMergePostProces: Nullable<PostProcess>;
  56184. /**
  56185. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56186. */
  56187. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56188. /**
  56189. * Base post-process used to calculate the average luminance of the final image for HDR
  56190. */
  56191. luminancePostProcess: Nullable<PostProcess>;
  56192. /**
  56193. * Post-processes used to create down sample post-processes in order to get
  56194. * the average luminance of the final image for HDR
  56195. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56196. */
  56197. luminanceDownSamplePostProcesses: PostProcess[];
  56198. /**
  56199. * Post-process used to create a HDR effect (light adaptation)
  56200. */
  56201. hdrPostProcess: Nullable<PostProcess>;
  56202. /**
  56203. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56204. */
  56205. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56206. /**
  56207. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56208. */
  56209. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56210. /**
  56211. * Post-process used to merge the final HDR post-process and the real scene color
  56212. */
  56213. hdrFinalPostProcess: Nullable<PostProcess>;
  56214. /**
  56215. * Post-process used to create a lens flare effect
  56216. */
  56217. lensFlarePostProcess: Nullable<PostProcess>;
  56218. /**
  56219. * Post-process that merges the result of the lens flare post-process and the real scene color
  56220. */
  56221. lensFlareComposePostProcess: Nullable<PostProcess>;
  56222. /**
  56223. * Post-process used to create a motion blur effect
  56224. */
  56225. motionBlurPostProcess: Nullable<PostProcess>;
  56226. /**
  56227. * Post-process used to create a depth of field effect
  56228. */
  56229. depthOfFieldPostProcess: Nullable<PostProcess>;
  56230. /**
  56231. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56232. */
  56233. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56234. /**
  56235. * Represents the brightness threshold in order to configure the illuminated surfaces
  56236. */
  56237. brightThreshold: number;
  56238. /**
  56239. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56240. */
  56241. blurWidth: number;
  56242. /**
  56243. * Sets if the blur for highlighted surfaces must be only horizontal
  56244. */
  56245. horizontalBlur: boolean;
  56246. /**
  56247. * Gets the overall exposure used by the pipeline
  56248. */
  56249. /**
  56250. * Sets the overall exposure used by the pipeline
  56251. */
  56252. exposure: number;
  56253. /**
  56254. * Texture used typically to simulate "dirty" on camera lens
  56255. */
  56256. lensTexture: Nullable<Texture>;
  56257. /**
  56258. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56259. */
  56260. volumetricLightCoefficient: number;
  56261. /**
  56262. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56263. */
  56264. volumetricLightPower: number;
  56265. /**
  56266. * Used the set the blur intensity to smooth the volumetric lights
  56267. */
  56268. volumetricLightBlurScale: number;
  56269. /**
  56270. * Light (spot or directional) used to generate the volumetric lights rays
  56271. * The source light must have a shadow generate so the pipeline can get its
  56272. * depth map
  56273. */
  56274. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56275. /**
  56276. * For eye adaptation, represents the minimum luminance the eye can see
  56277. */
  56278. hdrMinimumLuminance: number;
  56279. /**
  56280. * For eye adaptation, represents the decrease luminance speed
  56281. */
  56282. hdrDecreaseRate: number;
  56283. /**
  56284. * For eye adaptation, represents the increase luminance speed
  56285. */
  56286. hdrIncreaseRate: number;
  56287. /**
  56288. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56289. */
  56290. /**
  56291. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56292. */
  56293. hdrAutoExposure: boolean;
  56294. /**
  56295. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56296. */
  56297. lensColorTexture: Nullable<Texture>;
  56298. /**
  56299. * The overall strengh for the lens flare effect
  56300. */
  56301. lensFlareStrength: number;
  56302. /**
  56303. * Dispersion coefficient for lens flare ghosts
  56304. */
  56305. lensFlareGhostDispersal: number;
  56306. /**
  56307. * Main lens flare halo width
  56308. */
  56309. lensFlareHaloWidth: number;
  56310. /**
  56311. * Based on the lens distortion effect, defines how much the lens flare result
  56312. * is distorted
  56313. */
  56314. lensFlareDistortionStrength: number;
  56315. /**
  56316. * Lens star texture must be used to simulate rays on the flares and is available
  56317. * in the documentation
  56318. */
  56319. lensStarTexture: Nullable<Texture>;
  56320. /**
  56321. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56322. * flare effect by taking account of the dirt texture
  56323. */
  56324. lensFlareDirtTexture: Nullable<Texture>;
  56325. /**
  56326. * Represents the focal length for the depth of field effect
  56327. */
  56328. depthOfFieldDistance: number;
  56329. /**
  56330. * Represents the blur intensity for the blurred part of the depth of field effect
  56331. */
  56332. depthOfFieldBlurWidth: number;
  56333. /**
  56334. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56335. */
  56336. /**
  56337. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56338. */
  56339. motionStrength: number;
  56340. /**
  56341. * Gets wether or not the motion blur post-process is object based or screen based.
  56342. */
  56343. /**
  56344. * Sets wether or not the motion blur post-process should be object based or screen based
  56345. */
  56346. objectBasedMotionBlur: boolean;
  56347. /**
  56348. * List of animations for the pipeline (IAnimatable implementation)
  56349. */
  56350. animations: Animation[];
  56351. /**
  56352. * Private members
  56353. */
  56354. private _scene;
  56355. private _currentDepthOfFieldSource;
  56356. private _basePostProcess;
  56357. private _fixedExposure;
  56358. private _currentExposure;
  56359. private _hdrAutoExposure;
  56360. private _hdrCurrentLuminance;
  56361. private _motionStrength;
  56362. private _isObjectBasedMotionBlur;
  56363. private _floatTextureType;
  56364. private _ratio;
  56365. private _bloomEnabled;
  56366. private _depthOfFieldEnabled;
  56367. private _vlsEnabled;
  56368. private _lensFlareEnabled;
  56369. private _hdrEnabled;
  56370. private _motionBlurEnabled;
  56371. private _fxaaEnabled;
  56372. private _motionBlurSamples;
  56373. private _volumetricLightStepsCount;
  56374. private _samples;
  56375. /**
  56376. * @ignore
  56377. * Specifies if the bloom pipeline is enabled
  56378. */
  56379. BloomEnabled: boolean;
  56380. /**
  56381. * @ignore
  56382. * Specifies if the depth of field pipeline is enabed
  56383. */
  56384. DepthOfFieldEnabled: boolean;
  56385. /**
  56386. * @ignore
  56387. * Specifies if the lens flare pipeline is enabed
  56388. */
  56389. LensFlareEnabled: boolean;
  56390. /**
  56391. * @ignore
  56392. * Specifies if the HDR pipeline is enabled
  56393. */
  56394. HDREnabled: boolean;
  56395. /**
  56396. * @ignore
  56397. * Specifies if the volumetric lights scattering effect is enabled
  56398. */
  56399. VLSEnabled: boolean;
  56400. /**
  56401. * @ignore
  56402. * Specifies if the motion blur effect is enabled
  56403. */
  56404. MotionBlurEnabled: boolean;
  56405. /**
  56406. * Specifies if anti-aliasing is enabled
  56407. */
  56408. fxaaEnabled: boolean;
  56409. /**
  56410. * Specifies the number of steps used to calculate the volumetric lights
  56411. * Typically in interval [50, 200]
  56412. */
  56413. volumetricLightStepsCount: number;
  56414. /**
  56415. * Specifies the number of samples used for the motion blur effect
  56416. * Typically in interval [16, 64]
  56417. */
  56418. motionBlurSamples: number;
  56419. /**
  56420. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56421. */
  56422. samples: number;
  56423. /**
  56424. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56425. * @constructor
  56426. * @param name The rendering pipeline name
  56427. * @param scene The scene linked to this pipeline
  56428. * @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)
  56429. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56430. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56431. */
  56432. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56433. private _buildPipeline;
  56434. private _createDownSampleX4PostProcess;
  56435. private _createBrightPassPostProcess;
  56436. private _createBlurPostProcesses;
  56437. private _createTextureAdderPostProcess;
  56438. private _createVolumetricLightPostProcess;
  56439. private _createLuminancePostProcesses;
  56440. private _createHdrPostProcess;
  56441. private _createLensFlarePostProcess;
  56442. private _createDepthOfFieldPostProcess;
  56443. private _createMotionBlurPostProcess;
  56444. private _getDepthTexture;
  56445. private _disposePostProcesses;
  56446. /**
  56447. * Dispose of the pipeline and stop all post processes
  56448. */
  56449. dispose(): void;
  56450. /**
  56451. * Serialize the rendering pipeline (Used when exporting)
  56452. * @returns the serialized object
  56453. */
  56454. serialize(): any;
  56455. /**
  56456. * Parse the serialized pipeline
  56457. * @param source Source pipeline.
  56458. * @param scene The scene to load the pipeline to.
  56459. * @param rootUrl The URL of the serialized pipeline.
  56460. * @returns An instantiated pipeline from the serialized object.
  56461. */
  56462. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56463. /**
  56464. * Luminance steps
  56465. */
  56466. static LuminanceSteps: number;
  56467. }
  56468. }
  56469. declare module BABYLON {
  56470. /** @hidden */
  56471. export var tonemapPixelShader: {
  56472. name: string;
  56473. shader: string;
  56474. };
  56475. }
  56476. declare module BABYLON {
  56477. /** Defines operator used for tonemapping */
  56478. export enum TonemappingOperator {
  56479. /** Hable */
  56480. Hable = 0,
  56481. /** Reinhard */
  56482. Reinhard = 1,
  56483. /** HejiDawson */
  56484. HejiDawson = 2,
  56485. /** Photographic */
  56486. Photographic = 3
  56487. }
  56488. /**
  56489. * Defines a post process to apply tone mapping
  56490. */
  56491. export class TonemapPostProcess extends PostProcess {
  56492. private _operator;
  56493. /** Defines the required exposure adjustement */
  56494. exposureAdjustment: number;
  56495. /**
  56496. * Creates a new TonemapPostProcess
  56497. * @param name defines the name of the postprocess
  56498. * @param _operator defines the operator to use
  56499. * @param exposureAdjustment defines the required exposure adjustement
  56500. * @param camera defines the camera to use (can be null)
  56501. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56502. * @param engine defines the hosting engine (can be ignore if camera is set)
  56503. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56504. */
  56505. constructor(name: string, _operator: TonemappingOperator,
  56506. /** Defines the required exposure adjustement */
  56507. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56508. }
  56509. }
  56510. declare module BABYLON {
  56511. /** @hidden */
  56512. export var depthVertexShader: {
  56513. name: string;
  56514. shader: string;
  56515. };
  56516. }
  56517. declare module BABYLON {
  56518. /** @hidden */
  56519. export var volumetricLightScatteringPixelShader: {
  56520. name: string;
  56521. shader: string;
  56522. };
  56523. }
  56524. declare module BABYLON {
  56525. /** @hidden */
  56526. export var volumetricLightScatteringPassPixelShader: {
  56527. name: string;
  56528. shader: string;
  56529. };
  56530. }
  56531. declare module BABYLON {
  56532. /**
  56533. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56534. */
  56535. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56536. private _volumetricLightScatteringPass;
  56537. private _volumetricLightScatteringRTT;
  56538. private _viewPort;
  56539. private _screenCoordinates;
  56540. private _cachedDefines;
  56541. /**
  56542. * If not undefined, the mesh position is computed from the attached node position
  56543. */
  56544. attachedNode: {
  56545. position: Vector3;
  56546. };
  56547. /**
  56548. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56549. */
  56550. customMeshPosition: Vector3;
  56551. /**
  56552. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56553. */
  56554. useCustomMeshPosition: boolean;
  56555. /**
  56556. * If the post-process should inverse the light scattering direction
  56557. */
  56558. invert: boolean;
  56559. /**
  56560. * The internal mesh used by the post-process
  56561. */
  56562. mesh: Mesh;
  56563. /**
  56564. * @hidden
  56565. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56566. */
  56567. useDiffuseColor: boolean;
  56568. /**
  56569. * Array containing the excluded meshes not rendered in the internal pass
  56570. */
  56571. excludedMeshes: AbstractMesh[];
  56572. /**
  56573. * Controls the overall intensity of the post-process
  56574. */
  56575. exposure: number;
  56576. /**
  56577. * Dissipates each sample's contribution in range [0, 1]
  56578. */
  56579. decay: number;
  56580. /**
  56581. * Controls the overall intensity of each sample
  56582. */
  56583. weight: number;
  56584. /**
  56585. * Controls the density of each sample
  56586. */
  56587. density: number;
  56588. /**
  56589. * @constructor
  56590. * @param name The post-process name
  56591. * @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)
  56592. * @param camera The camera that the post-process will be attached to
  56593. * @param mesh The mesh used to create the light scattering
  56594. * @param samples The post-process quality, default 100
  56595. * @param samplingModeThe post-process filtering mode
  56596. * @param engine The babylon engine
  56597. * @param reusable If the post-process is reusable
  56598. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56599. */
  56600. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56601. /**
  56602. * Returns the string "VolumetricLightScatteringPostProcess"
  56603. * @returns "VolumetricLightScatteringPostProcess"
  56604. */
  56605. getClassName(): string;
  56606. private _isReady;
  56607. /**
  56608. * Sets the new light position for light scattering effect
  56609. * @param position The new custom light position
  56610. */
  56611. setCustomMeshPosition(position: Vector3): void;
  56612. /**
  56613. * Returns the light position for light scattering effect
  56614. * @return Vector3 The custom light position
  56615. */
  56616. getCustomMeshPosition(): Vector3;
  56617. /**
  56618. * Disposes the internal assets and detaches the post-process from the camera
  56619. */
  56620. dispose(camera: Camera): void;
  56621. /**
  56622. * Returns the render target texture used by the post-process
  56623. * @return the render target texture used by the post-process
  56624. */
  56625. getPass(): RenderTargetTexture;
  56626. private _meshExcluded;
  56627. private _createPass;
  56628. private _updateMeshScreenCoordinates;
  56629. /**
  56630. * Creates a default mesh for the Volumeric Light Scattering post-process
  56631. * @param name The mesh name
  56632. * @param scene The scene where to create the mesh
  56633. * @return the default mesh
  56634. */
  56635. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56636. }
  56637. }
  56638. declare module BABYLON {
  56639. interface Scene {
  56640. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  56641. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  56642. /**
  56643. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56644. */
  56645. forceShowBoundingBoxes: boolean;
  56646. /**
  56647. * Gets the bounding box renderer associated with the scene
  56648. * @returns a BoundingBoxRenderer
  56649. */
  56650. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56651. }
  56652. interface AbstractMesh {
  56653. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  56654. /**
  56655. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56656. */
  56657. showBoundingBox: boolean;
  56658. }
  56659. /**
  56660. * Component responsible of rendering the bounding box of the meshes in a scene.
  56661. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56662. */
  56663. export class BoundingBoxRenderer implements ISceneComponent {
  56664. /**
  56665. * The component name helpfull to identify the component in the list of scene components.
  56666. */
  56667. readonly name: string;
  56668. /**
  56669. * The scene the component belongs to.
  56670. */
  56671. scene: Scene;
  56672. /**
  56673. * Color of the bounding box lines placed in front of an object
  56674. */
  56675. frontColor: Color3;
  56676. /**
  56677. * Color of the bounding box lines placed behind an object
  56678. */
  56679. backColor: Color3;
  56680. /**
  56681. * Defines if the renderer should show the back lines or not
  56682. */
  56683. showBackLines: boolean;
  56684. /**
  56685. * @hidden
  56686. */
  56687. renderList: SmartArray<BoundingBox>;
  56688. private _colorShader;
  56689. private _vertexBuffers;
  56690. private _indexBuffer;
  56691. private _fillIndexBuffer;
  56692. private _fillIndexData;
  56693. /**
  56694. * Instantiates a new bounding box renderer in a scene.
  56695. * @param scene the scene the renderer renders in
  56696. */
  56697. constructor(scene: Scene);
  56698. /**
  56699. * Registers the component in a given scene
  56700. */
  56701. register(): void;
  56702. private _evaluateSubMesh;
  56703. private _activeMesh;
  56704. private _prepareRessources;
  56705. private _createIndexBuffer;
  56706. /**
  56707. * Rebuilds the elements related to this component in case of
  56708. * context lost for instance.
  56709. */
  56710. rebuild(): void;
  56711. /**
  56712. * @hidden
  56713. */
  56714. reset(): void;
  56715. /**
  56716. * Render the bounding boxes of a specific rendering group
  56717. * @param renderingGroupId defines the rendering group to render
  56718. */
  56719. render(renderingGroupId: number): void;
  56720. /**
  56721. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56722. * @param mesh Define the mesh to render the occlusion bounding box for
  56723. */
  56724. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56725. /**
  56726. * Dispose and release the resources attached to this renderer.
  56727. */
  56728. dispose(): void;
  56729. }
  56730. }
  56731. declare module BABYLON {
  56732. /** @hidden */
  56733. export var depthPixelShader: {
  56734. name: string;
  56735. shader: string;
  56736. };
  56737. }
  56738. declare module BABYLON {
  56739. /**
  56740. * This represents a depth renderer in Babylon.
  56741. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56742. */
  56743. export class DepthRenderer {
  56744. private _scene;
  56745. private _depthMap;
  56746. private _effect;
  56747. private _cachedDefines;
  56748. private _camera;
  56749. /**
  56750. * Specifiess that the depth renderer will only be used within
  56751. * the camera it is created for.
  56752. * This can help forcing its rendering during the camera processing.
  56753. */
  56754. useOnlyInActiveCamera: boolean;
  56755. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  56756. /**
  56757. * Instantiates a depth renderer
  56758. * @param scene The scene the renderer belongs to
  56759. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56760. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56761. */
  56762. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56763. /**
  56764. * Creates the depth rendering effect and checks if the effect is ready.
  56765. * @param subMesh The submesh to be used to render the depth map of
  56766. * @param useInstances If multiple world instances should be used
  56767. * @returns if the depth renderer is ready to render the depth map
  56768. */
  56769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56770. /**
  56771. * Gets the texture which the depth map will be written to.
  56772. * @returns The depth map texture
  56773. */
  56774. getDepthMap(): RenderTargetTexture;
  56775. /**
  56776. * Disposes of the depth renderer.
  56777. */
  56778. dispose(): void;
  56779. }
  56780. }
  56781. declare module BABYLON {
  56782. interface Scene {
  56783. /** @hidden (Backing field) */ private _depthRenderer: {
  56784. [id: string]: DepthRenderer;
  56785. };
  56786. /**
  56787. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56788. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56789. * @returns the created depth renderer
  56790. */
  56791. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56792. /**
  56793. * Disables a depth renderer for a given camera
  56794. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56795. */
  56796. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56797. }
  56798. /**
  56799. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56800. * in several rendering techniques.
  56801. */
  56802. export class DepthRendererSceneComponent implements ISceneComponent {
  56803. /**
  56804. * The component name helpfull to identify the component in the list of scene components.
  56805. */
  56806. readonly name: string;
  56807. /**
  56808. * The scene the component belongs to.
  56809. */
  56810. scene: Scene;
  56811. /**
  56812. * Creates a new instance of the component for the given scene
  56813. * @param scene Defines the scene to register the component in
  56814. */
  56815. constructor(scene: Scene);
  56816. /**
  56817. * Registers the component in a given scene
  56818. */
  56819. register(): void;
  56820. /**
  56821. * Rebuilds the elements related to this component in case of
  56822. * context lost for instance.
  56823. */
  56824. rebuild(): void;
  56825. /**
  56826. * Disposes the component and the associated ressources
  56827. */
  56828. dispose(): void;
  56829. private _gatherRenderTargets;
  56830. private _gatherActiveCameraRenderTargets;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /** @hidden */
  56835. export var outlinePixelShader: {
  56836. name: string;
  56837. shader: string;
  56838. };
  56839. }
  56840. declare module BABYLON {
  56841. /** @hidden */
  56842. export var outlineVertexShader: {
  56843. name: string;
  56844. shader: string;
  56845. };
  56846. }
  56847. declare module BABYLON {
  56848. interface Scene {
  56849. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  56850. /**
  56851. * Gets the outline renderer associated with the scene
  56852. * @returns a OutlineRenderer
  56853. */
  56854. getOutlineRenderer(): OutlineRenderer;
  56855. }
  56856. interface AbstractMesh {
  56857. /** @hidden (Backing field) */ private _renderOutline: boolean;
  56858. /**
  56859. * Gets or sets a boolean indicating if the outline must be rendered as well
  56860. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56861. */
  56862. renderOutline: boolean;
  56863. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  56864. /**
  56865. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56866. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56867. */
  56868. renderOverlay: boolean;
  56869. }
  56870. /**
  56871. * This class is responsible to draw bothe outline/overlay of meshes.
  56872. * It should not be used directly but through the available method on mesh.
  56873. */
  56874. export class OutlineRenderer implements ISceneComponent {
  56875. /**
  56876. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56877. */
  56878. private static _StencilReference;
  56879. /**
  56880. * The name of the component. Each component must have a unique name.
  56881. */
  56882. name: string;
  56883. /**
  56884. * The scene the component belongs to.
  56885. */
  56886. scene: Scene;
  56887. /**
  56888. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56889. */
  56890. zOffset: number;
  56891. private _engine;
  56892. private _effect;
  56893. private _cachedDefines;
  56894. private _savedDepthWrite;
  56895. /**
  56896. * Instantiates a new outline renderer. (There could be only one per scene).
  56897. * @param scene Defines the scene it belongs to
  56898. */
  56899. constructor(scene: Scene);
  56900. /**
  56901. * Register the component to one instance of a scene.
  56902. */
  56903. register(): void;
  56904. /**
  56905. * Rebuilds the elements related to this component in case of
  56906. * context lost for instance.
  56907. */
  56908. rebuild(): void;
  56909. /**
  56910. * Disposes the component and the associated ressources.
  56911. */
  56912. dispose(): void;
  56913. /**
  56914. * Renders the outline in the canvas.
  56915. * @param subMesh Defines the sumesh to render
  56916. * @param batch Defines the batch of meshes in case of instances
  56917. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56918. */
  56919. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56920. /**
  56921. * Returns whether or not the outline renderer is ready for a given submesh.
  56922. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56923. * @param subMesh Defines the submesh to check readyness for
  56924. * @param useInstances Defines wheter wee are trying to render instances or not
  56925. * @returns true if ready otherwise false
  56926. */
  56927. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56928. private _beforeRenderingMesh;
  56929. private _afterRenderingMesh;
  56930. }
  56931. }
  56932. declare module BABYLON {
  56933. /**
  56934. * Defines the list of states available for a task inside a AssetsManager
  56935. */
  56936. export enum AssetTaskState {
  56937. /**
  56938. * Initialization
  56939. */
  56940. INIT = 0,
  56941. /**
  56942. * Running
  56943. */
  56944. RUNNING = 1,
  56945. /**
  56946. * Done
  56947. */
  56948. DONE = 2,
  56949. /**
  56950. * Error
  56951. */
  56952. ERROR = 3
  56953. }
  56954. /**
  56955. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56956. */
  56957. export abstract class AbstractAssetTask {
  56958. /**
  56959. * Task name
  56960. */ name: string;
  56961. /**
  56962. * Callback called when the task is successful
  56963. */
  56964. onSuccess: (task: any) => void;
  56965. /**
  56966. * Callback called when the task is not successful
  56967. */
  56968. onError: (task: any, message?: string, exception?: any) => void;
  56969. /**
  56970. * Creates a new AssetsManager
  56971. * @param name defines the name of the task
  56972. */
  56973. constructor(
  56974. /**
  56975. * Task name
  56976. */ name: string);
  56977. private _isCompleted;
  56978. private _taskState;
  56979. private _errorObject;
  56980. /**
  56981. * Get if the task is completed
  56982. */
  56983. readonly isCompleted: boolean;
  56984. /**
  56985. * Gets the current state of the task
  56986. */
  56987. readonly taskState: AssetTaskState;
  56988. /**
  56989. * Gets the current error object (if task is in error)
  56990. */
  56991. readonly errorObject: {
  56992. message?: string;
  56993. exception?: any;
  56994. };
  56995. /**
  56996. * Internal only
  56997. * @hidden
  56998. */ private _setErrorObject(message?: string, exception?: any): void;
  56999. /**
  57000. * Execute the current task
  57001. * @param scene defines the scene where you want your assets to be loaded
  57002. * @param onSuccess is a callback called when the task is successfully executed
  57003. * @param onError is a callback called if an error occurs
  57004. */
  57005. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57006. /**
  57007. * Execute the current task
  57008. * @param scene defines the scene where you want your assets to be loaded
  57009. * @param onSuccess is a callback called when the task is successfully executed
  57010. * @param onError is a callback called if an error occurs
  57011. */
  57012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57013. /**
  57014. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57015. * This can be used with failed tasks that have the reason for failure fixed.
  57016. */
  57017. reset(): void;
  57018. private onErrorCallback;
  57019. private onDoneCallback;
  57020. }
  57021. /**
  57022. * Define the interface used by progress events raised during assets loading
  57023. */
  57024. export interface IAssetsProgressEvent {
  57025. /**
  57026. * Defines the number of remaining tasks to process
  57027. */
  57028. remainingCount: number;
  57029. /**
  57030. * Defines the total number of tasks
  57031. */
  57032. totalCount: number;
  57033. /**
  57034. * Defines the task that was just processed
  57035. */
  57036. task: AbstractAssetTask;
  57037. }
  57038. /**
  57039. * Class used to share progress information about assets loading
  57040. */
  57041. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57042. /**
  57043. * Defines the number of remaining tasks to process
  57044. */
  57045. remainingCount: number;
  57046. /**
  57047. * Defines the total number of tasks
  57048. */
  57049. totalCount: number;
  57050. /**
  57051. * Defines the task that was just processed
  57052. */
  57053. task: AbstractAssetTask;
  57054. /**
  57055. * Creates a AssetsProgressEvent
  57056. * @param remainingCount defines the number of remaining tasks to process
  57057. * @param totalCount defines the total number of tasks
  57058. * @param task defines the task that was just processed
  57059. */
  57060. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57061. }
  57062. /**
  57063. * Define a task used by AssetsManager to load meshes
  57064. */
  57065. export class MeshAssetTask extends AbstractAssetTask {
  57066. /**
  57067. * Defines the name of the task
  57068. */
  57069. name: string;
  57070. /**
  57071. * Defines the list of mesh's names you want to load
  57072. */
  57073. meshesNames: any;
  57074. /**
  57075. * Defines the root url to use as a base to load your meshes and associated resources
  57076. */
  57077. rootUrl: string;
  57078. /**
  57079. * Defines the filename of the scene to load from
  57080. */
  57081. sceneFilename: string;
  57082. /**
  57083. * Gets the list of loaded meshes
  57084. */
  57085. loadedMeshes: Array<AbstractMesh>;
  57086. /**
  57087. * Gets the list of loaded particle systems
  57088. */
  57089. loadedParticleSystems: Array<IParticleSystem>;
  57090. /**
  57091. * Gets the list of loaded skeletons
  57092. */
  57093. loadedSkeletons: Array<Skeleton>;
  57094. /**
  57095. * Gets the list of loaded animation groups
  57096. */
  57097. loadedAnimationGroups: Array<AnimationGroup>;
  57098. /**
  57099. * Callback called when the task is successful
  57100. */
  57101. onSuccess: (task: MeshAssetTask) => void;
  57102. /**
  57103. * Callback called when the task is successful
  57104. */
  57105. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57106. /**
  57107. * Creates a new MeshAssetTask
  57108. * @param name defines the name of the task
  57109. * @param meshesNames defines the list of mesh's names you want to load
  57110. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57111. * @param sceneFilename defines the filename of the scene to load from
  57112. */
  57113. constructor(
  57114. /**
  57115. * Defines the name of the task
  57116. */
  57117. name: string,
  57118. /**
  57119. * Defines the list of mesh's names you want to load
  57120. */
  57121. meshesNames: any,
  57122. /**
  57123. * Defines the root url to use as a base to load your meshes and associated resources
  57124. */
  57125. rootUrl: string,
  57126. /**
  57127. * Defines the filename of the scene to load from
  57128. */
  57129. sceneFilename: string);
  57130. /**
  57131. * Execute the current task
  57132. * @param scene defines the scene where you want your assets to be loaded
  57133. * @param onSuccess is a callback called when the task is successfully executed
  57134. * @param onError is a callback called if an error occurs
  57135. */
  57136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57137. }
  57138. /**
  57139. * Define a task used by AssetsManager to load text content
  57140. */
  57141. export class TextFileAssetTask extends AbstractAssetTask {
  57142. /**
  57143. * Defines the name of the task
  57144. */
  57145. name: string;
  57146. /**
  57147. * Defines the location of the file to load
  57148. */
  57149. url: string;
  57150. /**
  57151. * Gets the loaded text string
  57152. */
  57153. text: string;
  57154. /**
  57155. * Callback called when the task is successful
  57156. */
  57157. onSuccess: (task: TextFileAssetTask) => void;
  57158. /**
  57159. * Callback called when the task is successful
  57160. */
  57161. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57162. /**
  57163. * Creates a new TextFileAssetTask object
  57164. * @param name defines the name of the task
  57165. * @param url defines the location of the file to load
  57166. */
  57167. constructor(
  57168. /**
  57169. * Defines the name of the task
  57170. */
  57171. name: string,
  57172. /**
  57173. * Defines the location of the file to load
  57174. */
  57175. url: string);
  57176. /**
  57177. * Execute the current task
  57178. * @param scene defines the scene where you want your assets to be loaded
  57179. * @param onSuccess is a callback called when the task is successfully executed
  57180. * @param onError is a callback called if an error occurs
  57181. */
  57182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57183. }
  57184. /**
  57185. * Define a task used by AssetsManager to load binary data
  57186. */
  57187. export class BinaryFileAssetTask extends AbstractAssetTask {
  57188. /**
  57189. * Defines the name of the task
  57190. */
  57191. name: string;
  57192. /**
  57193. * Defines the location of the file to load
  57194. */
  57195. url: string;
  57196. /**
  57197. * Gets the lodaded data (as an array buffer)
  57198. */
  57199. data: ArrayBuffer;
  57200. /**
  57201. * Callback called when the task is successful
  57202. */
  57203. onSuccess: (task: BinaryFileAssetTask) => void;
  57204. /**
  57205. * Callback called when the task is successful
  57206. */
  57207. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57208. /**
  57209. * Creates a new BinaryFileAssetTask object
  57210. * @param name defines the name of the new task
  57211. * @param url defines the location of the file to load
  57212. */
  57213. constructor(
  57214. /**
  57215. * Defines the name of the task
  57216. */
  57217. name: string,
  57218. /**
  57219. * Defines the location of the file to load
  57220. */
  57221. url: string);
  57222. /**
  57223. * Execute the current task
  57224. * @param scene defines the scene where you want your assets to be loaded
  57225. * @param onSuccess is a callback called when the task is successfully executed
  57226. * @param onError is a callback called if an error occurs
  57227. */
  57228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57229. }
  57230. /**
  57231. * Define a task used by AssetsManager to load images
  57232. */
  57233. export class ImageAssetTask extends AbstractAssetTask {
  57234. /**
  57235. * Defines the name of the task
  57236. */
  57237. name: string;
  57238. /**
  57239. * Defines the location of the image to load
  57240. */
  57241. url: string;
  57242. /**
  57243. * Gets the loaded images
  57244. */
  57245. image: HTMLImageElement;
  57246. /**
  57247. * Callback called when the task is successful
  57248. */
  57249. onSuccess: (task: ImageAssetTask) => void;
  57250. /**
  57251. * Callback called when the task is successful
  57252. */
  57253. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57254. /**
  57255. * Creates a new ImageAssetTask
  57256. * @param name defines the name of the task
  57257. * @param url defines the location of the image to load
  57258. */
  57259. constructor(
  57260. /**
  57261. * Defines the name of the task
  57262. */
  57263. name: string,
  57264. /**
  57265. * Defines the location of the image to load
  57266. */
  57267. url: string);
  57268. /**
  57269. * Execute the current task
  57270. * @param scene defines the scene where you want your assets to be loaded
  57271. * @param onSuccess is a callback called when the task is successfully executed
  57272. * @param onError is a callback called if an error occurs
  57273. */
  57274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57275. }
  57276. /**
  57277. * Defines the interface used by texture loading tasks
  57278. */
  57279. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57280. /**
  57281. * Gets the loaded texture
  57282. */
  57283. texture: TEX;
  57284. }
  57285. /**
  57286. * Define a task used by AssetsManager to load 2D textures
  57287. */
  57288. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57289. /**
  57290. * Defines the name of the task
  57291. */
  57292. name: string;
  57293. /**
  57294. * Defines the location of the file to load
  57295. */
  57296. url: string;
  57297. /**
  57298. * Defines if mipmap should not be generated (default is false)
  57299. */
  57300. noMipmap?: boolean | undefined;
  57301. /**
  57302. * Defines if texture must be inverted on Y axis (default is false)
  57303. */
  57304. invertY?: boolean | undefined;
  57305. /**
  57306. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57307. */
  57308. samplingMode: number;
  57309. /**
  57310. * Gets the loaded texture
  57311. */
  57312. texture: Texture;
  57313. /**
  57314. * Callback called when the task is successful
  57315. */
  57316. onSuccess: (task: TextureAssetTask) => void;
  57317. /**
  57318. * Callback called when the task is successful
  57319. */
  57320. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57321. /**
  57322. * Creates a new TextureAssetTask object
  57323. * @param name defines the name of the task
  57324. * @param url defines the location of the file to load
  57325. * @param noMipmap defines if mipmap should not be generated (default is false)
  57326. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57327. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57328. */
  57329. constructor(
  57330. /**
  57331. * Defines the name of the task
  57332. */
  57333. name: string,
  57334. /**
  57335. * Defines the location of the file to load
  57336. */
  57337. url: string,
  57338. /**
  57339. * Defines if mipmap should not be generated (default is false)
  57340. */
  57341. noMipmap?: boolean | undefined,
  57342. /**
  57343. * Defines if texture must be inverted on Y axis (default is false)
  57344. */
  57345. invertY?: boolean | undefined,
  57346. /**
  57347. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57348. */
  57349. samplingMode?: number);
  57350. /**
  57351. * Execute the current task
  57352. * @param scene defines the scene where you want your assets to be loaded
  57353. * @param onSuccess is a callback called when the task is successfully executed
  57354. * @param onError is a callback called if an error occurs
  57355. */
  57356. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57357. }
  57358. /**
  57359. * Define a task used by AssetsManager to load cube textures
  57360. */
  57361. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57362. /**
  57363. * Defines the name of the task
  57364. */
  57365. name: string;
  57366. /**
  57367. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57368. */
  57369. url: string;
  57370. /**
  57371. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57372. */
  57373. extensions?: string[] | undefined;
  57374. /**
  57375. * Defines if mipmaps should not be generated (default is false)
  57376. */
  57377. noMipmap?: boolean | undefined;
  57378. /**
  57379. * Defines the explicit list of files (undefined by default)
  57380. */
  57381. files?: string[] | undefined;
  57382. /**
  57383. * Gets the loaded texture
  57384. */
  57385. texture: CubeTexture;
  57386. /**
  57387. * Callback called when the task is successful
  57388. */
  57389. onSuccess: (task: CubeTextureAssetTask) => void;
  57390. /**
  57391. * Callback called when the task is successful
  57392. */
  57393. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57394. /**
  57395. * Creates a new CubeTextureAssetTask
  57396. * @param name defines the name of the task
  57397. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57398. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57399. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57400. * @param files defines the explicit list of files (undefined by default)
  57401. */
  57402. constructor(
  57403. /**
  57404. * Defines the name of the task
  57405. */
  57406. name: string,
  57407. /**
  57408. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57409. */
  57410. url: string,
  57411. /**
  57412. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57413. */
  57414. extensions?: string[] | undefined,
  57415. /**
  57416. * Defines if mipmaps should not be generated (default is false)
  57417. */
  57418. noMipmap?: boolean | undefined,
  57419. /**
  57420. * Defines the explicit list of files (undefined by default)
  57421. */
  57422. files?: string[] | undefined);
  57423. /**
  57424. * Execute the current task
  57425. * @param scene defines the scene where you want your assets to be loaded
  57426. * @param onSuccess is a callback called when the task is successfully executed
  57427. * @param onError is a callback called if an error occurs
  57428. */
  57429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57430. }
  57431. /**
  57432. * Define a task used by AssetsManager to load HDR cube textures
  57433. */
  57434. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57435. /**
  57436. * Defines the name of the task
  57437. */
  57438. name: string;
  57439. /**
  57440. * Defines the location of the file to load
  57441. */
  57442. url: string;
  57443. /**
  57444. * Defines the desired size (the more it increases the longer the generation will be)
  57445. */
  57446. size: number;
  57447. /**
  57448. * Defines if mipmaps should not be generated (default is false)
  57449. */
  57450. noMipmap: boolean;
  57451. /**
  57452. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57453. */
  57454. generateHarmonics: boolean;
  57455. /**
  57456. * 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)
  57457. */
  57458. gammaSpace: boolean;
  57459. /**
  57460. * Internal Use Only
  57461. */
  57462. reserved: boolean;
  57463. /**
  57464. * Gets the loaded texture
  57465. */
  57466. texture: HDRCubeTexture;
  57467. /**
  57468. * Callback called when the task is successful
  57469. */
  57470. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57471. /**
  57472. * Callback called when the task is successful
  57473. */
  57474. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57475. /**
  57476. * Creates a new HDRCubeTextureAssetTask object
  57477. * @param name defines the name of the task
  57478. * @param url defines the location of the file to load
  57479. * @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.
  57480. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57481. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57482. * @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)
  57483. * @param reserved Internal use only
  57484. */
  57485. constructor(
  57486. /**
  57487. * Defines the name of the task
  57488. */
  57489. name: string,
  57490. /**
  57491. * Defines the location of the file to load
  57492. */
  57493. url: string,
  57494. /**
  57495. * Defines the desired size (the more it increases the longer the generation will be)
  57496. */
  57497. size: number,
  57498. /**
  57499. * Defines if mipmaps should not be generated (default is false)
  57500. */
  57501. noMipmap?: boolean,
  57502. /**
  57503. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57504. */
  57505. generateHarmonics?: boolean,
  57506. /**
  57507. * 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)
  57508. */
  57509. gammaSpace?: boolean,
  57510. /**
  57511. * Internal Use Only
  57512. */
  57513. reserved?: boolean);
  57514. /**
  57515. * Execute the current task
  57516. * @param scene defines the scene where you want your assets to be loaded
  57517. * @param onSuccess is a callback called when the task is successfully executed
  57518. * @param onError is a callback called if an error occurs
  57519. */
  57520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57521. }
  57522. /**
  57523. * Define a task used by AssetsManager to load Equirectangular cube textures
  57524. */
  57525. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57526. /**
  57527. * Defines the name of the task
  57528. */
  57529. name: string;
  57530. /**
  57531. * Defines the location of the file to load
  57532. */
  57533. url: string;
  57534. /**
  57535. * Defines the desired size (the more it increases the longer the generation will be)
  57536. */
  57537. size: number;
  57538. /**
  57539. * Defines if mipmaps should not be generated (default is false)
  57540. */
  57541. noMipmap: boolean;
  57542. /**
  57543. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57544. * but the standard material would require them in Gamma space) (default is true)
  57545. */
  57546. gammaSpace: boolean;
  57547. /**
  57548. * Gets the loaded texture
  57549. */
  57550. texture: EquiRectangularCubeTexture;
  57551. /**
  57552. * Callback called when the task is successful
  57553. */
  57554. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57555. /**
  57556. * Callback called when the task is successful
  57557. */
  57558. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57559. /**
  57560. * Creates a new EquiRectangularCubeTextureAssetTask object
  57561. * @param name defines the name of the task
  57562. * @param url defines the location of the file to load
  57563. * @param size defines the desired size (the more it increases the longer the generation will be)
  57564. * If the size is omitted this implies you are using a preprocessed cubemap.
  57565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57566. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57567. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57568. * (default is true)
  57569. */
  57570. constructor(
  57571. /**
  57572. * Defines the name of the task
  57573. */
  57574. name: string,
  57575. /**
  57576. * Defines the location of the file to load
  57577. */
  57578. url: string,
  57579. /**
  57580. * Defines the desired size (the more it increases the longer the generation will be)
  57581. */
  57582. size: number,
  57583. /**
  57584. * Defines if mipmaps should not be generated (default is false)
  57585. */
  57586. noMipmap?: boolean,
  57587. /**
  57588. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57589. * but the standard material would require them in Gamma space) (default is true)
  57590. */
  57591. gammaSpace?: boolean);
  57592. /**
  57593. * Execute the current task
  57594. * @param scene defines the scene where you want your assets to be loaded
  57595. * @param onSuccess is a callback called when the task is successfully executed
  57596. * @param onError is a callback called if an error occurs
  57597. */
  57598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57599. }
  57600. /**
  57601. * This class can be used to easily import assets into a scene
  57602. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57603. */
  57604. export class AssetsManager {
  57605. private _scene;
  57606. private _isLoading;
  57607. protected _tasks: AbstractAssetTask[];
  57608. protected _waitingTasksCount: number;
  57609. protected _totalTasksCount: number;
  57610. /**
  57611. * Callback called when all tasks are processed
  57612. */
  57613. onFinish: (tasks: AbstractAssetTask[]) => void;
  57614. /**
  57615. * Callback called when a task is successful
  57616. */
  57617. onTaskSuccess: (task: AbstractAssetTask) => void;
  57618. /**
  57619. * Callback called when a task had an error
  57620. */
  57621. onTaskError: (task: AbstractAssetTask) => void;
  57622. /**
  57623. * Callback called when a task is done (whatever the result is)
  57624. */
  57625. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57626. /**
  57627. * Observable called when all tasks are processed
  57628. */
  57629. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57630. /**
  57631. * Observable called when a task had an error
  57632. */
  57633. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57634. /**
  57635. * Observable called when all tasks were executed
  57636. */
  57637. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57638. /**
  57639. * Observable called when a task is done (whatever the result is)
  57640. */
  57641. onProgressObservable: Observable<IAssetsProgressEvent>;
  57642. /**
  57643. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57645. */
  57646. useDefaultLoadingScreen: boolean;
  57647. /**
  57648. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  57649. * when all assets have been downloaded.
  57650. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  57651. */
  57652. autoHideLoadingUI: boolean;
  57653. /**
  57654. * Creates a new AssetsManager
  57655. * @param scene defines the scene to work on
  57656. */
  57657. constructor(scene: Scene);
  57658. /**
  57659. * Add a MeshAssetTask to the list of active tasks
  57660. * @param taskName defines the name of the new task
  57661. * @param meshesNames defines the name of meshes to load
  57662. * @param rootUrl defines the root url to use to locate files
  57663. * @param sceneFilename defines the filename of the scene file
  57664. * @returns a new MeshAssetTask object
  57665. */
  57666. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57667. /**
  57668. * Add a TextFileAssetTask to the list of active tasks
  57669. * @param taskName defines the name of the new task
  57670. * @param url defines the url of the file to load
  57671. * @returns a new TextFileAssetTask object
  57672. */
  57673. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57674. /**
  57675. * Add a BinaryFileAssetTask to the list of active tasks
  57676. * @param taskName defines the name of the new task
  57677. * @param url defines the url of the file to load
  57678. * @returns a new BinaryFileAssetTask object
  57679. */
  57680. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57681. /**
  57682. * Add a ImageAssetTask to the list of active tasks
  57683. * @param taskName defines the name of the new task
  57684. * @param url defines the url of the file to load
  57685. * @returns a new ImageAssetTask object
  57686. */
  57687. addImageTask(taskName: string, url: string): ImageAssetTask;
  57688. /**
  57689. * Add a TextureAssetTask to the list of active tasks
  57690. * @param taskName defines the name of the new task
  57691. * @param url defines the url of the file to load
  57692. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57693. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57694. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57695. * @returns a new TextureAssetTask object
  57696. */
  57697. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57698. /**
  57699. * Add a CubeTextureAssetTask to the list of active tasks
  57700. * @param taskName defines the name of the new task
  57701. * @param url defines the url of the file to load
  57702. * @param extensions defines the extension to use to load the cube map (can be null)
  57703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57704. * @param files defines the list of files to load (can be null)
  57705. * @returns a new CubeTextureAssetTask object
  57706. */
  57707. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57708. /**
  57709. *
  57710. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57711. * @param taskName defines the name of the new task
  57712. * @param url defines the url of the file to load
  57713. * @param size defines the size you want for the cubemap (can be null)
  57714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57715. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57716. * @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)
  57717. * @param reserved Internal use only
  57718. * @returns a new HDRCubeTextureAssetTask object
  57719. */
  57720. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57721. /**
  57722. *
  57723. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57724. * @param taskName defines the name of the new task
  57725. * @param url defines the url of the file to load
  57726. * @param size defines the size you want for the cubemap (can be null)
  57727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57728. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57729. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57730. * @returns a new EquiRectangularCubeTextureAssetTask object
  57731. */
  57732. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57733. /**
  57734. * Remove a task from the assets manager.
  57735. * @param task the task to remove
  57736. */
  57737. removeTask(task: AbstractAssetTask): void;
  57738. private _decreaseWaitingTasksCount;
  57739. private _runTask;
  57740. /**
  57741. * Reset the AssetsManager and remove all tasks
  57742. * @return the current instance of the AssetsManager
  57743. */
  57744. reset(): AssetsManager;
  57745. /**
  57746. * Start the loading process
  57747. * @return the current instance of the AssetsManager
  57748. */
  57749. load(): AssetsManager;
  57750. /**
  57751. * Start the loading process as an async operation
  57752. * @return a promise returning the list of failed tasks
  57753. */
  57754. loadAsync(): Promise<void>;
  57755. }
  57756. }
  57757. declare module BABYLON {
  57758. /**
  57759. * Wrapper class for promise with external resolve and reject.
  57760. */
  57761. export class Deferred<T> {
  57762. /**
  57763. * The promise associated with this deferred object.
  57764. */
  57765. readonly promise: Promise<T>;
  57766. private _resolve;
  57767. private _reject;
  57768. /**
  57769. * The resolve method of the promise associated with this deferred object.
  57770. */
  57771. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57772. /**
  57773. * The reject method of the promise associated with this deferred object.
  57774. */
  57775. readonly reject: (reason?: any) => void;
  57776. /**
  57777. * Constructor for this deferred object.
  57778. */
  57779. constructor();
  57780. }
  57781. }
  57782. declare module BABYLON {
  57783. /**
  57784. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57785. */
  57786. export class MeshExploder {
  57787. private _centerMesh;
  57788. private _meshes;
  57789. private _meshesOrigins;
  57790. private _toCenterVectors;
  57791. private _scaledDirection;
  57792. private _newPosition;
  57793. private _centerPosition;
  57794. /**
  57795. * Explodes meshes from a center mesh.
  57796. * @param meshes The meshes to explode.
  57797. * @param centerMesh The mesh to be center of explosion.
  57798. */
  57799. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57800. private _setCenterMesh;
  57801. /**
  57802. * Get class name
  57803. * @returns "MeshExploder"
  57804. */
  57805. getClassName(): string;
  57806. /**
  57807. * "Exploded meshes"
  57808. * @returns Array of meshes with the centerMesh at index 0.
  57809. */
  57810. getMeshes(): Array<Mesh>;
  57811. /**
  57812. * Explodes meshes giving a specific direction
  57813. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57814. */
  57815. explode(direction?: number): void;
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. /**
  57820. * Class used to help managing file picking and drag'n'drop
  57821. */
  57822. export class FilesInput {
  57823. /**
  57824. * List of files ready to be loaded
  57825. */
  57826. static readonly FilesToLoad: {
  57827. [key: string]: File;
  57828. };
  57829. /**
  57830. * Callback called when a file is processed
  57831. */
  57832. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57833. private _engine;
  57834. private _currentScene;
  57835. private _sceneLoadedCallback;
  57836. private _progressCallback;
  57837. private _additionalRenderLoopLogicCallback;
  57838. private _textureLoadingCallback;
  57839. private _startingProcessingFilesCallback;
  57840. private _onReloadCallback;
  57841. private _errorCallback;
  57842. private _elementToMonitor;
  57843. private _sceneFileToLoad;
  57844. private _filesToLoad;
  57845. /**
  57846. * Creates a new FilesInput
  57847. * @param engine defines the rendering engine
  57848. * @param scene defines the hosting scene
  57849. * @param sceneLoadedCallback callback called when scene is loaded
  57850. * @param progressCallback callback called to track progress
  57851. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57852. * @param textureLoadingCallback callback called when a texture is loading
  57853. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57854. * @param onReloadCallback callback called when a reload is requested
  57855. * @param errorCallback callback call if an error occurs
  57856. */
  57857. 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);
  57858. private _dragEnterHandler;
  57859. private _dragOverHandler;
  57860. private _dropHandler;
  57861. /**
  57862. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57863. * @param elementToMonitor defines the DOM element to track
  57864. */
  57865. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57866. /**
  57867. * Release all associated resources
  57868. */
  57869. dispose(): void;
  57870. private renderFunction;
  57871. private drag;
  57872. private drop;
  57873. private _traverseFolder;
  57874. private _processFiles;
  57875. /**
  57876. * Load files from a drop event
  57877. * @param event defines the drop event to use as source
  57878. */
  57879. loadFiles(event: any): void;
  57880. private _processReload;
  57881. /**
  57882. * Reload the current scene from the loaded files
  57883. */
  57884. reload(): void;
  57885. }
  57886. }
  57887. declare module BABYLON {
  57888. /**
  57889. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57890. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57891. */
  57892. export class SceneOptimization {
  57893. /**
  57894. * Defines the priority of this optimization (0 by default which means first in the list)
  57895. */
  57896. priority: number;
  57897. /**
  57898. * Gets a string describing the action executed by the current optimization
  57899. * @returns description string
  57900. */
  57901. getDescription(): string;
  57902. /**
  57903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57904. * @param scene defines the current scene where to apply this optimization
  57905. * @param optimizer defines the current optimizer
  57906. * @returns true if everything that can be done was applied
  57907. */
  57908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57909. /**
  57910. * Creates the SceneOptimization object
  57911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57912. * @param desc defines the description associated with the optimization
  57913. */
  57914. constructor(
  57915. /**
  57916. * Defines the priority of this optimization (0 by default which means first in the list)
  57917. */
  57918. priority?: number);
  57919. }
  57920. /**
  57921. * Defines an optimization used to reduce the size of render target textures
  57922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57923. */
  57924. export class TextureOptimization extends SceneOptimization {
  57925. /**
  57926. * Defines the priority of this optimization (0 by default which means first in the list)
  57927. */
  57928. priority: number;
  57929. /**
  57930. * 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
  57931. */
  57932. maximumSize: number;
  57933. /**
  57934. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57935. */
  57936. step: number;
  57937. /**
  57938. * Gets a string describing the action executed by the current optimization
  57939. * @returns description string
  57940. */
  57941. getDescription(): string;
  57942. /**
  57943. * Creates the TextureOptimization object
  57944. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57945. * @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
  57946. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57947. */
  57948. constructor(
  57949. /**
  57950. * Defines the priority of this optimization (0 by default which means first in the list)
  57951. */
  57952. priority?: number,
  57953. /**
  57954. * 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
  57955. */
  57956. maximumSize?: number,
  57957. /**
  57958. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57959. */
  57960. step?: number);
  57961. /**
  57962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57963. * @param scene defines the current scene where to apply this optimization
  57964. * @param optimizer defines the current optimizer
  57965. * @returns true if everything that can be done was applied
  57966. */
  57967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57968. }
  57969. /**
  57970. * Defines an optimization used to increase or decrease the rendering resolution
  57971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57972. */
  57973. export class HardwareScalingOptimization extends SceneOptimization {
  57974. /**
  57975. * Defines the priority of this optimization (0 by default which means first in the list)
  57976. */
  57977. priority: number;
  57978. /**
  57979. * Defines the maximum scale to use (2 by default)
  57980. */
  57981. maximumScale: number;
  57982. /**
  57983. * Defines the step to use between two passes (0.5 by default)
  57984. */
  57985. step: number;
  57986. private _currentScale;
  57987. private _directionOffset;
  57988. /**
  57989. * Gets a string describing the action executed by the current optimization
  57990. * @return description string
  57991. */
  57992. getDescription(): string;
  57993. /**
  57994. * Creates the HardwareScalingOptimization object
  57995. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57996. * @param maximumScale defines the maximum scale to use (2 by default)
  57997. * @param step defines the step to use between two passes (0.5 by default)
  57998. */
  57999. constructor(
  58000. /**
  58001. * Defines the priority of this optimization (0 by default which means first in the list)
  58002. */
  58003. priority?: number,
  58004. /**
  58005. * Defines the maximum scale to use (2 by default)
  58006. */
  58007. maximumScale?: number,
  58008. /**
  58009. * Defines the step to use between two passes (0.5 by default)
  58010. */
  58011. step?: number);
  58012. /**
  58013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58014. * @param scene defines the current scene where to apply this optimization
  58015. * @param optimizer defines the current optimizer
  58016. * @returns true if everything that can be done was applied
  58017. */
  58018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58019. }
  58020. /**
  58021. * Defines an optimization used to remove shadows
  58022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58023. */
  58024. export class ShadowsOptimization extends SceneOptimization {
  58025. /**
  58026. * Gets a string describing the action executed by the current optimization
  58027. * @return description string
  58028. */
  58029. getDescription(): string;
  58030. /**
  58031. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58032. * @param scene defines the current scene where to apply this optimization
  58033. * @param optimizer defines the current optimizer
  58034. * @returns true if everything that can be done was applied
  58035. */
  58036. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58037. }
  58038. /**
  58039. * Defines an optimization used to turn post-processes off
  58040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58041. */
  58042. export class PostProcessesOptimization extends SceneOptimization {
  58043. /**
  58044. * Gets a string describing the action executed by the current optimization
  58045. * @return description string
  58046. */
  58047. getDescription(): string;
  58048. /**
  58049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58050. * @param scene defines the current scene where to apply this optimization
  58051. * @param optimizer defines the current optimizer
  58052. * @returns true if everything that can be done was applied
  58053. */
  58054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58055. }
  58056. /**
  58057. * Defines an optimization used to turn lens flares off
  58058. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58059. */
  58060. export class LensFlaresOptimization extends SceneOptimization {
  58061. /**
  58062. * Gets a string describing the action executed by the current optimization
  58063. * @return description string
  58064. */
  58065. getDescription(): string;
  58066. /**
  58067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58068. * @param scene defines the current scene where to apply this optimization
  58069. * @param optimizer defines the current optimizer
  58070. * @returns true if everything that can be done was applied
  58071. */
  58072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58073. }
  58074. /**
  58075. * Defines an optimization based on user defined callback.
  58076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58077. */
  58078. export class CustomOptimization extends SceneOptimization {
  58079. /**
  58080. * Callback called to apply the custom optimization.
  58081. */
  58082. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58083. /**
  58084. * Callback called to get custom description
  58085. */
  58086. onGetDescription: () => string;
  58087. /**
  58088. * Gets a string describing the action executed by the current optimization
  58089. * @returns description string
  58090. */
  58091. getDescription(): string;
  58092. /**
  58093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58094. * @param scene defines the current scene where to apply this optimization
  58095. * @param optimizer defines the current optimizer
  58096. * @returns true if everything that can be done was applied
  58097. */
  58098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58099. }
  58100. /**
  58101. * Defines an optimization used to turn particles off
  58102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58103. */
  58104. export class ParticlesOptimization extends SceneOptimization {
  58105. /**
  58106. * Gets a string describing the action executed by the current optimization
  58107. * @return description string
  58108. */
  58109. getDescription(): string;
  58110. /**
  58111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58112. * @param scene defines the current scene where to apply this optimization
  58113. * @param optimizer defines the current optimizer
  58114. * @returns true if everything that can be done was applied
  58115. */
  58116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58117. }
  58118. /**
  58119. * Defines an optimization used to turn render targets off
  58120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58121. */
  58122. export class RenderTargetsOptimization extends SceneOptimization {
  58123. /**
  58124. * Gets a string describing the action executed by the current optimization
  58125. * @return description string
  58126. */
  58127. getDescription(): string;
  58128. /**
  58129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58130. * @param scene defines the current scene where to apply this optimization
  58131. * @param optimizer defines the current optimizer
  58132. * @returns true if everything that can be done was applied
  58133. */
  58134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58135. }
  58136. /**
  58137. * Defines an optimization used to merge meshes with compatible materials
  58138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58139. */
  58140. export class MergeMeshesOptimization extends SceneOptimization {
  58141. private static _UpdateSelectionTree;
  58142. /**
  58143. * Gets or sets a boolean which defines if optimization octree has to be updated
  58144. */
  58145. /**
  58146. * Gets or sets a boolean which defines if optimization octree has to be updated
  58147. */
  58148. static UpdateSelectionTree: boolean;
  58149. /**
  58150. * Gets a string describing the action executed by the current optimization
  58151. * @return description string
  58152. */
  58153. getDescription(): string;
  58154. private _canBeMerged;
  58155. /**
  58156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58157. * @param scene defines the current scene where to apply this optimization
  58158. * @param optimizer defines the current optimizer
  58159. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58160. * @returns true if everything that can be done was applied
  58161. */
  58162. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58163. }
  58164. /**
  58165. * Defines a list of options used by SceneOptimizer
  58166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58167. */
  58168. export class SceneOptimizerOptions {
  58169. /**
  58170. * Defines the target frame rate to reach (60 by default)
  58171. */
  58172. targetFrameRate: number;
  58173. /**
  58174. * Defines the interval between two checkes (2000ms by default)
  58175. */
  58176. trackerDuration: number;
  58177. /**
  58178. * Gets the list of optimizations to apply
  58179. */
  58180. optimizations: SceneOptimization[];
  58181. /**
  58182. * Creates a new list of options used by SceneOptimizer
  58183. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58184. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58185. */
  58186. constructor(
  58187. /**
  58188. * Defines the target frame rate to reach (60 by default)
  58189. */
  58190. targetFrameRate?: number,
  58191. /**
  58192. * Defines the interval between two checkes (2000ms by default)
  58193. */
  58194. trackerDuration?: number);
  58195. /**
  58196. * Add a new optimization
  58197. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58198. * @returns the current SceneOptimizerOptions
  58199. */
  58200. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58201. /**
  58202. * Add a new custom optimization
  58203. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58204. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58205. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58206. * @returns the current SceneOptimizerOptions
  58207. */
  58208. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58209. /**
  58210. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58211. * @param targetFrameRate defines the target frame rate (60 by default)
  58212. * @returns a SceneOptimizerOptions object
  58213. */
  58214. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58215. /**
  58216. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58217. * @param targetFrameRate defines the target frame rate (60 by default)
  58218. * @returns a SceneOptimizerOptions object
  58219. */
  58220. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58221. /**
  58222. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58223. * @param targetFrameRate defines the target frame rate (60 by default)
  58224. * @returns a SceneOptimizerOptions object
  58225. */
  58226. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58227. }
  58228. /**
  58229. * Class used to run optimizations in order to reach a target frame rate
  58230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58231. */
  58232. export class SceneOptimizer implements IDisposable {
  58233. private _isRunning;
  58234. private _options;
  58235. private _scene;
  58236. private _currentPriorityLevel;
  58237. private _targetFrameRate;
  58238. private _trackerDuration;
  58239. private _currentFrameRate;
  58240. private _sceneDisposeObserver;
  58241. private _improvementMode;
  58242. /**
  58243. * Defines an observable called when the optimizer reaches the target frame rate
  58244. */
  58245. onSuccessObservable: Observable<SceneOptimizer>;
  58246. /**
  58247. * Defines an observable called when the optimizer enables an optimization
  58248. */
  58249. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58250. /**
  58251. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58252. */
  58253. onFailureObservable: Observable<SceneOptimizer>;
  58254. /**
  58255. * Gets a boolean indicating if the optimizer is in improvement mode
  58256. */
  58257. readonly isInImprovementMode: boolean;
  58258. /**
  58259. * Gets the current priority level (0 at start)
  58260. */
  58261. readonly currentPriorityLevel: number;
  58262. /**
  58263. * Gets the current frame rate checked by the SceneOptimizer
  58264. */
  58265. readonly currentFrameRate: number;
  58266. /**
  58267. * Gets or sets the current target frame rate (60 by default)
  58268. */
  58269. /**
  58270. * Gets or sets the current target frame rate (60 by default)
  58271. */
  58272. targetFrameRate: number;
  58273. /**
  58274. * Gets or sets the current interval between two checks (every 2000ms by default)
  58275. */
  58276. /**
  58277. * Gets or sets the current interval between two checks (every 2000ms by default)
  58278. */
  58279. trackerDuration: number;
  58280. /**
  58281. * Gets the list of active optimizations
  58282. */
  58283. readonly optimizations: SceneOptimization[];
  58284. /**
  58285. * Creates a new SceneOptimizer
  58286. * @param scene defines the scene to work on
  58287. * @param options defines the options to use with the SceneOptimizer
  58288. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58289. * @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)
  58290. */
  58291. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58292. /**
  58293. * Stops the current optimizer
  58294. */
  58295. stop(): void;
  58296. /**
  58297. * Reset the optimizer to initial step (current priority level = 0)
  58298. */
  58299. reset(): void;
  58300. /**
  58301. * Start the optimizer. By default it will try to reach a specific framerate
  58302. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58303. */
  58304. start(): void;
  58305. private _checkCurrentState;
  58306. /**
  58307. * Release all resources
  58308. */
  58309. dispose(): void;
  58310. /**
  58311. * Helper function to create a SceneOptimizer with one single line of code
  58312. * @param scene defines the scene to work on
  58313. * @param options defines the options to use with the SceneOptimizer
  58314. * @param onSuccess defines a callback to call on success
  58315. * @param onFailure defines a callback to call on failure
  58316. * @returns the new SceneOptimizer object
  58317. */
  58318. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58319. }
  58320. }
  58321. declare module BABYLON {
  58322. /**
  58323. * Class used to serialize a scene into a string
  58324. */
  58325. export class SceneSerializer {
  58326. /**
  58327. * Clear cache used by a previous serialization
  58328. */
  58329. static ClearCache(): void;
  58330. /**
  58331. * Serialize a scene into a JSON compatible object
  58332. * @param scene defines the scene to serialize
  58333. * @returns a JSON compatible object
  58334. */
  58335. static Serialize(scene: Scene): any;
  58336. /**
  58337. * Serialize a mesh into a JSON compatible object
  58338. * @param toSerialize defines the mesh to serialize
  58339. * @param withParents defines if parents must be serialized as well
  58340. * @param withChildren defines if children must be serialized as well
  58341. * @returns a JSON compatible object
  58342. */
  58343. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58344. }
  58345. }
  58346. declare module BABYLON {
  58347. /**
  58348. * Class used to host texture specific utilities
  58349. */
  58350. export class TextureTools {
  58351. /**
  58352. * Uses the GPU to create a copy texture rescaled at a given size
  58353. * @param texture Texture to copy from
  58354. * @param width defines the desired width
  58355. * @param height defines the desired height
  58356. * @param useBilinearMode defines if bilinear mode has to be used
  58357. * @return the generated texture
  58358. */
  58359. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58360. }
  58361. }
  58362. declare module BABYLON {
  58363. /**
  58364. * This represents the different options available for the video capture.
  58365. */
  58366. export interface VideoRecorderOptions {
  58367. /** Defines the mime type of the video. */
  58368. mimeType: string;
  58369. /** Defines the FPS the video should be recorded at. */
  58370. fps: number;
  58371. /** Defines the chunk size for the recording data. */
  58372. recordChunckSize: number;
  58373. /** The audio tracks to attach to the recording. */
  58374. audioTracks?: MediaStreamTrack[];
  58375. }
  58376. /**
  58377. * This can help with recording videos from BabylonJS.
  58378. * This is based on the available WebRTC functionalities of the browser.
  58379. *
  58380. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58381. */
  58382. export class VideoRecorder {
  58383. private static readonly _defaultOptions;
  58384. /**
  58385. * Returns whether or not the VideoRecorder is available in your browser.
  58386. * @param engine Defines the Babylon Engine.
  58387. * @returns true if supported otherwise false.
  58388. */
  58389. static IsSupported(engine: Engine): boolean;
  58390. private readonly _options;
  58391. private _canvas;
  58392. private _mediaRecorder;
  58393. private _recordedChunks;
  58394. private _fileName;
  58395. private _resolve;
  58396. private _reject;
  58397. /**
  58398. * True when a recording is already in progress.
  58399. */
  58400. readonly isRecording: boolean;
  58401. /**
  58402. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  58403. * @param engine Defines the BabylonJS Engine you wish to record.
  58404. * @param options Defines options that can be used to customize the capture.
  58405. */
  58406. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58407. /**
  58408. * Stops the current recording before the default capture timeout passed in the startRecording function.
  58409. */
  58410. stopRecording(): void;
  58411. /**
  58412. * Starts recording the canvas for a max duration specified in parameters.
  58413. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  58414. * If null no automatic download will start and you can rely on the promise to get the data back.
  58415. * @param maxDuration Defines the maximum recording time in seconds.
  58416. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58417. * @return A promise callback at the end of the recording with the video data in Blob.
  58418. */
  58419. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58420. /**
  58421. * Releases internal resources used during the recording.
  58422. */
  58423. dispose(): void;
  58424. private _handleDataAvailable;
  58425. private _handleError;
  58426. private _handleStop;
  58427. }
  58428. }
  58429. declare module BABYLON {
  58430. /**
  58431. * Class containing a set of static utilities functions for screenshots
  58432. */
  58433. export class ScreenshotTools {
  58434. /**
  58435. * Captures a screenshot of the current rendering
  58436. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58437. * @param engine defines the rendering engine
  58438. * @param camera defines the source camera
  58439. * @param size This parameter can be set to a single number or to an object with the
  58440. * following (optional) properties: precision, width, height. If a single number is passed,
  58441. * it will be used for both width and height. If an object is passed, the screenshot size
  58442. * will be derived from the parameters. The precision property is a multiplier allowing
  58443. * rendering at a higher or lower resolution
  58444. * @param successCallback defines the callback receives a single parameter which contains the
  58445. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58446. * src parameter of an <img> to display it
  58447. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58448. * Check your browser for supported MIME types
  58449. */
  58450. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58451. /**
  58452. * Generates an image screenshot from the specified camera.
  58453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58454. * @param engine The engine to use for rendering
  58455. * @param camera The camera to use for rendering
  58456. * @param size This parameter can be set to a single number or to an object with the
  58457. * following (optional) properties: precision, width, height. If a single number is passed,
  58458. * it will be used for both width and height. If an object is passed, the screenshot size
  58459. * will be derived from the parameters. The precision property is a multiplier allowing
  58460. * rendering at a higher or lower resolution
  58461. * @param successCallback The callback receives a single parameter which contains the
  58462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58463. * src parameter of an <img> to display it
  58464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58465. * Check your browser for supported MIME types
  58466. * @param samples Texture samples (default: 1)
  58467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58468. * @param fileName A name for for the downloaded file.
  58469. */
  58470. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58471. }
  58472. }
  58473. declare module BABYLON {
  58474. /**
  58475. * A cursor which tracks a point on a path
  58476. */
  58477. export class PathCursor {
  58478. private path;
  58479. /**
  58480. * Stores path cursor callbacks for when an onchange event is triggered
  58481. */
  58482. private _onchange;
  58483. /**
  58484. * The value of the path cursor
  58485. */
  58486. value: number;
  58487. /**
  58488. * The animation array of the path cursor
  58489. */
  58490. animations: Animation[];
  58491. /**
  58492. * Initializes the path cursor
  58493. * @param path The path to track
  58494. */
  58495. constructor(path: Path2);
  58496. /**
  58497. * Gets the cursor point on the path
  58498. * @returns A point on the path cursor at the cursor location
  58499. */
  58500. getPoint(): Vector3;
  58501. /**
  58502. * Moves the cursor ahead by the step amount
  58503. * @param step The amount to move the cursor forward
  58504. * @returns This path cursor
  58505. */
  58506. moveAhead(step?: number): PathCursor;
  58507. /**
  58508. * Moves the cursor behind by the step amount
  58509. * @param step The amount to move the cursor back
  58510. * @returns This path cursor
  58511. */
  58512. moveBack(step?: number): PathCursor;
  58513. /**
  58514. * Moves the cursor by the step amount
  58515. * If the step amount is greater than one, an exception is thrown
  58516. * @param step The amount to move the cursor
  58517. * @returns This path cursor
  58518. */
  58519. move(step: number): PathCursor;
  58520. /**
  58521. * Ensures that the value is limited between zero and one
  58522. * @returns This path cursor
  58523. */
  58524. private ensureLimits;
  58525. /**
  58526. * Runs onchange callbacks on change (used by the animation engine)
  58527. * @returns This path cursor
  58528. */
  58529. private raiseOnChange;
  58530. /**
  58531. * Executes a function on change
  58532. * @param f A path cursor onchange callback
  58533. * @returns This path cursor
  58534. */
  58535. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58536. }
  58537. }
  58538. declare module BABYLON {
  58539. /** @hidden */
  58540. export var blurPixelShader: {
  58541. name: string;
  58542. shader: string;
  58543. };
  58544. }
  58545. declare module BABYLON {
  58546. /** @hidden */
  58547. export var pointCloudVertexDeclaration: {
  58548. name: string;
  58549. shader: string;
  58550. };
  58551. }
  58552. // Mixins
  58553. interface Window {
  58554. mozIndexedDB: IDBFactory;
  58555. webkitIndexedDB: IDBFactory;
  58556. msIndexedDB: IDBFactory;
  58557. webkitURL: typeof URL;
  58558. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58559. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58560. WebGLRenderingContext: WebGLRenderingContext;
  58561. MSGesture: MSGesture;
  58562. CANNON: any;
  58563. AudioContext: AudioContext;
  58564. webkitAudioContext: AudioContext;
  58565. PointerEvent: any;
  58566. Math: Math;
  58567. Uint8Array: Uint8ArrayConstructor;
  58568. Float32Array: Float32ArrayConstructor;
  58569. mozURL: typeof URL;
  58570. msURL: typeof URL;
  58571. VRFrameData: any; // WebVR, from specs 1.1
  58572. DracoDecoderModule: any;
  58573. setImmediate(handler: (...args: any[]) => void): number;
  58574. }
  58575. interface HTMLCanvasElement {
  58576. requestPointerLock(): void;
  58577. msRequestPointerLock?(): void;
  58578. mozRequestPointerLock?(): void;
  58579. webkitRequestPointerLock?(): void;
  58580. /** Track wether a record is in progress */
  58581. isRecording: boolean;
  58582. /** Capture Stream method defined by some browsers */
  58583. captureStream(fps?: number): MediaStream;
  58584. }
  58585. interface CanvasRenderingContext2D {
  58586. msImageSmoothingEnabled: boolean;
  58587. }
  58588. interface MouseEvent {
  58589. mozMovementX: number;
  58590. mozMovementY: number;
  58591. webkitMovementX: number;
  58592. webkitMovementY: number;
  58593. msMovementX: number;
  58594. msMovementY: number;
  58595. }
  58596. interface Navigator {
  58597. mozGetVRDevices: (any: any) => any;
  58598. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58599. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58600. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58601. webkitGetGamepads(): Gamepad[];
  58602. msGetGamepads(): Gamepad[];
  58603. webkitGamepads(): Gamepad[];
  58604. }
  58605. interface HTMLVideoElement {
  58606. mozSrcObject: any;
  58607. }
  58608. interface Math {
  58609. fround(x: number): number;
  58610. imul(a: number, b: number): number;
  58611. }
  58612. interface WebGLRenderingContext {
  58613. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58614. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58615. vertexAttribDivisor(index: number, divisor: number): void;
  58616. createVertexArray(): any;
  58617. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58618. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58619. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58620. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58621. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58622. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58623. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58624. // Queries
  58625. createQuery(): WebGLQuery;
  58626. deleteQuery(query: WebGLQuery): void;
  58627. beginQuery(target: number, query: WebGLQuery): void;
  58628. endQuery(target: number): void;
  58629. getQueryParameter(query: WebGLQuery, pname: number): any;
  58630. getQuery(target: number, pname: number): any;
  58631. MAX_SAMPLES: number;
  58632. RGBA8: number;
  58633. READ_FRAMEBUFFER: number;
  58634. DRAW_FRAMEBUFFER: number;
  58635. UNIFORM_BUFFER: number;
  58636. HALF_FLOAT_OES: number;
  58637. RGBA16F: number;
  58638. RGBA32F: number;
  58639. R32F: number;
  58640. RG32F: number;
  58641. RGB32F: number;
  58642. R16F: number;
  58643. RG16F: number;
  58644. RGB16F: number;
  58645. RED: number;
  58646. RG: number;
  58647. R8: number;
  58648. RG8: number;
  58649. UNSIGNED_INT_24_8: number;
  58650. DEPTH24_STENCIL8: number;
  58651. /* Multiple Render Targets */
  58652. drawBuffers(buffers: number[]): void;
  58653. readBuffer(src: number): void;
  58654. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58655. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58656. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58657. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58658. // Occlusion Query
  58659. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58660. ANY_SAMPLES_PASSED: number;
  58661. QUERY_RESULT_AVAILABLE: number;
  58662. QUERY_RESULT: number;
  58663. }
  58664. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58665. }
  58666. interface EXT_disjoint_timer_query {
  58667. QUERY_COUNTER_BITS_EXT: number;
  58668. TIME_ELAPSED_EXT: number;
  58669. TIMESTAMP_EXT: number;
  58670. GPU_DISJOINT_EXT: number;
  58671. QUERY_RESULT_EXT: number;
  58672. QUERY_RESULT_AVAILABLE_EXT: number;
  58673. queryCounterEXT(query: WebGLQuery, target: number): void;
  58674. createQueryEXT(): WebGLQuery;
  58675. beginQueryEXT(target: number, query: WebGLQuery): void;
  58676. endQueryEXT(target: number): void;
  58677. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58678. deleteQueryEXT(query: WebGLQuery): void;
  58679. }
  58680. interface WebGLUniformLocation { private _currentState: any;
  58681. }
  58682. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58683. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58684. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58685. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58686. interface WebGLRenderingContext {
  58687. readonly RASTERIZER_DISCARD: number;
  58688. readonly DEPTH_COMPONENT24: number;
  58689. readonly TEXTURE_3D: number;
  58690. readonly TEXTURE_2D_ARRAY: number;
  58691. readonly TEXTURE_COMPARE_FUNC: number;
  58692. readonly TEXTURE_COMPARE_MODE: number;
  58693. readonly COMPARE_REF_TO_TEXTURE: number;
  58694. readonly TEXTURE_WRAP_R: number;
  58695. readonly HALF_FLOAT: number;
  58696. readonly RGB8: number;
  58697. readonly RED_INTEGER: number;
  58698. readonly RG_INTEGER: number;
  58699. readonly RGB_INTEGER: number;
  58700. readonly RGBA_INTEGER: number;
  58701. readonly R8_SNORM: number;
  58702. readonly RG8_SNORM: number;
  58703. readonly RGB8_SNORM: number;
  58704. readonly RGBA8_SNORM: number;
  58705. readonly R8I: number;
  58706. readonly RG8I: number;
  58707. readonly RGB8I: number;
  58708. readonly RGBA8I: number;
  58709. readonly R8UI: number;
  58710. readonly RG8UI: number;
  58711. readonly RGB8UI: number;
  58712. readonly RGBA8UI: number;
  58713. readonly R16I: number;
  58714. readonly RG16I: number;
  58715. readonly RGB16I: number;
  58716. readonly RGBA16I: number;
  58717. readonly R16UI: number;
  58718. readonly RG16UI: number;
  58719. readonly RGB16UI: number;
  58720. readonly RGBA16UI: number;
  58721. readonly R32I: number;
  58722. readonly RG32I: number;
  58723. readonly RGB32I: number;
  58724. readonly RGBA32I: number;
  58725. readonly R32UI: number;
  58726. readonly RG32UI: number;
  58727. readonly RGB32UI: number;
  58728. readonly RGBA32UI: number;
  58729. readonly RGB10_A2UI: number;
  58730. readonly R11F_G11F_B10F: number;
  58731. readonly RGB9_E5: number;
  58732. readonly RGB10_A2: number;
  58733. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58734. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58735. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58736. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58737. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58738. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58739. 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;
  58740. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58741. readonly TRANSFORM_FEEDBACK: number;
  58742. readonly INTERLEAVED_ATTRIBS: number;
  58743. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58744. createTransformFeedback(): WebGLTransformFeedback;
  58745. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58746. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58747. beginTransformFeedback(primitiveMode: number): void;
  58748. endTransformFeedback(): void;
  58749. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58750. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58751. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58752. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58753. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58754. }
  58755. interface ImageBitmap {
  58756. readonly width: number;
  58757. readonly height: number;
  58758. close(): void;
  58759. }
  58760. interface WebGLQuery extends WebGLObject {
  58761. }
  58762. declare var WebGLQuery: {
  58763. prototype: WebGLQuery;
  58764. new(): WebGLQuery;
  58765. };
  58766. interface WebGLSampler extends WebGLObject {
  58767. }
  58768. declare var WebGLSampler: {
  58769. prototype: WebGLSampler;
  58770. new(): WebGLSampler;
  58771. };
  58772. interface WebGLSync extends WebGLObject {
  58773. }
  58774. declare var WebGLSync: {
  58775. prototype: WebGLSync;
  58776. new(): WebGLSync;
  58777. };
  58778. interface WebGLTransformFeedback extends WebGLObject {
  58779. }
  58780. declare var WebGLTransformFeedback: {
  58781. prototype: WebGLTransformFeedback;
  58782. new(): WebGLTransformFeedback;
  58783. };
  58784. interface WebGLVertexArrayObject extends WebGLObject {
  58785. }
  58786. declare var WebGLVertexArrayObject: {
  58787. prototype: WebGLVertexArrayObject;
  58788. new(): WebGLVertexArrayObject;
  58789. };
  58790. // Type definitions for WebVR API
  58791. // Project: https://w3c.github.io/webvr/
  58792. // Definitions by: six a <https://github.com/lostfictions>
  58793. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58794. interface VRDisplay extends EventTarget {
  58795. /**
  58796. * Dictionary of capabilities describing the VRDisplay.
  58797. */
  58798. readonly capabilities: VRDisplayCapabilities;
  58799. /**
  58800. * z-depth defining the far plane of the eye view frustum
  58801. * enables mapping of values in the render target depth
  58802. * attachment to scene coordinates. Initially set to 10000.0.
  58803. */
  58804. depthFar: number;
  58805. /**
  58806. * z-depth defining the near plane of the eye view frustum
  58807. * enables mapping of values in the render target depth
  58808. * attachment to scene coordinates. Initially set to 0.01.
  58809. */
  58810. depthNear: number;
  58811. /**
  58812. * An identifier for this distinct VRDisplay. Used as an
  58813. * association point in the Gamepad API.
  58814. */
  58815. readonly displayId: number;
  58816. /**
  58817. * A display name, a user-readable name identifying it.
  58818. */
  58819. readonly displayName: string;
  58820. readonly isConnected: boolean;
  58821. readonly isPresenting: boolean;
  58822. /**
  58823. * If this VRDisplay supports room-scale experiences, the optional
  58824. * stage attribute contains details on the room-scale parameters.
  58825. */
  58826. readonly stageParameters: VRStageParameters | null;
  58827. /**
  58828. * Passing the value returned by `requestAnimationFrame` to
  58829. * `cancelAnimationFrame` will unregister the callback.
  58830. * @param handle Define the hanle of the request to cancel
  58831. */
  58832. cancelAnimationFrame(handle: number): void;
  58833. /**
  58834. * Stops presenting to the VRDisplay.
  58835. * @returns a promise to know when it stopped
  58836. */
  58837. exitPresent(): Promise<void>;
  58838. /**
  58839. * Return the current VREyeParameters for the given eye.
  58840. * @param whichEye Define the eye we want the parameter for
  58841. * @returns the eye parameters
  58842. */
  58843. getEyeParameters(whichEye: string): VREyeParameters;
  58844. /**
  58845. * Populates the passed VRFrameData with the information required to render
  58846. * the current frame.
  58847. * @param frameData Define the data structure to populate
  58848. * @returns true if ok otherwise false
  58849. */
  58850. getFrameData(frameData: VRFrameData): boolean;
  58851. /**
  58852. * Get the layers currently being presented.
  58853. * @returns the list of VR layers
  58854. */
  58855. getLayers(): VRLayer[];
  58856. /**
  58857. * Return a VRPose containing the future predicted pose of the VRDisplay
  58858. * when the current frame will be presented. The value returned will not
  58859. * change until JavaScript has returned control to the browser.
  58860. *
  58861. * The VRPose will contain the position, orientation, velocity,
  58862. * and acceleration of each of these properties.
  58863. * @returns the pose object
  58864. */
  58865. getPose(): VRPose;
  58866. /**
  58867. * Return the current instantaneous pose of the VRDisplay, with no
  58868. * prediction applied.
  58869. * @returns the current instantaneous pose
  58870. */
  58871. getImmediatePose(): VRPose;
  58872. /**
  58873. * The callback passed to `requestAnimationFrame` will be called
  58874. * any time a new frame should be rendered. When the VRDisplay is
  58875. * presenting the callback will be called at the native refresh
  58876. * rate of the HMD. When not presenting this function acts
  58877. * identically to how window.requestAnimationFrame acts. Content should
  58878. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58879. * asynchronously from other displays and at differing refresh rates.
  58880. * @param callback Define the eaction to run next frame
  58881. * @returns the request handle it
  58882. */
  58883. requestAnimationFrame(callback: FrameRequestCallback): number;
  58884. /**
  58885. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58886. * Repeat calls while already presenting will update the VRLayers being displayed.
  58887. * @param layers Define the list of layer to present
  58888. * @returns a promise to know when the request has been fulfilled
  58889. */
  58890. requestPresent(layers: VRLayer[]): Promise<void>;
  58891. /**
  58892. * Reset the pose for this display, treating its current position and
  58893. * orientation as the "origin/zero" values. VRPose.position,
  58894. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58895. * updated when calling resetPose(). This should be called in only
  58896. * sitting-space experiences.
  58897. */
  58898. resetPose(): void;
  58899. /**
  58900. * The VRLayer provided to the VRDisplay will be captured and presented
  58901. * in the HMD. Calling this function has the same effect on the source
  58902. * canvas as any other operation that uses its source image, and canvases
  58903. * created without preserveDrawingBuffer set to true will be cleared.
  58904. * @param pose Define the pose to submit
  58905. */
  58906. submitFrame(pose?: VRPose): void;
  58907. }
  58908. declare var VRDisplay: {
  58909. prototype: VRDisplay;
  58910. new(): VRDisplay;
  58911. };
  58912. interface VRLayer {
  58913. leftBounds?: number[] | Float32Array | null;
  58914. rightBounds?: number[] | Float32Array | null;
  58915. source?: HTMLCanvasElement | null;
  58916. }
  58917. interface VRDisplayCapabilities {
  58918. readonly canPresent: boolean;
  58919. readonly hasExternalDisplay: boolean;
  58920. readonly hasOrientation: boolean;
  58921. readonly hasPosition: boolean;
  58922. readonly maxLayers: number;
  58923. }
  58924. interface VREyeParameters {
  58925. /** @deprecated */
  58926. readonly fieldOfView: VRFieldOfView;
  58927. readonly offset: Float32Array;
  58928. readonly renderHeight: number;
  58929. readonly renderWidth: number;
  58930. }
  58931. interface VRFieldOfView {
  58932. readonly downDegrees: number;
  58933. readonly leftDegrees: number;
  58934. readonly rightDegrees: number;
  58935. readonly upDegrees: number;
  58936. }
  58937. interface VRFrameData {
  58938. readonly leftProjectionMatrix: Float32Array;
  58939. readonly leftViewMatrix: Float32Array;
  58940. readonly pose: VRPose;
  58941. readonly rightProjectionMatrix: Float32Array;
  58942. readonly rightViewMatrix: Float32Array;
  58943. readonly timestamp: number;
  58944. }
  58945. interface VRPose {
  58946. readonly angularAcceleration: Float32Array | null;
  58947. readonly angularVelocity: Float32Array | null;
  58948. readonly linearAcceleration: Float32Array | null;
  58949. readonly linearVelocity: Float32Array | null;
  58950. readonly orientation: Float32Array | null;
  58951. readonly position: Float32Array | null;
  58952. readonly timestamp: number;
  58953. }
  58954. interface VRStageParameters {
  58955. sittingToStandingTransform?: Float32Array;
  58956. sizeX?: number;
  58957. sizeY?: number;
  58958. }
  58959. interface Navigator {
  58960. getVRDisplays(): Promise<VRDisplay[]>;
  58961. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58962. }
  58963. interface Window {
  58964. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58965. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58966. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58967. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58968. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58969. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58970. }
  58971. interface Gamepad {
  58972. readonly displayId: number;
  58973. }
  58974. interface XRDevice {
  58975. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58976. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58977. }
  58978. interface XRSession {
  58979. getInputSources(): Array<any>;
  58980. baseLayer: XRWebGLLayer;
  58981. requestFrameOfReference(type: string): Promise<void>;
  58982. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58983. end(): Promise<void>;
  58984. requestAnimationFrame: Function;
  58985. addEventListener: Function;
  58986. }
  58987. interface XRSessionCreationOptions {
  58988. outputContext?: WebGLRenderingContext | null;
  58989. immersive?: boolean;
  58990. environmentIntegration?: boolean;
  58991. }
  58992. interface XRLayer {
  58993. getViewport: Function;
  58994. framebufferWidth: number;
  58995. framebufferHeight: number;
  58996. }
  58997. interface XRView {
  58998. projectionMatrix: Float32Array;
  58999. }
  59000. interface XRFrame {
  59001. getDevicePose: Function;
  59002. getInputPose: Function;
  59003. views: Array<XRView>;
  59004. baseLayer: XRLayer;
  59005. }
  59006. interface XRFrameOfReference {
  59007. }
  59008. interface XRWebGLLayer extends XRLayer {
  59009. framebuffer: WebGLFramebuffer;
  59010. }
  59011. declare var XRWebGLLayer: {
  59012. prototype: XRWebGLLayer;
  59013. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59014. };
  59015. declare module BABYLON.GUI {
  59016. /**
  59017. * Class used to specific a value and its associated unit
  59018. */
  59019. export class ValueAndUnit {
  59020. /** defines the unit to store */
  59021. unit: number;
  59022. /** defines a boolean indicating if the value can be negative */
  59023. negativeValueAllowed: boolean;
  59024. private _value;
  59025. private _originalUnit;
  59026. /**
  59027. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59028. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59029. */
  59030. ignoreAdaptiveScaling: boolean;
  59031. /**
  59032. * Creates a new ValueAndUnit
  59033. * @param value defines the value to store
  59034. * @param unit defines the unit to store
  59035. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59036. */
  59037. constructor(value: number,
  59038. /** defines the unit to store */
  59039. unit?: number,
  59040. /** defines a boolean indicating if the value can be negative */
  59041. negativeValueAllowed?: boolean);
  59042. /** Gets a boolean indicating if the value is a percentage */
  59043. readonly isPercentage: boolean;
  59044. /** Gets a boolean indicating if the value is store as pixel */
  59045. readonly isPixel: boolean;
  59046. /** Gets direct internal value */
  59047. readonly internalValue: number;
  59048. /**
  59049. * Gets value as pixel
  59050. * @param host defines the root host
  59051. * @param refValue defines the reference value for percentages
  59052. * @returns the value as pixel
  59053. */
  59054. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59055. /**
  59056. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59057. * @param value defines the value to store
  59058. * @param unit defines the unit to store
  59059. * @returns the current ValueAndUnit
  59060. */
  59061. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59062. /**
  59063. * Gets the value accordingly to its unit
  59064. * @param host defines the root host
  59065. * @returns the value
  59066. */
  59067. getValue(host: AdvancedDynamicTexture): number;
  59068. /**
  59069. * Gets a string representation of the value
  59070. * @param host defines the root host
  59071. * @param decimals defines an optional number of decimals to display
  59072. * @returns a string
  59073. */
  59074. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59075. /**
  59076. * Store a value parsed from a string
  59077. * @param source defines the source string
  59078. * @returns true if the value was successfully parsed
  59079. */
  59080. fromString(source: string | number): boolean;
  59081. private static _Regex;
  59082. private static _UNITMODE_PERCENTAGE;
  59083. private static _UNITMODE_PIXEL;
  59084. /** UNITMODE_PERCENTAGE */
  59085. static readonly UNITMODE_PERCENTAGE: number;
  59086. /** UNITMODE_PIXEL */
  59087. static readonly UNITMODE_PIXEL: number;
  59088. }
  59089. }
  59090. declare module BABYLON.GUI {
  59091. /**
  59092. * Define a style used by control to automatically setup properties based on a template.
  59093. * Only support font related properties so far
  59094. */
  59095. export class Style implements BABYLON.IDisposable {
  59096. private _fontFamily;
  59097. private _fontStyle;
  59098. private _fontWeight;
  59099. /** @hidden */ private _host: AdvancedDynamicTexture;
  59100. /** @hidden */ private _fontSize: ValueAndUnit;
  59101. /**
  59102. * BABYLON.Observable raised when the style values are changed
  59103. */
  59104. onChangedObservable: BABYLON.Observable<Style>;
  59105. /**
  59106. * Creates a new style object
  59107. * @param host defines the AdvancedDynamicTexture which hosts this style
  59108. */
  59109. constructor(host: AdvancedDynamicTexture);
  59110. /**
  59111. * Gets or sets the font size
  59112. */
  59113. fontSize: string | number;
  59114. /**
  59115. * Gets or sets the font family
  59116. */
  59117. fontFamily: string;
  59118. /**
  59119. * Gets or sets the font style
  59120. */
  59121. fontStyle: string;
  59122. /** Gets or sets font weight */
  59123. fontWeight: string;
  59124. /** Dispose all associated resources */
  59125. dispose(): void;
  59126. }
  59127. }
  59128. declare module BABYLON.GUI {
  59129. /**
  59130. * Class used to transport BABYLON.Vector2 information for pointer events
  59131. */
  59132. export class Vector2WithInfo extends BABYLON.Vector2 {
  59133. /** defines the current mouse button index */
  59134. buttonIndex: number;
  59135. /**
  59136. * Creates a new Vector2WithInfo
  59137. * @param source defines the vector2 data to transport
  59138. * @param buttonIndex defines the current mouse button index
  59139. */
  59140. constructor(source: BABYLON.Vector2,
  59141. /** defines the current mouse button index */
  59142. buttonIndex?: number);
  59143. }
  59144. /** Class used to provide 2D matrix features */
  59145. export class Matrix2D {
  59146. /** Gets the internal array of 6 floats used to store matrix data */
  59147. m: Float32Array;
  59148. /**
  59149. * Creates a new matrix
  59150. * @param m00 defines value for (0, 0)
  59151. * @param m01 defines value for (0, 1)
  59152. * @param m10 defines value for (1, 0)
  59153. * @param m11 defines value for (1, 1)
  59154. * @param m20 defines value for (2, 0)
  59155. * @param m21 defines value for (2, 1)
  59156. */
  59157. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59158. /**
  59159. * Fills the matrix from direct values
  59160. * @param m00 defines value for (0, 0)
  59161. * @param m01 defines value for (0, 1)
  59162. * @param m10 defines value for (1, 0)
  59163. * @param m11 defines value for (1, 1)
  59164. * @param m20 defines value for (2, 0)
  59165. * @param m21 defines value for (2, 1)
  59166. * @returns the current modified matrix
  59167. */
  59168. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59169. /**
  59170. * Gets matrix determinant
  59171. * @returns the determinant
  59172. */
  59173. determinant(): number;
  59174. /**
  59175. * Inverses the matrix and stores it in a target matrix
  59176. * @param result defines the target matrix
  59177. * @returns the current matrix
  59178. */
  59179. invertToRef(result: Matrix2D): Matrix2D;
  59180. /**
  59181. * Multiplies the current matrix with another one
  59182. * @param other defines the second operand
  59183. * @param result defines the target matrix
  59184. * @returns the current matrix
  59185. */
  59186. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59187. /**
  59188. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59189. * @param x defines the x coordinate to transform
  59190. * @param y defines the x coordinate to transform
  59191. * @param result defines the target vector2
  59192. * @returns the current matrix
  59193. */
  59194. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59195. /**
  59196. * Creates an identity matrix
  59197. * @returns a new matrix
  59198. */
  59199. static Identity(): Matrix2D;
  59200. /**
  59201. * Creates a translation matrix and stores it in a target matrix
  59202. * @param x defines the x coordinate of the translation
  59203. * @param y defines the y coordinate of the translation
  59204. * @param result defines the target matrix
  59205. */
  59206. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59207. /**
  59208. * Creates a scaling matrix and stores it in a target matrix
  59209. * @param x defines the x coordinate of the scaling
  59210. * @param y defines the y coordinate of the scaling
  59211. * @param result defines the target matrix
  59212. */
  59213. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59214. /**
  59215. * Creates a rotation matrix and stores it in a target matrix
  59216. * @param angle defines the rotation angle
  59217. * @param result defines the target matrix
  59218. */
  59219. static RotationToRef(angle: number, result: Matrix2D): void;
  59220. private static _TempPreTranslationMatrix;
  59221. private static _TempPostTranslationMatrix;
  59222. private static _TempRotationMatrix;
  59223. private static _TempScalingMatrix;
  59224. private static _TempCompose0;
  59225. private static _TempCompose1;
  59226. private static _TempCompose2;
  59227. /**
  59228. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59229. * @param tx defines the x coordinate of the translation
  59230. * @param ty defines the y coordinate of the translation
  59231. * @param angle defines the rotation angle
  59232. * @param scaleX defines the x coordinate of the scaling
  59233. * @param scaleY defines the y coordinate of the scaling
  59234. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59235. * @param result defines the target matrix
  59236. */
  59237. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59238. }
  59239. }
  59240. declare module BABYLON.GUI {
  59241. /**
  59242. * Class used to store 2D control sizes
  59243. */
  59244. export class Measure {
  59245. /** defines left coordinate */
  59246. left: number;
  59247. /** defines top coordinate */
  59248. top: number;
  59249. /** defines width dimension */
  59250. width: number;
  59251. /** defines height dimension */
  59252. height: number;
  59253. /**
  59254. * Creates a new measure
  59255. * @param left defines left coordinate
  59256. * @param top defines top coordinate
  59257. * @param width defines width dimension
  59258. * @param height defines height dimension
  59259. */
  59260. constructor(
  59261. /** defines left coordinate */
  59262. left: number,
  59263. /** defines top coordinate */
  59264. top: number,
  59265. /** defines width dimension */
  59266. width: number,
  59267. /** defines height dimension */
  59268. height: number);
  59269. /**
  59270. * Copy from another measure
  59271. * @param other defines the other measure to copy from
  59272. */
  59273. copyFrom(other: Measure): void;
  59274. /**
  59275. * Copy from a group of 4 floats
  59276. * @param left defines left coordinate
  59277. * @param top defines top coordinate
  59278. * @param width defines width dimension
  59279. * @param height defines height dimension
  59280. */
  59281. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59282. /**
  59283. * Computes the axis aligned bounding box measure for two given measures
  59284. * @param a Input measure
  59285. * @param b Input measure
  59286. * @param result the resulting bounding measure
  59287. */
  59288. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59289. /**
  59290. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59291. * @param transform the matrix to transform the measure before computing the AABB
  59292. * @param result the resulting AABB
  59293. */
  59294. transformToRef(transform: Matrix2D, result: Measure): void;
  59295. /**
  59296. * Check equality between this measure and another one
  59297. * @param other defines the other measures
  59298. * @returns true if both measures are equals
  59299. */
  59300. isEqualsTo(other: Measure): boolean;
  59301. /**
  59302. * Creates an empty measure
  59303. * @returns a new measure
  59304. */
  59305. static Empty(): Measure;
  59306. }
  59307. }
  59308. declare module BABYLON.GUI {
  59309. /**
  59310. * Interface used to define a control that can receive focus
  59311. */
  59312. export interface IFocusableControl {
  59313. /**
  59314. * Function called when the control receives the focus
  59315. */
  59316. onFocus(): void;
  59317. /**
  59318. * Function called when the control loses the focus
  59319. */
  59320. onBlur(): void;
  59321. /**
  59322. * Function called to let the control handle keyboard events
  59323. * @param evt defines the current keyboard event
  59324. */
  59325. processKeyboard(evt: KeyboardEvent): void;
  59326. /**
  59327. * Function called to get the list of controls that should not steal the focus from this control
  59328. * @returns an array of controls
  59329. */
  59330. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59331. }
  59332. /**
  59333. * Class used to create texture to support 2D GUI elements
  59334. * @see http://doc.babylonjs.com/how_to/gui
  59335. */
  59336. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59337. private _isDirty;
  59338. private _renderObserver;
  59339. private _resizeObserver;
  59340. private _preKeyboardObserver;
  59341. private _pointerMoveObserver;
  59342. private _pointerObserver;
  59343. private _canvasPointerOutObserver;
  59344. private _background;
  59345. /** @hidden */ private _rootContainer: Container;
  59346. /** @hidden */ private _lastPickedControl: Control;
  59347. /** @hidden */ private _lastControlOver: {
  59348. [pointerId: number]: Control;
  59349. };
  59350. /** @hidden */ private _lastControlDown: {
  59351. [pointerId: number]: Control;
  59352. };
  59353. /** @hidden */ private _capturingControl: {
  59354. [pointerId: number]: Control;
  59355. };
  59356. /** @hidden */ private _shouldBlockPointer: boolean;
  59357. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59358. /** @hidden */ private _linkedControls: Control[];
  59359. private _isFullscreen;
  59360. private _fullscreenViewport;
  59361. private _idealWidth;
  59362. private _idealHeight;
  59363. private _useSmallestIdeal;
  59364. private _renderAtIdealSize;
  59365. private _focusedControl;
  59366. private _blockNextFocusCheck;
  59367. private _renderScale;
  59368. private _rootCanvas;
  59369. private _cursorChanged;
  59370. /**
  59371. * Define type to string to ensure compatibility across browsers
  59372. * Safari doesn't support DataTransfer constructor
  59373. */
  59374. private _clipboardData;
  59375. /**
  59376. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59377. */
  59378. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59379. /**
  59380. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59381. */
  59382. onControlPickedObservable: BABYLON.Observable<Control>;
  59383. /**
  59384. * BABYLON.Observable event triggered before layout is evaluated
  59385. */
  59386. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59387. /**
  59388. * BABYLON.Observable event triggered after the layout was evaluated
  59389. */
  59390. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59391. /**
  59392. * BABYLON.Observable event triggered before the texture is rendered
  59393. */
  59394. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59395. /**
  59396. * BABYLON.Observable event triggered after the texture was rendered
  59397. */
  59398. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59399. /**
  59400. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59401. */
  59402. premulAlpha: boolean;
  59403. /**
  59404. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59405. * Useful when you want more antialiasing
  59406. */
  59407. renderScale: number;
  59408. /** Gets or sets the background color */
  59409. background: string;
  59410. /**
  59411. * Gets or sets the ideal width used to design controls.
  59412. * The GUI will then rescale everything accordingly
  59413. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59414. */
  59415. idealWidth: number;
  59416. /**
  59417. * Gets or sets the ideal height used to design controls.
  59418. * The GUI will then rescale everything accordingly
  59419. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59420. */
  59421. idealHeight: number;
  59422. /**
  59423. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59424. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59425. */
  59426. useSmallestIdeal: boolean;
  59427. /**
  59428. * Gets or sets a boolean indicating if adaptive scaling must be used
  59429. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59430. */
  59431. renderAtIdealSize: boolean;
  59432. /**
  59433. * Gets the underlying layer used to render the texture when in fullscreen mode
  59434. */
  59435. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59436. /**
  59437. * Gets the root container control
  59438. */
  59439. readonly rootContainer: Container;
  59440. /**
  59441. * Returns an array containing the root container.
  59442. * This is mostly used to let the Inspector introspects the ADT
  59443. * @returns an array containing the rootContainer
  59444. */
  59445. getChildren(): Array<Container>;
  59446. /**
  59447. * Will return all controls that are inside this texture
  59448. * @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
  59449. * @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
  59450. * @return all child controls
  59451. */
  59452. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59453. /**
  59454. * Gets or sets the current focused control
  59455. */
  59456. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59457. /**
  59458. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59459. */
  59460. isForeground: boolean;
  59461. /**
  59462. * Gets or set information about clipboardData
  59463. */
  59464. clipboardData: string;
  59465. /**
  59466. * Creates a new AdvancedDynamicTexture
  59467. * @param name defines the name of the texture
  59468. * @param width defines the width of the texture
  59469. * @param height defines the height of the texture
  59470. * @param scene defines the hosting scene
  59471. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59472. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59473. */
  59474. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59475. /**
  59476. * Get the current class name of the texture useful for serialization or dynamic coding.
  59477. * @returns "AdvancedDynamicTexture"
  59478. */
  59479. getClassName(): string;
  59480. /**
  59481. * Function used to execute a function on all controls
  59482. * @param func defines the function to execute
  59483. * @param container defines the container where controls belong. If null the root container will be used
  59484. */
  59485. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59486. private _useInvalidateRectOptimization;
  59487. /**
  59488. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59489. */
  59490. useInvalidateRectOptimization: boolean;
  59491. private _invalidatedRectangle;
  59492. /**
  59493. * Invalidates a rectangle area on the gui texture
  59494. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59495. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59496. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59497. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59498. */
  59499. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59500. /**
  59501. * Marks the texture as dirty forcing a complete update
  59502. */
  59503. markAsDirty(): void;
  59504. /**
  59505. * Helper function used to create a new style
  59506. * @returns a new style
  59507. * @see http://doc.babylonjs.com/how_to/gui#styles
  59508. */
  59509. createStyle(): Style;
  59510. /**
  59511. * Adds a new control to the root container
  59512. * @param control defines the control to add
  59513. * @returns the current texture
  59514. */
  59515. addControl(control: Control): AdvancedDynamicTexture;
  59516. /**
  59517. * Removes a control from the root container
  59518. * @param control defines the control to remove
  59519. * @returns the current texture
  59520. */
  59521. removeControl(control: Control): AdvancedDynamicTexture;
  59522. /**
  59523. * Release all resources
  59524. */
  59525. dispose(): void;
  59526. private _onResize;
  59527. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59528. /**
  59529. * Get screen coordinates for a vector3
  59530. * @param position defines the position to project
  59531. * @param worldMatrix defines the world matrix to use
  59532. * @returns the projected position
  59533. */
  59534. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59535. private _checkUpdate;
  59536. private _clearMeasure;
  59537. private _render;
  59538. /** @hidden */ private _changeCursor(cursor: string): void;
  59539. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  59540. private _doPicking;
  59541. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  59542. [pointerId: number]: Control;
  59543. }, control: Control): void;
  59544. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  59545. /** Attach to all scene events required to support pointer events */
  59546. attach(): void;
  59547. /** @hidden */
  59548. private onClipboardCopy;
  59549. /** @hidden */
  59550. private onClipboardCut;
  59551. /** @hidden */
  59552. private onClipboardPaste;
  59553. /**
  59554. * Register the clipboard Events onto the canvas
  59555. */
  59556. registerClipboardEvents(): void;
  59557. /**
  59558. * Unregister the clipboard Events from the canvas
  59559. */
  59560. unRegisterClipboardEvents(): void;
  59561. /**
  59562. * Connect the texture to a hosting mesh to enable interactions
  59563. * @param mesh defines the mesh to attach to
  59564. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59565. */
  59566. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59567. /**
  59568. * Move the focus to a specific control
  59569. * @param control defines the control which will receive the focus
  59570. */
  59571. moveFocusToControl(control: IFocusableControl): void;
  59572. private _manageFocus;
  59573. private _attachToOnPointerOut;
  59574. /**
  59575. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59576. * @param mesh defines the mesh which will receive the texture
  59577. * @param width defines the texture width (1024 by default)
  59578. * @param height defines the texture height (1024 by default)
  59579. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59580. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59581. * @returns a new AdvancedDynamicTexture
  59582. */
  59583. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59584. /**
  59585. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59586. * In this mode the texture will rely on a layer for its rendering.
  59587. * This allows it to be treated like any other layer.
  59588. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59589. * LayerMask is set through advancedTexture.layer.layerMask
  59590. * @param name defines name for the texture
  59591. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59592. * @param scene defines the hsoting scene
  59593. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59594. * @returns a new AdvancedDynamicTexture
  59595. */
  59596. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59597. }
  59598. }
  59599. declare module BABYLON.GUI {
  59600. /**
  59601. * Root class used for all 2D controls
  59602. * @see http://doc.babylonjs.com/how_to/gui#controls
  59603. */
  59604. export class Control {
  59605. /** defines the name of the control */
  59606. name?: string | undefined;
  59607. /**
  59608. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59609. */
  59610. static AllowAlphaInheritance: boolean;
  59611. private _alpha;
  59612. private _alphaSet;
  59613. private _zIndex;
  59614. /** @hidden */ private _host: AdvancedDynamicTexture;
  59615. /** Gets or sets the control parent */
  59616. parent: BABYLON.Nullable<Container>;
  59617. /** @hidden */ private _currentMeasure: Measure;
  59618. private _fontFamily;
  59619. private _fontStyle;
  59620. private _fontWeight;
  59621. private _fontSize;
  59622. private _font;
  59623. /** @hidden */ private _width: ValueAndUnit;
  59624. /** @hidden */ private _height: ValueAndUnit;
  59625. /** @hidden */
  59626. protected _fontOffset: {
  59627. ascent: number;
  59628. height: number;
  59629. descent: number;
  59630. };
  59631. private _color;
  59632. private _style;
  59633. private _styleObserver;
  59634. /** @hidden */
  59635. protected _horizontalAlignment: number;
  59636. /** @hidden */
  59637. protected _verticalAlignment: number;
  59638. /** @hidden */
  59639. protected _isDirty: boolean;
  59640. /** @hidden */
  59641. protected _wasDirty: boolean;
  59642. /** @hidden */ private _tempParentMeasure: Measure;
  59643. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59644. /** @hidden */
  59645. protected _cachedParentMeasure: Measure;
  59646. private _paddingLeft;
  59647. private _paddingRight;
  59648. private _paddingTop;
  59649. private _paddingBottom;
  59650. /** @hidden */ private _left: ValueAndUnit;
  59651. /** @hidden */ private _top: ValueAndUnit;
  59652. private _scaleX;
  59653. private _scaleY;
  59654. private _rotation;
  59655. private _transformCenterX;
  59656. private _transformCenterY;
  59657. /** @hidden */ private _transformMatrix: Matrix2D;
  59658. /** @hidden */
  59659. protected _invertTransformMatrix: Matrix2D;
  59660. /** @hidden */
  59661. protected _transformedPosition: BABYLON.Vector2;
  59662. private _isMatrixDirty;
  59663. private _cachedOffsetX;
  59664. private _cachedOffsetY;
  59665. private _isVisible;
  59666. private _isHighlighted;
  59667. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59668. private _fontSet;
  59669. private _dummyVector2;
  59670. private _downCount;
  59671. private _enterCount;
  59672. private _doNotRender;
  59673. private _downPointerIds;
  59674. protected _isEnabled: boolean;
  59675. protected _disabledColor: string;
  59676. /** @hidden */
  59677. protected _rebuildLayout: boolean;
  59678. /** @hidden */ private _isClipped: boolean;
  59679. /** @hidden */ private _tag: any;
  59680. /**
  59681. * 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
  59682. */
  59683. uniqueId: number;
  59684. /**
  59685. * Gets or sets an object used to store user defined information for the node
  59686. */
  59687. metadata: any;
  59688. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59689. isHitTestVisible: boolean;
  59690. /** Gets or sets a boolean indicating if the control can block pointer events */
  59691. isPointerBlocker: boolean;
  59692. /** Gets or sets a boolean indicating if the control can be focusable */
  59693. isFocusInvisible: boolean;
  59694. /**
  59695. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59696. * 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
  59697. */
  59698. clipChildren: boolean;
  59699. /**
  59700. * Gets or sets a boolean indicating that control content must be clipped
  59701. * 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
  59702. */
  59703. clipContent: boolean;
  59704. /**
  59705. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59706. */
  59707. useBitmapCache: boolean;
  59708. private _cacheData;
  59709. private _shadowOffsetX;
  59710. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59711. shadowOffsetX: number;
  59712. private _shadowOffsetY;
  59713. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59714. shadowOffsetY: number;
  59715. private _shadowBlur;
  59716. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59717. shadowBlur: number;
  59718. private _shadowColor;
  59719. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59720. shadowColor: string;
  59721. /** Gets or sets the cursor to use when the control is hovered */
  59722. hoverCursor: string;
  59723. /** @hidden */
  59724. protected _linkOffsetX: ValueAndUnit;
  59725. /** @hidden */
  59726. protected _linkOffsetY: ValueAndUnit;
  59727. /** Gets the control type name */
  59728. readonly typeName: string;
  59729. /**
  59730. * Get the current class name of the control.
  59731. * @returns current class name
  59732. */
  59733. getClassName(): string;
  59734. /**
  59735. * An event triggered when the pointer move over the control.
  59736. */
  59737. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  59738. /**
  59739. * An event triggered when the pointer move out of the control.
  59740. */
  59741. onPointerOutObservable: BABYLON.Observable<Control>;
  59742. /**
  59743. * An event triggered when the pointer taps the control
  59744. */
  59745. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  59746. /**
  59747. * An event triggered when pointer up
  59748. */
  59749. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  59750. /**
  59751. * An event triggered when a control is clicked on
  59752. */
  59753. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  59754. /**
  59755. * An event triggered when pointer enters the control
  59756. */
  59757. onPointerEnterObservable: BABYLON.Observable<Control>;
  59758. /**
  59759. * An event triggered when the control is marked as dirty
  59760. */
  59761. onDirtyObservable: BABYLON.Observable<Control>;
  59762. /**
  59763. * An event triggered before drawing the control
  59764. */
  59765. onBeforeDrawObservable: BABYLON.Observable<Control>;
  59766. /**
  59767. * An event triggered after the control was drawn
  59768. */
  59769. onAfterDrawObservable: BABYLON.Observable<Control>;
  59770. /**
  59771. * Get the hosting AdvancedDynamicTexture
  59772. */
  59773. readonly host: AdvancedDynamicTexture;
  59774. /** Gets or set information about font offsets (used to render and align text) */
  59775. fontOffset: {
  59776. ascent: number;
  59777. height: number;
  59778. descent: number;
  59779. };
  59780. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  59781. alpha: number;
  59782. /**
  59783. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  59784. */
  59785. isHighlighted: boolean;
  59786. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  59787. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59788. */
  59789. scaleX: number;
  59790. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  59791. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59792. */
  59793. scaleY: number;
  59794. /** Gets or sets the rotation angle (0 by default)
  59795. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59796. */
  59797. rotation: number;
  59798. /** Gets or sets the transformation center on Y axis (0 by default)
  59799. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59800. */
  59801. transformCenterY: number;
  59802. /** Gets or sets the transformation center on X axis (0 by default)
  59803. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59804. */
  59805. transformCenterX: number;
  59806. /**
  59807. * Gets or sets the horizontal alignment
  59808. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59809. */
  59810. horizontalAlignment: number;
  59811. /**
  59812. * Gets or sets the vertical alignment
  59813. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59814. */
  59815. verticalAlignment: number;
  59816. /**
  59817. * Gets or sets control width
  59818. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59819. */
  59820. width: string | number;
  59821. /**
  59822. * Gets or sets the control width in pixel
  59823. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59824. */
  59825. widthInPixels: number;
  59826. /**
  59827. * Gets or sets control height
  59828. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59829. */
  59830. height: string | number;
  59831. /**
  59832. * Gets or sets control height in pixel
  59833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59834. */
  59835. heightInPixels: number;
  59836. /** Gets or set font family */
  59837. fontFamily: string;
  59838. /** Gets or sets font style */
  59839. fontStyle: string;
  59840. /** Gets or sets font weight */
  59841. fontWeight: string;
  59842. /**
  59843. * Gets or sets style
  59844. * @see http://doc.babylonjs.com/how_to/gui#styles
  59845. */
  59846. style: BABYLON.Nullable<Style>;
  59847. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  59848. /** Gets or sets font size in pixels */
  59849. fontSizeInPixels: number;
  59850. /** Gets or sets font size */
  59851. fontSize: string | number;
  59852. /** Gets or sets foreground color */
  59853. color: string;
  59854. /** Gets or sets z index which is used to reorder controls on the z axis */
  59855. zIndex: number;
  59856. /** Gets or sets a boolean indicating if the control can be rendered */
  59857. notRenderable: boolean;
  59858. /** Gets or sets a boolean indicating if the control is visible */
  59859. isVisible: boolean;
  59860. /** Gets a boolean indicating that the control needs to update its rendering */
  59861. readonly isDirty: boolean;
  59862. /**
  59863. * Gets the current linked mesh (or null if none)
  59864. */
  59865. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59866. /**
  59867. * Gets or sets a value indicating the padding to use on the left of the control
  59868. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59869. */
  59870. paddingLeft: string | number;
  59871. /**
  59872. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  59873. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59874. */
  59875. paddingLeftInPixels: number;
  59876. /**
  59877. * Gets or sets a value indicating the padding to use on the right of the control
  59878. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59879. */
  59880. paddingRight: string | number;
  59881. /**
  59882. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  59883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59884. */
  59885. paddingRightInPixels: number;
  59886. /**
  59887. * Gets or sets a value indicating the padding to use on the top of the control
  59888. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59889. */
  59890. paddingTop: string | number;
  59891. /**
  59892. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  59893. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59894. */
  59895. paddingTopInPixels: number;
  59896. /**
  59897. * Gets or sets a value indicating the padding to use on the bottom of the control
  59898. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59899. */
  59900. paddingBottom: string | number;
  59901. /**
  59902. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  59903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59904. */
  59905. paddingBottomInPixels: number;
  59906. /**
  59907. * Gets or sets a value indicating the left coordinate of the control
  59908. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59909. */
  59910. left: string | number;
  59911. /**
  59912. * Gets or sets a value indicating the left coordinate in pixels of the control
  59913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59914. */
  59915. leftInPixels: number;
  59916. /**
  59917. * Gets or sets a value indicating the top coordinate of the control
  59918. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59919. */
  59920. top: string | number;
  59921. /**
  59922. * Gets or sets a value indicating the top coordinate in pixels of the control
  59923. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59924. */
  59925. topInPixels: number;
  59926. /**
  59927. * Gets or sets a value indicating the offset on X axis to the linked mesh
  59928. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59929. */
  59930. linkOffsetX: string | number;
  59931. /**
  59932. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  59933. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59934. */
  59935. linkOffsetXInPixels: number;
  59936. /**
  59937. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  59938. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59939. */
  59940. linkOffsetY: string | number;
  59941. /**
  59942. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  59943. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59944. */
  59945. linkOffsetYInPixels: number;
  59946. /** Gets the center coordinate on X axis */
  59947. readonly centerX: number;
  59948. /** Gets the center coordinate on Y axis */
  59949. readonly centerY: number;
  59950. /** Gets or sets if control is Enabled*/
  59951. isEnabled: boolean;
  59952. /** Gets or sets background color of control if it's disabled*/
  59953. disabledColor: string;
  59954. /**
  59955. * Creates a new control
  59956. * @param name defines the name of the control
  59957. */
  59958. constructor(
  59959. /** defines the name of the control */
  59960. name?: string | undefined);
  59961. /** @hidden */
  59962. protected _getTypeName(): string;
  59963. /**
  59964. * Gets the first ascendant in the hierarchy of the given type
  59965. * @param className defines the required type
  59966. * @returns the ascendant or null if not found
  59967. */
  59968. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  59969. /** @hidden */ private _resetFontCache(): void;
  59970. /**
  59971. * Determines if a container is an ascendant of the current control
  59972. * @param container defines the container to look for
  59973. * @returns true if the container is one of the ascendant of the control
  59974. */
  59975. isAscendant(container: Control): boolean;
  59976. /**
  59977. * Gets coordinates in local control space
  59978. * @param globalCoordinates defines the coordinates to transform
  59979. * @returns the new coordinates in local space
  59980. */
  59981. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59982. /**
  59983. * Gets coordinates in local control space
  59984. * @param globalCoordinates defines the coordinates to transform
  59985. * @param result defines the target vector2 where to store the result
  59986. * @returns the current control
  59987. */
  59988. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  59989. /**
  59990. * Gets coordinates in parent local control space
  59991. * @param globalCoordinates defines the coordinates to transform
  59992. * @returns the new coordinates in parent local space
  59993. */
  59994. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59995. /**
  59996. * Move the current control to a vector3 position projected onto the screen.
  59997. * @param position defines the target position
  59998. * @param scene defines the hosting scene
  59999. */
  60000. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60001. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60002. /**
  60003. * Will return all controls that have this control as ascendant
  60004. * @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
  60005. * @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
  60006. * @return all child controls
  60007. */
  60008. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60009. /**
  60010. * Link current control with a target mesh
  60011. * @param mesh defines the mesh to link with
  60012. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60013. */
  60014. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60015. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60016. /** @hidden */ private _offsetLeft(offset: number): void;
  60017. /** @hidden */ private _offsetTop(offset: number): void;
  60018. /** @hidden */ private _markMatrixAsDirty(): void;
  60019. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  60020. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  60021. /** @hidden */
  60022. protected invalidateRect(): void;
  60023. /** @hidden */ private _markAsDirty(force?: boolean): void;
  60024. /** @hidden */ private _markAllAsDirty(): void;
  60025. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  60026. /** @hidden */
  60027. protected _transform(context?: CanvasRenderingContext2D): void;
  60028. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  60029. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60030. /** @hidden */
  60031. protected _applyStates(context: CanvasRenderingContext2D): void;
  60032. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60033. /** @hidden */
  60034. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60035. protected _evaluateClippingState(parentMeasure: Measure): void;
  60036. /** @hidden */ private _measure(): void;
  60037. /** @hidden */
  60038. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60039. /** @hidden */
  60040. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60041. /** @hidden */
  60042. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60043. /** @hidden */
  60044. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60045. private static _ClipMeasure;
  60046. private _tmpMeasureA;
  60047. private _clip;
  60048. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60049. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60050. /**
  60051. * Tests if a given coordinates belong to the current control
  60052. * @param x defines x coordinate to test
  60053. * @param y defines y coordinate to test
  60054. * @returns true if the coordinates are inside the control
  60055. */
  60056. contains(x: number, y: number): boolean;
  60057. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60058. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60059. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  60060. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  60061. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60062. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60063. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60064. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60065. private _prepareFont;
  60066. /** Releases associated resources */
  60067. dispose(): void;
  60068. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60069. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60070. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60071. private static _VERTICAL_ALIGNMENT_TOP;
  60072. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60073. private static _VERTICAL_ALIGNMENT_CENTER;
  60074. /** HORIZONTAL_ALIGNMENT_LEFT */
  60075. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60076. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60077. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60078. /** HORIZONTAL_ALIGNMENT_CENTER */
  60079. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60080. /** VERTICAL_ALIGNMENT_TOP */
  60081. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60082. /** VERTICAL_ALIGNMENT_BOTTOM */
  60083. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60084. /** VERTICAL_ALIGNMENT_CENTER */
  60085. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60086. private static _FontHeightSizes;
  60087. /** @hidden */ private static _GetFontOffset(font: string): {
  60088. ascent: number;
  60089. height: number;
  60090. descent: number;
  60091. };
  60092. /**
  60093. * Creates a stack panel that can be used to render headers
  60094. * @param control defines the control to associate with the header
  60095. * @param text defines the text of the header
  60096. * @param size defines the size of the header
  60097. * @param options defines options used to configure the header
  60098. * @returns a new StackPanel
  60099. * @ignore
  60100. * @hidden
  60101. */
  60102. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60103. isHorizontal: boolean;
  60104. controlFirst: boolean;
  60105. }) => any;
  60106. /** @hidden */
  60107. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60108. }
  60109. }
  60110. declare module BABYLON.GUI {
  60111. /**
  60112. * Root class for 2D containers
  60113. * @see http://doc.babylonjs.com/how_to/gui#containers
  60114. */
  60115. export class Container extends Control {
  60116. name?: string | undefined;
  60117. /** @hidden */
  60118. protected _children: Control[];
  60119. /** @hidden */
  60120. protected _measureForChildren: Measure;
  60121. /** @hidden */
  60122. protected _background: string;
  60123. /** @hidden */
  60124. protected _adaptWidthToChildren: boolean;
  60125. /** @hidden */
  60126. protected _adaptHeightToChildren: boolean;
  60127. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60128. adaptHeightToChildren: boolean;
  60129. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60130. adaptWidthToChildren: boolean;
  60131. /** Gets or sets background color */
  60132. background: string;
  60133. /** Gets the list of children */
  60134. readonly children: Control[];
  60135. /**
  60136. * Creates a new Container
  60137. * @param name defines the name of the container
  60138. */
  60139. constructor(name?: string | undefined);
  60140. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  60141. /**
  60142. * Gets a child using its name
  60143. * @param name defines the child name to look for
  60144. * @returns the child control if found
  60145. */
  60146. getChildByName(name: string): BABYLON.Nullable<Control>;
  60147. /**
  60148. * Gets a child using its type and its name
  60149. * @param name defines the child name to look for
  60150. * @param type defines the child type to look for
  60151. * @returns the child control if found
  60152. */
  60153. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60154. /**
  60155. * Search for a specific control in children
  60156. * @param control defines the control to look for
  60157. * @returns true if the control is in child list
  60158. */
  60159. containsControl(control: Control): boolean;
  60160. /**
  60161. * Adds a new control to the current container
  60162. * @param control defines the control to add
  60163. * @returns the current container
  60164. */
  60165. addControl(control: BABYLON.Nullable<Control>): Container;
  60166. /**
  60167. * Removes all controls from the current container
  60168. * @returns the current container
  60169. */
  60170. clearControls(): Container;
  60171. /**
  60172. * Removes a control from the current container
  60173. * @param control defines the control to remove
  60174. * @returns the current container
  60175. */
  60176. removeControl(control: Control): Container;
  60177. /** @hidden */ private _reOrderControl(control: Control): void;
  60178. /** @hidden */ private _offsetLeft(offset: number): void;
  60179. /** @hidden */ private _offsetTop(offset: number): void;
  60180. /** @hidden */ private _markAllAsDirty(): void;
  60181. /** @hidden */
  60182. protected _localDraw(context: CanvasRenderingContext2D): void;
  60183. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  60184. /** @hidden */
  60185. protected _beforeLayout(): void;
  60186. /** @hidden */
  60187. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60188. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60189. protected _postMeasure(): void;
  60190. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60191. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60192. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60193. /** @hidden */
  60194. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60195. /** Releases associated resources */
  60196. dispose(): void;
  60197. }
  60198. }
  60199. declare module BABYLON.GUI {
  60200. /** Class used to create rectangle container */
  60201. export class Rectangle extends Container {
  60202. name?: string | undefined;
  60203. private _thickness;
  60204. private _cornerRadius;
  60205. /** Gets or sets border thickness */
  60206. thickness: number;
  60207. /** Gets or sets the corner radius angle */
  60208. cornerRadius: number;
  60209. /**
  60210. * Creates a new Rectangle
  60211. * @param name defines the control name
  60212. */
  60213. constructor(name?: string | undefined);
  60214. protected _getTypeName(): string;
  60215. protected _localDraw(context: CanvasRenderingContext2D): void;
  60216. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60217. private _drawRoundedRect;
  60218. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60219. }
  60220. }
  60221. declare module BABYLON.GUI {
  60222. /**
  60223. * Enum that determines the text-wrapping mode to use.
  60224. */
  60225. export enum TextWrapping {
  60226. /**
  60227. * Clip the text when it's larger than Control.width; this is the default mode.
  60228. */
  60229. Clip = 0,
  60230. /**
  60231. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60232. */
  60233. WordWrap = 1,
  60234. /**
  60235. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60236. */
  60237. Ellipsis = 2
  60238. }
  60239. /**
  60240. * Class used to create text block control
  60241. */
  60242. export class TextBlock extends Control {
  60243. /**
  60244. * Defines the name of the control
  60245. */
  60246. name?: string | undefined;
  60247. private _text;
  60248. private _textWrapping;
  60249. private _textHorizontalAlignment;
  60250. private _textVerticalAlignment;
  60251. private _lines;
  60252. private _resizeToFit;
  60253. private _lineSpacing;
  60254. private _outlineWidth;
  60255. private _outlineColor;
  60256. /**
  60257. * An event triggered after the text is changed
  60258. */
  60259. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60260. /**
  60261. * An event triggered after the text was broken up into lines
  60262. */
  60263. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60264. /**
  60265. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60266. */
  60267. readonly lines: any[];
  60268. /**
  60269. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60270. */
  60271. /**
  60272. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60273. */
  60274. resizeToFit: boolean;
  60275. /**
  60276. * Gets or sets a boolean indicating if text must be wrapped
  60277. */
  60278. /**
  60279. * Gets or sets a boolean indicating if text must be wrapped
  60280. */
  60281. textWrapping: TextWrapping | boolean;
  60282. /**
  60283. * Gets or sets text to display
  60284. */
  60285. /**
  60286. * Gets or sets text to display
  60287. */
  60288. text: string;
  60289. /**
  60290. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60291. */
  60292. /**
  60293. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60294. */
  60295. textHorizontalAlignment: number;
  60296. /**
  60297. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60298. */
  60299. /**
  60300. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60301. */
  60302. textVerticalAlignment: number;
  60303. /**
  60304. * Gets or sets line spacing value
  60305. */
  60306. /**
  60307. * Gets or sets line spacing value
  60308. */
  60309. lineSpacing: string | number;
  60310. /**
  60311. * Gets or sets outlineWidth of the text to display
  60312. */
  60313. /**
  60314. * Gets or sets outlineWidth of the text to display
  60315. */
  60316. outlineWidth: number;
  60317. /**
  60318. * Gets or sets outlineColor of the text to display
  60319. */
  60320. /**
  60321. * Gets or sets outlineColor of the text to display
  60322. */
  60323. outlineColor: string;
  60324. /**
  60325. * Creates a new TextBlock object
  60326. * @param name defines the name of the control
  60327. * @param text defines the text to display (emptry string by default)
  60328. */
  60329. constructor(
  60330. /**
  60331. * Defines the name of the control
  60332. */
  60333. name?: string | undefined, text?: string);
  60334. protected _getTypeName(): string;
  60335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60336. private _drawText;
  60337. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60338. protected _applyStates(context: CanvasRenderingContext2D): void;
  60339. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60340. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60341. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60342. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60343. protected _renderLines(context: CanvasRenderingContext2D): void;
  60344. /**
  60345. * Given a width constraint applied on the text block, find the expected height
  60346. * @returns expected height
  60347. */
  60348. computeExpectedHeight(): number;
  60349. dispose(): void;
  60350. }
  60351. }
  60352. declare module BABYLON.GUI {
  60353. /**
  60354. * Class used to create 2D images
  60355. */
  60356. export class Image extends Control {
  60357. name?: string | undefined;
  60358. private static _WorkingCanvas;
  60359. private _domImage;
  60360. private _imageWidth;
  60361. private _imageHeight;
  60362. private _loaded;
  60363. private _stretch;
  60364. private _source;
  60365. private _autoScale;
  60366. private _sourceLeft;
  60367. private _sourceTop;
  60368. private _sourceWidth;
  60369. private _sourceHeight;
  60370. private _cellWidth;
  60371. private _cellHeight;
  60372. private _cellId;
  60373. private _populateNinePatchSlicesFromImage;
  60374. private _sliceLeft;
  60375. private _sliceRight;
  60376. private _sliceTop;
  60377. private _sliceBottom;
  60378. private _detectPointerOnOpaqueOnly;
  60379. /**
  60380. * BABYLON.Observable notified when the content is loaded
  60381. */
  60382. onImageLoadedObservable: BABYLON.Observable<Image>;
  60383. /**
  60384. * Gets a boolean indicating that the content is loaded
  60385. */
  60386. readonly isLoaded: boolean;
  60387. /**
  60388. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60389. */
  60390. populateNinePatchSlicesFromImage: boolean;
  60391. /**
  60392. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60393. * Beware using this as this will comsume more memory as the image has to be stored twice
  60394. */
  60395. detectPointerOnOpaqueOnly: boolean;
  60396. /**
  60397. * Gets or sets the left value for slicing (9-patch)
  60398. */
  60399. sliceLeft: number;
  60400. /**
  60401. * Gets or sets the right value for slicing (9-patch)
  60402. */
  60403. sliceRight: number;
  60404. /**
  60405. * Gets or sets the top value for slicing (9-patch)
  60406. */
  60407. sliceTop: number;
  60408. /**
  60409. * Gets or sets the bottom value for slicing (9-patch)
  60410. */
  60411. sliceBottom: number;
  60412. /**
  60413. * Gets or sets the left coordinate in the source image
  60414. */
  60415. sourceLeft: number;
  60416. /**
  60417. * Gets or sets the top coordinate in the source image
  60418. */
  60419. sourceTop: number;
  60420. /**
  60421. * Gets or sets the width to capture in the source image
  60422. */
  60423. sourceWidth: number;
  60424. /**
  60425. * Gets or sets the height to capture in the source image
  60426. */
  60427. sourceHeight: number;
  60428. /**
  60429. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60430. * @see http://doc.babylonjs.com/how_to/gui#image
  60431. */
  60432. autoScale: boolean;
  60433. /** Gets or sets the streching mode used by the image */
  60434. stretch: number;
  60435. /**
  60436. * Gets or sets the internal DOM image used to render the control
  60437. */
  60438. domImage: HTMLImageElement;
  60439. private _onImageLoaded;
  60440. private _extractNinePatchSliceDataFromImage;
  60441. /**
  60442. * Gets or sets image source url
  60443. */
  60444. source: BABYLON.Nullable<string>;
  60445. /**
  60446. * Gets or sets the cell width to use when animation sheet is enabled
  60447. * @see http://doc.babylonjs.com/how_to/gui#image
  60448. */
  60449. cellWidth: number;
  60450. /**
  60451. * Gets or sets the cell height to use when animation sheet is enabled
  60452. * @see http://doc.babylonjs.com/how_to/gui#image
  60453. */
  60454. cellHeight: number;
  60455. /**
  60456. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60457. * @see http://doc.babylonjs.com/how_to/gui#image
  60458. */
  60459. cellId: number;
  60460. /**
  60461. * Creates a new Image
  60462. * @param name defines the control name
  60463. * @param url defines the image url
  60464. */
  60465. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60466. /**
  60467. * Tests if a given coordinates belong to the current control
  60468. * @param x defines x coordinate to test
  60469. * @param y defines y coordinate to test
  60470. * @returns true if the coordinates are inside the control
  60471. */
  60472. contains(x: number, y: number): boolean;
  60473. protected _getTypeName(): string;
  60474. /** Force the control to synchronize with its content */
  60475. synchronizeSizeWithContent(): void;
  60476. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60477. private _prepareWorkingCanvasForOpaqueDetection;
  60478. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  60479. private _renderCornerPatch;
  60480. private _renderNinePatch;
  60481. dispose(): void;
  60482. /** STRETCH_NONE */
  60483. static readonly STRETCH_NONE: number;
  60484. /** STRETCH_FILL */
  60485. static readonly STRETCH_FILL: number;
  60486. /** STRETCH_UNIFORM */
  60487. static readonly STRETCH_UNIFORM: number;
  60488. /** STRETCH_EXTEND */
  60489. static readonly STRETCH_EXTEND: number;
  60490. /** NINE_PATCH */
  60491. static readonly STRETCH_NINE_PATCH: number;
  60492. }
  60493. }
  60494. declare module BABYLON.GUI {
  60495. /**
  60496. * Class used to create 2D buttons
  60497. */
  60498. export class Button extends Rectangle {
  60499. name?: string | undefined;
  60500. /**
  60501. * Function called to generate a pointer enter animation
  60502. */
  60503. pointerEnterAnimation: () => void;
  60504. /**
  60505. * Function called to generate a pointer out animation
  60506. */
  60507. pointerOutAnimation: () => void;
  60508. /**
  60509. * Function called to generate a pointer down animation
  60510. */
  60511. pointerDownAnimation: () => void;
  60512. /**
  60513. * Function called to generate a pointer up animation
  60514. */
  60515. pointerUpAnimation: () => void;
  60516. private _image;
  60517. /**
  60518. * Returns the image part of the button (if any)
  60519. */
  60520. readonly image: BABYLON.Nullable<Image>;
  60521. private _textBlock;
  60522. /**
  60523. * Returns the image part of the button (if any)
  60524. */
  60525. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60526. /**
  60527. * Creates a new Button
  60528. * @param name defines the name of the button
  60529. */
  60530. constructor(name?: string | undefined);
  60531. protected _getTypeName(): string;
  60532. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60533. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  60534. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  60535. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60536. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60537. /**
  60538. * Creates a new button made with an image and a text
  60539. * @param name defines the name of the button
  60540. * @param text defines the text of the button
  60541. * @param imageUrl defines the url of the image
  60542. * @returns a new Button
  60543. */
  60544. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60545. /**
  60546. * Creates a new button made with an image
  60547. * @param name defines the name of the button
  60548. * @param imageUrl defines the url of the image
  60549. * @returns a new Button
  60550. */
  60551. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60552. /**
  60553. * Creates a new button made with a text
  60554. * @param name defines the name of the button
  60555. * @param text defines the text of the button
  60556. * @returns a new Button
  60557. */
  60558. static CreateSimpleButton(name: string, text: string): Button;
  60559. /**
  60560. * Creates a new button made with an image and a centered text
  60561. * @param name defines the name of the button
  60562. * @param text defines the text of the button
  60563. * @param imageUrl defines the url of the image
  60564. * @returns a new Button
  60565. */
  60566. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60567. }
  60568. }
  60569. declare module BABYLON.GUI {
  60570. /**
  60571. * Class used to create a 2D stack panel container
  60572. */
  60573. export class StackPanel extends Container {
  60574. name?: string | undefined;
  60575. private _isVertical;
  60576. private _manualWidth;
  60577. private _manualHeight;
  60578. private _doNotTrackManualChanges;
  60579. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60580. isVertical: boolean;
  60581. /**
  60582. * Gets or sets panel width.
  60583. * This value should not be set when in horizontal mode as it will be computed automatically
  60584. */
  60585. width: string | number;
  60586. /**
  60587. * Gets or sets panel height.
  60588. * This value should not be set when in vertical mode as it will be computed automatically
  60589. */
  60590. height: string | number;
  60591. /**
  60592. * Creates a new StackPanel
  60593. * @param name defines control name
  60594. */
  60595. constructor(name?: string | undefined);
  60596. protected _getTypeName(): string;
  60597. /** @hidden */
  60598. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60599. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60600. protected _postMeasure(): void;
  60601. }
  60602. }
  60603. declare module BABYLON.GUI {
  60604. /**
  60605. * Class used to represent a 2D checkbox
  60606. */
  60607. export class Checkbox extends Control {
  60608. name?: string | undefined;
  60609. private _isChecked;
  60610. private _background;
  60611. private _checkSizeRatio;
  60612. private _thickness;
  60613. /** Gets or sets border thickness */
  60614. thickness: number;
  60615. /**
  60616. * BABYLON.Observable raised when isChecked property changes
  60617. */
  60618. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60619. /** Gets or sets a value indicating the ratio between overall size and check size */
  60620. checkSizeRatio: number;
  60621. /** Gets or sets background color */
  60622. background: string;
  60623. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60624. isChecked: boolean;
  60625. /**
  60626. * Creates a new CheckBox
  60627. * @param name defines the control name
  60628. */
  60629. constructor(name?: string | undefined);
  60630. protected _getTypeName(): string;
  60631. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60632. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60633. /**
  60634. * Utility function to easily create a checkbox with a header
  60635. * @param title defines the label to use for the header
  60636. * @param onValueChanged defines the callback to call when value changes
  60637. * @returns a StackPanel containing the checkbox and a textBlock
  60638. */
  60639. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60640. }
  60641. }
  60642. declare module BABYLON.GUI {
  60643. /**
  60644. * Class used to store key control properties
  60645. */
  60646. export class KeyPropertySet {
  60647. /** Width */
  60648. width?: string;
  60649. /** Height */
  60650. height?: string;
  60651. /** Left padding */
  60652. paddingLeft?: string;
  60653. /** Right padding */
  60654. paddingRight?: string;
  60655. /** Top padding */
  60656. paddingTop?: string;
  60657. /** Bottom padding */
  60658. paddingBottom?: string;
  60659. /** Foreground color */
  60660. color?: string;
  60661. /** Background color */
  60662. background?: string;
  60663. }
  60664. /**
  60665. * Class used to create virtual keyboard
  60666. */
  60667. export class VirtualKeyboard extends StackPanel {
  60668. /** BABYLON.Observable raised when a key is pressed */
  60669. onKeyPressObservable: BABYLON.Observable<string>;
  60670. /** Gets or sets default key button width */
  60671. defaultButtonWidth: string;
  60672. /** Gets or sets default key button height */
  60673. defaultButtonHeight: string;
  60674. /** Gets or sets default key button left padding */
  60675. defaultButtonPaddingLeft: string;
  60676. /** Gets or sets default key button right padding */
  60677. defaultButtonPaddingRight: string;
  60678. /** Gets or sets default key button top padding */
  60679. defaultButtonPaddingTop: string;
  60680. /** Gets or sets default key button bottom padding */
  60681. defaultButtonPaddingBottom: string;
  60682. /** Gets or sets default key button foreground color */
  60683. defaultButtonColor: string;
  60684. /** Gets or sets default key button background color */
  60685. defaultButtonBackground: string;
  60686. /** Gets or sets shift button foreground color */
  60687. shiftButtonColor: string;
  60688. /** Gets or sets shift button thickness*/
  60689. selectedShiftThickness: number;
  60690. /** Gets shift key state */
  60691. shiftState: number;
  60692. protected _getTypeName(): string;
  60693. private _createKey;
  60694. /**
  60695. * Adds a new row of keys
  60696. * @param keys defines the list of keys to add
  60697. * @param propertySets defines the associated property sets
  60698. */
  60699. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  60700. /**
  60701. * Set the shift key to a specific state
  60702. * @param shiftState defines the new shift state
  60703. */
  60704. applyShiftState(shiftState: number): void;
  60705. private _currentlyConnectedInputText;
  60706. private _connectedInputTexts;
  60707. private _onKeyPressObserver;
  60708. /** Gets the input text control currently attached to the keyboard */
  60709. readonly connectedInputText: BABYLON.Nullable<InputText>;
  60710. /**
  60711. * Connects the keyboard with an input text control
  60712. *
  60713. * @param input defines the target control
  60714. */
  60715. connect(input: InputText): void;
  60716. /**
  60717. * Disconnects the keyboard from connected InputText controls
  60718. *
  60719. * @param input optionally defines a target control, otherwise all are disconnected
  60720. */
  60721. disconnect(input?: InputText): void;
  60722. private _removeConnectedInputObservables;
  60723. /**
  60724. * Release all resources
  60725. */
  60726. dispose(): void;
  60727. /**
  60728. * Creates a new keyboard using a default layout
  60729. *
  60730. * @param name defines control name
  60731. * @returns a new VirtualKeyboard
  60732. */
  60733. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  60734. }
  60735. }
  60736. declare module BABYLON.GUI {
  60737. /**
  60738. * Class used to create input text control
  60739. */
  60740. export class InputText extends Control implements IFocusableControl {
  60741. name?: string | undefined;
  60742. private _text;
  60743. private _placeholderText;
  60744. private _background;
  60745. private _focusedBackground;
  60746. private _focusedColor;
  60747. private _placeholderColor;
  60748. private _thickness;
  60749. private _margin;
  60750. private _autoStretchWidth;
  60751. private _maxWidth;
  60752. private _isFocused;
  60753. private _blinkTimeout;
  60754. private _blinkIsEven;
  60755. private _cursorOffset;
  60756. private _scrollLeft;
  60757. private _textWidth;
  60758. private _clickedCoordinate;
  60759. private _deadKey;
  60760. private _addKey;
  60761. private _currentKey;
  60762. private _isTextHighlightOn;
  60763. private _textHighlightColor;
  60764. private _highligherOpacity;
  60765. private _highlightedText;
  60766. private _startHighlightIndex;
  60767. private _endHighlightIndex;
  60768. private _cursorIndex;
  60769. private _onFocusSelectAll;
  60770. private _isPointerDown;
  60771. private _onClipboardObserver;
  60772. private _onPointerDblTapObserver;
  60773. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  60774. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  60775. promptMessage: string;
  60776. /** BABYLON.Observable raised when the text changes */
  60777. onTextChangedObservable: BABYLON.Observable<InputText>;
  60778. /** BABYLON.Observable raised just before an entered character is to be added */
  60779. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  60780. /** BABYLON.Observable raised when the control gets the focus */
  60781. onFocusObservable: BABYLON.Observable<InputText>;
  60782. /** BABYLON.Observable raised when the control loses the focus */
  60783. onBlurObservable: BABYLON.Observable<InputText>;
  60784. /**Observable raised when the text is highlighted */
  60785. onTextHighlightObservable: BABYLON.Observable<InputText>;
  60786. /**Observable raised when copy event is triggered */
  60787. onTextCopyObservable: BABYLON.Observable<InputText>;
  60788. /** BABYLON.Observable raised when cut event is triggered */
  60789. onTextCutObservable: BABYLON.Observable<InputText>;
  60790. /** BABYLON.Observable raised when paste event is triggered */
  60791. onTextPasteObservable: BABYLON.Observable<InputText>;
  60792. /** BABYLON.Observable raised when a key event was processed */
  60793. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  60794. /** Gets or sets the maximum width allowed by the control */
  60795. maxWidth: string | number;
  60796. /** Gets the maximum width allowed by the control in pixels */
  60797. readonly maxWidthInPixels: number;
  60798. /** Gets or sets the text highlighter transparency; default: 0.4 */
  60799. highligherOpacity: number;
  60800. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  60801. onFocusSelectAll: boolean;
  60802. /** Gets or sets the text hightlight color */
  60803. textHighlightColor: string;
  60804. /** Gets or sets control margin */
  60805. margin: string;
  60806. /** Gets control margin in pixels */
  60807. readonly marginInPixels: number;
  60808. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  60809. autoStretchWidth: boolean;
  60810. /** Gets or sets border thickness */
  60811. thickness: number;
  60812. /** Gets or sets the background color when focused */
  60813. focusedBackground: string;
  60814. /** Gets or sets the background color when focused */
  60815. focusedColor: string;
  60816. /** Gets or sets the background color */
  60817. background: string;
  60818. /** Gets or sets the placeholder color */
  60819. placeholderColor: string;
  60820. /** Gets or sets the text displayed when the control is empty */
  60821. placeholderText: string;
  60822. /** Gets or sets the dead key flag */
  60823. deadKey: boolean;
  60824. /** Gets or sets the highlight text */
  60825. highlightedText: string;
  60826. /** Gets or sets if the current key should be added */
  60827. addKey: boolean;
  60828. /** Gets or sets the value of the current key being entered */
  60829. currentKey: string;
  60830. /** Gets or sets the text displayed in the control */
  60831. text: string;
  60832. /** Gets or sets control width */
  60833. width: string | number;
  60834. /**
  60835. * Creates a new InputText
  60836. * @param name defines the control name
  60837. * @param text defines the text of the control
  60838. */
  60839. constructor(name?: string | undefined, text?: string);
  60840. /** @hidden */
  60841. onBlur(): void;
  60842. /** @hidden */
  60843. onFocus(): void;
  60844. protected _getTypeName(): string;
  60845. /**
  60846. * Function called to get the list of controls that should not steal the focus from this control
  60847. * @returns an array of controls
  60848. */
  60849. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60850. /** @hidden */
  60851. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  60852. /** @hidden */
  60853. private _updateValueFromCursorIndex;
  60854. /** @hidden */
  60855. private _processDblClick;
  60856. /** @hidden */
  60857. private _selectAllText;
  60858. /**
  60859. * Handles the keyboard event
  60860. * @param evt Defines the KeyboardEvent
  60861. */
  60862. processKeyboard(evt: KeyboardEvent): void;
  60863. /** @hidden */
  60864. private _onCopyText;
  60865. /** @hidden */
  60866. private _onCutText;
  60867. /** @hidden */
  60868. 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;
  60869. protected _beforeRenderText(text: string): string;
  60870. dispose(): void;
  60871. }
  60872. }
  60873. declare module BABYLON.GUI {
  60874. /**
  60875. * Class used to create a 2D grid container
  60876. */
  60877. export class Grid extends Container {
  60878. name?: string | undefined;
  60879. private _rowDefinitions;
  60880. private _columnDefinitions;
  60881. private _cells;
  60882. private _childControls;
  60883. /**
  60884. * Gets the number of columns
  60885. */
  60886. readonly columnCount: number;
  60887. /**
  60888. * Gets the number of rows
  60889. */
  60890. readonly rowCount: number;
  60891. /** Gets the list of children */
  60892. readonly children: Control[];
  60893. /** Gets the list of cells (e.g. the containers) */
  60894. readonly cells: {
  60895. [key: string]: Container;
  60896. };
  60897. /**
  60898. * Gets the definition of a specific row
  60899. * @param index defines the index of the row
  60900. * @returns the row definition
  60901. */
  60902. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60903. /**
  60904. * Gets the definition of a specific column
  60905. * @param index defines the index of the column
  60906. * @returns the column definition
  60907. */
  60908. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60909. /**
  60910. * Adds a new row to the grid
  60911. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60912. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  60913. * @returns the current grid
  60914. */
  60915. addRowDefinition(height: number, isPixel?: boolean): Grid;
  60916. /**
  60917. * Adds a new column to the grid
  60918. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60919. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60920. * @returns the current grid
  60921. */
  60922. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  60923. /**
  60924. * Update a row definition
  60925. * @param index defines the index of the row to update
  60926. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60927. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  60928. * @returns the current grid
  60929. */
  60930. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  60931. /**
  60932. * Update a column definition
  60933. * @param index defines the index of the column to update
  60934. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60935. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60936. * @returns the current grid
  60937. */
  60938. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  60939. /**
  60940. * Gets the list of children stored in a specific cell
  60941. * @param row defines the row to check
  60942. * @param column defines the column to check
  60943. * @returns the list of controls
  60944. */
  60945. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  60946. /**
  60947. * Gets a string representing the child cell info (row x column)
  60948. * @param child defines the control to get info from
  60949. * @returns a string containing the child cell info (row x column)
  60950. */
  60951. getChildCellInfo(child: Control): string;
  60952. private _removeCell;
  60953. private _offsetCell;
  60954. /**
  60955. * Remove a column definition at specified index
  60956. * @param index defines the index of the column to remove
  60957. * @returns the current grid
  60958. */
  60959. removeColumnDefinition(index: number): Grid;
  60960. /**
  60961. * Remove a row definition at specified index
  60962. * @param index defines the index of the row to remove
  60963. * @returns the current grid
  60964. */
  60965. removeRowDefinition(index: number): Grid;
  60966. /**
  60967. * Adds a new control to the current grid
  60968. * @param control defines the control to add
  60969. * @param row defines the row where to add the control (0 by default)
  60970. * @param column defines the column where to add the control (0 by default)
  60971. * @returns the current grid
  60972. */
  60973. addControl(control: Control, row?: number, column?: number): Grid;
  60974. /**
  60975. * Removes a control from the current container
  60976. * @param control defines the control to remove
  60977. * @returns the current container
  60978. */
  60979. removeControl(control: Control): Container;
  60980. /**
  60981. * Creates a new Grid
  60982. * @param name defines control name
  60983. */
  60984. constructor(name?: string | undefined);
  60985. protected _getTypeName(): string;
  60986. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  60987. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60988. /** Releases associated resources */
  60989. dispose(): void;
  60990. }
  60991. }
  60992. declare module BABYLON.GUI {
  60993. /** Class used to create color pickers */
  60994. export class ColorPicker extends Control {
  60995. name?: string | undefined;
  60996. private static _Epsilon;
  60997. private _colorWheelCanvas;
  60998. private _value;
  60999. private _tmpColor;
  61000. private _pointerStartedOnSquare;
  61001. private _pointerStartedOnWheel;
  61002. private _squareLeft;
  61003. private _squareTop;
  61004. private _squareSize;
  61005. private _h;
  61006. private _s;
  61007. private _v;
  61008. private _lastPointerDownID;
  61009. /**
  61010. * BABYLON.Observable raised when the value changes
  61011. */
  61012. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61013. /** Gets or sets the color of the color picker */
  61014. value: BABYLON.Color3;
  61015. /**
  61016. * Gets or sets control width
  61017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61018. */
  61019. width: string | number;
  61020. /**
  61021. * Gets or sets control height
  61022. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61023. */
  61024. /** Gets or sets control height */
  61025. height: string | number;
  61026. /** Gets or sets control size */
  61027. size: string | number;
  61028. /**
  61029. * Creates a new ColorPicker
  61030. * @param name defines the control name
  61031. */
  61032. constructor(name?: string | undefined);
  61033. protected _getTypeName(): string;
  61034. /** @hidden */
  61035. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61036. private _updateSquareProps;
  61037. private _drawGradientSquare;
  61038. private _drawCircle;
  61039. private _createColorWheelCanvas;
  61040. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  61041. private _pointerIsDown;
  61042. private _updateValueFromPointer;
  61043. private _isPointOnSquare;
  61044. 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;
  61045. /**
  61046. * This function expands the color picker by creating a color picker dialog with manual
  61047. * color value input and the ability to save colors into an array to be used later in
  61048. * subsequent launches of the dialogue.
  61049. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61050. * @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.
  61051. * @returns picked color as a hex string and the saved colors array as hex strings.
  61052. */
  61053. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61054. pickerWidth?: string;
  61055. pickerHeight?: string;
  61056. headerHeight?: string;
  61057. lastColor?: string;
  61058. swatchLimit?: number;
  61059. numSwatchesPerLine?: number;
  61060. savedColors?: Array<string>;
  61061. }): Promise<{
  61062. savedColors?: string[];
  61063. pickedColor: string;
  61064. }>;
  61065. }
  61066. }
  61067. declare module BABYLON.GUI {
  61068. /** Class used to create 2D ellipse containers */
  61069. export class Ellipse extends Container {
  61070. name?: string | undefined;
  61071. private _thickness;
  61072. /** Gets or sets border thickness */
  61073. thickness: number;
  61074. /**
  61075. * Creates a new Ellipse
  61076. * @param name defines the control name
  61077. */
  61078. constructor(name?: string | undefined);
  61079. protected _getTypeName(): string;
  61080. protected _localDraw(context: CanvasRenderingContext2D): void;
  61081. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61082. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61083. }
  61084. }
  61085. declare module BABYLON.GUI {
  61086. /**
  61087. * Class used to create a password control
  61088. */
  61089. export class InputPassword extends InputText {
  61090. protected _beforeRenderText(text: string): string;
  61091. }
  61092. }
  61093. declare module BABYLON.GUI {
  61094. /** Class used to render 2D lines */
  61095. export class Line extends Control {
  61096. name?: string | undefined;
  61097. private _lineWidth;
  61098. private _x1;
  61099. private _y1;
  61100. private _x2;
  61101. private _y2;
  61102. private _dash;
  61103. private _connectedControl;
  61104. private _connectedControlDirtyObserver;
  61105. /** Gets or sets the dash pattern */
  61106. dash: Array<number>;
  61107. /** Gets or sets the control connected with the line end */
  61108. connectedControl: Control;
  61109. /** Gets or sets start coordinates on X axis */
  61110. x1: string | number;
  61111. /** Gets or sets start coordinates on Y axis */
  61112. y1: string | number;
  61113. /** Gets or sets end coordinates on X axis */
  61114. x2: string | number;
  61115. /** Gets or sets end coordinates on Y axis */
  61116. y2: string | number;
  61117. /** Gets or sets line width */
  61118. lineWidth: number;
  61119. /** Gets or sets horizontal alignment */
  61120. horizontalAlignment: number;
  61121. /** Gets or sets vertical alignment */
  61122. verticalAlignment: number;
  61123. private readonly _effectiveX2;
  61124. private readonly _effectiveY2;
  61125. /**
  61126. * Creates a new Line
  61127. * @param name defines the control name
  61128. */
  61129. constructor(name?: string | undefined);
  61130. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  61131. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61132. /**
  61133. * Move one end of the line given 3D cartesian coordinates.
  61134. * @param position Targeted world position
  61135. * @param scene BABYLON.Scene
  61136. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61137. */
  61138. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61139. /**
  61140. * Move one end of the line to a position in screen absolute space.
  61141. * @param projectedPosition Position in screen absolute space (X, Y)
  61142. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61143. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61144. }
  61145. }
  61146. declare module BABYLON.GUI {
  61147. /**
  61148. * Class used to store a point for a MultiLine object.
  61149. * The point can be pure 2D coordinates, a mesh or a control
  61150. */
  61151. export class MultiLinePoint {
  61152. private _multiLine;
  61153. private _x;
  61154. private _y;
  61155. private _control;
  61156. private _mesh;
  61157. private _controlObserver;
  61158. private _meshObserver;
  61159. /** @hidden */ private _point: BABYLON.Vector2;
  61160. /**
  61161. * Creates a new MultiLinePoint
  61162. * @param multiLine defines the source MultiLine object
  61163. */
  61164. constructor(multiLine: MultiLine);
  61165. /** Gets or sets x coordinate */
  61166. x: string | number;
  61167. /** Gets or sets y coordinate */
  61168. y: string | number;
  61169. /** Gets or sets the control associated with this point */
  61170. control: BABYLON.Nullable<Control>;
  61171. /** Gets or sets the mesh associated with this point */
  61172. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61173. /** Resets links */
  61174. resetLinks(): void;
  61175. /**
  61176. * Gets a translation vector
  61177. * @returns the translation vector
  61178. */
  61179. translate(): BABYLON.Vector2;
  61180. private _translatePoint;
  61181. /** Release associated resources */
  61182. dispose(): void;
  61183. }
  61184. }
  61185. declare module BABYLON.GUI {
  61186. /**
  61187. * Class used to create multi line control
  61188. */
  61189. export class MultiLine extends Control {
  61190. name?: string | undefined;
  61191. private _lineWidth;
  61192. private _dash;
  61193. private _points;
  61194. private _minX;
  61195. private _minY;
  61196. private _maxX;
  61197. private _maxY;
  61198. /**
  61199. * Creates a new MultiLine
  61200. * @param name defines the control name
  61201. */
  61202. constructor(name?: string | undefined);
  61203. /** Gets or sets dash pattern */
  61204. dash: Array<number>;
  61205. /**
  61206. * Gets point stored at specified index
  61207. * @param index defines the index to look for
  61208. * @returns the requested point if found
  61209. */
  61210. getAt(index: number): MultiLinePoint;
  61211. /** Function called when a point is updated */
  61212. onPointUpdate: () => void;
  61213. /**
  61214. * Adds new points to the point collection
  61215. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61216. * @returns the list of created MultiLinePoint
  61217. */
  61218. add(...items: (AbstractMesh | Control | {
  61219. x: string | number;
  61220. y: string | number;
  61221. })[]): MultiLinePoint[];
  61222. /**
  61223. * Adds a new point to the point collection
  61224. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61225. * @returns the created MultiLinePoint
  61226. */
  61227. push(item?: (AbstractMesh | Control | {
  61228. x: string | number;
  61229. y: string | number;
  61230. })): MultiLinePoint;
  61231. /**
  61232. * Remove a specific value or point from the active point collection
  61233. * @param value defines the value or point to remove
  61234. */
  61235. remove(value: number | MultiLinePoint): void;
  61236. /**
  61237. * Resets this object to initial state (no point)
  61238. */
  61239. reset(): void;
  61240. /**
  61241. * Resets all links
  61242. */
  61243. resetLinks(): void;
  61244. /** Gets or sets line width */
  61245. lineWidth: number;
  61246. horizontalAlignment: number;
  61247. verticalAlignment: number;
  61248. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61249. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  61250. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61251. dispose(): void;
  61252. }
  61253. }
  61254. declare module BABYLON.GUI {
  61255. /**
  61256. * Class used to create radio button controls
  61257. */
  61258. export class RadioButton extends Control {
  61259. name?: string | undefined;
  61260. private _isChecked;
  61261. private _background;
  61262. private _checkSizeRatio;
  61263. private _thickness;
  61264. /** Gets or sets border thickness */
  61265. thickness: number;
  61266. /** Gets or sets group name */
  61267. group: string;
  61268. /** BABYLON.Observable raised when isChecked is changed */
  61269. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61270. /** Gets or sets a value indicating the ratio between overall size and check size */
  61271. checkSizeRatio: number;
  61272. /** Gets or sets background color */
  61273. background: string;
  61274. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61275. isChecked: boolean;
  61276. /**
  61277. * Creates a new RadioButton
  61278. * @param name defines the control name
  61279. */
  61280. constructor(name?: string | undefined);
  61281. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61282. /**
  61283. * Utility function to easily create a radio button with a header
  61284. * @param title defines the label to use for the header
  61285. * @param group defines the group to use for the radio button
  61286. * @param isChecked defines the initial state of the radio button
  61287. * @param onValueChanged defines the callback to call when value changes
  61288. * @returns a StackPanel containing the radio button and a textBlock
  61289. */
  61290. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61291. }
  61292. }
  61293. declare module BABYLON.GUI {
  61294. /**
  61295. * Class used to create slider controls
  61296. */
  61297. export class BaseSlider extends Control {
  61298. name?: string | undefined;
  61299. protected _thumbWidth: ValueAndUnit;
  61300. private _minimum;
  61301. private _maximum;
  61302. private _value;
  61303. private _isVertical;
  61304. protected _barOffset: ValueAndUnit;
  61305. private _isThumbClamped;
  61306. protected _displayThumb: boolean;
  61307. private _step;
  61308. private _lastPointerDownID;
  61309. protected _effectiveBarOffset: number;
  61310. protected _renderLeft: number;
  61311. protected _renderTop: number;
  61312. protected _renderWidth: number;
  61313. protected _renderHeight: number;
  61314. protected _backgroundBoxLength: number;
  61315. protected _backgroundBoxThickness: number;
  61316. protected _effectiveThumbThickness: number;
  61317. /** BABYLON.Observable raised when the sldier value changes */
  61318. onValueChangedObservable: BABYLON.Observable<number>;
  61319. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61320. displayThumb: boolean;
  61321. /** Gets or sets a step to apply to values (0 by default) */
  61322. step: number;
  61323. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61324. barOffset: string | number;
  61325. /** Gets main bar offset in pixels*/
  61326. readonly barOffsetInPixels: number;
  61327. /** Gets or sets thumb width */
  61328. thumbWidth: string | number;
  61329. /** Gets thumb width in pixels */
  61330. readonly thumbWidthInPixels: number;
  61331. /** Gets or sets minimum value */
  61332. minimum: number;
  61333. /** Gets or sets maximum value */
  61334. maximum: number;
  61335. /** Gets or sets current value */
  61336. value: number;
  61337. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61338. isVertical: boolean;
  61339. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61340. isThumbClamped: boolean;
  61341. /**
  61342. * Creates a new BaseSlider
  61343. * @param name defines the control name
  61344. */
  61345. constructor(name?: string | undefined);
  61346. protected _getTypeName(): string;
  61347. protected _getThumbPosition(): number;
  61348. protected _getThumbThickness(type: string): number;
  61349. protected _prepareRenderingData(type: string): void;
  61350. private _pointerIsDown;
  61351. /** @hidden */
  61352. 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;
  61353. }
  61354. }
  61355. declare module BABYLON.GUI {
  61356. /**
  61357. * Class used to create slider controls
  61358. */
  61359. export class Slider extends BaseSlider {
  61360. name?: string | undefined;
  61361. private _background;
  61362. private _borderColor;
  61363. private _isThumbCircle;
  61364. protected _displayValueBar: boolean;
  61365. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61366. displayValueBar: boolean;
  61367. /** Gets or sets border color */
  61368. borderColor: string;
  61369. /** Gets or sets background color */
  61370. background: string;
  61371. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61372. isThumbCircle: boolean;
  61373. /**
  61374. * Creates a new Slider
  61375. * @param name defines the control name
  61376. */
  61377. constructor(name?: string | undefined);
  61378. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61379. }
  61380. }
  61381. declare module BABYLON.GUI {
  61382. /** Class used to create a RadioGroup
  61383. * which contains groups of radio buttons
  61384. */
  61385. export class SelectorGroup {
  61386. /** name of SelectorGroup */
  61387. name: string;
  61388. private _groupPanel;
  61389. private _selectors;
  61390. private _groupHeader;
  61391. /**
  61392. * Creates a new SelectorGroup
  61393. * @param name of group, used as a group heading
  61394. */
  61395. constructor(
  61396. /** name of SelectorGroup */
  61397. name: string);
  61398. /** Gets the groupPanel of the SelectorGroup */
  61399. readonly groupPanel: StackPanel;
  61400. /** Gets the selectors array */
  61401. readonly selectors: StackPanel[];
  61402. /** Gets and sets the group header */
  61403. header: string;
  61404. /** @hidden */
  61405. private _addGroupHeader;
  61406. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  61407. /** Removes the selector at the given position
  61408. * @param selectorNb the position of the selector within the group
  61409. */
  61410. removeSelector(selectorNb: number): void;
  61411. }
  61412. /** Class used to create a CheckboxGroup
  61413. * which contains groups of checkbox buttons
  61414. */
  61415. export class CheckboxGroup extends SelectorGroup {
  61416. /** Adds a checkbox as a control
  61417. * @param text is the label for the selector
  61418. * @param func is the function called when the Selector is checked
  61419. * @param checked is true when Selector is checked
  61420. */
  61421. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61422. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61423. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61424. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61425. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61426. }
  61427. /** Class used to create a RadioGroup
  61428. * which contains groups of radio buttons
  61429. */
  61430. export class RadioGroup extends SelectorGroup {
  61431. private _selectNb;
  61432. /** Adds a radio button as a control
  61433. * @param label is the label for the selector
  61434. * @param func is the function called when the Selector is checked
  61435. * @param checked is true when Selector is checked
  61436. */
  61437. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61438. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61439. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61440. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61441. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61442. }
  61443. /** Class used to create a SliderGroup
  61444. * which contains groups of slider buttons
  61445. */
  61446. export class SliderGroup extends SelectorGroup {
  61447. /**
  61448. * Adds a slider to the SelectorGroup
  61449. * @param label is the label for the SliderBar
  61450. * @param func is the function called when the Slider moves
  61451. * @param unit is a string describing the units used, eg degrees or metres
  61452. * @param min is the minimum value for the Slider
  61453. * @param max is the maximum value for the Slider
  61454. * @param value is the start value for the Slider between min and max
  61455. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61456. */
  61457. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61458. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61459. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61460. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61461. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61462. }
  61463. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61464. * @see http://doc.babylonjs.com/how_to/selector
  61465. */
  61466. export class SelectionPanel extends Rectangle {
  61467. /** name of SelectionPanel */
  61468. name: string;
  61469. /** an array of SelectionGroups */
  61470. groups: SelectorGroup[];
  61471. private _panel;
  61472. private _buttonColor;
  61473. private _buttonBackground;
  61474. private _headerColor;
  61475. private _barColor;
  61476. private _barHeight;
  61477. private _spacerHeight;
  61478. private _labelColor;
  61479. private _groups;
  61480. private _bars;
  61481. /**
  61482. * Creates a new SelectionPanel
  61483. * @param name of SelectionPanel
  61484. * @param groups is an array of SelectionGroups
  61485. */
  61486. constructor(
  61487. /** name of SelectionPanel */
  61488. name: string,
  61489. /** an array of SelectionGroups */
  61490. groups?: SelectorGroup[]);
  61491. protected _getTypeName(): string;
  61492. /** Gets or sets the headerColor */
  61493. headerColor: string;
  61494. private _setHeaderColor;
  61495. /** Gets or sets the button color */
  61496. buttonColor: string;
  61497. private _setbuttonColor;
  61498. /** Gets or sets the label color */
  61499. labelColor: string;
  61500. private _setLabelColor;
  61501. /** Gets or sets the button background */
  61502. buttonBackground: string;
  61503. private _setButtonBackground;
  61504. /** Gets or sets the color of separator bar */
  61505. barColor: string;
  61506. private _setBarColor;
  61507. /** Gets or sets the height of separator bar */
  61508. barHeight: string;
  61509. private _setBarHeight;
  61510. /** Gets or sets the height of spacers*/
  61511. spacerHeight: string;
  61512. private _setSpacerHeight;
  61513. /** Adds a bar between groups */
  61514. private _addSpacer;
  61515. /** Add a group to the selection panel
  61516. * @param group is the selector group to add
  61517. */
  61518. addGroup(group: SelectorGroup): void;
  61519. /** Remove the group from the given position
  61520. * @param groupNb is the position of the group in the list
  61521. */
  61522. removeGroup(groupNb: number): void;
  61523. /** Change a group header label
  61524. * @param label is the new group header label
  61525. * @param groupNb is the number of the group to relabel
  61526. * */
  61527. setHeaderName(label: string, groupNb: number): void;
  61528. /** Change selector label to the one given
  61529. * @param label is the new selector label
  61530. * @param groupNb is the number of the groupcontaining the selector
  61531. * @param selectorNb is the number of the selector within a group to relabel
  61532. * */
  61533. relabel(label: string, groupNb: number, selectorNb: number): void;
  61534. /** For a given group position remove the selector at the given position
  61535. * @param groupNb is the number of the group to remove the selector from
  61536. * @param selectorNb is the number of the selector within the group
  61537. */
  61538. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61539. /** For a given group position of correct type add a checkbox button
  61540. * @param groupNb is the number of the group to remove the selector from
  61541. * @param label is the label for the selector
  61542. * @param func is the function called when the Selector is checked
  61543. * @param checked is true when Selector is checked
  61544. */
  61545. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61546. /** For a given group position of correct type add a radio button
  61547. * @param groupNb is the number of the group to remove the selector from
  61548. * @param label is the label for the selector
  61549. * @param func is the function called when the Selector is checked
  61550. * @param checked is true when Selector is checked
  61551. */
  61552. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61553. /**
  61554. * For a given slider group add a slider
  61555. * @param groupNb is the number of the group to add the slider to
  61556. * @param label is the label for the Slider
  61557. * @param func is the function called when the Slider moves
  61558. * @param unit is a string describing the units used, eg degrees or metres
  61559. * @param min is the minimum value for the Slider
  61560. * @param max is the maximum value for the Slider
  61561. * @param value is the start value for the Slider between min and max
  61562. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61563. */
  61564. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61565. }
  61566. }
  61567. declare module BABYLON.GUI {
  61568. /**
  61569. * Class used to hold a the container for ScrollViewer
  61570. * @hidden
  61571. */
  61572. export class _ScrollViewerWindow extends Container {
  61573. parentClientWidth: number;
  61574. parentClientHeight: number;
  61575. /**
  61576. * Creates a new ScrollViewerWindow
  61577. * @param name of ScrollViewerWindow
  61578. */
  61579. constructor(name?: string);
  61580. protected _getTypeName(): string;
  61581. /** @hidden */
  61582. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61583. protected _postMeasure(): void;
  61584. }
  61585. }
  61586. declare module BABYLON.GUI {
  61587. /**
  61588. * Class used to create slider controls
  61589. */
  61590. export class ScrollBar extends BaseSlider {
  61591. name?: string | undefined;
  61592. private _background;
  61593. private _borderColor;
  61594. private _thumbMeasure;
  61595. /** Gets or sets border color */
  61596. borderColor: string;
  61597. /** Gets or sets background color */
  61598. background: string;
  61599. /**
  61600. * Creates a new Slider
  61601. * @param name defines the control name
  61602. */
  61603. constructor(name?: string | undefined);
  61604. protected _getTypeName(): string;
  61605. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  61606. private _first;
  61607. private _originX;
  61608. private _originY;
  61609. /** @hidden */
  61610. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61611. }
  61612. }
  61613. declare module BABYLON.GUI {
  61614. /**
  61615. * Class used to hold a viewer window and sliders in a grid
  61616. */
  61617. export class ScrollViewer extends Rectangle {
  61618. private _grid;
  61619. private _horizontalBarSpace;
  61620. private _verticalBarSpace;
  61621. private _dragSpace;
  61622. private _horizontalBar;
  61623. private _verticalBar;
  61624. private _barColor;
  61625. private _barBackground;
  61626. private _barSize;
  61627. private _endLeft;
  61628. private _endTop;
  61629. private _window;
  61630. private _pointerIsOver;
  61631. private _wheelPrecision;
  61632. private _onPointerObserver;
  61633. private _clientWidth;
  61634. private _clientHeight;
  61635. /**
  61636. * Gets the horizontal scrollbar
  61637. */
  61638. readonly horizontalBar: ScrollBar;
  61639. /**
  61640. * Gets the vertical scrollbar
  61641. */
  61642. readonly verticalBar: ScrollBar;
  61643. /**
  61644. * Adds a new control to the current container
  61645. * @param control defines the control to add
  61646. * @returns the current container
  61647. */
  61648. addControl(control: BABYLON.Nullable<Control>): Container;
  61649. /**
  61650. * Removes a control from the current container
  61651. * @param control defines the control to remove
  61652. * @returns the current container
  61653. */
  61654. removeControl(control: Control): Container;
  61655. /** Gets the list of children */
  61656. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  61657. /**
  61658. * Creates a new ScrollViewer
  61659. * @param name of ScrollViewer
  61660. */
  61661. constructor(name?: string);
  61662. /** Reset the scroll viewer window to initial size */
  61663. resetWindow(): void;
  61664. protected _getTypeName(): string;
  61665. private _buildClientSizes;
  61666. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61667. protected _postMeasure(): void;
  61668. /**
  61669. * Gets or sets the mouse wheel precision
  61670. * from 0 to 1 with a default value of 0.05
  61671. * */
  61672. wheelPrecision: number;
  61673. /** Gets or sets the bar color */
  61674. barColor: string;
  61675. /** Gets or sets the size of the bar */
  61676. barSize: number;
  61677. /** Gets or sets the bar background */
  61678. barBackground: string;
  61679. /** @hidden */
  61680. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  61681. /** @hidden */
  61682. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61683. /** Releases associated resources */
  61684. dispose(): void;
  61685. }
  61686. }
  61687. declare module BABYLON.GUI {
  61688. /** Class used to render a grid */
  61689. export class DisplayGrid extends Control {
  61690. name?: string | undefined;
  61691. private _cellWidth;
  61692. private _cellHeight;
  61693. private _minorLineTickness;
  61694. private _minorLineColor;
  61695. private _majorLineTickness;
  61696. private _majorLineColor;
  61697. private _majorLineFrequency;
  61698. private _background;
  61699. private _displayMajorLines;
  61700. private _displayMinorLines;
  61701. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  61702. displayMinorLines: boolean;
  61703. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  61704. displayMajorLines: boolean;
  61705. /** Gets or sets background color (Black by default) */
  61706. background: string;
  61707. /** Gets or sets the width of each cell (20 by default) */
  61708. cellWidth: number;
  61709. /** Gets or sets the height of each cell (20 by default) */
  61710. cellHeight: number;
  61711. /** Gets or sets the tickness of minor lines (1 by default) */
  61712. minorLineTickness: number;
  61713. /** Gets or sets the color of minor lines (DarkGray by default) */
  61714. minorLineColor: string;
  61715. /** Gets or sets the tickness of major lines (2 by default) */
  61716. majorLineTickness: number;
  61717. /** Gets or sets the color of major lines (White by default) */
  61718. majorLineColor: string;
  61719. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  61720. majorLineFrequency: number;
  61721. /**
  61722. * Creates a new GridDisplayRectangle
  61723. * @param name defines the control name
  61724. */
  61725. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  61726. protected _getTypeName(): string;
  61727. }
  61728. }
  61729. declare module BABYLON.GUI {
  61730. /**
  61731. * Class used to create slider controls based on images
  61732. */
  61733. export class ImageBasedSlider extends BaseSlider {
  61734. name?: string | undefined;
  61735. private _backgroundImage;
  61736. private _thumbImage;
  61737. private _valueBarImage;
  61738. private _tempMeasure;
  61739. displayThumb: boolean;
  61740. /**
  61741. * Gets or sets the image used to render the background
  61742. */
  61743. backgroundImage: Image;
  61744. /**
  61745. * Gets or sets the image used to render the value bar
  61746. */
  61747. valueBarImage: Image;
  61748. /**
  61749. * Gets or sets the image used to render the thumb
  61750. */
  61751. thumbImage: Image;
  61752. /**
  61753. * Creates a new ImageBasedSlider
  61754. * @param name defines the control name
  61755. */
  61756. constructor(name?: string | undefined);
  61757. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61758. }
  61759. }
  61760. declare module BABYLON.GUI {
  61761. /**
  61762. * Forcing an export so that this code will execute
  61763. * @hidden
  61764. */
  61765. const name = "Statics";
  61766. }
  61767. declare module BABYLON.GUI {
  61768. /**
  61769. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  61770. */
  61771. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  61772. /**
  61773. * Define the instrumented AdvancedDynamicTexture.
  61774. */
  61775. texture: AdvancedDynamicTexture;
  61776. private _captureRenderTime;
  61777. private _renderTime;
  61778. private _captureLayoutTime;
  61779. private _layoutTime;
  61780. private _onBeginRenderObserver;
  61781. private _onEndRenderObserver;
  61782. private _onBeginLayoutObserver;
  61783. private _onEndLayoutObserver;
  61784. /**
  61785. * Gets the perf counter used to capture render time
  61786. */
  61787. readonly renderTimeCounter: BABYLON.PerfCounter;
  61788. /**
  61789. * Gets the perf counter used to capture layout time
  61790. */
  61791. readonly layoutTimeCounter: BABYLON.PerfCounter;
  61792. /**
  61793. * Enable or disable the render time capture
  61794. */
  61795. captureRenderTime: boolean;
  61796. /**
  61797. * Enable or disable the layout time capture
  61798. */
  61799. captureLayoutTime: boolean;
  61800. /**
  61801. * Instantiates a new advanced dynamic texture instrumentation.
  61802. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  61803. * @param texture Defines the AdvancedDynamicTexture to instrument
  61804. */
  61805. constructor(
  61806. /**
  61807. * Define the instrumented AdvancedDynamicTexture.
  61808. */
  61809. texture: AdvancedDynamicTexture);
  61810. /**
  61811. * Dispose and release associated resources.
  61812. */
  61813. dispose(): void;
  61814. }
  61815. }
  61816. declare module BABYLON.GUI {
  61817. /**
  61818. * Class used to create containers for controls
  61819. */
  61820. export class Container3D extends Control3D {
  61821. private _blockLayout;
  61822. /**
  61823. * Gets the list of child controls
  61824. */
  61825. protected _children: Control3D[];
  61826. /**
  61827. * Gets the list of child controls
  61828. */
  61829. readonly children: Array<Control3D>;
  61830. /**
  61831. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  61832. * This is helpful to optimize layout operation when adding multiple children in a row
  61833. */
  61834. blockLayout: boolean;
  61835. /**
  61836. * Creates a new container
  61837. * @param name defines the container name
  61838. */
  61839. constructor(name?: string);
  61840. /**
  61841. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  61842. * @returns the current container
  61843. */
  61844. updateLayout(): Container3D;
  61845. /**
  61846. * Gets a boolean indicating if the given control is in the children of this control
  61847. * @param control defines the control to check
  61848. * @returns true if the control is in the child list
  61849. */
  61850. containsControl(control: Control3D): boolean;
  61851. /**
  61852. * Adds a control to the children of this control
  61853. * @param control defines the control to add
  61854. * @returns the current container
  61855. */
  61856. addControl(control: Control3D): Container3D;
  61857. /**
  61858. * This function will be called everytime a new control is added
  61859. */
  61860. protected _arrangeChildren(): void;
  61861. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61862. /**
  61863. * Removes a control from the children of this control
  61864. * @param control defines the control to remove
  61865. * @returns the current container
  61866. */
  61867. removeControl(control: Control3D): Container3D;
  61868. protected _getTypeName(): string;
  61869. /**
  61870. * Releases all associated resources
  61871. */
  61872. dispose(): void;
  61873. /** Control rotation will remain unchanged */
  61874. static readonly UNSET_ORIENTATION: number;
  61875. /** Control will rotate to make it look at sphere central axis */
  61876. static readonly FACEORIGIN_ORIENTATION: number;
  61877. /** Control will rotate to make it look back at sphere central axis */
  61878. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  61879. /** Control will rotate to look at z axis (0, 0, 1) */
  61880. static readonly FACEFORWARD_ORIENTATION: number;
  61881. /** Control will rotate to look at negative z axis (0, 0, -1) */
  61882. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  61883. }
  61884. }
  61885. declare module BABYLON.GUI {
  61886. /**
  61887. * Class used to manage 3D user interface
  61888. * @see http://doc.babylonjs.com/how_to/gui3d
  61889. */
  61890. export class GUI3DManager implements BABYLON.IDisposable {
  61891. private _scene;
  61892. private _sceneDisposeObserver;
  61893. private _utilityLayer;
  61894. private _rootContainer;
  61895. private _pointerObserver;
  61896. private _pointerOutObserver;
  61897. /** @hidden */ private _lastPickedControl: Control3D;
  61898. /** @hidden */ private _lastControlOver: {
  61899. [pointerId: number]: Control3D;
  61900. };
  61901. /** @hidden */ private _lastControlDown: {
  61902. [pointerId: number]: Control3D;
  61903. };
  61904. /**
  61905. * BABYLON.Observable raised when the point picked by the pointer events changed
  61906. */
  61907. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  61908. /** @hidden */ private _sharedMaterials: {
  61909. [key: string]: BABYLON.Material;
  61910. };
  61911. /** Gets the hosting scene */
  61912. readonly scene: BABYLON.Scene;
  61913. /** Gets associated utility layer */
  61914. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  61915. /**
  61916. * Creates a new GUI3DManager
  61917. * @param scene
  61918. */
  61919. constructor(scene?: BABYLON.Scene);
  61920. private _handlePointerOut;
  61921. private _doPicking;
  61922. /**
  61923. * Gets the root container
  61924. */
  61925. readonly rootContainer: Container3D;
  61926. /**
  61927. * Gets a boolean indicating if the given control is in the root child list
  61928. * @param control defines the control to check
  61929. * @returns true if the control is in the root child list
  61930. */
  61931. containsControl(control: Control3D): boolean;
  61932. /**
  61933. * Adds a control to the root child list
  61934. * @param control defines the control to add
  61935. * @returns the current manager
  61936. */
  61937. addControl(control: Control3D): GUI3DManager;
  61938. /**
  61939. * Removes a control from the root child list
  61940. * @param control defines the control to remove
  61941. * @returns the current container
  61942. */
  61943. removeControl(control: Control3D): GUI3DManager;
  61944. /**
  61945. * Releases all associated resources
  61946. */
  61947. dispose(): void;
  61948. }
  61949. }
  61950. declare module BABYLON.GUI {
  61951. /**
  61952. * Class used to transport BABYLON.Vector3 information for pointer events
  61953. */
  61954. export class Vector3WithInfo extends BABYLON.Vector3 {
  61955. /** defines the current mouse button index */
  61956. buttonIndex: number;
  61957. /**
  61958. * Creates a new Vector3WithInfo
  61959. * @param source defines the vector3 data to transport
  61960. * @param buttonIndex defines the current mouse button index
  61961. */
  61962. constructor(source: BABYLON.Vector3,
  61963. /** defines the current mouse button index */
  61964. buttonIndex?: number);
  61965. }
  61966. }
  61967. declare module BABYLON.GUI {
  61968. /**
  61969. * Class used as base class for controls
  61970. */
  61971. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  61972. /** Defines the control name */
  61973. name?: string | undefined;
  61974. /** @hidden */ private _host: GUI3DManager;
  61975. private _node;
  61976. private _downCount;
  61977. private _enterCount;
  61978. private _downPointerIds;
  61979. private _isVisible;
  61980. /** Gets or sets the control position in world space */
  61981. position: BABYLON.Vector3;
  61982. /** Gets or sets the control scaling in world space */
  61983. scaling: BABYLON.Vector3;
  61984. /** Callback used to start pointer enter animation */
  61985. pointerEnterAnimation: () => void;
  61986. /** Callback used to start pointer out animation */
  61987. pointerOutAnimation: () => void;
  61988. /** Callback used to start pointer down animation */
  61989. pointerDownAnimation: () => void;
  61990. /** Callback used to start pointer up animation */
  61991. pointerUpAnimation: () => void;
  61992. /**
  61993. * An event triggered when the pointer move over the control
  61994. */
  61995. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  61996. /**
  61997. * An event triggered when the pointer move out of the control
  61998. */
  61999. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62000. /**
  62001. * An event triggered when the pointer taps the control
  62002. */
  62003. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62004. /**
  62005. * An event triggered when pointer is up
  62006. */
  62007. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62008. /**
  62009. * An event triggered when a control is clicked on (with a mouse)
  62010. */
  62011. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62012. /**
  62013. * An event triggered when pointer enters the control
  62014. */
  62015. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62016. /**
  62017. * Gets or sets the parent container
  62018. */
  62019. parent: BABYLON.Nullable<Container3D>;
  62020. private _behaviors;
  62021. /**
  62022. * Gets the list of attached behaviors
  62023. * @see http://doc.babylonjs.com/features/behaviour
  62024. */
  62025. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62026. /**
  62027. * Attach a behavior to the control
  62028. * @see http://doc.babylonjs.com/features/behaviour
  62029. * @param behavior defines the behavior to attach
  62030. * @returns the current control
  62031. */
  62032. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62033. /**
  62034. * Remove an attached behavior
  62035. * @see http://doc.babylonjs.com/features/behaviour
  62036. * @param behavior defines the behavior to attach
  62037. * @returns the current control
  62038. */
  62039. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62040. /**
  62041. * Gets an attached behavior by name
  62042. * @param name defines the name of the behavior to look for
  62043. * @see http://doc.babylonjs.com/features/behaviour
  62044. * @returns null if behavior was not found else the requested behavior
  62045. */
  62046. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62047. /** Gets or sets a boolean indicating if the control is visible */
  62048. isVisible: boolean;
  62049. /**
  62050. * Creates a new control
  62051. * @param name defines the control name
  62052. */
  62053. constructor(
  62054. /** Defines the control name */
  62055. name?: string | undefined);
  62056. /**
  62057. * Gets a string representing the class name
  62058. */
  62059. readonly typeName: string;
  62060. /**
  62061. * Get the current class name of the control.
  62062. * @returns current class name
  62063. */
  62064. getClassName(): string;
  62065. protected _getTypeName(): string;
  62066. /**
  62067. * Gets the transform node used by this control
  62068. */
  62069. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62070. /**
  62071. * Gets the mesh used to render this control
  62072. */
  62073. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62074. /**
  62075. * Link the control as child of the given node
  62076. * @param node defines the node to link to. Use null to unlink the control
  62077. * @returns the current control
  62078. */
  62079. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62080. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  62081. /**
  62082. * Node creation.
  62083. * Can be overriden by children
  62084. * @param scene defines the scene where the node must be attached
  62085. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62086. */
  62087. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62088. /**
  62089. * Affect a material to the given mesh
  62090. * @param mesh defines the mesh which will represent the control
  62091. */
  62092. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62093. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62094. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  62095. /** @hidden */ private _onPointerOut(target: Control3D): void;
  62096. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62097. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62098. /** @hidden */
  62099. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62100. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62101. /** @hidden */ private _disposeNode(): void;
  62102. /**
  62103. * Releases all associated resources
  62104. */
  62105. dispose(): void;
  62106. }
  62107. }
  62108. declare module BABYLON.GUI {
  62109. /**
  62110. * Class used as a root to all buttons
  62111. */
  62112. export class AbstractButton3D extends Control3D {
  62113. /**
  62114. * Creates a new button
  62115. * @param name defines the control name
  62116. */
  62117. constructor(name?: string);
  62118. protected _getTypeName(): string;
  62119. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62120. }
  62121. }
  62122. declare module BABYLON.GUI {
  62123. /**
  62124. * Class used to create a button in 3D
  62125. */
  62126. export class Button3D extends AbstractButton3D {
  62127. /** @hidden */
  62128. protected _currentMaterial: BABYLON.Material;
  62129. private _facadeTexture;
  62130. private _content;
  62131. private _contentResolution;
  62132. private _contentScaleRatio;
  62133. /**
  62134. * Gets or sets the texture resolution used to render content (512 by default)
  62135. */
  62136. contentResolution: BABYLON.int;
  62137. /**
  62138. * Gets or sets the texture scale ratio used to render content (2 by default)
  62139. */
  62140. contentScaleRatio: number;
  62141. protected _disposeFacadeTexture(): void;
  62142. protected _resetContent(): void;
  62143. /**
  62144. * Creates a new button
  62145. * @param name defines the control name
  62146. */
  62147. constructor(name?: string);
  62148. /**
  62149. * Gets or sets the GUI 2D content used to display the button's facade
  62150. */
  62151. content: Control;
  62152. /**
  62153. * Apply the facade texture (created from the content property).
  62154. * This function can be overloaded by child classes
  62155. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62156. */
  62157. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62158. protected _getTypeName(): string;
  62159. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62160. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62161. /**
  62162. * Releases all associated resources
  62163. */
  62164. dispose(): void;
  62165. }
  62166. }
  62167. declare module BABYLON.GUI {
  62168. /**
  62169. * Abstract class used to create a container panel deployed on the surface of a volume
  62170. */
  62171. export abstract class VolumeBasedPanel extends Container3D {
  62172. private _columns;
  62173. private _rows;
  62174. private _rowThenColum;
  62175. private _orientation;
  62176. protected _cellWidth: number;
  62177. protected _cellHeight: number;
  62178. /**
  62179. * Gets or sets the distance between elements
  62180. */
  62181. margin: number;
  62182. /**
  62183. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62184. * | Value | Type | Description |
  62185. * | ----- | ----------------------------------- | ----------- |
  62186. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62187. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62188. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62189. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62190. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62191. */
  62192. orientation: number;
  62193. /**
  62194. * Gets or sets the number of columns requested (10 by default).
  62195. * The panel will automatically compute the number of rows based on number of child controls.
  62196. */
  62197. columns: BABYLON.int;
  62198. /**
  62199. * Gets or sets a the number of rows requested.
  62200. * The panel will automatically compute the number of columns based on number of child controls.
  62201. */
  62202. rows: BABYLON.int;
  62203. /**
  62204. * Creates new VolumeBasedPanel
  62205. */
  62206. constructor();
  62207. protected _arrangeChildren(): void;
  62208. /** Child classes must implement this function to provide correct control positioning */
  62209. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62210. /** Child classes can implement this function to provide additional processing */
  62211. protected _finalProcessing(): void;
  62212. }
  62213. }
  62214. declare module BABYLON.GUI {
  62215. /**
  62216. * Class used to create a container panel deployed on the surface of a cylinder
  62217. */
  62218. export class CylinderPanel extends VolumeBasedPanel {
  62219. private _radius;
  62220. /**
  62221. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62222. */
  62223. radius: BABYLON.float;
  62224. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62225. private _cylindricalMapping;
  62226. }
  62227. }
  62228. declare module BABYLON.GUI {
  62229. /** @hidden */
  62230. export var fluentVertexShader: {
  62231. name: string;
  62232. shader: string;
  62233. };
  62234. }
  62235. declare module BABYLON.GUI {
  62236. /** @hidden */
  62237. export var fluentPixelShader: {
  62238. name: string;
  62239. shader: string;
  62240. };
  62241. }
  62242. declare module BABYLON.GUI {
  62243. /** @hidden */
  62244. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62245. INNERGLOW: boolean;
  62246. BORDER: boolean;
  62247. HOVERLIGHT: boolean;
  62248. TEXTURE: boolean;
  62249. constructor();
  62250. }
  62251. /**
  62252. * Class used to render controls with fluent desgin
  62253. */
  62254. export class FluentMaterial extends BABYLON.PushMaterial {
  62255. /**
  62256. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62257. */
  62258. innerGlowColorIntensity: number;
  62259. /**
  62260. * Gets or sets the inner glow color (white by default)
  62261. */
  62262. innerGlowColor: BABYLON.Color3;
  62263. /**
  62264. * Gets or sets alpha value (default is 1.0)
  62265. */
  62266. alpha: number;
  62267. /**
  62268. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62269. */
  62270. albedoColor: BABYLON.Color3;
  62271. /**
  62272. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62273. */
  62274. renderBorders: boolean;
  62275. /**
  62276. * Gets or sets border width (default is 0.5)
  62277. */
  62278. borderWidth: number;
  62279. /**
  62280. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62281. */
  62282. edgeSmoothingValue: number;
  62283. /**
  62284. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62285. */
  62286. borderMinValue: number;
  62287. /**
  62288. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62289. */
  62290. renderHoverLight: boolean;
  62291. /**
  62292. * Gets or sets the radius used to render the hover light (default is 1.0)
  62293. */
  62294. hoverRadius: number;
  62295. /**
  62296. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62297. */
  62298. hoverColor: BABYLON.Color4;
  62299. /**
  62300. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62301. */
  62302. hoverPosition: BABYLON.Vector3;
  62303. private _albedoTexture;
  62304. /** Gets or sets the texture to use for albedo color */
  62305. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62306. /**
  62307. * Creates a new Fluent material
  62308. * @param name defines the name of the material
  62309. * @param scene defines the hosting scene
  62310. */
  62311. constructor(name: string, scene: BABYLON.Scene);
  62312. needAlphaBlending(): boolean;
  62313. needAlphaTesting(): boolean;
  62314. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62315. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62317. getActiveTextures(): BABYLON.BaseTexture[];
  62318. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62319. dispose(forceDisposeEffect?: boolean): void;
  62320. clone(name: string): FluentMaterial;
  62321. serialize(): any;
  62322. getClassName(): string;
  62323. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62324. }
  62325. }
  62326. declare module BABYLON.GUI {
  62327. /**
  62328. * Class used to create a holographic button in 3D
  62329. */
  62330. export class HolographicButton extends Button3D {
  62331. private _backPlate;
  62332. private _textPlate;
  62333. private _frontPlate;
  62334. private _text;
  62335. private _imageUrl;
  62336. private _shareMaterials;
  62337. private _frontMaterial;
  62338. private _backMaterial;
  62339. private _plateMaterial;
  62340. private _pickedPointObserver;
  62341. private _tooltipFade;
  62342. private _tooltipTextBlock;
  62343. private _tooltipTexture;
  62344. private _tooltipMesh;
  62345. private _tooltipHoverObserver;
  62346. private _tooltipOutObserver;
  62347. private _disposeTooltip;
  62348. /**
  62349. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62350. */
  62351. tooltipText: BABYLON.Nullable<string>;
  62352. /**
  62353. * Gets or sets text for the button
  62354. */
  62355. text: string;
  62356. /**
  62357. * Gets or sets the image url for the button
  62358. */
  62359. imageUrl: string;
  62360. /**
  62361. * Gets the back material used by this button
  62362. */
  62363. readonly backMaterial: FluentMaterial;
  62364. /**
  62365. * Gets the front material used by this button
  62366. */
  62367. readonly frontMaterial: FluentMaterial;
  62368. /**
  62369. * Gets the plate material used by this button
  62370. */
  62371. readonly plateMaterial: BABYLON.StandardMaterial;
  62372. /**
  62373. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62374. */
  62375. readonly shareMaterials: boolean;
  62376. /**
  62377. * Creates a new button
  62378. * @param name defines the control name
  62379. */
  62380. constructor(name?: string, shareMaterials?: boolean);
  62381. protected _getTypeName(): string;
  62382. private _rebuildContent;
  62383. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62384. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62385. private _createBackMaterial;
  62386. private _createFrontMaterial;
  62387. private _createPlateMaterial;
  62388. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62389. /**
  62390. * Releases all associated resources
  62391. */
  62392. dispose(): void;
  62393. }
  62394. }
  62395. declare module BABYLON.GUI {
  62396. /**
  62397. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62398. */
  62399. export class MeshButton3D extends Button3D {
  62400. /** @hidden */
  62401. protected _currentMesh: BABYLON.Mesh;
  62402. /**
  62403. * Creates a new 3D button based on a mesh
  62404. * @param mesh mesh to become a 3D button
  62405. * @param name defines the control name
  62406. */
  62407. constructor(mesh: BABYLON.Mesh, name?: string);
  62408. protected _getTypeName(): string;
  62409. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62410. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62411. }
  62412. }
  62413. declare module BABYLON.GUI {
  62414. /**
  62415. * Class used to create a container panel deployed on the surface of a plane
  62416. */
  62417. export class PlanePanel extends VolumeBasedPanel {
  62418. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62419. }
  62420. }
  62421. declare module BABYLON.GUI {
  62422. /**
  62423. * Class used to create a container panel where items get randomized planar mapping
  62424. */
  62425. export class ScatterPanel extends VolumeBasedPanel {
  62426. private _iteration;
  62427. /**
  62428. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62429. */
  62430. iteration: BABYLON.float;
  62431. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62432. private _scatterMapping;
  62433. protected _finalProcessing(): void;
  62434. }
  62435. }
  62436. declare module BABYLON.GUI {
  62437. /**
  62438. * Class used to create a container panel deployed on the surface of a sphere
  62439. */
  62440. export class SpherePanel extends VolumeBasedPanel {
  62441. private _radius;
  62442. /**
  62443. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62444. */
  62445. radius: BABYLON.float;
  62446. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62447. private _sphericalMapping;
  62448. }
  62449. }
  62450. declare module BABYLON.GUI {
  62451. /**
  62452. * Class used to create a stack panel in 3D on XY plane
  62453. */
  62454. export class StackPanel3D extends Container3D {
  62455. private _isVertical;
  62456. /**
  62457. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62458. */
  62459. isVertical: boolean;
  62460. /**
  62461. * Gets or sets the distance between elements
  62462. */
  62463. margin: number;
  62464. /**
  62465. * Creates new StackPanel
  62466. * @param isVertical
  62467. */
  62468. constructor(isVertical?: boolean);
  62469. protected _arrangeChildren(): void;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * Mode that determines the coordinate system to use.
  62475. */
  62476. export enum GLTFLoaderCoordinateSystemMode {
  62477. /**
  62478. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62479. */
  62480. AUTO = 0,
  62481. /**
  62482. * Sets the useRightHandedSystem flag on the scene.
  62483. */
  62484. FORCE_RIGHT_HANDED = 1
  62485. }
  62486. /**
  62487. * Mode that determines what animations will start.
  62488. */
  62489. export enum GLTFLoaderAnimationStartMode {
  62490. /**
  62491. * No animation will start.
  62492. */
  62493. NONE = 0,
  62494. /**
  62495. * The first animation will start.
  62496. */
  62497. FIRST = 1,
  62498. /**
  62499. * All animations will start.
  62500. */
  62501. ALL = 2
  62502. }
  62503. /**
  62504. * Interface that contains the data for the glTF asset.
  62505. */
  62506. export interface IGLTFLoaderData {
  62507. /**
  62508. * Object that represents the glTF JSON.
  62509. */
  62510. json: Object;
  62511. /**
  62512. * The BIN chunk of a binary glTF.
  62513. */
  62514. bin: Nullable<ArrayBufferView>;
  62515. }
  62516. /**
  62517. * Interface for extending the loader.
  62518. */
  62519. export interface IGLTFLoaderExtension {
  62520. /**
  62521. * The name of this extension.
  62522. */
  62523. readonly name: string;
  62524. /**
  62525. * Defines whether this extension is enabled.
  62526. */
  62527. enabled: boolean;
  62528. }
  62529. /**
  62530. * Loader state.
  62531. */
  62532. export enum GLTFLoaderState {
  62533. /**
  62534. * The asset is loading.
  62535. */
  62536. LOADING = 0,
  62537. /**
  62538. * The asset is ready for rendering.
  62539. */
  62540. READY = 1,
  62541. /**
  62542. * The asset is completely loaded.
  62543. */
  62544. COMPLETE = 2
  62545. }
  62546. /** @hidden */
  62547. export interface IGLTFLoader extends IDisposable {
  62548. readonly state: Nullable<GLTFLoaderState>;
  62549. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62550. meshes: AbstractMesh[];
  62551. particleSystems: IParticleSystem[];
  62552. skeletons: Skeleton[];
  62553. animationGroups: AnimationGroup[];
  62554. }>;
  62555. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62556. }
  62557. /**
  62558. * File loader for loading glTF files into a scene.
  62559. */
  62560. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62561. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62562. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62563. /**
  62564. * Raised when the asset has been parsed
  62565. */
  62566. onParsedObservable: Observable<IGLTFLoaderData>;
  62567. private _onParsedObserver;
  62568. /**
  62569. * Raised when the asset has been parsed
  62570. */
  62571. onParsed: (loaderData: IGLTFLoaderData) => void;
  62572. /**
  62573. * 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.
  62574. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62575. * Defaults to true.
  62576. * @hidden
  62577. */
  62578. static IncrementalLoading: boolean;
  62579. /**
  62580. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62581. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62582. * @hidden
  62583. */
  62584. static HomogeneousCoordinates: boolean;
  62585. /**
  62586. * The coordinate system mode. Defaults to AUTO.
  62587. */
  62588. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62589. /**
  62590. * The animation start mode. Defaults to FIRST.
  62591. */
  62592. animationStartMode: GLTFLoaderAnimationStartMode;
  62593. /**
  62594. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62595. */
  62596. compileMaterials: boolean;
  62597. /**
  62598. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62599. */
  62600. useClipPlane: boolean;
  62601. /**
  62602. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62603. */
  62604. compileShadowGenerators: boolean;
  62605. /**
  62606. * Defines if the Alpha blended materials are only applied as coverage.
  62607. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62608. * If true, no extra effects are applied to transparent pixels.
  62609. */
  62610. transparencyAsCoverage: boolean;
  62611. /**
  62612. * Function called before loading a url referenced by the asset.
  62613. */
  62614. preprocessUrlAsync: (url: string) => Promise<string>;
  62615. /**
  62616. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62617. */
  62618. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  62619. private _onMeshLoadedObserver;
  62620. /**
  62621. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62622. */
  62623. onMeshLoaded: (mesh: AbstractMesh) => void;
  62624. /**
  62625. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  62626. */
  62627. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  62628. private _onTextureLoadedObserver;
  62629. /**
  62630. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  62631. */
  62632. onTextureLoaded: (texture: BaseTexture) => void;
  62633. /**
  62634. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  62635. */
  62636. readonly onMaterialLoadedObservable: Observable<Material>;
  62637. private _onMaterialLoadedObserver;
  62638. /**
  62639. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  62640. */
  62641. onMaterialLoaded: (material: Material) => void;
  62642. /**
  62643. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  62644. */
  62645. readonly onCameraLoadedObservable: Observable<Camera>;
  62646. private _onCameraLoadedObserver;
  62647. /**
  62648. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  62649. */
  62650. onCameraLoaded: (camera: Camera) => void;
  62651. /**
  62652. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  62653. * For assets with LODs, raised when all of the LODs are complete.
  62654. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62655. */
  62656. readonly onCompleteObservable: Observable<void>;
  62657. private _onCompleteObserver;
  62658. /**
  62659. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  62660. * For assets with LODs, raised when all of the LODs are complete.
  62661. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62662. */
  62663. onComplete: () => void;
  62664. /**
  62665. * Observable raised when an error occurs.
  62666. */
  62667. readonly onErrorObservable: Observable<any>;
  62668. private _onErrorObserver;
  62669. /**
  62670. * Callback raised when an error occurs.
  62671. */
  62672. onError: (reason: any) => void;
  62673. /**
  62674. * Observable raised after the loader is disposed.
  62675. */
  62676. readonly onDisposeObservable: Observable<void>;
  62677. private _onDisposeObserver;
  62678. /**
  62679. * Callback raised after the loader is disposed.
  62680. */
  62681. onDispose: () => void;
  62682. /**
  62683. * Observable raised after a loader extension is created.
  62684. * Set additional options for a loader extension in this event.
  62685. */
  62686. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  62687. private _onExtensionLoadedObserver;
  62688. /**
  62689. * Callback raised after a loader extension is created.
  62690. */
  62691. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  62692. /**
  62693. * Defines if the loader logging is enabled.
  62694. */
  62695. loggingEnabled: boolean;
  62696. /**
  62697. * Defines if the loader should capture performance counters.
  62698. */
  62699. capturePerformanceCounters: boolean;
  62700. /**
  62701. * Defines if the loader should validate the asset.
  62702. */
  62703. validate: boolean;
  62704. /**
  62705. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  62706. */
  62707. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  62708. private _onValidatedObserver;
  62709. /**
  62710. * Callback raised after a loader extension is created.
  62711. */
  62712. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  62713. private _loader;
  62714. /**
  62715. * Name of the loader ("gltf")
  62716. */
  62717. name: string;
  62718. /**
  62719. * Supported file extensions of the loader (.gltf, .glb)
  62720. */
  62721. extensions: ISceneLoaderPluginExtensions;
  62722. /**
  62723. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  62724. */
  62725. dispose(): void;
  62726. /** @hidden */ private _clear(): void;
  62727. /**
  62728. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  62729. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62730. * @param scene the scene the meshes should be added to
  62731. * @param data the glTF data to load
  62732. * @param rootUrl root url to load from
  62733. * @param onProgress event that fires when loading progress has occured
  62734. * @param fileName Defines the name of the file to load
  62735. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62736. */
  62737. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62738. meshes: AbstractMesh[];
  62739. particleSystems: IParticleSystem[];
  62740. skeletons: Skeleton[];
  62741. animationGroups: AnimationGroup[];
  62742. }>;
  62743. /**
  62744. * Imports all objects from the loaded glTF data and adds them to the scene
  62745. * @param scene the scene the objects should be added to
  62746. * @param data the glTF data to load
  62747. * @param rootUrl root url to load from
  62748. * @param onProgress event that fires when loading progress has occured
  62749. * @param fileName Defines the name of the file to load
  62750. * @returns a promise which completes when objects have been loaded to the scene
  62751. */
  62752. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62753. /**
  62754. * Load into an asset container.
  62755. * @param scene The scene to load into
  62756. * @param data The data to import
  62757. * @param rootUrl The root url for scene and resources
  62758. * @param onProgress The callback when the load progresses
  62759. * @param fileName Defines the name of the file to load
  62760. * @returns The loaded asset container
  62761. */
  62762. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  62763. /**
  62764. * If the data string can be loaded directly.
  62765. * @param data string contianing the file data
  62766. * @returns if the data can be loaded directly
  62767. */
  62768. canDirectLoad(data: string): boolean;
  62769. /**
  62770. * Rewrites a url by combining a root url and response url.
  62771. */
  62772. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  62773. /**
  62774. * Instantiates a glTF file loader plugin.
  62775. * @returns the created plugin
  62776. */
  62777. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  62778. /**
  62779. * The loader state or null if the loader is not active.
  62780. */
  62781. readonly loaderState: Nullable<GLTFLoaderState>;
  62782. /**
  62783. * Returns a promise that resolves when the asset is completely loaded.
  62784. * @returns a promise that resolves when the asset is completely loaded.
  62785. */
  62786. whenCompleteAsync(): Promise<void>;
  62787. private _parseAsync;
  62788. private _validateAsync;
  62789. private _getLoader;
  62790. private _unpackBinary;
  62791. private _unpackBinaryV1;
  62792. private _unpackBinaryV2;
  62793. private static _parseVersion;
  62794. private static _compareVersion;
  62795. private static _decodeBufferToText;
  62796. private static readonly _logSpaces;
  62797. private _logIndentLevel;
  62798. private _loggingEnabled;
  62799. /** @hidden */ private _log: (message: string) => void;
  62800. /** @hidden */ private _logOpen(message: string): void;
  62801. /** @hidden */ private _logClose(): void;
  62802. private _logEnabled;
  62803. private _logDisabled;
  62804. private _capturePerformanceCounters;
  62805. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  62806. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  62807. private _startPerformanceCounterEnabled;
  62808. private _startPerformanceCounterDisabled;
  62809. private _endPerformanceCounterEnabled;
  62810. private _endPerformanceCounterDisabled;
  62811. }
  62812. }
  62813. declare module BABYLON.GLTF1 {
  62814. /**
  62815. * Enums
  62816. * @hidden
  62817. */
  62818. export enum EComponentType {
  62819. BYTE = 5120,
  62820. UNSIGNED_BYTE = 5121,
  62821. SHORT = 5122,
  62822. UNSIGNED_SHORT = 5123,
  62823. FLOAT = 5126
  62824. }
  62825. /** @hidden */
  62826. export enum EShaderType {
  62827. FRAGMENT = 35632,
  62828. VERTEX = 35633
  62829. }
  62830. /** @hidden */
  62831. export enum EParameterType {
  62832. BYTE = 5120,
  62833. UNSIGNED_BYTE = 5121,
  62834. SHORT = 5122,
  62835. UNSIGNED_SHORT = 5123,
  62836. INT = 5124,
  62837. UNSIGNED_INT = 5125,
  62838. FLOAT = 5126,
  62839. FLOAT_VEC2 = 35664,
  62840. FLOAT_VEC3 = 35665,
  62841. FLOAT_VEC4 = 35666,
  62842. INT_VEC2 = 35667,
  62843. INT_VEC3 = 35668,
  62844. INT_VEC4 = 35669,
  62845. BOOL = 35670,
  62846. BOOL_VEC2 = 35671,
  62847. BOOL_VEC3 = 35672,
  62848. BOOL_VEC4 = 35673,
  62849. FLOAT_MAT2 = 35674,
  62850. FLOAT_MAT3 = 35675,
  62851. FLOAT_MAT4 = 35676,
  62852. SAMPLER_2D = 35678
  62853. }
  62854. /** @hidden */
  62855. export enum ETextureWrapMode {
  62856. CLAMP_TO_EDGE = 33071,
  62857. MIRRORED_REPEAT = 33648,
  62858. REPEAT = 10497
  62859. }
  62860. /** @hidden */
  62861. export enum ETextureFilterType {
  62862. NEAREST = 9728,
  62863. LINEAR = 9728,
  62864. NEAREST_MIPMAP_NEAREST = 9984,
  62865. LINEAR_MIPMAP_NEAREST = 9985,
  62866. NEAREST_MIPMAP_LINEAR = 9986,
  62867. LINEAR_MIPMAP_LINEAR = 9987
  62868. }
  62869. /** @hidden */
  62870. export enum ETextureFormat {
  62871. ALPHA = 6406,
  62872. RGB = 6407,
  62873. RGBA = 6408,
  62874. LUMINANCE = 6409,
  62875. LUMINANCE_ALPHA = 6410
  62876. }
  62877. /** @hidden */
  62878. export enum ECullingType {
  62879. FRONT = 1028,
  62880. BACK = 1029,
  62881. FRONT_AND_BACK = 1032
  62882. }
  62883. /** @hidden */
  62884. export enum EBlendingFunction {
  62885. ZERO = 0,
  62886. ONE = 1,
  62887. SRC_COLOR = 768,
  62888. ONE_MINUS_SRC_COLOR = 769,
  62889. DST_COLOR = 774,
  62890. ONE_MINUS_DST_COLOR = 775,
  62891. SRC_ALPHA = 770,
  62892. ONE_MINUS_SRC_ALPHA = 771,
  62893. DST_ALPHA = 772,
  62894. ONE_MINUS_DST_ALPHA = 773,
  62895. CONSTANT_COLOR = 32769,
  62896. ONE_MINUS_CONSTANT_COLOR = 32770,
  62897. CONSTANT_ALPHA = 32771,
  62898. ONE_MINUS_CONSTANT_ALPHA = 32772,
  62899. SRC_ALPHA_SATURATE = 776
  62900. }
  62901. /** @hidden */
  62902. export interface IGLTFProperty {
  62903. extensions?: {
  62904. [key: string]: any;
  62905. };
  62906. extras?: Object;
  62907. }
  62908. /** @hidden */
  62909. export interface IGLTFChildRootProperty extends IGLTFProperty {
  62910. name?: string;
  62911. }
  62912. /** @hidden */
  62913. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  62914. bufferView: string;
  62915. byteOffset: number;
  62916. byteStride: number;
  62917. count: number;
  62918. type: string;
  62919. componentType: EComponentType;
  62920. max?: number[];
  62921. min?: number[];
  62922. name?: string;
  62923. }
  62924. /** @hidden */
  62925. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  62926. buffer: string;
  62927. byteOffset: number;
  62928. byteLength: number;
  62929. byteStride: number;
  62930. target?: number;
  62931. }
  62932. /** @hidden */
  62933. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  62934. uri: string;
  62935. byteLength?: number;
  62936. type?: string;
  62937. }
  62938. /** @hidden */
  62939. export interface IGLTFShader extends IGLTFChildRootProperty {
  62940. uri: string;
  62941. type: EShaderType;
  62942. }
  62943. /** @hidden */
  62944. export interface IGLTFProgram extends IGLTFChildRootProperty {
  62945. attributes: string[];
  62946. fragmentShader: string;
  62947. vertexShader: string;
  62948. }
  62949. /** @hidden */
  62950. export interface IGLTFTechniqueParameter {
  62951. type: number;
  62952. count?: number;
  62953. semantic?: string;
  62954. node?: string;
  62955. value?: number | boolean | string | Array<any>;
  62956. source?: string;
  62957. babylonValue?: any;
  62958. }
  62959. /** @hidden */
  62960. export interface IGLTFTechniqueCommonProfile {
  62961. lightingModel: string;
  62962. texcoordBindings: Object;
  62963. parameters?: Array<any>;
  62964. }
  62965. /** @hidden */
  62966. export interface IGLTFTechniqueStatesFunctions {
  62967. blendColor?: number[];
  62968. blendEquationSeparate?: number[];
  62969. blendFuncSeparate?: number[];
  62970. colorMask: boolean[];
  62971. cullFace: number[];
  62972. }
  62973. /** @hidden */
  62974. export interface IGLTFTechniqueStates {
  62975. enable: number[];
  62976. functions: IGLTFTechniqueStatesFunctions;
  62977. }
  62978. /** @hidden */
  62979. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  62980. parameters: {
  62981. [key: string]: IGLTFTechniqueParameter;
  62982. };
  62983. program: string;
  62984. attributes: {
  62985. [key: string]: string;
  62986. };
  62987. uniforms: {
  62988. [key: string]: string;
  62989. };
  62990. states: IGLTFTechniqueStates;
  62991. }
  62992. /** @hidden */
  62993. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  62994. technique?: string;
  62995. values: string[];
  62996. }
  62997. /** @hidden */
  62998. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  62999. attributes: {
  63000. [key: string]: string;
  63001. };
  63002. indices: string;
  63003. material: string;
  63004. mode?: number;
  63005. }
  63006. /** @hidden */
  63007. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63008. primitives: IGLTFMeshPrimitive[];
  63009. }
  63010. /** @hidden */
  63011. export interface IGLTFImage extends IGLTFChildRootProperty {
  63012. uri: string;
  63013. }
  63014. /** @hidden */
  63015. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63016. magFilter?: number;
  63017. minFilter?: number;
  63018. wrapS?: number;
  63019. wrapT?: number;
  63020. }
  63021. /** @hidden */
  63022. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63023. sampler: string;
  63024. source: string;
  63025. format?: ETextureFormat;
  63026. internalFormat?: ETextureFormat;
  63027. target?: number;
  63028. type?: number;
  63029. babylonTexture?: Texture;
  63030. }
  63031. /** @hidden */
  63032. export interface IGLTFAmbienLight {
  63033. color?: number[];
  63034. }
  63035. /** @hidden */
  63036. export interface IGLTFDirectionalLight {
  63037. color?: number[];
  63038. }
  63039. /** @hidden */
  63040. export interface IGLTFPointLight {
  63041. color?: number[];
  63042. constantAttenuation?: number;
  63043. linearAttenuation?: number;
  63044. quadraticAttenuation?: number;
  63045. }
  63046. /** @hidden */
  63047. export interface IGLTFSpotLight {
  63048. color?: number[];
  63049. constantAttenuation?: number;
  63050. fallOfAngle?: number;
  63051. fallOffExponent?: number;
  63052. linearAttenuation?: number;
  63053. quadraticAttenuation?: number;
  63054. }
  63055. /** @hidden */
  63056. export interface IGLTFLight extends IGLTFChildRootProperty {
  63057. type: string;
  63058. }
  63059. /** @hidden */
  63060. export interface IGLTFCameraOrthographic {
  63061. xmag: number;
  63062. ymag: number;
  63063. zfar: number;
  63064. znear: number;
  63065. }
  63066. /** @hidden */
  63067. export interface IGLTFCameraPerspective {
  63068. aspectRatio: number;
  63069. yfov: number;
  63070. zfar: number;
  63071. znear: number;
  63072. }
  63073. /** @hidden */
  63074. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63075. type: string;
  63076. }
  63077. /** @hidden */
  63078. export interface IGLTFAnimationChannelTarget {
  63079. id: string;
  63080. path: string;
  63081. }
  63082. /** @hidden */
  63083. export interface IGLTFAnimationChannel {
  63084. sampler: string;
  63085. target: IGLTFAnimationChannelTarget;
  63086. }
  63087. /** @hidden */
  63088. export interface IGLTFAnimationSampler {
  63089. input: string;
  63090. output: string;
  63091. interpolation?: string;
  63092. }
  63093. /** @hidden */
  63094. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63095. channels?: IGLTFAnimationChannel[];
  63096. parameters?: {
  63097. [key: string]: string;
  63098. };
  63099. samplers?: {
  63100. [key: string]: IGLTFAnimationSampler;
  63101. };
  63102. }
  63103. /** @hidden */
  63104. export interface IGLTFNodeInstanceSkin {
  63105. skeletons: string[];
  63106. skin: string;
  63107. meshes: string[];
  63108. }
  63109. /** @hidden */
  63110. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63111. bindShapeMatrix: number[];
  63112. inverseBindMatrices: string;
  63113. jointNames: string[];
  63114. babylonSkeleton?: Skeleton;
  63115. }
  63116. /** @hidden */
  63117. export interface IGLTFNode extends IGLTFChildRootProperty {
  63118. camera?: string;
  63119. children: string[];
  63120. skin?: string;
  63121. jointName?: string;
  63122. light?: string;
  63123. matrix: number[];
  63124. mesh?: string;
  63125. meshes?: string[];
  63126. rotation?: number[];
  63127. scale?: number[];
  63128. translation?: number[];
  63129. babylonNode?: Node;
  63130. }
  63131. /** @hidden */
  63132. export interface IGLTFScene extends IGLTFChildRootProperty {
  63133. nodes: string[];
  63134. }
  63135. /** @hidden */
  63136. export interface IGLTFRuntime {
  63137. extensions: {
  63138. [key: string]: any;
  63139. };
  63140. accessors: {
  63141. [key: string]: IGLTFAccessor;
  63142. };
  63143. buffers: {
  63144. [key: string]: IGLTFBuffer;
  63145. };
  63146. bufferViews: {
  63147. [key: string]: IGLTFBufferView;
  63148. };
  63149. meshes: {
  63150. [key: string]: IGLTFMesh;
  63151. };
  63152. lights: {
  63153. [key: string]: IGLTFLight;
  63154. };
  63155. cameras: {
  63156. [key: string]: IGLTFCamera;
  63157. };
  63158. nodes: {
  63159. [key: string]: IGLTFNode;
  63160. };
  63161. images: {
  63162. [key: string]: IGLTFImage;
  63163. };
  63164. textures: {
  63165. [key: string]: IGLTFTexture;
  63166. };
  63167. shaders: {
  63168. [key: string]: IGLTFShader;
  63169. };
  63170. programs: {
  63171. [key: string]: IGLTFProgram;
  63172. };
  63173. samplers: {
  63174. [key: string]: IGLTFSampler;
  63175. };
  63176. techniques: {
  63177. [key: string]: IGLTFTechnique;
  63178. };
  63179. materials: {
  63180. [key: string]: IGLTFMaterial;
  63181. };
  63182. animations: {
  63183. [key: string]: IGLTFAnimation;
  63184. };
  63185. skins: {
  63186. [key: string]: IGLTFSkins;
  63187. };
  63188. currentScene?: Object;
  63189. scenes: {
  63190. [key: string]: IGLTFScene;
  63191. };
  63192. extensionsUsed: string[];
  63193. extensionsRequired?: string[];
  63194. buffersCount: number;
  63195. shaderscount: number;
  63196. scene: Scene;
  63197. rootUrl: string;
  63198. loadedBufferCount: number;
  63199. loadedBufferViews: {
  63200. [name: string]: ArrayBufferView;
  63201. };
  63202. loadedShaderCount: number;
  63203. importOnlyMeshes: boolean;
  63204. importMeshesNames?: string[];
  63205. dummyNodes: Node[];
  63206. }
  63207. /** @hidden */
  63208. export interface INodeToRoot {
  63209. bone: Bone;
  63210. node: IGLTFNode;
  63211. id: string;
  63212. }
  63213. /** @hidden */
  63214. export interface IJointNode {
  63215. node: IGLTFNode;
  63216. id: string;
  63217. }
  63218. }
  63219. declare module BABYLON.GLTF1 {
  63220. /**
  63221. * Utils functions for GLTF
  63222. * @hidden
  63223. */
  63224. export class GLTFUtils {
  63225. /**
  63226. * Sets the given "parameter" matrix
  63227. * @param scene: the Scene object
  63228. * @param source: the source node where to pick the matrix
  63229. * @param parameter: the GLTF technique parameter
  63230. * @param uniformName: the name of the shader's uniform
  63231. * @param shaderMaterial: the shader material
  63232. */
  63233. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63234. /**
  63235. * Sets the given "parameter" matrix
  63236. * @param shaderMaterial: the shader material
  63237. * @param uniform: the name of the shader's uniform
  63238. * @param value: the value of the uniform
  63239. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63240. */
  63241. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63242. /**
  63243. * Returns the wrap mode of the texture
  63244. * @param mode: the mode value
  63245. */
  63246. static GetWrapMode(mode: number): number;
  63247. /**
  63248. * Returns the byte stride giving an accessor
  63249. * @param accessor: the GLTF accessor objet
  63250. */
  63251. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63252. /**
  63253. * Returns the texture filter mode giving a mode value
  63254. * @param mode: the filter mode value
  63255. */
  63256. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63257. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63258. /**
  63259. * Returns a buffer from its accessor
  63260. * @param gltfRuntime: the GLTF runtime
  63261. * @param accessor: the GLTF accessor
  63262. */
  63263. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63264. /**
  63265. * Decodes a buffer view into a string
  63266. * @param view: the buffer view
  63267. */
  63268. static DecodeBufferToText(view: ArrayBufferView): string;
  63269. /**
  63270. * Returns the default material of gltf. Related to
  63271. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63272. * @param scene: the Babylon.js scene
  63273. */
  63274. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63275. private static _DefaultMaterial;
  63276. }
  63277. }
  63278. declare module BABYLON.GLTF1 {
  63279. /**
  63280. * Implementation of the base glTF spec
  63281. * @hidden
  63282. */
  63283. export class GLTFLoaderBase {
  63284. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63285. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63286. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63287. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63288. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63289. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63290. }
  63291. /**
  63292. * glTF V1 Loader
  63293. * @hidden
  63294. */
  63295. export class GLTFLoader implements IGLTFLoader {
  63296. static Extensions: {
  63297. [name: string]: GLTFLoaderExtension;
  63298. };
  63299. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63300. state: Nullable<GLTFLoaderState>;
  63301. dispose(): void;
  63302. private _importMeshAsync;
  63303. /**
  63304. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63305. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63306. * @param scene the scene the meshes should be added to
  63307. * @param data gltf data containing information of the meshes in a loaded file
  63308. * @param rootUrl root url to load from
  63309. * @param onProgress event that fires when loading progress has occured
  63310. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63311. */
  63312. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63313. meshes: AbstractMesh[];
  63314. particleSystems: IParticleSystem[];
  63315. skeletons: Skeleton[];
  63316. animationGroups: AnimationGroup[];
  63317. }>;
  63318. private _loadAsync;
  63319. /**
  63320. * Imports all objects from a loaded gltf file and adds them to the scene
  63321. * @param scene the scene the objects should be added to
  63322. * @param data gltf data containing information of the meshes in a loaded file
  63323. * @param rootUrl root url to load from
  63324. * @param onProgress event that fires when loading progress has occured
  63325. * @returns a promise which completes when objects have been loaded to the scene
  63326. */
  63327. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63328. private _loadShadersAsync;
  63329. private _loadBuffersAsync;
  63330. private _createNodes;
  63331. }
  63332. /** @hidden */
  63333. export abstract class GLTFLoaderExtension {
  63334. private _name;
  63335. constructor(name: string);
  63336. readonly name: string;
  63337. /**
  63338. * Defines an override for loading the runtime
  63339. * Return true to stop further extensions from loading the runtime
  63340. */
  63341. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63342. /**
  63343. * Defines an onverride for creating gltf runtime
  63344. * Return true to stop further extensions from creating the runtime
  63345. */
  63346. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63347. /**
  63348. * Defines an override for loading buffers
  63349. * Return true to stop further extensions from loading this buffer
  63350. */
  63351. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63352. /**
  63353. * Defines an override for loading texture buffers
  63354. * Return true to stop further extensions from loading this texture data
  63355. */
  63356. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63357. /**
  63358. * Defines an override for creating textures
  63359. * Return true to stop further extensions from loading this texture
  63360. */
  63361. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63362. /**
  63363. * Defines an override for loading shader strings
  63364. * Return true to stop further extensions from loading this shader data
  63365. */
  63366. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63367. /**
  63368. * Defines an override for loading materials
  63369. * Return true to stop further extensions from loading this material
  63370. */
  63371. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63372. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63373. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63374. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63375. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63376. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63377. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63378. private static LoadTextureBufferAsync;
  63379. private static CreateTextureAsync;
  63380. private static ApplyExtensions;
  63381. }
  63382. }
  63383. declare module BABYLON.GLTF1 {
  63384. /** @hidden */
  63385. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63386. private _bin;
  63387. constructor();
  63388. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63389. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63390. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63391. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63392. }
  63393. }
  63394. declare module BABYLON.GLTF1 {
  63395. /** @hidden */
  63396. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63397. constructor();
  63398. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63399. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63400. private _loadTexture;
  63401. }
  63402. }
  63403. declare module BABYLON.GLTF2.Loader {
  63404. /**
  63405. * Loader interface with an index field.
  63406. */
  63407. export interface IArrayItem {
  63408. /**
  63409. * The index of this item in the array.
  63410. */
  63411. index: number;
  63412. }
  63413. /**
  63414. * Loader interface with additional members.
  63415. */
  63416. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63417. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63418. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  63419. }
  63420. /**
  63421. * Loader interface with additional members.
  63422. */
  63423. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63424. }
  63425. /** @hidden */
  63426. export interface _IAnimationSamplerData {
  63427. input: Float32Array;
  63428. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63429. output: Float32Array;
  63430. }
  63431. /**
  63432. * Loader interface with additional members.
  63433. */
  63434. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63435. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  63436. }
  63437. /**
  63438. * Loader interface with additional members.
  63439. */
  63440. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63441. channels: IAnimationChannel[];
  63442. samplers: IAnimationSampler[];
  63443. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  63444. }
  63445. /**
  63446. * Loader interface with additional members.
  63447. */
  63448. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63449. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63450. }
  63451. /**
  63452. * Loader interface with additional members.
  63453. */
  63454. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63455. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63456. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  63457. }
  63458. /**
  63459. * Loader interface with additional members.
  63460. */
  63461. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63462. }
  63463. /**
  63464. * Loader interface with additional members.
  63465. */
  63466. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63467. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63468. }
  63469. /**
  63470. * Loader interface with additional members.
  63471. */
  63472. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63473. }
  63474. /**
  63475. * Loader interface with additional members.
  63476. */
  63477. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63478. }
  63479. /**
  63480. * Loader interface with additional members.
  63481. */
  63482. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63483. baseColorTexture?: ITextureInfo;
  63484. metallicRoughnessTexture?: ITextureInfo;
  63485. }
  63486. /**
  63487. * Loader interface with additional members.
  63488. */
  63489. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63490. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63491. normalTexture?: IMaterialNormalTextureInfo;
  63492. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63493. emissiveTexture?: ITextureInfo;
  63494. /** @hidden */ private _data?: {
  63495. [babylonDrawMode: number]: {
  63496. babylonMaterial: Material;
  63497. babylonMeshes: AbstractMesh[];
  63498. promise: Promise<void>;
  63499. };
  63500. };
  63501. }
  63502. /**
  63503. * Loader interface with additional members.
  63504. */
  63505. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63506. primitives: IMeshPrimitive[];
  63507. }
  63508. /**
  63509. * Loader interface with additional members.
  63510. */
  63511. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63512. /** @hidden */ private _instanceData?: {
  63513. babylonSourceMesh: Mesh;
  63514. promise: Promise<any>;
  63515. };
  63516. }
  63517. /**
  63518. * Loader interface with additional members.
  63519. */
  63520. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63521. /**
  63522. * The parent glTF node.
  63523. */
  63524. parent?: INode;
  63525. /** @hidden */ private _babylonTransformNode?: TransformNode;
  63526. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  63527. /** @hidden */ private _babylonBones?: Bone[];
  63528. /** @hidden */ private _numMorphTargets?: number;
  63529. }
  63530. /** @hidden */
  63531. export interface _ISamplerData {
  63532. noMipMaps: boolean;
  63533. samplingMode: number;
  63534. wrapU: number;
  63535. wrapV: number;
  63536. }
  63537. /**
  63538. * Loader interface with additional members.
  63539. */
  63540. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63541. /** @hidden */ private _data?: _ISamplerData;
  63542. }
  63543. /**
  63544. * Loader interface with additional members.
  63545. */
  63546. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63547. }
  63548. /**
  63549. * Loader interface with additional members.
  63550. */
  63551. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63552. /** @hidden */ private _data?: {
  63553. babylonSkeleton: Skeleton;
  63554. promise: Promise<void>;
  63555. };
  63556. }
  63557. /**
  63558. * Loader interface with additional members.
  63559. */
  63560. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63561. }
  63562. /**
  63563. * Loader interface with additional members.
  63564. */
  63565. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63566. }
  63567. /**
  63568. * Loader interface with additional members.
  63569. */
  63570. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63571. accessors?: IAccessor[];
  63572. animations?: IAnimation[];
  63573. buffers?: IBuffer[];
  63574. bufferViews?: IBufferView[];
  63575. cameras?: ICamera[];
  63576. images?: IImage[];
  63577. materials?: IMaterial[];
  63578. meshes?: IMesh[];
  63579. nodes?: INode[];
  63580. samplers?: ISampler[];
  63581. scenes?: IScene[];
  63582. skins?: ISkin[];
  63583. textures?: ITexture[];
  63584. }
  63585. }
  63586. declare module BABYLON.GLTF2 {
  63587. /**
  63588. * Interface for a glTF loader extension.
  63589. */
  63590. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63591. /**
  63592. * Called after the loader state changes to LOADING.
  63593. */
  63594. onLoading?(): void;
  63595. /**
  63596. * Called after the loader state changes to READY.
  63597. */
  63598. onReady?(): void;
  63599. /**
  63600. * Define this method to modify the default behavior when loading scenes.
  63601. * @param context The context when loading the asset
  63602. * @param scene The glTF scene property
  63603. * @returns A promise that resolves when the load is complete or null if not handled
  63604. */
  63605. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  63606. /**
  63607. * Define this method to modify the default behavior when loading nodes.
  63608. * @param context The context when loading the asset
  63609. * @param node The glTF node property
  63610. * @param assign A function called synchronously after parsing the glTF properties
  63611. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  63612. */
  63613. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63614. /**
  63615. * Define this method to modify the default behavior when loading cameras.
  63616. * @param context The context when loading the asset
  63617. * @param camera The glTF camera property
  63618. * @param assign A function called synchronously after parsing the glTF properties
  63619. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  63620. */
  63621. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  63622. /**
  63623. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  63624. * @param context The context when loading the asset
  63625. * @param primitive The glTF mesh primitive property
  63626. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  63627. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63628. /**
  63629. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63630. * @param context The context when loading the asset
  63631. * @param name The mesh name when loading the asset
  63632. * @param node The glTF node when loading the asset
  63633. * @param mesh The glTF mesh when loading the asset
  63634. * @param primitive The glTF mesh primitive property
  63635. * @param assign A function called synchronously after parsing the glTF properties
  63636. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63637. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63638. /**
  63639. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  63640. * @param context The context when loading the asset
  63641. * @param material The glTF material property
  63642. * @param assign A function called synchronously after parsing the glTF properties
  63643. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  63644. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63645. /**
  63646. * Define this method to modify the default behavior when creating materials.
  63647. * @param context The context when loading the asset
  63648. * @param material The glTF material property
  63649. * @param babylonDrawMode The draw mode for the Babylon material
  63650. * @returns The Babylon material or null if not handled
  63651. */
  63652. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  63653. /**
  63654. * Define this method to modify the default behavior when loading material properties.
  63655. * @param context The context when loading the asset
  63656. * @param material The glTF material property
  63657. * @param babylonMaterial The Babylon material
  63658. * @returns A promise that resolves when the load is complete or null if not handled
  63659. */
  63660. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63661. /**
  63662. * Define this method to modify the default behavior when loading texture infos.
  63663. * @param context The context when loading the asset
  63664. * @param textureInfo The glTF texture info property
  63665. * @param assign A function called synchronously after parsing the glTF properties
  63666. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  63667. */
  63668. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63669. /**
  63670. * Define this method to modify the default behavior when loading animations.
  63671. * @param context The context when loading the asset
  63672. * @param animation The glTF animation property
  63673. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  63674. */
  63675. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63676. /**
  63677. * @hidden Define this method to modify the default behavior when loading skins.
  63678. * @param context The context when loading the asset
  63679. * @param node The glTF node property
  63680. * @param skin The glTF skin property
  63681. * @returns A promise that resolves when the load is complete or null if not handled
  63682. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  63683. /**
  63684. * @hidden Define this method to modify the default behavior when loading uris.
  63685. * @param context The context when loading the asset
  63686. * @param property The glTF property associated with the uri
  63687. * @param uri The uri to load
  63688. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  63689. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63690. }
  63691. }
  63692. declare module BABYLON.GLTF2 {
  63693. /**
  63694. * Helper class for working with arrays when loading the glTF asset
  63695. */
  63696. export class ArrayItem {
  63697. /**
  63698. * Gets an item from the given array.
  63699. * @param context The context when loading the asset
  63700. * @param array The array to get the item from
  63701. * @param index The index to the array
  63702. * @returns The array item
  63703. */
  63704. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  63705. /**
  63706. * Assign an `index` field to each item of the given array.
  63707. * @param array The array of items
  63708. */
  63709. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  63710. }
  63711. /**
  63712. * The glTF 2.0 loader
  63713. */
  63714. export class GLTFLoader implements IGLTFLoader {
  63715. /** @hidden */ private _completePromises: Promise<any>[];
  63716. private _disposed;
  63717. private _parent;
  63718. private _state;
  63719. private _extensions;
  63720. private _rootUrl;
  63721. private _fileName;
  63722. private _uniqueRootUrl;
  63723. private _gltf;
  63724. private _babylonScene;
  63725. private _rootBabylonMesh;
  63726. private _defaultBabylonMaterialData;
  63727. private _progressCallback?;
  63728. private _requests;
  63729. private static readonly _DefaultSampler;
  63730. private static _ExtensionNames;
  63731. private static _ExtensionFactories;
  63732. /**
  63733. * Registers a loader extension.
  63734. * @param name The name of the loader extension.
  63735. * @param factory The factory function that creates the loader extension.
  63736. */
  63737. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  63738. /**
  63739. * Unregisters a loader extension.
  63740. * @param name The name of the loader extenion.
  63741. * @returns A boolean indicating whether the extension has been unregistered
  63742. */
  63743. static UnregisterExtension(name: string): boolean;
  63744. /**
  63745. * Gets the loader state.
  63746. */
  63747. readonly state: Nullable<GLTFLoaderState>;
  63748. /**
  63749. * The glTF object parsed from the JSON.
  63750. */
  63751. readonly gltf: IGLTF;
  63752. /**
  63753. * The Babylon scene when loading the asset.
  63754. */
  63755. readonly babylonScene: Scene;
  63756. /**
  63757. * The root Babylon mesh when loading the asset.
  63758. */
  63759. readonly rootBabylonMesh: Mesh;
  63760. /** @hidden */
  63761. constructor(parent: GLTFFileLoader);
  63762. /** @hidden */
  63763. dispose(): void;
  63764. /** @hidden */
  63765. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63766. meshes: AbstractMesh[];
  63767. particleSystems: IParticleSystem[];
  63768. skeletons: Skeleton[];
  63769. animationGroups: AnimationGroup[];
  63770. }>;
  63771. /** @hidden */
  63772. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63773. private _loadAsync;
  63774. private _loadData;
  63775. private _setupData;
  63776. private _loadExtensions;
  63777. private _checkExtensions;
  63778. private _setState;
  63779. private _createRootNode;
  63780. /**
  63781. * Loads a glTF scene.
  63782. * @param context The context when loading the asset
  63783. * @param scene The glTF scene property
  63784. * @returns A promise that resolves when the load is complete
  63785. */
  63786. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  63787. private _forEachPrimitive;
  63788. private _getMeshes;
  63789. private _getSkeletons;
  63790. private _getAnimationGroups;
  63791. private _startAnimations;
  63792. /**
  63793. * Loads a glTF node.
  63794. * @param context The context when loading the asset
  63795. * @param node The glTF node property
  63796. * @param assign A function called synchronously after parsing the glTF properties
  63797. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  63798. */
  63799. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  63800. private _loadMeshAsync;
  63801. /**
  63802. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63803. * @param context The context when loading the asset
  63804. * @param name The mesh name when loading the asset
  63805. * @param node The glTF node when loading the asset
  63806. * @param mesh The glTF mesh when loading the asset
  63807. * @param primitive The glTF mesh primitive property
  63808. * @param assign A function called synchronously after parsing the glTF properties
  63809. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63810. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63811. private _loadVertexDataAsync;
  63812. private _createMorphTargets;
  63813. private _loadMorphTargetsAsync;
  63814. private _loadMorphTargetVertexDataAsync;
  63815. private static _LoadTransform;
  63816. private _loadSkinAsync;
  63817. private _loadBones;
  63818. private _loadBone;
  63819. private _loadSkinInverseBindMatricesDataAsync;
  63820. private _updateBoneMatrices;
  63821. private _getNodeMatrix;
  63822. /**
  63823. * Loads a glTF camera.
  63824. * @param context The context when loading the asset
  63825. * @param camera The glTF camera property
  63826. * @param assign A function called synchronously after parsing the glTF properties
  63827. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  63828. */
  63829. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  63830. private _loadAnimationsAsync;
  63831. /**
  63832. * Loads a glTF animation.
  63833. * @param context The context when loading the asset
  63834. * @param animation The glTF animation property
  63835. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  63836. */
  63837. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  63838. /**
  63839. * @hidden Loads a glTF animation channel.
  63840. * @param context The context when loading the asset
  63841. * @param animationContext The context of the animation when loading the asset
  63842. * @param animation The glTF animation property
  63843. * @param channel The glTF animation channel property
  63844. * @param babylonAnimationGroup The babylon animation group property
  63845. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  63846. * @returns A void promise when the channel load is complete
  63847. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  63848. private _loadAnimationSamplerAsync;
  63849. private _loadBufferAsync;
  63850. /**
  63851. * Loads a glTF buffer view.
  63852. * @param context The context when loading the asset
  63853. * @param bufferView The glTF buffer view property
  63854. * @returns A promise that resolves with the loaded data when the load is complete
  63855. */
  63856. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  63857. private _loadIndicesAccessorAsync;
  63858. private _loadFloatAccessorAsync;
  63859. private _loadVertexBufferViewAsync;
  63860. private _loadVertexAccessorAsync;
  63861. private _loadMaterialMetallicRoughnessPropertiesAsync;
  63862. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  63863. private _createDefaultMaterial;
  63864. /**
  63865. * Creates a Babylon material from a glTF material.
  63866. * @param context The context when loading the asset
  63867. * @param material The glTF material property
  63868. * @param babylonDrawMode The draw mode for the Babylon material
  63869. * @returns The Babylon material
  63870. */
  63871. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  63872. /**
  63873. * Loads properties from a glTF material into a Babylon material.
  63874. * @param context The context when loading the asset
  63875. * @param material The glTF material property
  63876. * @param babylonMaterial The Babylon material
  63877. * @returns A promise that resolves when the load is complete
  63878. */
  63879. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63880. /**
  63881. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  63882. * @param context The context when loading the asset
  63883. * @param material The glTF material property
  63884. * @param babylonMaterial The Babylon material
  63885. * @returns A promise that resolves when the load is complete
  63886. */
  63887. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63888. /**
  63889. * Loads the alpha properties from a glTF material into a Babylon material.
  63890. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  63891. * @param context The context when loading the asset
  63892. * @param material The glTF material property
  63893. * @param babylonMaterial The Babylon material
  63894. */
  63895. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  63896. /**
  63897. * Loads a glTF texture info.
  63898. * @param context The context when loading the asset
  63899. * @param textureInfo The glTF texture info property
  63900. * @param assign A function called synchronously after parsing the glTF properties
  63901. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  63902. */
  63903. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  63904. private _loadTextureAsync;
  63905. private _loadSampler;
  63906. /**
  63907. * Loads a glTF image.
  63908. * @param context The context when loading the asset
  63909. * @param image The glTF image property
  63910. * @returns A promise that resolves with the loaded data when the load is complete
  63911. */
  63912. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  63913. /**
  63914. * Loads a glTF uri.
  63915. * @param context The context when loading the asset
  63916. * @param property The glTF property associated with the uri
  63917. * @param uri The base64 or relative uri
  63918. * @returns A promise that resolves with the loaded data when the load is complete
  63919. */
  63920. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  63921. private _onProgress;
  63922. /**
  63923. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  63924. * @param babylonObject the Babylon object with metadata
  63925. * @param pointer the JSON pointer
  63926. */
  63927. static AddPointerMetadata(babylonObject: {
  63928. metadata: any;
  63929. }, pointer: string): void;
  63930. private static _GetTextureWrapMode;
  63931. private static _GetTextureSamplingMode;
  63932. private static _GetTypedArray;
  63933. private static _GetNumComponents;
  63934. private static _ValidateUri;
  63935. private static _GetDrawMode;
  63936. private _compileMaterialsAsync;
  63937. private _compileShadowGeneratorsAsync;
  63938. private _forEachExtensions;
  63939. private _applyExtensions;
  63940. private _extensionsOnLoading;
  63941. private _extensionsOnReady;
  63942. private _extensionsLoadSceneAsync;
  63943. private _extensionsLoadNodeAsync;
  63944. private _extensionsLoadCameraAsync;
  63945. private _extensionsLoadVertexDataAsync;
  63946. private _extensionsLoadMeshPrimitiveAsync;
  63947. private _extensionsLoadMaterialAsync;
  63948. private _extensionsCreateMaterial;
  63949. private _extensionsLoadMaterialPropertiesAsync;
  63950. private _extensionsLoadTextureInfoAsync;
  63951. private _extensionsLoadAnimationAsync;
  63952. private _extensionsLoadSkinAsync;
  63953. private _extensionsLoadUriAsync;
  63954. /**
  63955. * Helper method called by a loader extension to load an glTF extension.
  63956. * @param context The context when loading the asset
  63957. * @param property The glTF property to load the extension from
  63958. * @param extensionName The name of the extension to load
  63959. * @param actionAsync The action to run
  63960. * @returns The promise returned by actionAsync or null if the extension does not exist
  63961. */
  63962. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63963. /**
  63964. * Helper method called by a loader extension to load a glTF extra.
  63965. * @param context The context when loading the asset
  63966. * @param property The glTF property to load the extra from
  63967. * @param extensionName The name of the extension to load
  63968. * @param actionAsync The action to run
  63969. * @returns The promise returned by actionAsync or null if the extra does not exist
  63970. */
  63971. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63972. /**
  63973. * Increments the indentation level and logs a message.
  63974. * @param message The message to log
  63975. */
  63976. logOpen(message: string): void;
  63977. /**
  63978. * Decrements the indentation level.
  63979. */
  63980. logClose(): void;
  63981. /**
  63982. * Logs a message
  63983. * @param message The message to log
  63984. */
  63985. log(message: string): void;
  63986. /**
  63987. * Starts a performance counter.
  63988. * @param counterName The name of the performance counter
  63989. */
  63990. startPerformanceCounter(counterName: string): void;
  63991. /**
  63992. * Ends a performance counter.
  63993. * @param counterName The name of the performance counter
  63994. */
  63995. endPerformanceCounter(counterName: string): void;
  63996. }
  63997. }
  63998. declare module BABYLON.GLTF2.Loader.Extensions {
  63999. /**
  64000. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64001. */
  64002. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64003. /** The name of this extension. */
  64004. readonly name: string;
  64005. /** Defines whether this extension is enabled. */
  64006. enabled: boolean;
  64007. private _loader;
  64008. private _lights?;
  64009. /** @hidden */
  64010. constructor(loader: GLTFLoader);
  64011. /** @hidden */
  64012. dispose(): void;
  64013. /** @hidden */
  64014. onLoading(): void;
  64015. /** @hidden */
  64016. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64017. private _loadLightAsync;
  64018. }
  64019. }
  64020. declare module BABYLON.GLTF2.Loader.Extensions {
  64021. /**
  64022. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64023. */
  64024. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64025. /** The name of this extension. */
  64026. readonly name: string;
  64027. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64028. dracoCompression?: DracoCompression;
  64029. /** Defines whether this extension is enabled. */
  64030. enabled: boolean;
  64031. private _loader;
  64032. /** @hidden */
  64033. constructor(loader: GLTFLoader);
  64034. /** @hidden */
  64035. dispose(): void;
  64036. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64037. }
  64038. }
  64039. declare module BABYLON.GLTF2.Loader.Extensions {
  64040. /**
  64041. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64042. */
  64043. export class KHR_lights implements IGLTFLoaderExtension {
  64044. /** The name of this extension. */
  64045. readonly name: string;
  64046. /** Defines whether this extension is enabled. */
  64047. enabled: boolean;
  64048. private _loader;
  64049. private _lights?;
  64050. /** @hidden */
  64051. constructor(loader: GLTFLoader);
  64052. /** @hidden */
  64053. dispose(): void;
  64054. /** @hidden */
  64055. onLoading(): void;
  64056. /** @hidden */
  64057. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64058. }
  64059. }
  64060. declare module BABYLON.GLTF2.Loader.Extensions {
  64061. /**
  64062. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64063. */
  64064. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64065. /** The name of this extension. */
  64066. readonly name: string;
  64067. /** Defines whether this extension is enabled. */
  64068. enabled: boolean;
  64069. private _loader;
  64070. /** @hidden */
  64071. constructor(loader: GLTFLoader);
  64072. /** @hidden */
  64073. dispose(): void;
  64074. /** @hidden */
  64075. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64076. private _loadSpecularGlossinessPropertiesAsync;
  64077. }
  64078. }
  64079. declare module BABYLON.GLTF2.Loader.Extensions {
  64080. /**
  64081. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64082. */
  64083. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64084. /** The name of this extension. */
  64085. readonly name: string;
  64086. /** Defines whether this extension is enabled. */
  64087. enabled: boolean;
  64088. private _loader;
  64089. /** @hidden */
  64090. constructor(loader: GLTFLoader);
  64091. /** @hidden */
  64092. dispose(): void;
  64093. /** @hidden */
  64094. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64095. private _loadUnlitPropertiesAsync;
  64096. }
  64097. }
  64098. declare module BABYLON.GLTF2.Loader.Extensions {
  64099. /**
  64100. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64101. */
  64102. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64103. /** The name of this extension. */
  64104. readonly name: string;
  64105. /** Defines whether this extension is enabled. */
  64106. enabled: boolean;
  64107. private _loader;
  64108. /** @hidden */
  64109. constructor(loader: GLTFLoader);
  64110. /** @hidden */
  64111. dispose(): void;
  64112. /** @hidden */
  64113. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64114. }
  64115. }
  64116. declare module BABYLON.GLTF2.Loader.Extensions {
  64117. /**
  64118. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64119. */
  64120. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64121. /** The name of this extension. */
  64122. readonly name: string;
  64123. /** Defines whether this extension is enabled. */
  64124. enabled: boolean;
  64125. private _loader;
  64126. private _clips;
  64127. private _emitters;
  64128. /** @hidden */
  64129. constructor(loader: GLTFLoader);
  64130. /** @hidden */
  64131. dispose(): void;
  64132. /** @hidden */
  64133. onLoading(): void;
  64134. /** @hidden */
  64135. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64136. /** @hidden */
  64137. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64138. /** @hidden */
  64139. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64140. private _loadClipAsync;
  64141. private _loadEmitterAsync;
  64142. private _getEventAction;
  64143. private _loadAnimationEventAsync;
  64144. }
  64145. }
  64146. declare module BABYLON.GLTF2.Loader.Extensions {
  64147. /**
  64148. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64149. */
  64150. export class MSFT_lod implements IGLTFLoaderExtension {
  64151. /** The name of this extension. */
  64152. readonly name: string;
  64153. /** Defines whether this extension is enabled. */
  64154. enabled: boolean;
  64155. /**
  64156. * Maximum number of LODs to load, starting from the lowest LOD.
  64157. */
  64158. maxLODsToLoad: number;
  64159. /**
  64160. * Observable raised when all node LODs of one level are loaded.
  64161. * The event data is the index of the loaded LOD starting from zero.
  64162. * Dispose the loader to cancel the loading of the next level of LODs.
  64163. */
  64164. onNodeLODsLoadedObservable: Observable<number>;
  64165. /**
  64166. * Observable raised when all material LODs of one level are loaded.
  64167. * The event data is the index of the loaded LOD starting from zero.
  64168. * Dispose the loader to cancel the loading of the next level of LODs.
  64169. */
  64170. onMaterialLODsLoadedObservable: Observable<number>;
  64171. private _loader;
  64172. private _nodeIndexLOD;
  64173. private _nodeSignalLODs;
  64174. private _nodePromiseLODs;
  64175. private _materialIndexLOD;
  64176. private _materialSignalLODs;
  64177. private _materialPromiseLODs;
  64178. /** @hidden */
  64179. constructor(loader: GLTFLoader);
  64180. /** @hidden */
  64181. dispose(): void;
  64182. /** @hidden */
  64183. onReady(): void;
  64184. /** @hidden */
  64185. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64186. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64187. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64188. /**
  64189. * Gets an array of LOD properties from lowest to highest.
  64190. */
  64191. private _getLODs;
  64192. private _disposeUnusedMaterials;
  64193. }
  64194. }
  64195. declare module BABYLON.GLTF2.Loader.Extensions {
  64196. /** @hidden */
  64197. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64198. readonly name: string;
  64199. enabled: boolean;
  64200. private _loader;
  64201. constructor(loader: GLTFLoader);
  64202. dispose(): void;
  64203. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64204. }
  64205. }
  64206. declare module BABYLON.GLTF2.Loader.Extensions {
  64207. /** @hidden */
  64208. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64209. readonly name: string;
  64210. enabled: boolean;
  64211. private _loader;
  64212. constructor(loader: GLTFLoader);
  64213. dispose(): void;
  64214. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64215. }
  64216. }
  64217. declare module BABYLON.GLTF2.Loader.Extensions {
  64218. /**
  64219. * Store glTF extras (if present) in BJS objects' metadata
  64220. */
  64221. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  64222. /** The name of this extension. */
  64223. readonly name: string;
  64224. /** Defines whether this extension is enabled. */
  64225. enabled: boolean;
  64226. private _loader;
  64227. private _assignExtras;
  64228. /** @hidden */
  64229. constructor(loader: GLTFLoader);
  64230. /** @hidden */
  64231. dispose(): void;
  64232. /** @hidden */
  64233. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64234. /** @hidden */
  64235. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64236. /** @hidden */
  64237. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /**
  64242. * Class reading and parsing the MTL file bundled with the obj file.
  64243. */
  64244. export class MTLFileLoader {
  64245. /**
  64246. * All material loaded from the mtl will be set here
  64247. */
  64248. materials: StandardMaterial[];
  64249. /**
  64250. * This function will read the mtl file and create each material described inside
  64251. * This function could be improve by adding :
  64252. * -some component missing (Ni, Tf...)
  64253. * -including the specific options available
  64254. *
  64255. * @param scene defines the scene the material will be created in
  64256. * @param data defines the mtl data to parse
  64257. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64258. */
  64259. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64260. /**
  64261. * Gets the texture for the material.
  64262. *
  64263. * If the material is imported from input file,
  64264. * We sanitize the url to ensure it takes the textre from aside the material.
  64265. *
  64266. * @param rootUrl The root url to load from
  64267. * @param value The value stored in the mtl
  64268. * @return The Texture
  64269. */
  64270. private static _getTexture;
  64271. }
  64272. /**
  64273. * Options for loading OBJ/MTL files
  64274. */
  64275. type MeshLoadOptions = {
  64276. /**
  64277. * Defines if UVs are optimized by default during load.
  64278. */
  64279. OptimizeWithUV: boolean;
  64280. /**
  64281. * Defines custom scaling of UV coordinates of loaded meshes.
  64282. */
  64283. UVScaling: Vector2;
  64284. /**
  64285. * Invert model on y-axis (does a model scaling inversion)
  64286. */
  64287. InvertY: boolean;
  64288. /**
  64289. * Invert Y-Axis of referenced textures on load
  64290. */
  64291. InvertTextureY: boolean;
  64292. /**
  64293. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64294. */
  64295. ImportVertexColors: boolean;
  64296. /**
  64297. * Compute the normals for the model, even if normals are present in the file.
  64298. */
  64299. ComputeNormals: boolean;
  64300. /**
  64301. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64302. */
  64303. SkipMaterials: boolean;
  64304. /**
  64305. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64306. */
  64307. MaterialLoadingFailsSilently: boolean;
  64308. };
  64309. /**
  64310. * OBJ file type loader.
  64311. * This is a babylon scene loader plugin.
  64312. */
  64313. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64314. /**
  64315. * Defines if UVs are optimized by default during load.
  64316. */
  64317. static OPTIMIZE_WITH_UV: boolean;
  64318. /**
  64319. * Invert model on y-axis (does a model scaling inversion)
  64320. */
  64321. static INVERT_Y: boolean;
  64322. /**
  64323. * Invert Y-Axis of referenced textures on load
  64324. */
  64325. static INVERT_TEXTURE_Y: boolean;
  64326. /**
  64327. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64328. */
  64329. static IMPORT_VERTEX_COLORS: boolean;
  64330. /**
  64331. * Compute the normals for the model, even if normals are present in the file.
  64332. */
  64333. static COMPUTE_NORMALS: boolean;
  64334. /**
  64335. * Defines custom scaling of UV coordinates of loaded meshes.
  64336. */
  64337. static UV_SCALING: Vector2;
  64338. /**
  64339. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64340. */
  64341. static SKIP_MATERIALS: boolean;
  64342. /**
  64343. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64344. *
  64345. * Defaults to true for backwards compatibility.
  64346. */
  64347. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64348. /**
  64349. * Defines the name of the plugin.
  64350. */
  64351. name: string;
  64352. /**
  64353. * Defines the extension the plugin is able to load.
  64354. */
  64355. extensions: string;
  64356. /** @hidden */
  64357. obj: RegExp;
  64358. /** @hidden */
  64359. group: RegExp;
  64360. /** @hidden */
  64361. mtllib: RegExp;
  64362. /** @hidden */
  64363. usemtl: RegExp;
  64364. /** @hidden */
  64365. smooth: RegExp;
  64366. /** @hidden */
  64367. vertexPattern: RegExp;
  64368. /** @hidden */
  64369. normalPattern: RegExp;
  64370. /** @hidden */
  64371. uvPattern: RegExp;
  64372. /** @hidden */
  64373. facePattern1: RegExp;
  64374. /** @hidden */
  64375. facePattern2: RegExp;
  64376. /** @hidden */
  64377. facePattern3: RegExp;
  64378. /** @hidden */
  64379. facePattern4: RegExp;
  64380. /** @hidden */
  64381. facePattern5: RegExp;
  64382. private _meshLoadOptions;
  64383. /**
  64384. * Creates loader for .OBJ files
  64385. *
  64386. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64387. */
  64388. constructor(meshLoadOptions?: MeshLoadOptions);
  64389. private static readonly currentMeshLoadOptions;
  64390. /**
  64391. * Calls synchronously the MTL file attached to this obj.
  64392. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64393. * Without this function materials are not displayed in the first frame (but displayed after).
  64394. * In consequence it is impossible to get material information in your HTML file
  64395. *
  64396. * @param url The URL of the MTL file
  64397. * @param rootUrl
  64398. * @param onSuccess Callback function to be called when the MTL file is loaded
  64399. * @private
  64400. */
  64401. private _loadMTL;
  64402. /**
  64403. * Instantiates a OBJ file loader plugin.
  64404. * @returns the created plugin
  64405. */
  64406. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64407. /**
  64408. * If the data string can be loaded directly.
  64409. *
  64410. * @param data string containing the file data
  64411. * @returns if the data can be loaded directly
  64412. */
  64413. canDirectLoad(data: string): boolean;
  64414. /**
  64415. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64416. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64417. * @param scene the scene the meshes should be added to
  64418. * @param data the OBJ data to load
  64419. * @param rootUrl root url to load from
  64420. * @param onProgress event that fires when loading progress has occured
  64421. * @param fileName Defines the name of the file to load
  64422. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64423. */
  64424. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64425. meshes: AbstractMesh[];
  64426. particleSystems: IParticleSystem[];
  64427. skeletons: Skeleton[];
  64428. animationGroups: AnimationGroup[];
  64429. }>;
  64430. /**
  64431. * Imports all objects from the loaded OBJ data and adds them to the scene
  64432. * @param scene the scene the objects should be added to
  64433. * @param data the OBJ data to load
  64434. * @param rootUrl root url to load from
  64435. * @param onProgress event that fires when loading progress has occured
  64436. * @param fileName Defines the name of the file to load
  64437. * @returns a promise which completes when objects have been loaded to the scene
  64438. */
  64439. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64440. /**
  64441. * Load into an asset container.
  64442. * @param scene The scene to load into
  64443. * @param data The data to import
  64444. * @param rootUrl The root url for scene and resources
  64445. * @param onProgress The callback when the load progresses
  64446. * @param fileName Defines the name of the file to load
  64447. * @returns The loaded asset container
  64448. */
  64449. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64450. /**
  64451. * Read the OBJ file and create an Array of meshes.
  64452. * Each mesh contains all information given by the OBJ and the MTL file.
  64453. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64454. *
  64455. * @param meshesNames
  64456. * @param scene Scene The scene where are displayed the data
  64457. * @param data String The content of the obj file
  64458. * @param rootUrl String The path to the folder
  64459. * @returns Array<AbstractMesh>
  64460. * @private
  64461. */
  64462. private _parseSolid;
  64463. }
  64464. }
  64465. declare module BABYLON {
  64466. /**
  64467. * STL file type loader.
  64468. * This is a babylon scene loader plugin.
  64469. */
  64470. export class STLFileLoader implements ISceneLoaderPlugin {
  64471. /** @hidden */
  64472. solidPattern: RegExp;
  64473. /** @hidden */
  64474. facetsPattern: RegExp;
  64475. /** @hidden */
  64476. normalPattern: RegExp;
  64477. /** @hidden */
  64478. vertexPattern: RegExp;
  64479. /**
  64480. * Defines the name of the plugin.
  64481. */
  64482. name: string;
  64483. /**
  64484. * Defines the extensions the stl loader is able to load.
  64485. * force data to come in as an ArrayBuffer
  64486. * we'll convert to string if it looks like it's an ASCII .stl
  64487. */
  64488. extensions: ISceneLoaderPluginExtensions;
  64489. /**
  64490. * Import meshes into a scene.
  64491. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64492. * @param scene The scene to import into
  64493. * @param data The data to import
  64494. * @param rootUrl The root url for scene and resources
  64495. * @param meshes The meshes array to import into
  64496. * @param particleSystems The particle systems array to import into
  64497. * @param skeletons The skeletons array to import into
  64498. * @param onError The callback when import fails
  64499. * @returns True if successful or false otherwise
  64500. */
  64501. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64502. /**
  64503. * Load into a scene.
  64504. * @param scene The scene to load into
  64505. * @param data The data to import
  64506. * @param rootUrl The root url for scene and resources
  64507. * @param onError The callback when import fails
  64508. * @returns true if successful or false otherwise
  64509. */
  64510. load(scene: Scene, data: any, rootUrl: string): boolean;
  64511. /**
  64512. * Load into an asset container.
  64513. * @param scene The scene to load into
  64514. * @param data The data to import
  64515. * @param rootUrl The root url for scene and resources
  64516. * @param onError The callback when import fails
  64517. * @returns The loaded asset container
  64518. */
  64519. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64520. private _isBinary;
  64521. private _parseBinary;
  64522. private _parseASCII;
  64523. }
  64524. }
  64525. declare module BABYLON {
  64526. /**
  64527. * Class for generating OBJ data from a Babylon scene.
  64528. */
  64529. export class OBJExport {
  64530. /**
  64531. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64532. * @param mesh defines the list of meshes to serialize
  64533. * @param materials defines if materials should be exported
  64534. * @param matlibname defines the name of the associated mtl file
  64535. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64536. * @returns the OBJ content
  64537. */
  64538. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64539. /**
  64540. * Exports the material(s) of a mesh in .MTL file format (text)
  64541. * @param mesh defines the mesh to extract the material from
  64542. * @returns the mtl content
  64543. */
  64544. static MTL(mesh: Mesh): string;
  64545. }
  64546. }
  64547. declare module BABYLON {
  64548. /** @hidden */
  64549. export var __IGLTFExporterExtension: number;
  64550. /**
  64551. * Interface for extending the exporter
  64552. * @hidden
  64553. */
  64554. export interface IGLTFExporterExtension {
  64555. /**
  64556. * The name of this extension
  64557. */
  64558. readonly name: string;
  64559. /**
  64560. * Defines whether this extension is enabled
  64561. */
  64562. enabled: boolean;
  64563. /**
  64564. * Defines whether this extension is required
  64565. */
  64566. required: boolean;
  64567. }
  64568. }
  64569. declare module BABYLON.GLTF2.Exporter {
  64570. /** @hidden */
  64571. export var __IGLTFExporterExtensionV2: number;
  64572. /**
  64573. * Interface for a glTF exporter extension
  64574. * @hidden
  64575. */
  64576. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64577. /**
  64578. * Define this method to modify the default behavior before exporting a texture
  64579. * @param context The context when loading the asset
  64580. * @param babylonTexture The glTF texture info property
  64581. * @param mimeType The mime-type of the generated image
  64582. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64583. */
  64584. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64585. /**
  64586. * Define this method to modify the default behavior when exporting texture info
  64587. * @param context The context when loading the asset
  64588. * @param meshPrimitive glTF mesh primitive
  64589. * @param babylonSubMesh Babylon submesh
  64590. * @param binaryWriter glTF serializer binary writer instance
  64591. * @returns nullable IMeshPrimitive promise
  64592. */
  64593. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64594. /**
  64595. * Define this method to modify the default behavior when exporting a node
  64596. * @param context The context when exporting the node
  64597. * @param node glTF node
  64598. * @param babylonNode BabylonJS node
  64599. * @returns nullable INode promise
  64600. */
  64601. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64602. /**
  64603. * Called after the exporter state changes to EXPORTING
  64604. */
  64605. onExporting?(): void;
  64606. }
  64607. }
  64608. declare module BABYLON.GLTF2.Exporter {
  64609. /**
  64610. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  64611. * @hidden
  64612. */
  64613. export class _GLTFMaterialExporter {
  64614. /**
  64615. * Represents the dielectric specular values for R, G and B
  64616. */
  64617. private static readonly _DielectricSpecular;
  64618. /**
  64619. * Allows the maximum specular power to be defined for material calculations
  64620. */
  64621. private static readonly _MaxSpecularPower;
  64622. /**
  64623. * Mapping to store textures
  64624. */
  64625. private _textureMap;
  64626. /**
  64627. * Numeric tolerance value
  64628. */
  64629. private static readonly _Epsilon;
  64630. /**
  64631. * Reference to the glTF Exporter
  64632. */
  64633. private _exporter;
  64634. constructor(exporter: _Exporter);
  64635. /**
  64636. * Specifies if two colors are approximately equal in value
  64637. * @param color1 first color to compare to
  64638. * @param color2 second color to compare to
  64639. * @param epsilon threshold value
  64640. */
  64641. private static FuzzyEquals;
  64642. /**
  64643. * Gets the materials from a Babylon scene and converts them to glTF materials
  64644. * @param scene babylonjs scene
  64645. * @param mimeType texture mime type
  64646. * @param images array of images
  64647. * @param textures array of textures
  64648. * @param materials array of materials
  64649. * @param imageData mapping of texture names to base64 textures
  64650. * @param hasTextureCoords specifies if texture coordinates are present on the material
  64651. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64652. /**
  64653. * Makes a copy of the glTF material without the texture parameters
  64654. * @param originalMaterial original glTF material
  64655. * @returns glTF material without texture parameters
  64656. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  64657. /**
  64658. * Specifies if the material has any texture parameters present
  64659. * @param material glTF Material
  64660. * @returns boolean specifying if texture parameters are present
  64661. */ private _hasTexturesPresent(material: IMaterial): boolean;
  64662. /**
  64663. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  64664. * @param babylonStandardMaterial
  64665. * @returns glTF Metallic Roughness Material representation
  64666. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  64667. /**
  64668. * Computes the metallic factor
  64669. * @param diffuse diffused value
  64670. * @param specular specular value
  64671. * @param oneMinusSpecularStrength one minus the specular strength
  64672. * @returns metallic value
  64673. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  64674. /**
  64675. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  64676. * @param glTFMaterial glTF material
  64677. * @param babylonMaterial Babylon material
  64678. */
  64679. private static _SetAlphaMode;
  64680. /**
  64681. * Converts a Babylon Standard Material to a glTF Material
  64682. * @param babylonStandardMaterial BJS Standard Material
  64683. * @param mimeType mime type to use for the textures
  64684. * @param images array of glTF image interfaces
  64685. * @param textures array of glTF texture interfaces
  64686. * @param materials array of glTF material interfaces
  64687. * @param imageData map of image file name to data
  64688. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64689. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64690. /**
  64691. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64692. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  64693. * @param mimeType mime type to use for the textures
  64694. * @param images array of glTF image interfaces
  64695. * @param textures array of glTF texture interfaces
  64696. * @param materials array of glTF material interfaces
  64697. * @param imageData map of image file name to data
  64698. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64699. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64700. /**
  64701. * Converts an image typed array buffer to a base64 image
  64702. * @param buffer typed array buffer
  64703. * @param width width of the image
  64704. * @param height height of the image
  64705. * @param mimeType mimetype of the image
  64706. * @returns base64 image string
  64707. */
  64708. private _createBase64FromCanvasAsync;
  64709. /**
  64710. * Generates a white texture based on the specified width and height
  64711. * @param width width of the texture in pixels
  64712. * @param height height of the texture in pixels
  64713. * @param scene babylonjs scene
  64714. * @returns white texture
  64715. */
  64716. private _createWhiteTexture;
  64717. /**
  64718. * 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
  64719. * @param texture1 first texture to resize
  64720. * @param texture2 second texture to resize
  64721. * @param scene babylonjs scene
  64722. * @returns resized textures or null
  64723. */
  64724. private _resizeTexturesToSameDimensions;
  64725. /**
  64726. * Converts an array of pixels to a Float32Array
  64727. * Throws an error if the pixel format is not supported
  64728. * @param pixels - array buffer containing pixel values
  64729. * @returns Float32 of pixels
  64730. */
  64731. private _convertPixelArrayToFloat32;
  64732. /**
  64733. * Convert Specular Glossiness Textures to Metallic Roughness
  64734. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  64735. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  64736. * @param diffuseTexture texture used to store diffuse information
  64737. * @param specularGlossinessTexture texture used to store specular and glossiness information
  64738. * @param factors specular glossiness material factors
  64739. * @param mimeType the mime type to use for the texture
  64740. * @returns pbr metallic roughness interface or null
  64741. */
  64742. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  64743. /**
  64744. * Converts specular glossiness material properties to metallic roughness
  64745. * @param specularGlossiness interface with specular glossiness material properties
  64746. * @returns interface with metallic roughness material properties
  64747. */
  64748. private _convertSpecularGlossinessToMetallicRoughness;
  64749. /**
  64750. * Calculates the surface reflectance, independent of lighting conditions
  64751. * @param color Color source to calculate brightness from
  64752. * @returns number representing the perceived brightness, or zero if color is undefined
  64753. */
  64754. private _getPerceivedBrightness;
  64755. /**
  64756. * Returns the maximum color component value
  64757. * @param color
  64758. * @returns maximum color component value, or zero if color is null or undefined
  64759. */
  64760. private _getMaxComponent;
  64761. /**
  64762. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  64763. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64764. * @param mimeType mime type to use for the textures
  64765. * @param images array of glTF image interfaces
  64766. * @param textures array of glTF texture interfaces
  64767. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64768. * @param imageData map of image file name to data
  64769. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64770. * @returns glTF PBR Metallic Roughness factors
  64771. */
  64772. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  64773. private _getGLTFTextureSampler;
  64774. private _getGLTFTextureWrapMode;
  64775. private _getGLTFTextureWrapModesSampler;
  64776. /**
  64777. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  64778. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64779. * @param mimeType mime type to use for the textures
  64780. * @param images array of glTF image interfaces
  64781. * @param textures array of glTF texture interfaces
  64782. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64783. * @param imageData map of image file name to data
  64784. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64785. * @returns glTF PBR Metallic Roughness factors
  64786. */
  64787. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  64788. /**
  64789. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64790. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64791. * @param mimeType mime type to use for the textures
  64792. * @param images array of glTF image interfaces
  64793. * @param textures array of glTF texture interfaces
  64794. * @param materials array of glTF material interfaces
  64795. * @param imageData map of image file name to data
  64796. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64797. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64798. private setMetallicRoughnessPbrMaterial;
  64799. private getPixelsFromTexture;
  64800. /**
  64801. * Extracts a texture from a Babylon texture into file data and glTF data
  64802. * @param babylonTexture Babylon texture to extract
  64803. * @param mimeType Mime Type of the babylonTexture
  64804. * @return glTF texture info, or null if the texture format is not supported
  64805. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64806. /**
  64807. * Builds a texture from base64 string
  64808. * @param base64Texture base64 texture string
  64809. * @param baseTextureName Name to use for the texture
  64810. * @param mimeType image mime type for the texture
  64811. * @param images array of images
  64812. * @param textures array of textures
  64813. * @param imageData map of image data
  64814. * @returns glTF texture info, or null if the texture format is not supported
  64815. */
  64816. private _getTextureInfoFromBase64;
  64817. }
  64818. }
  64819. declare module BABYLON {
  64820. /**
  64821. * Class for holding and downloading glTF file data
  64822. */
  64823. export class GLTFData {
  64824. /**
  64825. * Object which contains the file name as the key and its data as the value
  64826. */
  64827. glTFFiles: {
  64828. [fileName: string]: string | Blob;
  64829. };
  64830. /**
  64831. * Initializes the glTF file object
  64832. */
  64833. constructor();
  64834. /**
  64835. * Downloads the glTF data as files based on their names and data
  64836. */
  64837. downloadFiles(): void;
  64838. }
  64839. }
  64840. declare module BABYLON {
  64841. /**
  64842. * Holds a collection of exporter options and parameters
  64843. */
  64844. export interface IExportOptions {
  64845. /**
  64846. * Function which indicates whether a babylon node should be exported or not
  64847. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  64848. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  64849. */
  64850. shouldExportNode?(node: Node): boolean;
  64851. /**
  64852. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  64853. * @param metadata source metadata to read from
  64854. * @returns the data to store to glTF node extras
  64855. */
  64856. metadataSelector?(metadata: any): any;
  64857. /**
  64858. * The sample rate to bake animation curves
  64859. */
  64860. animationSampleRate?: number;
  64861. /**
  64862. * Begin serialization without waiting for the scene to be ready
  64863. */
  64864. exportWithoutWaitingForScene?: boolean;
  64865. }
  64866. /**
  64867. * Class for generating glTF data from a Babylon scene.
  64868. */
  64869. export class GLTF2Export {
  64870. /**
  64871. * Exports the geometry of the scene to .gltf file format asynchronously
  64872. * @param scene Babylon scene with scene hierarchy information
  64873. * @param filePrefix File prefix to use when generating the glTF file
  64874. * @param options Exporter options
  64875. * @returns Returns an object with a .gltf file and associates texture names
  64876. * as keys and their data and paths as values
  64877. */
  64878. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64879. private static _PreExportAsync;
  64880. private static _PostExportAsync;
  64881. /**
  64882. * Exports the geometry of the scene to .glb file format asychronously
  64883. * @param scene Babylon scene with scene hierarchy information
  64884. * @param filePrefix File prefix to use when generating glb file
  64885. * @param options Exporter options
  64886. * @returns Returns an object with a .glb filename as key and data as value
  64887. */
  64888. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64889. }
  64890. }
  64891. declare module BABYLON.GLTF2.Exporter {
  64892. /**
  64893. * @hidden
  64894. */
  64895. export class _GLTFUtilities {
  64896. /**
  64897. * Creates a buffer view based on the supplied arguments
  64898. * @param bufferIndex index value of the specified buffer
  64899. * @param byteOffset byte offset value
  64900. * @param byteLength byte length of the bufferView
  64901. * @param byteStride byte distance between conequential elements
  64902. * @param name name of the buffer view
  64903. * @returns bufferView for glTF
  64904. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  64905. /**
  64906. * Creates an accessor based on the supplied arguments
  64907. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  64908. * @param name The name of the accessor
  64909. * @param type The type of the accessor
  64910. * @param componentType The datatype of components in the attribute
  64911. * @param count The number of attributes referenced by this accessor
  64912. * @param byteOffset The offset relative to the start of the bufferView in bytes
  64913. * @param min Minimum value of each component in this attribute
  64914. * @param max Maximum value of each component in this attribute
  64915. * @returns accessor for glTF
  64916. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  64917. /**
  64918. * Calculates the minimum and maximum values of an array of position floats
  64919. * @param positions Positions array of a mesh
  64920. * @param vertexStart Starting vertex offset to calculate min and max values
  64921. * @param vertexCount Number of vertices to check for min and max values
  64922. * @returns min number array and max number array
  64923. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  64924. min: number[];
  64925. max: number[];
  64926. };
  64927. /**
  64928. * Converts a new right-handed Vector3
  64929. * @param vector vector3 array
  64930. * @returns right-handed Vector3
  64931. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  64932. /**
  64933. * Converts a Vector3 to right-handed
  64934. * @param vector Vector3 to convert to right-handed
  64935. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  64936. /**
  64937. * Converts a three element number array to right-handed
  64938. * @param vector number array to convert to right-handed
  64939. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  64940. /**
  64941. * Converts a new right-handed Vector3
  64942. * @param vector vector3 array
  64943. * @returns right-handed Vector3
  64944. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  64945. /**
  64946. * Converts a Vector3 to right-handed
  64947. * @param vector Vector3 to convert to right-handed
  64948. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  64949. /**
  64950. * Converts a three element number array to right-handed
  64951. * @param vector number array to convert to right-handed
  64952. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  64953. /**
  64954. * Converts a Vector4 to right-handed
  64955. * @param vector Vector4 to convert to right-handed
  64956. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  64957. /**
  64958. * Converts a Vector4 to right-handed
  64959. * @param vector Vector4 to convert to right-handed
  64960. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  64961. /**
  64962. * Converts a Quaternion to right-handed
  64963. * @param quaternion Source quaternion to convert to right-handed
  64964. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  64965. /**
  64966. * Converts a Quaternion to right-handed
  64967. * @param quaternion Source quaternion to convert to right-handed
  64968. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  64969. }
  64970. }
  64971. declare module BABYLON.GLTF2.Exporter {
  64972. /**
  64973. * Converts Babylon Scene into glTF 2.0.
  64974. * @hidden
  64975. */
  64976. export class _Exporter {
  64977. /**
  64978. * Stores the glTF to export
  64979. */ private _glTF: IGLTF;
  64980. /**
  64981. * Stores all generated buffer views, which represents views into the main glTF buffer data
  64982. */ private _bufferViews: IBufferView[];
  64983. /**
  64984. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  64985. */ private _accessors: IAccessor[];
  64986. /**
  64987. * Stores all the generated nodes, which contains transform and/or mesh information per node
  64988. */
  64989. private _nodes;
  64990. /**
  64991. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  64992. */
  64993. private _scenes;
  64994. /**
  64995. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  64996. */
  64997. private _meshes;
  64998. /**
  64999. * Stores all the generated material information, which represents the appearance of each primitive
  65000. */ private _materials: IMaterial[]; private _materialMap: {
  65001. [materialID: number]: number;
  65002. };
  65003. /**
  65004. * Stores all the generated texture information, which is referenced by glTF materials
  65005. */ private _textures: ITexture[];
  65006. /**
  65007. * Stores all the generated image information, which is referenced by glTF textures
  65008. */ private _images: IImage[];
  65009. /**
  65010. * Stores all the texture samplers
  65011. */ private _samplers: ISampler[];
  65012. /**
  65013. * Stores all the generated animation samplers, which is referenced by glTF animations
  65014. */
  65015. /**
  65016. * Stores the animations for glTF models
  65017. */
  65018. private _animations;
  65019. /**
  65020. * Stores the total amount of bytes stored in the glTF buffer
  65021. */
  65022. private _totalByteLength;
  65023. /**
  65024. * Stores a reference to the Babylon scene containing the source geometry and material information
  65025. */ private _babylonScene: Scene;
  65026. /**
  65027. * Stores a map of the image data, where the key is the file name and the value
  65028. * is the image data
  65029. */ private _imageData: {
  65030. [fileName: string]: {
  65031. data: Uint8Array;
  65032. mimeType: ImageMimeType;
  65033. };
  65034. };
  65035. /**
  65036. * Stores a map of the unique id of a node to its index in the node array
  65037. */
  65038. private _nodeMap;
  65039. /**
  65040. * Specifies if the Babylon scene should be converted to right-handed on export
  65041. */ private _convertToRightHandedSystem: boolean;
  65042. /**
  65043. * Baked animation sample rate
  65044. */
  65045. private _animationSampleRate;
  65046. private _options;
  65047. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  65048. private _extensions;
  65049. private static _ExtensionNames;
  65050. private static _ExtensionFactories;
  65051. 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>>;
  65052. private _forEachExtensions;
  65053. private _extensionsOnExporting;
  65054. /**
  65055. * Load glTF serializer extensions
  65056. */
  65057. private _loadExtensions;
  65058. /**
  65059. * Creates a glTF Exporter instance, which can accept optional exporter options
  65060. * @param babylonScene Babylon scene object
  65061. * @param options Options to modify the behavior of the exporter
  65062. */
  65063. constructor(babylonScene: Scene, options?: IExportOptions);
  65064. /**
  65065. * Registers a glTF exporter extension
  65066. * @param name Name of the extension to export
  65067. * @param factory The factory function that creates the exporter extension
  65068. */
  65069. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65070. /**
  65071. * Un-registers an exporter extension
  65072. * @param name The name fo the exporter extension
  65073. * @returns A boolean indicating whether the extension has been un-registered
  65074. */
  65075. static UnregisterExtension(name: string): boolean;
  65076. /**
  65077. * Lazy load a local engine with premultiplied alpha set to false
  65078. */ private _getLocalEngine(): Engine;
  65079. private reorderIndicesBasedOnPrimitiveMode;
  65080. /**
  65081. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65082. * clock-wise during export to glTF
  65083. * @param submesh BabylonJS submesh
  65084. * @param primitiveMode Primitive mode of the mesh
  65085. * @param sideOrientation the winding order of the submesh
  65086. * @param vertexBufferKind The type of vertex attribute
  65087. * @param meshAttributeArray The vertex attribute data
  65088. * @param byteOffset The offset to the binary data
  65089. * @param binaryWriter The binary data for the glTF file
  65090. */
  65091. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65092. /**
  65093. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65094. * clock-wise during export to glTF
  65095. * @param submesh BabylonJS submesh
  65096. * @param primitiveMode Primitive mode of the mesh
  65097. * @param sideOrientation the winding order of the submesh
  65098. * @param vertexBufferKind The type of vertex attribute
  65099. * @param meshAttributeArray The vertex attribute data
  65100. * @param byteOffset The offset to the binary data
  65101. * @param binaryWriter The binary data for the glTF file
  65102. */
  65103. private reorderTriangleFillMode;
  65104. /**
  65105. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65106. * clock-wise during export to glTF
  65107. * @param submesh BabylonJS submesh
  65108. * @param primitiveMode Primitive mode of the mesh
  65109. * @param sideOrientation the winding order of the submesh
  65110. * @param vertexBufferKind The type of vertex attribute
  65111. * @param meshAttributeArray The vertex attribute data
  65112. * @param byteOffset The offset to the binary data
  65113. * @param binaryWriter The binary data for the glTF file
  65114. */
  65115. private reorderTriangleStripDrawMode;
  65116. /**
  65117. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65118. * clock-wise during export to glTF
  65119. * @param submesh BabylonJS submesh
  65120. * @param primitiveMode Primitive mode of the mesh
  65121. * @param sideOrientation the winding order of the submesh
  65122. * @param vertexBufferKind The type of vertex attribute
  65123. * @param meshAttributeArray The vertex attribute data
  65124. * @param byteOffset The offset to the binary data
  65125. * @param binaryWriter The binary data for the glTF file
  65126. */
  65127. private reorderTriangleFanMode;
  65128. /**
  65129. * Writes the vertex attribute data to binary
  65130. * @param vertices The vertices to write to the binary writer
  65131. * @param byteOffset The offset into the binary writer to overwrite binary data
  65132. * @param vertexAttributeKind The vertex attribute type
  65133. * @param meshAttributeArray The vertex attribute data
  65134. * @param binaryWriter The writer containing the binary data
  65135. */
  65136. private writeVertexAttributeData;
  65137. /**
  65138. * Writes mesh attribute data to a data buffer
  65139. * Returns the bytelength of the data
  65140. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65141. * @param meshAttributeArray Array containing the attribute data
  65142. * @param binaryWriter The buffer to write the binary data to
  65143. * @param indices Used to specify the order of the vertex data
  65144. */
  65145. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65146. /**
  65147. * Generates glTF json data
  65148. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65149. * @param glTFPrefix Text to use when prefixing a glTF file
  65150. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65151. * @returns json data as string
  65152. */
  65153. private generateJSON;
  65154. /**
  65155. * Generates data for .gltf and .bin files based on the glTF prefix string
  65156. * @param glTFPrefix Text to use when prefixing a glTF file
  65157. * @returns GLTFData with glTF file data
  65158. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65159. /**
  65160. * Creates a binary buffer for glTF
  65161. * @returns array buffer for binary data
  65162. */
  65163. private _generateBinaryAsync;
  65164. /**
  65165. * Pads the number to a multiple of 4
  65166. * @param num number to pad
  65167. * @returns padded number
  65168. */
  65169. private _getPadding;
  65170. /**
  65171. * Generates a glb file from the json and binary data
  65172. * Returns an object with the glb file name as the key and data as the value
  65173. * @param glTFPrefix
  65174. * @returns object with glb filename as key and data as value
  65175. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65176. /**
  65177. * Sets the TRS for each node
  65178. * @param node glTF Node for storing the transformation data
  65179. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65180. */
  65181. private setNodeTransformation;
  65182. private getVertexBufferFromMesh;
  65183. /**
  65184. * Creates a bufferview based on the vertices type for the Babylon mesh
  65185. * @param kind Indicates the type of vertices data
  65186. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65187. * @param binaryWriter The buffer to write the bufferview data to
  65188. */
  65189. private createBufferViewKind;
  65190. /**
  65191. * The primitive mode of the Babylon mesh
  65192. * @param babylonMesh The BabylonJS mesh
  65193. */
  65194. private getMeshPrimitiveMode;
  65195. /**
  65196. * Sets the primitive mode of the glTF mesh primitive
  65197. * @param meshPrimitive glTF mesh primitive
  65198. * @param primitiveMode The primitive mode
  65199. */
  65200. private setPrimitiveMode;
  65201. /**
  65202. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65203. * @param meshPrimitive glTF mesh primitive
  65204. * @param attributeKind vertex attribute
  65205. * @returns boolean specifying if uv coordinates are present
  65206. */
  65207. private setAttributeKind;
  65208. /**
  65209. * Sets data for the primitive attributes of each submesh
  65210. * @param mesh glTF Mesh object to store the primitive attribute information
  65211. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65212. * @param binaryWriter Buffer to write the attribute data to
  65213. */
  65214. private setPrimitiveAttributesAsync;
  65215. /**
  65216. * Creates a glTF scene based on the array of meshes
  65217. * Returns the the total byte offset
  65218. * @param babylonScene Babylon scene to get the mesh data from
  65219. * @param binaryWriter Buffer to write binary data to
  65220. */
  65221. private createSceneAsync;
  65222. /**
  65223. * Creates a mapping of Node unique id to node index and handles animations
  65224. * @param babylonScene Babylon Scene
  65225. * @param nodes Babylon transform nodes
  65226. * @param binaryWriter Buffer to write binary data to
  65227. * @returns Node mapping of unique id to index
  65228. */
  65229. private createNodeMapAndAnimationsAsync;
  65230. /**
  65231. * Creates a glTF node from a Babylon mesh
  65232. * @param babylonMesh Source Babylon mesh
  65233. * @param binaryWriter Buffer for storing geometry data
  65234. * @returns glTF node
  65235. */
  65236. private createNodeAsync;
  65237. }
  65238. /**
  65239. * @hidden
  65240. *
  65241. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65242. */
  65243. export class _BinaryWriter {
  65244. /**
  65245. * Array buffer which stores all binary data
  65246. */
  65247. private _arrayBuffer;
  65248. /**
  65249. * View of the array buffer
  65250. */
  65251. private _dataView;
  65252. /**
  65253. * byte offset of data in array buffer
  65254. */
  65255. private _byteOffset;
  65256. /**
  65257. * Initialize binary writer with an initial byte length
  65258. * @param byteLength Initial byte length of the array buffer
  65259. */
  65260. constructor(byteLength: number);
  65261. /**
  65262. * Resize the array buffer to the specified byte length
  65263. * @param byteLength
  65264. */
  65265. private resizeBuffer;
  65266. /**
  65267. * Get an array buffer with the length of the byte offset
  65268. * @returns ArrayBuffer resized to the byte offset
  65269. */
  65270. getArrayBuffer(): ArrayBuffer;
  65271. /**
  65272. * Get the byte offset of the array buffer
  65273. * @returns byte offset
  65274. */
  65275. getByteOffset(): number;
  65276. /**
  65277. * Stores an UInt8 in the array buffer
  65278. * @param entry
  65279. * @param byteOffset If defined, specifies where to set the value as an offset.
  65280. */
  65281. setUInt8(entry: number, byteOffset?: number): void;
  65282. /**
  65283. * Gets an UInt32 in the array buffer
  65284. * @param entry
  65285. * @param byteOffset If defined, specifies where to set the value as an offset.
  65286. */
  65287. getUInt32(byteOffset: number): number;
  65288. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65289. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65290. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65291. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65292. /**
  65293. * Stores a Float32 in the array buffer
  65294. * @param entry
  65295. */
  65296. setFloat32(entry: number, byteOffset?: number): void;
  65297. /**
  65298. * Stores an UInt32 in the array buffer
  65299. * @param entry
  65300. * @param byteOffset If defined, specifies where to set the value as an offset.
  65301. */
  65302. setUInt32(entry: number, byteOffset?: number): void;
  65303. }
  65304. }
  65305. declare module BABYLON.GLTF2.Exporter {
  65306. /**
  65307. * @hidden
  65308. * Interface to store animation data.
  65309. */
  65310. export interface _IAnimationData {
  65311. /**
  65312. * Keyframe data.
  65313. */
  65314. inputs: number[];
  65315. /**
  65316. * Value data.
  65317. */
  65318. outputs: number[][];
  65319. /**
  65320. * Animation interpolation data.
  65321. */
  65322. samplerInterpolation: AnimationSamplerInterpolation;
  65323. /**
  65324. * Minimum keyframe value.
  65325. */
  65326. inputsMin: number;
  65327. /**
  65328. * Maximum keyframe value.
  65329. */
  65330. inputsMax: number;
  65331. }
  65332. /**
  65333. * @hidden
  65334. */
  65335. export interface _IAnimationInfo {
  65336. /**
  65337. * The target channel for the animation
  65338. */
  65339. animationChannelTargetPath: AnimationChannelTargetPath;
  65340. /**
  65341. * The glTF accessor type for the data.
  65342. */
  65343. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65344. /**
  65345. * Specifies if quaternions should be used.
  65346. */
  65347. useQuaternion: boolean;
  65348. }
  65349. /**
  65350. * @hidden
  65351. * Utility class for generating glTF animation data from BabylonJS.
  65352. */
  65353. export class _GLTFAnimation {
  65354. /**
  65355. * @ignore
  65356. *
  65357. * Creates glTF channel animation from BabylonJS animation.
  65358. * @param babylonTransformNode - BabylonJS mesh.
  65359. * @param animation - animation.
  65360. * @param animationChannelTargetPath - The target animation channel.
  65361. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65362. * @param useQuaternion - Specifies if quaternions are used.
  65363. * @returns nullable IAnimationData
  65364. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65365. private static _DeduceAnimationInfo;
  65366. /**
  65367. * @ignore
  65368. * Create node animations from the transform node animations
  65369. * @param babylonNode
  65370. * @param runtimeGLTFAnimation
  65371. * @param idleGLTFAnimations
  65372. * @param nodeMap
  65373. * @param nodes
  65374. * @param binaryWriter
  65375. * @param bufferViews
  65376. * @param accessors
  65377. * @param convertToRightHandedSystem
  65378. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65379. [key: number]: number;
  65380. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65381. /**
  65382. * @ignore
  65383. * Create node animations from the animation groups
  65384. * @param babylonScene
  65385. * @param glTFAnimations
  65386. * @param nodeMap
  65387. * @param nodes
  65388. * @param binaryWriter
  65389. * @param bufferViews
  65390. * @param accessors
  65391. * @param convertToRightHandedSystem
  65392. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65393. [key: number]: number;
  65394. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65395. private static AddAnimation;
  65396. /**
  65397. * Create a baked animation
  65398. * @param babylonTransformNode BabylonJS mesh
  65399. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65400. * @param animationChannelTargetPath animation target channel
  65401. * @param minFrame minimum animation frame
  65402. * @param maxFrame maximum animation frame
  65403. * @param fps frames per second of the animation
  65404. * @param inputs input key frames of the animation
  65405. * @param outputs output key frame data of the animation
  65406. * @param convertToRightHandedSystem converts the values to right-handed
  65407. * @param useQuaternion specifies if quaternions should be used
  65408. */
  65409. private static _CreateBakedAnimation;
  65410. private static _ConvertFactorToVector3OrQuaternion;
  65411. private static _SetInterpolatedValue;
  65412. /**
  65413. * Creates linear animation from the animation key frames
  65414. * @param babylonTransformNode BabylonJS mesh
  65415. * @param animation BabylonJS animation
  65416. * @param animationChannelTargetPath The target animation channel
  65417. * @param frameDelta The difference between the last and first frame of the animation
  65418. * @param inputs Array to store the key frame times
  65419. * @param outputs Array to store the key frame data
  65420. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65421. * @param useQuaternion Specifies if quaternions are used in the animation
  65422. */
  65423. private static _CreateLinearOrStepAnimation;
  65424. /**
  65425. * Creates cubic spline animation from the animation key frames
  65426. * @param babylonTransformNode BabylonJS mesh
  65427. * @param animation BabylonJS animation
  65428. * @param animationChannelTargetPath The target animation channel
  65429. * @param frameDelta The difference between the last and first frame of the animation
  65430. * @param inputs Array to store the key frame times
  65431. * @param outputs Array to store the key frame data
  65432. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65433. * @param useQuaternion Specifies if quaternions are used in the animation
  65434. */
  65435. private static _CreateCubicSplineAnimation;
  65436. private static _GetBasePositionRotationOrScale;
  65437. /**
  65438. * Adds a key frame value
  65439. * @param keyFrame
  65440. * @param animation
  65441. * @param outputs
  65442. * @param animationChannelTargetPath
  65443. * @param basePositionRotationOrScale
  65444. * @param convertToRightHandedSystem
  65445. * @param useQuaternion
  65446. */
  65447. private static _AddKeyframeValue;
  65448. /**
  65449. * Determine the interpolation based on the key frames
  65450. * @param keyFrames
  65451. * @param animationChannelTargetPath
  65452. * @param useQuaternion
  65453. */
  65454. private static _DeduceInterpolation;
  65455. /**
  65456. * Adds an input tangent or output tangent to the output data
  65457. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65458. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65459. * @param outputs The animation data by keyframe
  65460. * @param animationChannelTargetPath The target animation channel
  65461. * @param interpolation The interpolation type
  65462. * @param keyFrame The key frame with the animation data
  65463. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65464. * @param useQuaternion Specifies if quaternions are used
  65465. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65466. */
  65467. private static AddSplineTangent;
  65468. /**
  65469. * Get the minimum and maximum key frames' frame values
  65470. * @param keyFrames animation key frames
  65471. * @returns the minimum and maximum key frame value
  65472. */
  65473. private static calculateMinMaxKeyFrames;
  65474. }
  65475. }
  65476. declare module BABYLON.GLTF2.Exporter {
  65477. /** @hidden */
  65478. export var textureTransformPixelShader: {
  65479. name: string;
  65480. shader: string;
  65481. };
  65482. }
  65483. declare module BABYLON.GLTF2.Exporter.Extensions {
  65484. /**
  65485. * @hidden
  65486. */
  65487. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65488. /** Name of this extension */
  65489. readonly name: string;
  65490. /** Defines whether this extension is enabled */
  65491. enabled: boolean;
  65492. /** Defines whether this extension is required */
  65493. required: boolean;
  65494. /** Reference to the glTF exporter */
  65495. private _exporter;
  65496. constructor(exporter: _Exporter);
  65497. dispose(): void;
  65498. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65499. /**
  65500. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65501. * @param babylonTexture
  65502. * @param offset
  65503. * @param rotation
  65504. * @param scale
  65505. * @param scene
  65506. */
  65507. private _textureTransformTextureAsync;
  65508. }
  65509. }
  65510. declare module BABYLON.GLTF2.Exporter.Extensions {
  65511. /**
  65512. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65513. */
  65514. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65515. /** The name of this extension. */
  65516. readonly name: string;
  65517. /** Defines whether this extension is enabled. */
  65518. enabled: boolean;
  65519. /** Defines whether this extension is required */
  65520. required: boolean;
  65521. /** Reference to the glTF exporter */
  65522. private _exporter;
  65523. private _lights;
  65524. /** @hidden */
  65525. constructor(exporter: _Exporter);
  65526. /** @hidden */
  65527. dispose(): void;
  65528. /** @hidden */
  65529. onExporting(): void;
  65530. /**
  65531. * Define this method to modify the default behavior when exporting a node
  65532. * @param context The context when exporting the node
  65533. * @param node glTF node
  65534. * @param babylonNode BabylonJS node
  65535. * @returns nullable INode promise
  65536. */
  65537. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65538. }
  65539. }
  65540. declare module BABYLON {
  65541. /**
  65542. * Class for generating STL data from a Babylon scene.
  65543. */
  65544. export class STLExport {
  65545. /**
  65546. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65547. * @param meshes list defines the mesh to serialize
  65548. * @param download triggers the automatic download of the file.
  65549. * @param fileName changes the downloads fileName.
  65550. * @param binary changes the STL to a binary type.
  65551. * @param isLittleEndian toggle for binary type exporter.
  65552. * @returns the STL as UTF8 string
  65553. */
  65554. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65555. }
  65556. }
  65557. /**
  65558. * @ignoreChildren
  65559. * @ignore
  65560. */
  65561. declare module "babylonjs-gltf2interface" {
  65562. export = BABYLON.GLTF2;
  65563. }
  65564. /**
  65565. * Module for glTF 2.0 Interface
  65566. * @ignoreChildren
  65567. * @ignore
  65568. */
  65569. declare module BABYLON.GLTF2 {
  65570. /**
  65571. * The datatype of the components in the attribute
  65572. */
  65573. const enum AccessorComponentType {
  65574. /**
  65575. * Byte
  65576. */
  65577. BYTE = 5120,
  65578. /**
  65579. * Unsigned Byte
  65580. */
  65581. UNSIGNED_BYTE = 5121,
  65582. /**
  65583. * Short
  65584. */
  65585. SHORT = 5122,
  65586. /**
  65587. * Unsigned Short
  65588. */
  65589. UNSIGNED_SHORT = 5123,
  65590. /**
  65591. * Unsigned Int
  65592. */
  65593. UNSIGNED_INT = 5125,
  65594. /**
  65595. * Float
  65596. */
  65597. FLOAT = 5126,
  65598. }
  65599. /**
  65600. * Specifies if the attirbute is a scalar, vector, or matrix
  65601. */
  65602. const enum AccessorType {
  65603. /**
  65604. * Scalar
  65605. */
  65606. SCALAR = "SCALAR",
  65607. /**
  65608. * Vector2
  65609. */
  65610. VEC2 = "VEC2",
  65611. /**
  65612. * Vector3
  65613. */
  65614. VEC3 = "VEC3",
  65615. /**
  65616. * Vector4
  65617. */
  65618. VEC4 = "VEC4",
  65619. /**
  65620. * Matrix2x2
  65621. */
  65622. MAT2 = "MAT2",
  65623. /**
  65624. * Matrix3x3
  65625. */
  65626. MAT3 = "MAT3",
  65627. /**
  65628. * Matrix4x4
  65629. */
  65630. MAT4 = "MAT4",
  65631. }
  65632. /**
  65633. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65634. */
  65635. const enum AnimationChannelTargetPath {
  65636. /**
  65637. * Translation
  65638. */
  65639. TRANSLATION = "translation",
  65640. /**
  65641. * Rotation
  65642. */
  65643. ROTATION = "rotation",
  65644. /**
  65645. * Scale
  65646. */
  65647. SCALE = "scale",
  65648. /**
  65649. * Weights
  65650. */
  65651. WEIGHTS = "weights",
  65652. }
  65653. /**
  65654. * Interpolation algorithm
  65655. */
  65656. const enum AnimationSamplerInterpolation {
  65657. /**
  65658. * The animated values are linearly interpolated between keyframes
  65659. */
  65660. LINEAR = "LINEAR",
  65661. /**
  65662. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  65663. */
  65664. STEP = "STEP",
  65665. /**
  65666. * The animation's interpolation is computed using a cubic spline with specified tangents
  65667. */
  65668. CUBICSPLINE = "CUBICSPLINE",
  65669. }
  65670. /**
  65671. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65672. */
  65673. const enum CameraType {
  65674. /**
  65675. * A perspective camera containing properties to create a perspective projection matrix
  65676. */
  65677. PERSPECTIVE = "perspective",
  65678. /**
  65679. * An orthographic camera containing properties to create an orthographic projection matrix
  65680. */
  65681. ORTHOGRAPHIC = "orthographic",
  65682. }
  65683. /**
  65684. * The mime-type of the image
  65685. */
  65686. const enum ImageMimeType {
  65687. /**
  65688. * JPEG Mime-type
  65689. */
  65690. JPEG = "image/jpeg",
  65691. /**
  65692. * PNG Mime-type
  65693. */
  65694. PNG = "image/png",
  65695. }
  65696. /**
  65697. * The alpha rendering mode of the material
  65698. */
  65699. const enum MaterialAlphaMode {
  65700. /**
  65701. * The alpha value is ignored and the rendered output is fully opaque
  65702. */
  65703. OPAQUE = "OPAQUE",
  65704. /**
  65705. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  65706. */
  65707. MASK = "MASK",
  65708. /**
  65709. * 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)
  65710. */
  65711. BLEND = "BLEND",
  65712. }
  65713. /**
  65714. * The type of the primitives to render
  65715. */
  65716. const enum MeshPrimitiveMode {
  65717. /**
  65718. * Points
  65719. */
  65720. POINTS = 0,
  65721. /**
  65722. * Lines
  65723. */
  65724. LINES = 1,
  65725. /**
  65726. * Line Loop
  65727. */
  65728. LINE_LOOP = 2,
  65729. /**
  65730. * Line Strip
  65731. */
  65732. LINE_STRIP = 3,
  65733. /**
  65734. * Triangles
  65735. */
  65736. TRIANGLES = 4,
  65737. /**
  65738. * Triangle Strip
  65739. */
  65740. TRIANGLE_STRIP = 5,
  65741. /**
  65742. * Triangle Fan
  65743. */
  65744. TRIANGLE_FAN = 6,
  65745. }
  65746. /**
  65747. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65748. */
  65749. const enum TextureMagFilter {
  65750. /**
  65751. * Nearest
  65752. */
  65753. NEAREST = 9728,
  65754. /**
  65755. * Linear
  65756. */
  65757. LINEAR = 9729,
  65758. }
  65759. /**
  65760. * Minification filter. All valid values correspond to WebGL enums
  65761. */
  65762. const enum TextureMinFilter {
  65763. /**
  65764. * Nearest
  65765. */
  65766. NEAREST = 9728,
  65767. /**
  65768. * Linear
  65769. */
  65770. LINEAR = 9729,
  65771. /**
  65772. * Nearest Mip-Map Nearest
  65773. */
  65774. NEAREST_MIPMAP_NEAREST = 9984,
  65775. /**
  65776. * Linear Mipmap Nearest
  65777. */
  65778. LINEAR_MIPMAP_NEAREST = 9985,
  65779. /**
  65780. * Nearest Mipmap Linear
  65781. */
  65782. NEAREST_MIPMAP_LINEAR = 9986,
  65783. /**
  65784. * Linear Mipmap Linear
  65785. */
  65786. LINEAR_MIPMAP_LINEAR = 9987,
  65787. }
  65788. /**
  65789. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65790. */
  65791. const enum TextureWrapMode {
  65792. /**
  65793. * Clamp to Edge
  65794. */
  65795. CLAMP_TO_EDGE = 33071,
  65796. /**
  65797. * Mirrored Repeat
  65798. */
  65799. MIRRORED_REPEAT = 33648,
  65800. /**
  65801. * Repeat
  65802. */
  65803. REPEAT = 10497,
  65804. }
  65805. /**
  65806. * glTF Property
  65807. */
  65808. interface IProperty {
  65809. /**
  65810. * Dictionary object with extension-specific objects
  65811. */
  65812. extensions?: {
  65813. [key: string]: any;
  65814. };
  65815. /**
  65816. * Application-Specific data
  65817. */
  65818. extras?: any;
  65819. }
  65820. /**
  65821. * glTF Child of Root Property
  65822. */
  65823. interface IChildRootProperty extends IProperty {
  65824. /**
  65825. * The user-defined name of this object
  65826. */
  65827. name?: string;
  65828. }
  65829. /**
  65830. * Indices of those attributes that deviate from their initialization value
  65831. */
  65832. interface IAccessorSparseIndices extends IProperty {
  65833. /**
  65834. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65835. */
  65836. bufferView: number;
  65837. /**
  65838. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65839. */
  65840. byteOffset?: number;
  65841. /**
  65842. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  65843. */
  65844. componentType: AccessorComponentType;
  65845. }
  65846. /**
  65847. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  65848. */
  65849. interface IAccessorSparseValues extends IProperty {
  65850. /**
  65851. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65852. */
  65853. bufferView: number;
  65854. /**
  65855. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65856. */
  65857. byteOffset?: number;
  65858. }
  65859. /**
  65860. * Sparse storage of attributes that deviate from their initialization value
  65861. */
  65862. interface IAccessorSparse extends IProperty {
  65863. /**
  65864. * The number of attributes encoded in this sparse accessor
  65865. */
  65866. count: number;
  65867. /**
  65868. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  65869. */
  65870. indices: IAccessorSparseIndices;
  65871. /**
  65872. * 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
  65873. */
  65874. values: IAccessorSparseValues;
  65875. }
  65876. /**
  65877. * 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
  65878. */
  65879. interface IAccessor extends IChildRootProperty {
  65880. /**
  65881. * The index of the bufferview
  65882. */
  65883. bufferView?: number;
  65884. /**
  65885. * The offset relative to the start of the bufferView in bytes
  65886. */
  65887. byteOffset?: number;
  65888. /**
  65889. * The datatype of components in the attribute
  65890. */
  65891. componentType: AccessorComponentType;
  65892. /**
  65893. * Specifies whether integer data values should be normalized
  65894. */
  65895. normalized?: boolean;
  65896. /**
  65897. * The number of attributes referenced by this accessor
  65898. */
  65899. count: number;
  65900. /**
  65901. * Specifies if the attribute is a scalar, vector, or matrix
  65902. */
  65903. type: AccessorType;
  65904. /**
  65905. * Maximum value of each component in this attribute
  65906. */
  65907. max?: number[];
  65908. /**
  65909. * Minimum value of each component in this attribute
  65910. */
  65911. min?: number[];
  65912. /**
  65913. * Sparse storage of attributes that deviate from their initialization value
  65914. */
  65915. sparse?: IAccessorSparse;
  65916. }
  65917. /**
  65918. * Targets an animation's sampler at a node's property
  65919. */
  65920. interface IAnimationChannel extends IProperty {
  65921. /**
  65922. * The index of a sampler in this animation used to compute the value for the target
  65923. */
  65924. sampler: number;
  65925. /**
  65926. * The index of the node and TRS property to target
  65927. */
  65928. target: IAnimationChannelTarget;
  65929. }
  65930. /**
  65931. * The index of the node and TRS property that an animation channel targets
  65932. */
  65933. interface IAnimationChannelTarget extends IProperty {
  65934. /**
  65935. * The index of the node to target
  65936. */
  65937. node: number;
  65938. /**
  65939. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65940. */
  65941. path: AnimationChannelTargetPath;
  65942. }
  65943. /**
  65944. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65945. */
  65946. interface IAnimationSampler extends IProperty {
  65947. /**
  65948. * The index of an accessor containing keyframe input values, e.g., time
  65949. */
  65950. input: number;
  65951. /**
  65952. * Interpolation algorithm
  65953. */
  65954. interpolation?: AnimationSamplerInterpolation;
  65955. /**
  65956. * The index of an accessor, containing keyframe output values
  65957. */
  65958. output: number;
  65959. }
  65960. /**
  65961. * A keyframe animation
  65962. */
  65963. interface IAnimation extends IChildRootProperty {
  65964. /**
  65965. * An array of channels, each of which targets an animation's sampler at a node's property
  65966. */
  65967. channels: IAnimationChannel[];
  65968. /**
  65969. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65970. */
  65971. samplers: IAnimationSampler[];
  65972. }
  65973. /**
  65974. * Metadata about the glTF asset
  65975. */
  65976. interface IAsset extends IChildRootProperty {
  65977. /**
  65978. * A copyright message suitable for display to credit the content creator
  65979. */
  65980. copyright?: string;
  65981. /**
  65982. * Tool that generated this glTF model. Useful for debugging
  65983. */
  65984. generator?: string;
  65985. /**
  65986. * The glTF version that this asset targets
  65987. */
  65988. version: string;
  65989. /**
  65990. * The minimum glTF version that this asset targets
  65991. */
  65992. minVersion?: string;
  65993. }
  65994. /**
  65995. * A buffer points to binary geometry, animation, or skins
  65996. */
  65997. interface IBuffer extends IChildRootProperty {
  65998. /**
  65999. * 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
  66000. */
  66001. uri?: string;
  66002. /**
  66003. * The length of the buffer in bytes
  66004. */
  66005. byteLength: number;
  66006. }
  66007. /**
  66008. * A view into a buffer generally representing a subset of the buffer
  66009. */
  66010. interface IBufferView extends IChildRootProperty {
  66011. /**
  66012. * The index of the buffer
  66013. */
  66014. buffer: number;
  66015. /**
  66016. * The offset into the buffer in bytes
  66017. */
  66018. byteOffset?: number;
  66019. /**
  66020. * The lenth of the bufferView in bytes
  66021. */
  66022. byteLength: number;
  66023. /**
  66024. * The stride, in bytes
  66025. */
  66026. byteStride?: number;
  66027. }
  66028. /**
  66029. * An orthographic camera containing properties to create an orthographic projection matrix
  66030. */
  66031. interface ICameraOrthographic extends IProperty {
  66032. /**
  66033. * The floating-point horizontal magnification of the view. Must not be zero
  66034. */
  66035. xmag: number;
  66036. /**
  66037. * The floating-point vertical magnification of the view. Must not be zero
  66038. */
  66039. ymag: number;
  66040. /**
  66041. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66042. */
  66043. zfar: number;
  66044. /**
  66045. * The floating-point distance to the near clipping plane
  66046. */
  66047. znear: number;
  66048. }
  66049. /**
  66050. * A perspective camera containing properties to create a perspective projection matrix
  66051. */
  66052. interface ICameraPerspective extends IProperty {
  66053. /**
  66054. * The floating-point aspect ratio of the field of view
  66055. */
  66056. aspectRatio?: number;
  66057. /**
  66058. * The floating-point vertical field of view in radians
  66059. */
  66060. yfov: number;
  66061. /**
  66062. * The floating-point distance to the far clipping plane
  66063. */
  66064. zfar?: number;
  66065. /**
  66066. * The floating-point distance to the near clipping plane
  66067. */
  66068. znear: number;
  66069. }
  66070. /**
  66071. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66072. */
  66073. interface ICamera extends IChildRootProperty {
  66074. /**
  66075. * An orthographic camera containing properties to create an orthographic projection matrix
  66076. */
  66077. orthographic?: ICameraOrthographic;
  66078. /**
  66079. * A perspective camera containing properties to create a perspective projection matrix
  66080. */
  66081. perspective?: ICameraPerspective;
  66082. /**
  66083. * Specifies if the camera uses a perspective or orthographic projection
  66084. */
  66085. type: CameraType;
  66086. }
  66087. /**
  66088. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66089. */
  66090. interface IImage extends IChildRootProperty {
  66091. /**
  66092. * 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
  66093. */
  66094. uri?: string;
  66095. /**
  66096. * The image's MIME type
  66097. */
  66098. mimeType?: ImageMimeType;
  66099. /**
  66100. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66101. */
  66102. bufferView?: number;
  66103. }
  66104. /**
  66105. * Material Normal Texture Info
  66106. */
  66107. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66108. /**
  66109. * The scalar multiplier applied to each normal vector of the normal texture
  66110. */
  66111. scale?: number;
  66112. }
  66113. /**
  66114. * Material Occlusion Texture Info
  66115. */
  66116. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66117. /**
  66118. * A scalar multiplier controlling the amount of occlusion applied
  66119. */
  66120. strength?: number;
  66121. }
  66122. /**
  66123. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66124. */
  66125. interface IMaterialPbrMetallicRoughness {
  66126. /**
  66127. * The material's base color factor
  66128. */
  66129. baseColorFactor?: number[];
  66130. /**
  66131. * The base color texture
  66132. */
  66133. baseColorTexture?: ITextureInfo;
  66134. /**
  66135. * The metalness of the material
  66136. */
  66137. metallicFactor?: number;
  66138. /**
  66139. * The roughness of the material
  66140. */
  66141. roughnessFactor?: number;
  66142. /**
  66143. * The metallic-roughness texture
  66144. */
  66145. metallicRoughnessTexture?: ITextureInfo;
  66146. }
  66147. /**
  66148. * The material appearance of a primitive
  66149. */
  66150. interface IMaterial extends IChildRootProperty {
  66151. /**
  66152. * 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
  66153. */
  66154. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66155. /**
  66156. * The normal map texture
  66157. */
  66158. normalTexture?: IMaterialNormalTextureInfo;
  66159. /**
  66160. * The occlusion map texture
  66161. */
  66162. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66163. /**
  66164. * The emissive map texture
  66165. */
  66166. emissiveTexture?: ITextureInfo;
  66167. /**
  66168. * 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
  66169. */
  66170. emissiveFactor?: number[];
  66171. /**
  66172. * The alpha rendering mode of the material
  66173. */
  66174. alphaMode?: MaterialAlphaMode;
  66175. /**
  66176. * The alpha cutoff value of the material
  66177. */
  66178. alphaCutoff?: number;
  66179. /**
  66180. * Specifies whether the material is double sided
  66181. */
  66182. doubleSided?: boolean;
  66183. }
  66184. /**
  66185. * Geometry to be rendered with the given material
  66186. */
  66187. interface IMeshPrimitive extends IProperty {
  66188. /**
  66189. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66190. */
  66191. attributes: {
  66192. [name: string]: number;
  66193. };
  66194. /**
  66195. * The index of the accessor that contains the indices
  66196. */
  66197. indices?: number;
  66198. /**
  66199. * The index of the material to apply to this primitive when rendering
  66200. */
  66201. material?: number;
  66202. /**
  66203. * The type of primitives to render. All valid values correspond to WebGL enums
  66204. */
  66205. mode?: MeshPrimitiveMode;
  66206. /**
  66207. * 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
  66208. */
  66209. targets?: {
  66210. [name: string]: number;
  66211. }[];
  66212. }
  66213. /**
  66214. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66215. */
  66216. interface IMesh extends IChildRootProperty {
  66217. /**
  66218. * An array of primitives, each defining geometry to be rendered with a material
  66219. */
  66220. primitives: IMeshPrimitive[];
  66221. /**
  66222. * Array of weights to be applied to the Morph Targets
  66223. */
  66224. weights?: number[];
  66225. }
  66226. /**
  66227. * A node in the node hierarchy
  66228. */
  66229. interface INode extends IChildRootProperty {
  66230. /**
  66231. * The index of the camera referenced by this node
  66232. */
  66233. camera?: number;
  66234. /**
  66235. * The indices of this node's children
  66236. */
  66237. children?: number[];
  66238. /**
  66239. * The index of the skin referenced by this node
  66240. */
  66241. skin?: number;
  66242. /**
  66243. * A floating-point 4x4 transformation matrix stored in column-major order
  66244. */
  66245. matrix?: number[];
  66246. /**
  66247. * The index of the mesh in this node
  66248. */
  66249. mesh?: number;
  66250. /**
  66251. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66252. */
  66253. rotation?: number[];
  66254. /**
  66255. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66256. */
  66257. scale?: number[];
  66258. /**
  66259. * The node's translation along the x, y, and z axes
  66260. */
  66261. translation?: number[];
  66262. /**
  66263. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66264. */
  66265. weights?: number[];
  66266. }
  66267. /**
  66268. * Texture sampler properties for filtering and wrapping modes
  66269. */
  66270. interface ISampler extends IChildRootProperty {
  66271. /**
  66272. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66273. */
  66274. magFilter?: TextureMagFilter;
  66275. /**
  66276. * Minification filter. All valid values correspond to WebGL enums
  66277. */
  66278. minFilter?: TextureMinFilter;
  66279. /**
  66280. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66281. */
  66282. wrapS?: TextureWrapMode;
  66283. /**
  66284. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66285. */
  66286. wrapT?: TextureWrapMode;
  66287. }
  66288. /**
  66289. * The root nodes of a scene
  66290. */
  66291. interface IScene extends IChildRootProperty {
  66292. /**
  66293. * The indices of each root node
  66294. */
  66295. nodes: number[];
  66296. }
  66297. /**
  66298. * Joints and matrices defining a skin
  66299. */
  66300. interface ISkin extends IChildRootProperty {
  66301. /**
  66302. * 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
  66303. */
  66304. inverseBindMatrices?: number;
  66305. /**
  66306. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66307. */
  66308. skeleton?: number;
  66309. /**
  66310. * 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)
  66311. */
  66312. joints: number[];
  66313. }
  66314. /**
  66315. * A texture and its sampler
  66316. */
  66317. interface ITexture extends IChildRootProperty {
  66318. /**
  66319. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66320. */
  66321. sampler?: number;
  66322. /**
  66323. * The index of the image used by this texture
  66324. */
  66325. source: number;
  66326. }
  66327. /**
  66328. * Reference to a texture
  66329. */
  66330. interface ITextureInfo extends IProperty {
  66331. /**
  66332. * The index of the texture
  66333. */
  66334. index: number;
  66335. /**
  66336. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66337. */
  66338. texCoord?: number;
  66339. }
  66340. /**
  66341. * The root object for a glTF asset
  66342. */
  66343. interface IGLTF extends IProperty {
  66344. /**
  66345. * An array of accessors. An accessor is a typed view into a bufferView
  66346. */
  66347. accessors?: IAccessor[];
  66348. /**
  66349. * An array of keyframe animations
  66350. */
  66351. animations?: IAnimation[];
  66352. /**
  66353. * Metadata about the glTF asset
  66354. */
  66355. asset: IAsset;
  66356. /**
  66357. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66358. */
  66359. buffers?: IBuffer[];
  66360. /**
  66361. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66362. */
  66363. bufferViews?: IBufferView[];
  66364. /**
  66365. * An array of cameras
  66366. */
  66367. cameras?: ICamera[];
  66368. /**
  66369. * Names of glTF extensions used somewhere in this asset
  66370. */
  66371. extensionsUsed?: string[];
  66372. /**
  66373. * Names of glTF extensions required to properly load this asset
  66374. */
  66375. extensionsRequired?: string[];
  66376. /**
  66377. * An array of images. An image defines data used to create a texture
  66378. */
  66379. images?: IImage[];
  66380. /**
  66381. * An array of materials. A material defines the appearance of a primitive
  66382. */
  66383. materials?: IMaterial[];
  66384. /**
  66385. * An array of meshes. A mesh is a set of primitives to be rendered
  66386. */
  66387. meshes?: IMesh[];
  66388. /**
  66389. * An array of nodes
  66390. */
  66391. nodes?: INode[];
  66392. /**
  66393. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66394. */
  66395. samplers?: ISampler[];
  66396. /**
  66397. * The index of the default scene
  66398. */
  66399. scene?: number;
  66400. /**
  66401. * An array of scenes
  66402. */
  66403. scenes?: IScene[];
  66404. /**
  66405. * An array of skins. A skin is defined by joints and matrices
  66406. */
  66407. skins?: ISkin[];
  66408. /**
  66409. * An array of textures
  66410. */
  66411. textures?: ITexture[];
  66412. }
  66413. /**
  66414. * The glTF validation results
  66415. */
  66416. interface IGLTFValidationResults {
  66417. info: {
  66418. generator: string;
  66419. hasAnimations: boolean;
  66420. hasDefaultScene: boolean;
  66421. hasMaterials: boolean;
  66422. hasMorphTargets: boolean;
  66423. hasSkins: boolean;
  66424. hasTextures: boolean;
  66425. maxAttributesUsed: number;
  66426. primitivesCount: number
  66427. };
  66428. issues: {
  66429. messages: Array<string>;
  66430. numErrors: number;
  66431. numHints: number;
  66432. numInfos: number;
  66433. numWarnings: number;
  66434. truncated: boolean
  66435. };
  66436. mimeType: string;
  66437. uri: string;
  66438. validatedAt: string;
  66439. validatorVersion: string;
  66440. }
  66441. /**
  66442. * The glTF validation options
  66443. */
  66444. interface IGLTFValidationOptions {
  66445. uri?: string;
  66446. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66447. validateAccessorData?: boolean;
  66448. maxIssues?: number;
  66449. ignoredIssues?: Array<string>;
  66450. severityOverrides?: Object;
  66451. }
  66452. /**
  66453. * The glTF validator object
  66454. */
  66455. interface IGLTFValidator {
  66456. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66457. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66458. }
  66459. }
  66460. declare module BABYLON {
  66461. /** @hidden */
  66462. export var cellPixelShader: {
  66463. name: string;
  66464. shader: string;
  66465. };
  66466. }
  66467. declare module BABYLON {
  66468. /** @hidden */
  66469. export var cellVertexShader: {
  66470. name: string;
  66471. shader: string;
  66472. };
  66473. }
  66474. declare module BABYLON {
  66475. export class CellMaterial extends BABYLON.PushMaterial {
  66476. private _diffuseTexture;
  66477. diffuseTexture: BABYLON.BaseTexture;
  66478. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  66479. computeHighLevel: boolean;
  66480. private _disableLighting;
  66481. disableLighting: boolean;
  66482. private _maxSimultaneousLights;
  66483. maxSimultaneousLights: number;
  66484. private _renderId;
  66485. constructor(name: string, scene: BABYLON.Scene);
  66486. needAlphaBlending(): boolean;
  66487. needAlphaTesting(): boolean;
  66488. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66489. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66490. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66491. getAnimatables(): BABYLON.IAnimatable[];
  66492. getActiveTextures(): BABYLON.BaseTexture[];
  66493. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66494. dispose(forceDisposeEffect?: boolean): void;
  66495. getClassName(): string;
  66496. clone(name: string): CellMaterial;
  66497. serialize(): any;
  66498. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66499. }
  66500. }
  66501. declare module BABYLON {
  66502. export class CustomShaderStructure {
  66503. FragmentStore: string;
  66504. VertexStore: string;
  66505. constructor();
  66506. }
  66507. export class ShaderSpecialParts {
  66508. constructor();
  66509. Fragment_Begin: string;
  66510. Fragment_Definitions: string;
  66511. Fragment_MainBegin: string;
  66512. Fragment_Custom_Diffuse: string;
  66513. Fragment_Before_Lights: string;
  66514. Fragment_Before_Fog: string;
  66515. Fragment_Custom_Alpha: string;
  66516. Fragment_Before_FragColor: string;
  66517. Vertex_Begin: string;
  66518. Vertex_Definitions: string;
  66519. Vertex_MainBegin: string;
  66520. Vertex_Before_PositionUpdated: string;
  66521. Vertex_Before_NormalUpdated: string;
  66522. Vertex_MainEnd: string;
  66523. }
  66524. export class CustomMaterial extends BABYLON.StandardMaterial {
  66525. static ShaderIndexer: number;
  66526. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  66527. FragmentShader: string;
  66528. VertexShader: string;
  66529. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66530. ReviewUniform(name: string, arr: string[]): string[];
  66531. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66532. constructor(name: string, scene: BABYLON.Scene);
  66533. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66534. Fragment_Begin(shaderPart: string): CustomMaterial;
  66535. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66536. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66537. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66538. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66539. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66540. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66541. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66542. Vertex_Begin(shaderPart: string): CustomMaterial;
  66543. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66544. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66545. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66546. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66547. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66548. }
  66549. }
  66550. declare module BABYLON {
  66551. export class ShaderAlebdoParts {
  66552. constructor();
  66553. Fragment_Begin: string;
  66554. Fragment_Definitions: string;
  66555. Fragment_MainBegin: string;
  66556. Fragment_Custom_Albedo: string;
  66557. Fragment_Before_Lights: string;
  66558. Fragment_Custom_MetallicRoughness: string;
  66559. Fragment_Custom_MicroSurface: string;
  66560. Fragment_Before_Fog: string;
  66561. Fragment_Custom_Alpha: string;
  66562. Fragment_Before_FragColor: string;
  66563. Vertex_Begin: string;
  66564. Vertex_Definitions: string;
  66565. Vertex_MainBegin: string;
  66566. Vertex_Before_PositionUpdated: string;
  66567. Vertex_Before_NormalUpdated: string;
  66568. Vertex_MainEnd: string;
  66569. }
  66570. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  66571. static ShaderIndexer: number;
  66572. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  66573. FragmentShader: string;
  66574. VertexShader: string;
  66575. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66576. ReviewUniform(name: string, arr: string[]): string[];
  66577. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  66578. constructor(name: string, scene: BABYLON.Scene);
  66579. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  66580. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  66581. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  66582. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  66583. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  66584. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  66585. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  66586. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  66587. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  66588. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  66589. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  66590. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  66591. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  66592. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  66593. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  66594. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  66595. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  66596. }
  66597. }
  66598. declare module BABYLON {
  66599. /** @hidden */
  66600. export var firePixelShader: {
  66601. name: string;
  66602. shader: string;
  66603. };
  66604. }
  66605. declare module BABYLON {
  66606. /** @hidden */
  66607. export var fireVertexShader: {
  66608. name: string;
  66609. shader: string;
  66610. };
  66611. }
  66612. declare module BABYLON {
  66613. export class FireMaterial extends BABYLON.PushMaterial {
  66614. private _diffuseTexture;
  66615. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66616. private _distortionTexture;
  66617. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66618. private _opacityTexture;
  66619. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66620. diffuseColor: BABYLON.Color3;
  66621. speed: number;
  66622. private _scaledDiffuse;
  66623. private _renderId;
  66624. private _lastTime;
  66625. constructor(name: string, scene: BABYLON.Scene);
  66626. needAlphaBlending(): boolean;
  66627. needAlphaTesting(): boolean;
  66628. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66629. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66630. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66631. getAnimatables(): BABYLON.IAnimatable[];
  66632. getActiveTextures(): BABYLON.BaseTexture[];
  66633. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66634. getClassName(): string;
  66635. dispose(forceDisposeEffect?: boolean): void;
  66636. clone(name: string): FireMaterial;
  66637. serialize(): any;
  66638. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  66639. }
  66640. }
  66641. declare module BABYLON {
  66642. /** @hidden */
  66643. export var furPixelShader: {
  66644. name: string;
  66645. shader: string;
  66646. };
  66647. }
  66648. declare module BABYLON {
  66649. /** @hidden */
  66650. export var furVertexShader: {
  66651. name: string;
  66652. shader: string;
  66653. };
  66654. }
  66655. declare module BABYLON {
  66656. export class FurMaterial extends BABYLON.PushMaterial {
  66657. private _diffuseTexture;
  66658. diffuseTexture: BABYLON.BaseTexture;
  66659. private _heightTexture;
  66660. heightTexture: BABYLON.BaseTexture;
  66661. diffuseColor: BABYLON.Color3;
  66662. furLength: number;
  66663. furAngle: number;
  66664. furColor: BABYLON.Color3;
  66665. furOffset: number;
  66666. furSpacing: number;
  66667. furGravity: BABYLON.Vector3;
  66668. furSpeed: number;
  66669. furDensity: number;
  66670. furOcclusion: number;
  66671. furTexture: BABYLON.DynamicTexture;
  66672. private _disableLighting;
  66673. disableLighting: boolean;
  66674. private _maxSimultaneousLights;
  66675. maxSimultaneousLights: number;
  66676. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  66677. private _renderId;
  66678. private _furTime;
  66679. constructor(name: string, scene: BABYLON.Scene);
  66680. furTime: number;
  66681. needAlphaBlending(): boolean;
  66682. needAlphaTesting(): boolean;
  66683. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66684. updateFur(): void;
  66685. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66686. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66687. getAnimatables(): BABYLON.IAnimatable[];
  66688. getActiveTextures(): BABYLON.BaseTexture[];
  66689. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66690. dispose(forceDisposeEffect?: boolean): void;
  66691. clone(name: string): FurMaterial;
  66692. serialize(): any;
  66693. getClassName(): string;
  66694. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  66695. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  66696. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  66697. }
  66698. }
  66699. declare module BABYLON {
  66700. /** @hidden */
  66701. export var gradientPixelShader: {
  66702. name: string;
  66703. shader: string;
  66704. };
  66705. }
  66706. declare module BABYLON {
  66707. /** @hidden */
  66708. export var gradientVertexShader: {
  66709. name: string;
  66710. shader: string;
  66711. };
  66712. }
  66713. declare module BABYLON {
  66714. export class GradientMaterial extends BABYLON.PushMaterial {
  66715. private _maxSimultaneousLights;
  66716. maxSimultaneousLights: number;
  66717. topColor: BABYLON.Color3;
  66718. topColorAlpha: number;
  66719. bottomColor: BABYLON.Color3;
  66720. bottomColorAlpha: number;
  66721. offset: number;
  66722. scale: number;
  66723. smoothness: number;
  66724. private _disableLighting;
  66725. disableLighting: boolean;
  66726. private _renderId;
  66727. constructor(name: string, scene: BABYLON.Scene);
  66728. needAlphaBlending(): boolean;
  66729. needAlphaTesting(): boolean;
  66730. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66731. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66732. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66733. getAnimatables(): BABYLON.IAnimatable[];
  66734. dispose(forceDisposeEffect?: boolean): void;
  66735. clone(name: string): GradientMaterial;
  66736. serialize(): any;
  66737. getClassName(): string;
  66738. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  66739. }
  66740. }
  66741. declare module BABYLON {
  66742. /** @hidden */
  66743. export var gridPixelShader: {
  66744. name: string;
  66745. shader: string;
  66746. };
  66747. }
  66748. declare module BABYLON {
  66749. /** @hidden */
  66750. export var gridVertexShader: {
  66751. name: string;
  66752. shader: string;
  66753. };
  66754. }
  66755. declare module BABYLON {
  66756. /**
  66757. * The grid materials allows you to wrap any shape with a grid.
  66758. * Colors are customizable.
  66759. */
  66760. export class GridMaterial extends BABYLON.PushMaterial {
  66761. /**
  66762. * Main color of the grid (e.g. between lines)
  66763. */
  66764. mainColor: BABYLON.Color3;
  66765. /**
  66766. * Color of the grid lines.
  66767. */
  66768. lineColor: BABYLON.Color3;
  66769. /**
  66770. * The scale of the grid compared to unit.
  66771. */
  66772. gridRatio: number;
  66773. /**
  66774. * Allows setting an offset for the grid lines.
  66775. */
  66776. gridOffset: BABYLON.Vector3;
  66777. /**
  66778. * The frequency of thicker lines.
  66779. */
  66780. majorUnitFrequency: number;
  66781. /**
  66782. * The visibility of minor units in the grid.
  66783. */
  66784. minorUnitVisibility: number;
  66785. /**
  66786. * The grid opacity outside of the lines.
  66787. */
  66788. opacity: number;
  66789. /**
  66790. * Determine RBG output is premultiplied by alpha value.
  66791. */
  66792. preMultiplyAlpha: boolean;
  66793. private _opacityTexture;
  66794. opacityTexture: BABYLON.BaseTexture;
  66795. private _gridControl;
  66796. private _renderId;
  66797. /**
  66798. * constructor
  66799. * @param name The name given to the material in order to identify it afterwards.
  66800. * @param scene The scene the material is used in.
  66801. */
  66802. constructor(name: string, scene: BABYLON.Scene);
  66803. /**
  66804. * Returns wehter or not the grid requires alpha blending.
  66805. */
  66806. needAlphaBlending(): boolean;
  66807. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66808. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66809. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66810. /**
  66811. * Dispose the material and its associated resources.
  66812. * @param forceDisposeEffect will also dispose the used effect when true
  66813. */
  66814. dispose(forceDisposeEffect?: boolean): void;
  66815. clone(name: string): GridMaterial;
  66816. serialize(): any;
  66817. getClassName(): string;
  66818. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  66819. }
  66820. }
  66821. declare module BABYLON {
  66822. /** @hidden */
  66823. export var lavaPixelShader: {
  66824. name: string;
  66825. shader: string;
  66826. };
  66827. }
  66828. declare module BABYLON {
  66829. /** @hidden */
  66830. export var lavaVertexShader: {
  66831. name: string;
  66832. shader: string;
  66833. };
  66834. }
  66835. declare module BABYLON {
  66836. export class LavaMaterial extends BABYLON.PushMaterial {
  66837. private _diffuseTexture;
  66838. diffuseTexture: BABYLON.BaseTexture;
  66839. noiseTexture: BABYLON.BaseTexture;
  66840. fogColor: BABYLON.Color3;
  66841. speed: number;
  66842. movingSpeed: number;
  66843. lowFrequencySpeed: number;
  66844. fogDensity: number;
  66845. private _lastTime;
  66846. diffuseColor: BABYLON.Color3;
  66847. private _disableLighting;
  66848. disableLighting: boolean;
  66849. private _unlit;
  66850. unlit: boolean;
  66851. private _maxSimultaneousLights;
  66852. maxSimultaneousLights: number;
  66853. private _scaledDiffuse;
  66854. private _renderId;
  66855. constructor(name: string, scene: BABYLON.Scene);
  66856. needAlphaBlending(): boolean;
  66857. needAlphaTesting(): boolean;
  66858. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66859. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66860. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66861. getAnimatables(): BABYLON.IAnimatable[];
  66862. getActiveTextures(): BABYLON.BaseTexture[];
  66863. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66864. dispose(forceDisposeEffect?: boolean): void;
  66865. clone(name: string): LavaMaterial;
  66866. serialize(): any;
  66867. getClassName(): string;
  66868. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  66869. }
  66870. }
  66871. declare module BABYLON {
  66872. /** @hidden */
  66873. export var mixPixelShader: {
  66874. name: string;
  66875. shader: string;
  66876. };
  66877. }
  66878. declare module BABYLON {
  66879. /** @hidden */
  66880. export var mixVertexShader: {
  66881. name: string;
  66882. shader: string;
  66883. };
  66884. }
  66885. declare module BABYLON {
  66886. export class MixMaterial extends BABYLON.PushMaterial {
  66887. /**
  66888. * Mix textures
  66889. */
  66890. private _mixTexture1;
  66891. mixTexture1: BABYLON.BaseTexture;
  66892. private _mixTexture2;
  66893. mixTexture2: BABYLON.BaseTexture;
  66894. /**
  66895. * Diffuse textures
  66896. */
  66897. private _diffuseTexture1;
  66898. diffuseTexture1: BABYLON.Texture;
  66899. private _diffuseTexture2;
  66900. diffuseTexture2: BABYLON.Texture;
  66901. private _diffuseTexture3;
  66902. diffuseTexture3: BABYLON.Texture;
  66903. private _diffuseTexture4;
  66904. diffuseTexture4: BABYLON.Texture;
  66905. private _diffuseTexture5;
  66906. diffuseTexture5: BABYLON.Texture;
  66907. private _diffuseTexture6;
  66908. diffuseTexture6: BABYLON.Texture;
  66909. private _diffuseTexture7;
  66910. diffuseTexture7: BABYLON.Texture;
  66911. private _diffuseTexture8;
  66912. diffuseTexture8: BABYLON.Texture;
  66913. /**
  66914. * Uniforms
  66915. */
  66916. diffuseColor: BABYLON.Color3;
  66917. specularColor: BABYLON.Color3;
  66918. specularPower: number;
  66919. private _disableLighting;
  66920. disableLighting: boolean;
  66921. private _maxSimultaneousLights;
  66922. maxSimultaneousLights: number;
  66923. private _renderId;
  66924. constructor(name: string, scene: BABYLON.Scene);
  66925. needAlphaBlending(): boolean;
  66926. needAlphaTesting(): boolean;
  66927. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66928. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66929. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66930. getAnimatables(): BABYLON.IAnimatable[];
  66931. getActiveTextures(): BABYLON.BaseTexture[];
  66932. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66933. dispose(forceDisposeEffect?: boolean): void;
  66934. clone(name: string): MixMaterial;
  66935. serialize(): any;
  66936. getClassName(): string;
  66937. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  66938. }
  66939. }
  66940. declare module BABYLON {
  66941. /** @hidden */
  66942. export var normalPixelShader: {
  66943. name: string;
  66944. shader: string;
  66945. };
  66946. }
  66947. declare module BABYLON {
  66948. /** @hidden */
  66949. export var normalVertexShader: {
  66950. name: string;
  66951. shader: string;
  66952. };
  66953. }
  66954. declare module BABYLON {
  66955. export class NormalMaterial extends BABYLON.PushMaterial {
  66956. private _diffuseTexture;
  66957. diffuseTexture: BABYLON.BaseTexture;
  66958. diffuseColor: BABYLON.Color3;
  66959. private _disableLighting;
  66960. disableLighting: boolean;
  66961. private _maxSimultaneousLights;
  66962. maxSimultaneousLights: number;
  66963. private _renderId;
  66964. constructor(name: string, scene: BABYLON.Scene);
  66965. needAlphaBlending(): boolean;
  66966. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66967. needAlphaTesting(): boolean;
  66968. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66969. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66970. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66971. getAnimatables(): BABYLON.IAnimatable[];
  66972. getActiveTextures(): BABYLON.BaseTexture[];
  66973. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66974. dispose(forceDisposeEffect?: boolean): void;
  66975. clone(name: string): NormalMaterial;
  66976. serialize(): any;
  66977. getClassName(): string;
  66978. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  66979. }
  66980. }
  66981. declare module BABYLON {
  66982. /** @hidden */
  66983. export var shadowOnlyPixelShader: {
  66984. name: string;
  66985. shader: string;
  66986. };
  66987. }
  66988. declare module BABYLON {
  66989. /** @hidden */
  66990. export var shadowOnlyVertexShader: {
  66991. name: string;
  66992. shader: string;
  66993. };
  66994. }
  66995. declare module BABYLON {
  66996. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  66997. private _renderId;
  66998. private _activeLight;
  66999. constructor(name: string, scene: BABYLON.Scene);
  67000. shadowColor: BABYLON.Color3;
  67001. needAlphaBlending(): boolean;
  67002. needAlphaTesting(): boolean;
  67003. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67004. activeLight: BABYLON.IShadowLight;
  67005. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67006. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67007. clone(name: string): ShadowOnlyMaterial;
  67008. serialize(): any;
  67009. getClassName(): string;
  67010. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67011. }
  67012. }
  67013. declare module BABYLON {
  67014. /** @hidden */
  67015. export var simplePixelShader: {
  67016. name: string;
  67017. shader: string;
  67018. };
  67019. }
  67020. declare module BABYLON {
  67021. /** @hidden */
  67022. export var simpleVertexShader: {
  67023. name: string;
  67024. shader: string;
  67025. };
  67026. }
  67027. declare module BABYLON {
  67028. export class SimpleMaterial extends BABYLON.PushMaterial {
  67029. private _diffuseTexture;
  67030. diffuseTexture: BABYLON.BaseTexture;
  67031. diffuseColor: BABYLON.Color3;
  67032. private _disableLighting;
  67033. disableLighting: boolean;
  67034. private _maxSimultaneousLights;
  67035. maxSimultaneousLights: number;
  67036. private _renderId;
  67037. constructor(name: string, scene: BABYLON.Scene);
  67038. needAlphaBlending(): boolean;
  67039. needAlphaTesting(): boolean;
  67040. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67041. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67042. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67043. getAnimatables(): BABYLON.IAnimatable[];
  67044. getActiveTextures(): BABYLON.BaseTexture[];
  67045. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67046. dispose(forceDisposeEffect?: boolean): void;
  67047. clone(name: string): SimpleMaterial;
  67048. serialize(): any;
  67049. getClassName(): string;
  67050. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67051. }
  67052. }
  67053. declare module BABYLON {
  67054. /** @hidden */
  67055. export var skyPixelShader: {
  67056. name: string;
  67057. shader: string;
  67058. };
  67059. }
  67060. declare module BABYLON {
  67061. /** @hidden */
  67062. export var skyVertexShader: {
  67063. name: string;
  67064. shader: string;
  67065. };
  67066. }
  67067. declare module BABYLON {
  67068. /**
  67069. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67070. * @see https://doc.babylonjs.com/extensions/sky
  67071. */
  67072. export class SkyMaterial extends BABYLON.PushMaterial {
  67073. /**
  67074. * Defines the overall luminance of sky in interval ]0, 1[.
  67075. */
  67076. luminance: number;
  67077. /**
  67078. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67079. */
  67080. turbidity: number;
  67081. /**
  67082. * Defines the sky appearance (light intensity).
  67083. */
  67084. rayleigh: number;
  67085. /**
  67086. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67087. */
  67088. mieCoefficient: number;
  67089. /**
  67090. * Defines the amount of haze particles following the Mie scattering theory.
  67091. */
  67092. mieDirectionalG: number;
  67093. /**
  67094. * Defines the distance of the sun according to the active scene camera.
  67095. */
  67096. distance: number;
  67097. /**
  67098. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67099. * "inclined".
  67100. */
  67101. inclination: number;
  67102. /**
  67103. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67104. * an object direction and a reference direction.
  67105. */
  67106. azimuth: number;
  67107. /**
  67108. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67109. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67110. */
  67111. sunPosition: BABYLON.Vector3;
  67112. /**
  67113. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67114. * .sunPosition property.
  67115. */
  67116. useSunPosition: boolean;
  67117. /**
  67118. * Defines an offset vector used to get a horizon offset.
  67119. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67120. */
  67121. cameraOffset: BABYLON.Vector3;
  67122. private _cameraPosition;
  67123. private _renderId;
  67124. /**
  67125. * Instantiates a new sky material.
  67126. * This material allows to create dynamic and texture free
  67127. * effects for skyboxes by taking care of the atmosphere state.
  67128. * @see https://doc.babylonjs.com/extensions/sky
  67129. * @param name Define the name of the material in the scene
  67130. * @param scene Define the scene the material belong to
  67131. */
  67132. constructor(name: string, scene: BABYLON.Scene);
  67133. /**
  67134. * Specifies if the material will require alpha blending
  67135. * @returns a boolean specifying if alpha blending is needed
  67136. */
  67137. needAlphaBlending(): boolean;
  67138. /**
  67139. * Specifies if this material should be rendered in alpha test mode
  67140. * @returns false as the sky material doesn't need alpha testing.
  67141. */
  67142. needAlphaTesting(): boolean;
  67143. /**
  67144. * Get the texture used for alpha test purpose.
  67145. * @returns null as the sky material has no texture.
  67146. */
  67147. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67148. /**
  67149. * Get if the submesh is ready to be used and all its information available.
  67150. * Child classes can use it to update shaders
  67151. * @param mesh defines the mesh to check
  67152. * @param subMesh defines which submesh to check
  67153. * @param useInstances specifies that instances should be used
  67154. * @returns a boolean indicating that the submesh is ready or not
  67155. */
  67156. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67157. /**
  67158. * Binds the submesh to this material by preparing the effect and shader to draw
  67159. * @param world defines the world transformation matrix
  67160. * @param mesh defines the mesh containing the submesh
  67161. * @param subMesh defines the submesh to bind the material to
  67162. */
  67163. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67164. /**
  67165. * Get the list of animatables in the material.
  67166. * @returns the list of animatables object used in the material
  67167. */
  67168. getAnimatables(): BABYLON.IAnimatable[];
  67169. /**
  67170. * Disposes the material
  67171. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67172. */
  67173. dispose(forceDisposeEffect?: boolean): void;
  67174. /**
  67175. * Makes a duplicate of the material, and gives it a new name
  67176. * @param name defines the new name for the duplicated material
  67177. * @returns the cloned material
  67178. */
  67179. clone(name: string): SkyMaterial;
  67180. /**
  67181. * Serializes this material in a JSON representation
  67182. * @returns the serialized material object
  67183. */
  67184. serialize(): any;
  67185. /**
  67186. * Gets the current class name of the material e.g. "SkyMaterial"
  67187. * Mainly use in serialization.
  67188. * @returns the class name
  67189. */
  67190. getClassName(): string;
  67191. /**
  67192. * Creates a sky material from parsed material data
  67193. * @param source defines the JSON representation of the material
  67194. * @param scene defines the hosting scene
  67195. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67196. * @returns a new sky material
  67197. */
  67198. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67199. }
  67200. }
  67201. declare module BABYLON {
  67202. /** @hidden */
  67203. export var terrainPixelShader: {
  67204. name: string;
  67205. shader: string;
  67206. };
  67207. }
  67208. declare module BABYLON {
  67209. /** @hidden */
  67210. export var terrainVertexShader: {
  67211. name: string;
  67212. shader: string;
  67213. };
  67214. }
  67215. declare module BABYLON {
  67216. export class TerrainMaterial extends BABYLON.PushMaterial {
  67217. private _mixTexture;
  67218. mixTexture: BABYLON.BaseTexture;
  67219. private _diffuseTexture1;
  67220. diffuseTexture1: BABYLON.Texture;
  67221. private _diffuseTexture2;
  67222. diffuseTexture2: BABYLON.Texture;
  67223. private _diffuseTexture3;
  67224. diffuseTexture3: BABYLON.Texture;
  67225. private _bumpTexture1;
  67226. bumpTexture1: BABYLON.Texture;
  67227. private _bumpTexture2;
  67228. bumpTexture2: BABYLON.Texture;
  67229. private _bumpTexture3;
  67230. bumpTexture3: BABYLON.Texture;
  67231. diffuseColor: BABYLON.Color3;
  67232. specularColor: BABYLON.Color3;
  67233. specularPower: number;
  67234. private _disableLighting;
  67235. disableLighting: boolean;
  67236. private _maxSimultaneousLights;
  67237. maxSimultaneousLights: number;
  67238. private _renderId;
  67239. constructor(name: string, scene: BABYLON.Scene);
  67240. needAlphaBlending(): boolean;
  67241. needAlphaTesting(): boolean;
  67242. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67243. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67244. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67245. getAnimatables(): BABYLON.IAnimatable[];
  67246. getActiveTextures(): BABYLON.BaseTexture[];
  67247. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67248. dispose(forceDisposeEffect?: boolean): void;
  67249. clone(name: string): TerrainMaterial;
  67250. serialize(): any;
  67251. getClassName(): string;
  67252. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67253. }
  67254. }
  67255. declare module BABYLON {
  67256. /** @hidden */
  67257. export var triplanarPixelShader: {
  67258. name: string;
  67259. shader: string;
  67260. };
  67261. }
  67262. declare module BABYLON {
  67263. /** @hidden */
  67264. export var triplanarVertexShader: {
  67265. name: string;
  67266. shader: string;
  67267. };
  67268. }
  67269. declare module BABYLON {
  67270. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67271. mixTexture: BABYLON.BaseTexture;
  67272. private _diffuseTextureX;
  67273. diffuseTextureX: BABYLON.BaseTexture;
  67274. private _diffuseTextureY;
  67275. diffuseTextureY: BABYLON.BaseTexture;
  67276. private _diffuseTextureZ;
  67277. diffuseTextureZ: BABYLON.BaseTexture;
  67278. private _normalTextureX;
  67279. normalTextureX: BABYLON.BaseTexture;
  67280. private _normalTextureY;
  67281. normalTextureY: BABYLON.BaseTexture;
  67282. private _normalTextureZ;
  67283. normalTextureZ: BABYLON.BaseTexture;
  67284. tileSize: number;
  67285. diffuseColor: BABYLON.Color3;
  67286. specularColor: BABYLON.Color3;
  67287. specularPower: number;
  67288. private _disableLighting;
  67289. disableLighting: boolean;
  67290. private _maxSimultaneousLights;
  67291. maxSimultaneousLights: number;
  67292. private _renderId;
  67293. constructor(name: string, scene: BABYLON.Scene);
  67294. needAlphaBlending(): boolean;
  67295. needAlphaTesting(): boolean;
  67296. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67297. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67298. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67299. getAnimatables(): BABYLON.IAnimatable[];
  67300. getActiveTextures(): BABYLON.BaseTexture[];
  67301. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67302. dispose(forceDisposeEffect?: boolean): void;
  67303. clone(name: string): TriPlanarMaterial;
  67304. serialize(): any;
  67305. getClassName(): string;
  67306. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67307. }
  67308. }
  67309. declare module BABYLON {
  67310. /** @hidden */
  67311. export var waterPixelShader: {
  67312. name: string;
  67313. shader: string;
  67314. };
  67315. }
  67316. declare module BABYLON {
  67317. /** @hidden */
  67318. export var waterVertexShader: {
  67319. name: string;
  67320. shader: string;
  67321. };
  67322. }
  67323. declare module BABYLON {
  67324. export class WaterMaterial extends BABYLON.PushMaterial {
  67325. renderTargetSize: BABYLON.Vector2;
  67326. private _bumpTexture;
  67327. bumpTexture: BABYLON.BaseTexture;
  67328. diffuseColor: BABYLON.Color3;
  67329. specularColor: BABYLON.Color3;
  67330. specularPower: number;
  67331. private _disableLighting;
  67332. disableLighting: boolean;
  67333. private _maxSimultaneousLights;
  67334. maxSimultaneousLights: number;
  67335. /**
  67336. * @param {number}: Represents the wind force
  67337. */
  67338. windForce: number;
  67339. /**
  67340. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67341. */
  67342. windDirection: BABYLON.Vector2;
  67343. /**
  67344. * @param {number}: Wave height, represents the height of the waves
  67345. */
  67346. waveHeight: number;
  67347. /**
  67348. * @param {number}: Bump height, represents the bump height related to the bump map
  67349. */
  67350. bumpHeight: number;
  67351. /**
  67352. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67353. */
  67354. private _bumpSuperimpose;
  67355. bumpSuperimpose: boolean;
  67356. /**
  67357. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67358. */
  67359. private _fresnelSeparate;
  67360. fresnelSeparate: boolean;
  67361. /**
  67362. * @param {boolean}: bump Waves modify the reflection.
  67363. */
  67364. private _bumpAffectsReflection;
  67365. bumpAffectsReflection: boolean;
  67366. /**
  67367. * @param {number}: The water color blended with the refraction (near)
  67368. */
  67369. waterColor: BABYLON.Color3;
  67370. /**
  67371. * @param {number}: The blend factor related to the water color
  67372. */
  67373. colorBlendFactor: number;
  67374. /**
  67375. * @param {number}: The water color blended with the reflection (far)
  67376. */
  67377. waterColor2: BABYLON.Color3;
  67378. /**
  67379. * @param {number}: The blend factor related to the water color (reflection, far)
  67380. */
  67381. colorBlendFactor2: number;
  67382. /**
  67383. * @param {number}: Represents the maximum length of a wave
  67384. */
  67385. waveLength: number;
  67386. /**
  67387. * @param {number}: Defines the waves speed
  67388. */
  67389. waveSpeed: number;
  67390. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67391. private _mesh;
  67392. private _refractionRTT;
  67393. private _reflectionRTT;
  67394. private _reflectionTransform;
  67395. private _lastTime;
  67396. private _lastDeltaTime;
  67397. private _renderId;
  67398. private _useLogarithmicDepth;
  67399. private _waitingRenderList;
  67400. /**
  67401. * Gets a boolean indicating that current material needs to register RTT
  67402. */
  67403. readonly hasRenderTargetTextures: boolean;
  67404. /**
  67405. * Constructor
  67406. */
  67407. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67408. useLogarithmicDepth: boolean;
  67409. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67410. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67411. addToRenderList(node: any): void;
  67412. enableRenderTargets(enable: boolean): void;
  67413. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67414. readonly renderTargetsEnabled: boolean;
  67415. needAlphaBlending(): boolean;
  67416. needAlphaTesting(): boolean;
  67417. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67418. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67419. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67420. private _createRenderTargets;
  67421. getAnimatables(): BABYLON.IAnimatable[];
  67422. getActiveTextures(): BABYLON.BaseTexture[];
  67423. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67424. dispose(forceDisposeEffect?: boolean): void;
  67425. clone(name: string): WaterMaterial;
  67426. serialize(): any;
  67427. getClassName(): string;
  67428. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67429. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /** @hidden */
  67434. export var asciiartPixelShader: {
  67435. name: string;
  67436. shader: string;
  67437. };
  67438. }
  67439. declare module BABYLON {
  67440. /**
  67441. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67442. *
  67443. * It basically takes care rendering the font front the given font size to a texture.
  67444. * This is used later on in the postprocess.
  67445. */
  67446. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67447. private _font;
  67448. private _text;
  67449. private _charSize;
  67450. /**
  67451. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67452. */
  67453. readonly charSize: number;
  67454. /**
  67455. * Create a new instance of the Ascii Art FontTexture class
  67456. * @param name the name of the texture
  67457. * @param font the font to use, use the W3C CSS notation
  67458. * @param text the caracter set to use in the rendering.
  67459. * @param scene the scene that owns the texture
  67460. */
  67461. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67462. /**
  67463. * Gets the max char width of a font.
  67464. * @param font the font to use, use the W3C CSS notation
  67465. * @return the max char width
  67466. */
  67467. private getFontWidth;
  67468. /**
  67469. * Gets the max char height of a font.
  67470. * @param font the font to use, use the W3C CSS notation
  67471. * @return the max char height
  67472. */
  67473. private getFontHeight;
  67474. /**
  67475. * Clones the current AsciiArtTexture.
  67476. * @return the clone of the texture.
  67477. */
  67478. clone(): AsciiArtFontTexture;
  67479. /**
  67480. * Parses a json object representing the texture and returns an instance of it.
  67481. * @param source the source JSON representation
  67482. * @param scene the scene to create the texture for
  67483. * @return the parsed texture
  67484. */
  67485. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67486. }
  67487. /**
  67488. * Option available in the Ascii Art Post Process.
  67489. */
  67490. export interface IAsciiArtPostProcessOptions {
  67491. /**
  67492. * The font to use following the w3c font definition.
  67493. */
  67494. font?: string;
  67495. /**
  67496. * The character set to use in the postprocess.
  67497. */
  67498. characterSet?: string;
  67499. /**
  67500. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67501. * This number is defined between 0 and 1;
  67502. */
  67503. mixToTile?: number;
  67504. /**
  67505. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67506. * This number is defined between 0 and 1;
  67507. */
  67508. mixToNormal?: number;
  67509. }
  67510. /**
  67511. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67512. *
  67513. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67514. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67515. */
  67516. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67517. /**
  67518. * The font texture used to render the char in the post process.
  67519. */
  67520. private _asciiArtFontTexture;
  67521. /**
  67522. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67523. * This number is defined between 0 and 1;
  67524. */
  67525. mixToTile: number;
  67526. /**
  67527. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67528. * This number is defined between 0 and 1;
  67529. */
  67530. mixToNormal: number;
  67531. /**
  67532. * Instantiates a new Ascii Art Post Process.
  67533. * @param name the name to give to the postprocess
  67534. * @camera the camera to apply the post process to.
  67535. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67536. */
  67537. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67538. }
  67539. }
  67540. declare module BABYLON {
  67541. /** @hidden */
  67542. export var digitalrainPixelShader: {
  67543. name: string;
  67544. shader: string;
  67545. };
  67546. }
  67547. declare module BABYLON {
  67548. /**
  67549. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  67550. *
  67551. * It basically takes care rendering the font front the given font size to a texture.
  67552. * This is used later on in the postprocess.
  67553. */
  67554. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  67555. private _font;
  67556. private _text;
  67557. private _charSize;
  67558. /**
  67559. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67560. */
  67561. readonly charSize: number;
  67562. /**
  67563. * Create a new instance of the Digital Rain FontTexture class
  67564. * @param name the name of the texture
  67565. * @param font the font to use, use the W3C CSS notation
  67566. * @param text the caracter set to use in the rendering.
  67567. * @param scene the scene that owns the texture
  67568. */
  67569. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67570. /**
  67571. * Gets the max char width of a font.
  67572. * @param font the font to use, use the W3C CSS notation
  67573. * @return the max char width
  67574. */
  67575. private getFontWidth;
  67576. /**
  67577. * Gets the max char height of a font.
  67578. * @param font the font to use, use the W3C CSS notation
  67579. * @return the max char height
  67580. */
  67581. private getFontHeight;
  67582. /**
  67583. * Clones the current DigitalRainFontTexture.
  67584. * @return the clone of the texture.
  67585. */
  67586. clone(): DigitalRainFontTexture;
  67587. /**
  67588. * Parses a json object representing the texture and returns an instance of it.
  67589. * @param source the source JSON representation
  67590. * @param scene the scene to create the texture for
  67591. * @return the parsed texture
  67592. */
  67593. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  67594. }
  67595. /**
  67596. * Option available in the Digital Rain Post Process.
  67597. */
  67598. export interface IDigitalRainPostProcessOptions {
  67599. /**
  67600. * The font to use following the w3c font definition.
  67601. */
  67602. font?: string;
  67603. /**
  67604. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67605. * This number is defined between 0 and 1;
  67606. */
  67607. mixToTile?: number;
  67608. /**
  67609. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67610. * This number is defined between 0 and 1;
  67611. */
  67612. mixToNormal?: number;
  67613. }
  67614. /**
  67615. * DigitalRainPostProcess helps rendering everithing in digital rain.
  67616. *
  67617. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67618. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  67619. */
  67620. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  67621. /**
  67622. * The font texture used to render the char in the post process.
  67623. */
  67624. private _digitalRainFontTexture;
  67625. /**
  67626. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67627. * This number is defined between 0 and 1;
  67628. */
  67629. mixToTile: number;
  67630. /**
  67631. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67632. * This number is defined between 0 and 1;
  67633. */
  67634. mixToNormal: number;
  67635. /**
  67636. * Instantiates a new Digital Rain Post Process.
  67637. * @param name the name to give to the postprocess
  67638. * @camera the camera to apply the post process to.
  67639. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  67640. */
  67641. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  67642. }
  67643. }
  67644. declare module BABYLON {
  67645. /** @hidden */
  67646. export var oceanPostProcessPixelShader: {
  67647. name: string;
  67648. shader: string;
  67649. };
  67650. }
  67651. declare module BABYLON {
  67652. /**
  67653. * Option available in the Ocean Post Process.
  67654. */
  67655. export interface IOceanPostProcessOptions {
  67656. /**
  67657. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67658. */
  67659. reflectionSize?: number | {
  67660. width: number;
  67661. height: number;
  67662. } | {
  67663. ratio: number;
  67664. };
  67665. /**
  67666. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67667. */
  67668. refractionSize?: number | {
  67669. width: number;
  67670. height: number;
  67671. } | {
  67672. ratio: number;
  67673. };
  67674. }
  67675. /**
  67676. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  67677. *
  67678. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67679. * Example usage:
  67680. * var pp = new OceanPostProcess("myOcean", camera);
  67681. * pp.reflectionEnabled = true;
  67682. * pp.refractionEnabled = true;
  67683. */
  67684. export class OceanPostProcess extends BABYLON.PostProcess {
  67685. /**
  67686. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  67687. */
  67688. /**
  67689. * Sets weither or not the real-time reflection is enabled on the ocean.
  67690. * Is set to true, the reflection mirror texture will be used as reflection texture.
  67691. */
  67692. reflectionEnabled: boolean;
  67693. /**
  67694. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  67695. */
  67696. /**
  67697. * Sets weither or not the real-time refraction is enabled on the ocean.
  67698. * Is set to true, the refraction render target texture will be used as refraction texture.
  67699. */
  67700. refractionEnabled: boolean;
  67701. /**
  67702. * Gets wether or not the post-processes is supported by the running hardware.
  67703. * This requires draw buffer supports.
  67704. */
  67705. readonly isSupported: boolean;
  67706. /**
  67707. * This is the reflection mirror texture used to display reflections on the ocean.
  67708. * By default, render list is empty.
  67709. */
  67710. reflectionTexture: BABYLON.MirrorTexture;
  67711. /**
  67712. * This is the refraction render target texture used to display refraction on the ocean.
  67713. * By default, render list is empty.
  67714. */
  67715. refractionTexture: BABYLON.RenderTargetTexture;
  67716. private _time;
  67717. private _cameraRotation;
  67718. private _cameraViewMatrix;
  67719. private _reflectionEnabled;
  67720. private _refractionEnabled;
  67721. private _geometryRenderer;
  67722. /**
  67723. * Instantiates a new Ocean Post Process.
  67724. * @param name the name to give to the postprocess.
  67725. * @camera the camera to apply the post process to.
  67726. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  67727. */
  67728. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  67729. /**
  67730. * Returns the appropriate defines according to the current configuration.
  67731. */
  67732. private _getDefines;
  67733. /**
  67734. * Computes the current camera rotation as the shader requires a camera rotation.
  67735. */
  67736. private _computeCameraRotation;
  67737. }
  67738. }
  67739. declare module BABYLON {
  67740. /** @hidden */
  67741. export var brickProceduralTexturePixelShader: {
  67742. name: string;
  67743. shader: string;
  67744. };
  67745. }
  67746. declare module BABYLON {
  67747. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  67748. private _numberOfBricksHeight;
  67749. private _numberOfBricksWidth;
  67750. private _jointColor;
  67751. private _brickColor;
  67752. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67753. updateShaderUniforms(): void;
  67754. numberOfBricksHeight: number;
  67755. numberOfBricksWidth: number;
  67756. jointColor: BABYLON.Color3;
  67757. brickColor: BABYLON.Color3;
  67758. /**
  67759. * Serializes this brick procedural texture
  67760. * @returns a serialized brick procedural texture object
  67761. */
  67762. serialize(): any;
  67763. /**
  67764. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  67765. * @param parsedTexture defines parsed texture data
  67766. * @param scene defines the current scene
  67767. * @param rootUrl defines the root URL containing brick procedural texture information
  67768. * @returns a parsed Brick Procedural BABYLON.Texture
  67769. */
  67770. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  67771. }
  67772. }
  67773. declare module BABYLON {
  67774. /** @hidden */
  67775. export var cloudProceduralTexturePixelShader: {
  67776. name: string;
  67777. shader: string;
  67778. };
  67779. }
  67780. declare module BABYLON {
  67781. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  67782. private _skyColor;
  67783. private _cloudColor;
  67784. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67785. updateShaderUniforms(): void;
  67786. skyColor: BABYLON.Color4;
  67787. cloudColor: BABYLON.Color4;
  67788. /**
  67789. * Serializes this cloud procedural texture
  67790. * @returns a serialized cloud procedural texture object
  67791. */
  67792. serialize(): any;
  67793. /**
  67794. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  67795. * @param parsedTexture defines parsed texture data
  67796. * @param scene defines the current scene
  67797. * @param rootUrl defines the root URL containing cloud procedural texture information
  67798. * @returns a parsed Cloud Procedural BABYLON.Texture
  67799. */
  67800. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  67801. }
  67802. }
  67803. declare module BABYLON {
  67804. /** @hidden */
  67805. export var fireProceduralTexturePixelShader: {
  67806. name: string;
  67807. shader: string;
  67808. };
  67809. }
  67810. declare module BABYLON {
  67811. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  67812. private _time;
  67813. private _speed;
  67814. private _autoGenerateTime;
  67815. private _fireColors;
  67816. private _alphaThreshold;
  67817. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67818. updateShaderUniforms(): void;
  67819. render(useCameraPostProcess?: boolean): void;
  67820. static readonly PurpleFireColors: BABYLON.Color3[];
  67821. static readonly GreenFireColors: BABYLON.Color3[];
  67822. static readonly RedFireColors: BABYLON.Color3[];
  67823. static readonly BlueFireColors: BABYLON.Color3[];
  67824. autoGenerateTime: boolean;
  67825. fireColors: BABYLON.Color3[];
  67826. time: number;
  67827. speed: BABYLON.Vector2;
  67828. alphaThreshold: number;
  67829. /**
  67830. * Serializes this fire procedural texture
  67831. * @returns a serialized fire procedural texture object
  67832. */
  67833. serialize(): any;
  67834. /**
  67835. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  67836. * @param parsedTexture defines parsed texture data
  67837. * @param scene defines the current scene
  67838. * @param rootUrl defines the root URL containing fire procedural texture information
  67839. * @returns a parsed Fire Procedural BABYLON.Texture
  67840. */
  67841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /** @hidden */
  67846. export var grassProceduralTexturePixelShader: {
  67847. name: string;
  67848. shader: string;
  67849. };
  67850. }
  67851. declare module BABYLON {
  67852. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  67853. private _grassColors;
  67854. private _groundColor;
  67855. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67856. updateShaderUniforms(): void;
  67857. grassColors: BABYLON.Color3[];
  67858. groundColor: BABYLON.Color3;
  67859. /**
  67860. * Serializes this grass procedural texture
  67861. * @returns a serialized grass procedural texture object
  67862. */
  67863. serialize(): any;
  67864. /**
  67865. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  67866. * @param parsedTexture defines parsed texture data
  67867. * @param scene defines the current scene
  67868. * @param rootUrl defines the root URL containing grass procedural texture information
  67869. * @returns a parsed Grass Procedural BABYLON.Texture
  67870. */
  67871. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  67872. }
  67873. }
  67874. declare module BABYLON {
  67875. /** @hidden */
  67876. export var marbleProceduralTexturePixelShader: {
  67877. name: string;
  67878. shader: string;
  67879. };
  67880. }
  67881. declare module BABYLON {
  67882. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  67883. private _numberOfTilesHeight;
  67884. private _numberOfTilesWidth;
  67885. private _amplitude;
  67886. private _jointColor;
  67887. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67888. updateShaderUniforms(): void;
  67889. numberOfTilesHeight: number;
  67890. amplitude: number;
  67891. numberOfTilesWidth: number;
  67892. jointColor: BABYLON.Color3;
  67893. /**
  67894. * Serializes this marble procedural texture
  67895. * @returns a serialized marble procedural texture object
  67896. */
  67897. serialize(): any;
  67898. /**
  67899. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  67900. * @param parsedTexture defines parsed texture data
  67901. * @param scene defines the current scene
  67902. * @param rootUrl defines the root URL containing marble procedural texture information
  67903. * @returns a parsed Marble Procedural BABYLON.Texture
  67904. */
  67905. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  67906. }
  67907. }
  67908. declare module BABYLON {
  67909. /** @hidden */
  67910. export var normalMapProceduralTexturePixelShader: {
  67911. name: string;
  67912. shader: string;
  67913. };
  67914. }
  67915. declare module BABYLON {
  67916. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  67917. private _baseTexture;
  67918. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67919. updateShaderUniforms(): void;
  67920. render(useCameraPostProcess?: boolean): void;
  67921. resize(size: any, generateMipMaps: any): void;
  67922. baseTexture: BABYLON.Texture;
  67923. /**
  67924. * Serializes this normal map procedural texture
  67925. * @returns a serialized normal map procedural texture object
  67926. */
  67927. serialize(): any;
  67928. /**
  67929. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  67930. * @param parsedTexture defines parsed texture data
  67931. * @param scene defines the current scene
  67932. * @param rootUrl defines the root URL containing normal map procedural texture information
  67933. * @returns a parsed Normal Map Procedural BABYLON.Texture
  67934. */
  67935. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export var perlinNoiseProceduralTexturePixelShader: {
  67941. name: string;
  67942. shader: string;
  67943. };
  67944. }
  67945. declare module BABYLON {
  67946. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  67947. time: number;
  67948. timeScale: number;
  67949. translationSpeed: number;
  67950. private _currentTranslation;
  67951. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67952. updateShaderUniforms(): void;
  67953. render(useCameraPostProcess?: boolean): void;
  67954. resize(size: any, generateMipMaps: any): void;
  67955. /**
  67956. * Serializes this perlin noise procedural texture
  67957. * @returns a serialized perlin noise procedural texture object
  67958. */
  67959. serialize(): any;
  67960. /**
  67961. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  67962. * @param parsedTexture defines parsed texture data
  67963. * @param scene defines the current scene
  67964. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  67965. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  67966. */
  67967. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /** @hidden */
  67972. export var roadProceduralTexturePixelShader: {
  67973. name: string;
  67974. shader: string;
  67975. };
  67976. }
  67977. declare module BABYLON {
  67978. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  67979. private _roadColor;
  67980. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67981. updateShaderUniforms(): void;
  67982. roadColor: BABYLON.Color3;
  67983. /**
  67984. * Serializes this road procedural texture
  67985. * @returns a serialized road procedural texture object
  67986. */
  67987. serialize(): any;
  67988. /**
  67989. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  67990. * @param parsedTexture defines parsed texture data
  67991. * @param scene defines the current scene
  67992. * @param rootUrl defines the root URL containing road procedural texture information
  67993. * @returns a parsed Road Procedural BABYLON.Texture
  67994. */
  67995. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  67996. }
  67997. }
  67998. declare module BABYLON {
  67999. /** @hidden */
  68000. export var starfieldProceduralTexturePixelShader: {
  68001. name: string;
  68002. shader: string;
  68003. };
  68004. }
  68005. declare module BABYLON {
  68006. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68007. private _time;
  68008. private _alpha;
  68009. private _beta;
  68010. private _zoom;
  68011. private _formuparam;
  68012. private _stepsize;
  68013. private _tile;
  68014. private _brightness;
  68015. private _darkmatter;
  68016. private _distfading;
  68017. private _saturation;
  68018. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68019. updateShaderUniforms(): void;
  68020. time: number;
  68021. alpha: number;
  68022. beta: number;
  68023. formuparam: number;
  68024. stepsize: number;
  68025. zoom: number;
  68026. tile: number;
  68027. brightness: number;
  68028. darkmatter: number;
  68029. distfading: number;
  68030. saturation: number;
  68031. /**
  68032. * Serializes this starfield procedural texture
  68033. * @returns a serialized starfield procedural texture object
  68034. */
  68035. serialize(): any;
  68036. /**
  68037. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68038. * @param parsedTexture defines parsed texture data
  68039. * @param scene defines the current scene
  68040. * @param rootUrl defines the root URL containing startfield procedural texture information
  68041. * @returns a parsed Starfield Procedural BABYLON.Texture
  68042. */
  68043. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68044. }
  68045. }
  68046. declare module BABYLON {
  68047. /** @hidden */
  68048. export var woodProceduralTexturePixelShader: {
  68049. name: string;
  68050. shader: string;
  68051. };
  68052. }
  68053. declare module BABYLON {
  68054. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68055. private _ampScale;
  68056. private _woodColor;
  68057. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68058. updateShaderUniforms(): void;
  68059. ampScale: number;
  68060. woodColor: BABYLON.Color3;
  68061. /**
  68062. * Serializes this wood procedural texture
  68063. * @returns a serialized wood procedural texture object
  68064. */
  68065. serialize(): any;
  68066. /**
  68067. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68068. * @param parsedTexture defines parsed texture data
  68069. * @param scene defines the current scene
  68070. * @param rootUrl defines the root URL containing wood procedural texture information
  68071. * @returns a parsed Wood Procedural BABYLON.Texture
  68072. */
  68073. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68074. }
  68075. }